Commit 48744345 authored by 刘_震's avatar 刘_震

清洗表数据入库,材料编码后端代码优化以及返回矿id

parent db2b774d
......@@ -40,4 +40,6 @@ public interface ActSuppliesCleaningRuleMapper
void addActSuppliesImportCleaningAcc(@Param("actSuppliesImportCleaningAccs") List<ActSuppliesImportCleaningAcc> actSuppliesImportCleaningAccs);
List<ActSuppliesImportCleaningAcc> selectActSuppliesCleaningCopy(Long id);
void insert(@Param("accList") List<ActSuppliesImportCleaningAcc> cleaningAccList);
}
package com.ruoyi.system.service.impl;
import com.ruoyi.system.domain.ActSuppliesImportCleaningAcc;
import com.ruoyi.system.domain.ActSuppliesMaterialDetails;
import com.ruoyi.system.domain.ActSuppliesMaterialInfo;
import com.ruoyi.system.mapper.ActSuppliesCleaningRuleMapper;
import com.ruoyi.system.mapper.ActSuppliesMaterialMapper;
import com.ruoyi.system.service.ActMaterialService;
import com.ruoyi.system.service.ActSuppliesMaterialService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -19,9 +23,11 @@ import java.util.stream.Stream;
* @date 2024/7/8
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class ActSuppliesMaterialServiceImpl implements ActSuppliesMaterialService {
private final ActSuppliesMaterialMapper actSuppliesMaterialMapper;
private final ActSuppliesCleaningRuleMapper actSuppliesCleaningRuleMapper;
@Override
......@@ -37,13 +43,32 @@ public class ActSuppliesMaterialServiceImpl implements ActSuppliesMaterialServic
String mineId = part[0];
String dateColumn = part[1];
//执行删除操作
actSuppliesMaterialMapper.delete(mineId,dateColumn);
actSuppliesMaterialMapper.delete(mineId, dateColumn);
}
List<ActSuppliesImportCleaningAcc> cleaningAccList = new ArrayList<>();
for (ActSuppliesMaterialDetails material : materials) {
if (material != null) { // 检查 material 是否为 null
ActSuppliesImportCleaningAcc cleaningAcc = new ActSuppliesImportCleaningAcc();
cleaningAcc.setId(UUID.randomUUID().toString().replace("-", ""));
cleaningAcc.setSskId(material.getMineId() != null ? material.getMineId() : ""); // 处理可能的 null
cleaningAcc.setHdate(material.getDateColumn() != null ? material.getDateColumn() : "");
cleaningAcc.setNameColumn(material.getNameColumn() != null ? material.getNameColumn() : "");
cleaningAcc.setCodeColumn(material.getCodeColumn() != null ? material.getCodeColumn() : "");
cleaningAcc.setDepartmentColumn(material.getDepartmentColumn() != null ? material.getDepartmentColumn() : "");
cleaningAcc.setNumberColumn(material.getNameColumn() != null ? material.getNameColumn() : "");
cleaningAcc.setMoneyColumn(material.getMoneyColumn() != null ? material.getMoneyColumn().toString() : "0");
cleaningAcc.setMoneyColumns(material.getMoney() != null ? material.getMoney().toString() : "0");
cleaningAcc.setsOfExpenses(material.getSourceColoumn() != null ? material.getSourceColoumn() : "");
cleaningAcc.setUnit(material.getUnit() != null ? material.getUnit() : "");
cleaningAcc.setModel(material.getModel() != null ? material.getModel() : "");
cleaningAccList.add(cleaningAcc);
}
}
actSuppliesCleaningRuleMapper.insert(cleaningAccList);
Boolean saved = actSuppliesMaterialMapper.save(materials);
if (!saved) {
return false;
}
return true;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.ActSuppliesCleaningRuleMapper">
<resultMap type="ActSuppliesImportCleaning" id="ActSuppliesImportCleaningResult">
<result property="id" column="id" />
<result property="roleId" column="role_id" />
<result property="hId" column="h_id" />
<result property="sskId" column="ssk_id" />
<result property="date" column="date" />
<result property="id" column="id"/>
<result property="roleId" column="role_id"/>
<result property="hId" column="h_id"/>
<result property="sskId" column="ssk_id"/>
<result property="date" column="date"/>
<result property="nameColumn" column="name_column"/>
<result property="codeColumn" column="code_column" />
<result property="departmentColumn" column="department_column" />
<result property="numberColumn" column="number_column" />
<result property="moneyColumn" column="money_column" />
<result property="dateColumn" column="date_column" />
<result property="sOfExpenses" column="source_of_expenses" />
<result property="categories" column="categories" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="codeColumn" column="code_column"/>
<result property="departmentColumn" column="department_column"/>
<result property="numberColumn" column="number_column"/>
<result property="moneyColumn" column="money_column"/>
<result property="dateColumn" column="date_column"/>
<result property="sOfExpenses" column="source_of_expenses"/>
<result property="categories" column="categories"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<resultMap type="ActSuppliesImportCleaningAcc" id="ActSuppliesImportCleaningResultAcc">
<result property="id" column="id" />
<result property="hId" column="h_id" />
<result property="sskId" column="ssk_id" />
<result property="hdate" column="hdate" />
<result property="id" column="id"/>
<result property="hId" column="h_id"/>
<result property="sskId" column="ssk_id"/>
<result property="hdate" column="hdate"/>
<result property="kmCode" column="km_code"/>
<result property="nameColumn" column="name_column"/>
<result property="codeColumn" column="code_column" />
<result property="departmentColumn" column="department_column" />
<result property="numberColumn" column="number_column" />
<result property="moneyColumn" column="money_column" />
<result property="moneyColumns" column="money_columns" />
<result property="dateColumn" column="date_column" />
<result property="sOfExpenses" column="source_of_expenses" />
<result property="categories" column="categories" />
<result property="codeColumn" column="code_column"/>
<result property="departmentColumn" column="department_column"/>
<result property="numberColumn" column="number_column"/>
<result property="moneyColumn" column="money_column"/>
<result property="moneyColumns" column="money_columns"/>
<result property="dateColumn" column="date_column"/>
<result property="sOfExpenses" column="source_of_expenses"/>
<result property="categories" column="categories"/>
</resultMap>
<select id="selectActSuppliesCleaningCopy" parameterType="Long" resultMap="ActSuppliesImportCleaningResultAcc">
SELECT ssk_id,hdate,department_column ,categories ,source_of_expenses ,SUM(number_column) number_column,SUM(money_column) money_column,SUM(money_columns) money_columns FROM act_supplies_import_cleaning_copy1 WHERE hid = #{id} GROUP BY department_column,categories,hdate,ssk_id,source_of_expenses
SELECT ssk_id,
hdate,
department_column,
categories,
source_of_expenses,
SUM(number_column) number_column,
SUM(money_column) money_column,
SUM(money_columns) money_columns
FROM act_supplies_import_cleaning_copy1
WHERE hid = #{id}
GROUP BY department_column, categories, hdate, ssk_id, source_of_expenses
</select>
<insert id="insertActSuppliesImportCleaning" parameterType="ActSuppliesImportCleaning" useGeneratedKeys="true" keyProperty="id">
<insert id="insertActSuppliesImportCleaning" parameterType="ActSuppliesImportCleaning" useGeneratedKeys="true"
keyProperty="id">
insert into act_supplies_import_cleaning
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roleId!= null">role_id,</if>
......@@ -75,7 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="addActSuppliesSixMinesSummaryTable" parameterType="ActSuppliesSixMinesSummaryTable" useGeneratedKeys="true" keyProperty="id">
<insert id="addActSuppliesSixMinesSummaryTable" parameterType="ActSuppliesSixMinesSummaryTable"
useGeneratedKeys="true" keyProperty="id">
insert into act_supplies_sixminessummarytable
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
......@@ -109,7 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="addActSuppliesImportTable" parameterType="ActSuppliesImportTable" useGeneratedKeys="true" keyProperty="id">
<insert id="addActSuppliesImportTable" parameterType="ActSuppliesImportTable" useGeneratedKeys="true"
keyProperty="id">
insert into act_supplies_import_table
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
......@@ -252,72 +264,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="addActSuppliesImportCleaningAcc" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
<insert id="addActSuppliesImportCleaningAcc" parameterType="java.util.List" useGeneratedKeys="true"
keyProperty="id">
insert into act_supplies_import_cleaning_copy1
(id,hid,ssk_id,hdate,km_code,yy_uuid,name_column,code_column,department_column,number_column,money_columns,money_column,date_column,source_of_expenses,categories)
values
<foreach collection="actSuppliesImportCleaningAccs" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.id},
#{item.hId},
#{item.sskId},
#{item.hdate},
#{item.kmCode},
#{item.yyUuid},
#{item.nameColumn},
#{item.codeColumn},
#{item.departmentColumn},
#{item.numberColumn},
#{item.moneyColumns},
#{item.moneyColumn},
#{item.dateColumn},
#{item.sOfExpenses},
#{item.categories},
</trim>
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.id},
#{item.hId},
#{item.sskId},
#{item.hdate},
#{item.kmCode},
#{item.yyUuid},
#{item.nameColumn},
#{item.codeColumn},
#{item.departmentColumn},
#{item.numberColumn},
#{item.moneyColumns},
#{item.moneyColumn},
#{item.dateColumn},
#{item.sOfExpenses},
#{item.categories},
</trim>
</foreach>
</insert>
<!-- <insert id="addActSuppliesImportCleaningAcc" parameterType="ActSuppliesImportCleaningAcc" useGeneratedKeys="true" keyProperty="id">-->
<!-- insert into act_supplies_import_cleaning_copy1-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">id,</if>-->
<!-- <if test="hId != null">hid,</if>-->
<!-- <if test="sskId != null">ssk_id,</if>-->
<!-- <if test="hdate != null">hdate,</if>-->
<!-- <if test="kmCode != null">km_code,</if>-->
<!-- <if test="yyUuid != null">yy_uuid,</if>-->
<!-- <if test="nameColumn != null">name_column,</if>-->
<!-- <if test="codeColumn != null">code_column,</if>-->
<!-- <if test="departmentColumn != null">department_column,</if>-->
<!-- <if test="numberColumn != null">number_column,</if>-->
<!-- <if test="moneyColumns != null">money_columns,</if>-->
<!-- <if test="moneyColumn != null">money_column,</if>-->
<!-- <if test="dateColumn != null">date_column,</if>-->
<!-- <if test="sOfExpenses != null">source_of_expenses,</if>-->
<!-- <if test="categories != null">categories,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">#{id},</if>-->
<!-- <if test="hId != null">#{hId},</if>-->
<!-- <if test="sskId != null">#{sskId},</if>-->
<!-- <if test="hdate != null">#{hdate},</if>-->
<!-- <if test="kmCode != null">#{kmCode},</if>-->
<!-- <if test="yyUuid != null">#{yyUuid},</if>-->
<!-- <if test="nameColumn != null">#{nameColumn},</if>-->
<!-- <if test="codeColumn != null">#{codeColumn},</if>-->
<!-- <if test="departmentColumn != null">#{departmentColumn},</if>-->
<!-- <if test="numberColumn != null">#{numberColumn},</if>-->
<!-- <if test="moneyColumns != null">#{moneyColumns},</if>-->
<!-- <if test="moneyColumn != null">#{moneyColumn},</if>-->
<!-- <if test="dateColumn != null">#{dateColumn},</if>-->
<!-- <if test="sOfExpenses != null">#{sOfExpenses},</if>-->
<!-- <if test="categories != null">#{categories},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<!-- <insert id="addActSuppliesImportCleaningAcc" parameterType="ActSuppliesImportCleaningAcc" useGeneratedKeys="true" keyProperty="id">-->
<!-- insert into act_supplies_import_cleaning_copy1-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">id,</if>-->
<!-- <if test="hId != null">hid,</if>-->
<!-- <if test="sskId != null">ssk_id,</if>-->
<!-- <if test="hdate != null">hdate,</if>-->
<!-- <if test="kmCode != null">km_code,</if>-->
<!-- <if test="yyUuid != null">yy_uuid,</if>-->
<!-- <if test="nameColumn != null">name_column,</if>-->
<!-- <if test="codeColumn != null">code_column,</if>-->
<!-- <if test="departmentColumn != null">department_column,</if>-->
<!-- <if test="numberColumn != null">number_column,</if>-->
<!-- <if test="moneyColumns != null">money_columns,</if>-->
<!-- <if test="moneyColumn != null">money_column,</if>-->
<!-- <if test="dateColumn != null">date_column,</if>-->
<!-- <if test="sOfExpenses != null">source_of_expenses,</if>-->
<!-- <if test="categories != null">categories,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">#{id},</if>-->
<!-- <if test="hId != null">#{hId},</if>-->
<!-- <if test="sskId != null">#{sskId},</if>-->
<!-- <if test="hdate != null">#{hdate},</if>-->
<!-- <if test="kmCode != null">#{kmCode},</if>-->
<!-- <if test="yyUuid != null">#{yyUuid},</if>-->
<!-- <if test="nameColumn != null">#{nameColumn},</if>-->
<!-- <if test="codeColumn != null">#{codeColumn},</if>-->
<!-- <if test="departmentColumn != null">#{departmentColumn},</if>-->
<!-- <if test="numberColumn != null">#{numberColumn},</if>-->
<!-- <if test="moneyColumns != null">#{moneyColumns},</if>-->
<!-- <if test="moneyColumn != null">#{moneyColumn},</if>-->
<!-- <if test="dateColumn != null">#{dateColumn},</if>-->
<!-- <if test="sOfExpenses != null">#{sOfExpenses},</if>-->
<!-- <if test="categories != null">#{categories},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<insert id="addActSuppliesImportCleaning" parameterType="ActSuppliesImportCleaning" useGeneratedKeys="true" keyProperty="id">
<insert id="addActSuppliesImportCleaning" parameterType="ActSuppliesImportCleaning" useGeneratedKeys="true"
keyProperty="id">
insert into act_supplies_import_cleaning
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
......@@ -638,19 +651,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<delete id="deleteActSuppliesSixMinesSummaryTable" parameterType="Long">
delete from act_supplies_sixminessummarytable where h_id = #{id}
delete
from act_supplies_sixminessummarytable
where h_id = #{id}
</delete>
<delete id="deleteActSuppliesImportCleaning" parameterType="Long">
delete from act_supplies_import_cleaning where h_id = #{id}
delete
from act_supplies_import_cleaning
where h_id = #{id}
</delete>
<delete id="deleteActSuppliesImportTable" parameterType="Long">
delete from act_supplies_import_table where h_id = #{id}
delete
from act_supplies_import_table
where h_id = #{id}
</delete>
<delete id="deleteActSuppliesImportTableCopy" parameterType="String">
delete from act_supplies_import_cleaning_copy1 where yy_uuid = #{importUuid}
delete
from act_supplies_import_cleaning_copy1
where yy_uuid = #{importUuid}
</delete>
<insert id="addInsertConvertAcc" parameterType="ActSuppliesImportTable" useGeneratedKeys="true" keyProperty="id">
......@@ -799,6 +820,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="a63 != null">#{a63},</if>
</trim>
</insert>
<insert id="insert"
parameterType="java.util.List">
insert into act_supplies_import_cleaning_copy1
(id,ssk_id, hdate, name_column,
code_column, department_column, number_column,
money_columns, money_column,
source_of_expenses,model,unit)
values
<foreach collection="accList" item="item" separator=",">
(#{item.id},
#{item.sskId},
#{item.hdate},
#{item.nameColumn},
#{item.codeColumn},
#{item.departmentColumn},
#{item.numberColumn},
#{item.moneyColumns},
#{item.moneyColumn},
#{item.sOfExpenses},
#{item.model},
#{item.unit}
)
</foreach>
</insert>
</mapper>
......@@ -6,14 +6,11 @@ import com.ruoyi.system.domain.ActSuppliesDetails;
import com.ruoyi.system.domain.ActSuppliesMaterialCode;
import com.ruoyi.system.mapper.AsiccSuppliesMapper;
import com.ruoyi.system.model.wages.dao.AsiccDAO;
import com.ruoyi.system.model.wages.vo.AsiccVo;
import com.ruoyi.system.service.AsiccSuppliesService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.Range;
import org.springframework.stereotype.Service;
import javax.accessibility.AccessibleValue;
import java.lang.reflect.Array;
import java.util.*;
/**
......@@ -28,262 +25,210 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
@Override
public Map<String, Object> getData(AsiccDAO asiccDAO) {
//处理特殊矿,如果那个表中有这个矿
//获取矿id
String mineId = asiccDAO.getMineId();
List<ActSuppliesMaterialCode> materialCodeList = asiccSuppliesMapper.selectByMineId(mineId);
// 使用Lambda表达式按codeMin的长度从长到短排序
Comparator<ActSuppliesMaterialCode> comparator = Comparator.comparing(code -> code.getCodeMin().length());
materialCodeList.sort(comparator.reversed());
System.out.println(materialCodeList);
if (materialCodeList.isEmpty()) {
return getLevelByCode(mineId, asiccDAO);
} else {
return getElseByCode(mineId, asiccDAO, materialCodeList);
}
}
/**
* 处理特殊表不存在的矿id情况
*
* @param mineId 矿id()
* @return 一级,二级分类
*/
private Map<String, Object> getLevelByCode(String mineId, AsiccDAO asiccDAO) {
Map<String, Object> voMap = new HashMap<>();
//如果不存在这个矿信息,就走通用的规则
List<ActSupplies> suppliesList;
//获取相关信息-一级分类、二级分类
List<ActSupplies> suppliesList = asiccSuppliesMapper.selectLevelInfo();
Map<Object, String> suppliesMap = new HashMap<>();
if (materialCodeList.isEmpty()) {
//查询一级分类,二级分类,以及对应的id
suppliesList = asiccSuppliesMapper.selectLevelInfo();
//存放suppliesList的一级分类和二级分类以及对应的id
suppliesList.forEach(supplies -> {
String oneLevel = supplies.getOneLevel();
String twoLevel = supplies.getTwoLevel();
Long id = supplies.getId();
String finalLevel = oneLevel + "_" + twoLevel;
suppliesMap.put(id, finalLevel);
});
List<ActSuppliesDetails> detailsList = asiccSuppliesMapper.select();
//存放detailsList中的code
Map<String, Object> codeMap = new HashMap<>();
detailsList.forEach(v -> {
String actCode = v.getCode();
Long sid = v.getSid();
codeMap.put(actCode, sid);
});
//特殊处理最后没有匹配上的数据的id为10
ActSupplies actSupplies = asiccSuppliesMapper.selectByNum();
//存放处理之后的code (asiccDAO中的Code)
for (String code : asiccDAO.getCodes()) {
Map<String, Object> map = new HashMap<>();
//存放基本生产原煤的一级、二级分类
Map<String, Object> codeList1 = new HashMap<>();
//存放基本生产洗煤的一级、二级分类
Map<String, Object> codeList2 = new HashMap<>();
//存放其他费用来源的一级、二级分类
Map<String, Object> codeList3 = new HashMap<>();
//存放制造费用-原煤
Map<String, Object> codeList4 = new HashMap<>();
if (mineId.equals("010102")) {
String kmCode = StringUtils.substring(code, 0, 6);
if (codeMap.containsKey(kmCode)) {
get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3,kmCode, codeList4);
} else {
kmCode = StringUtils.substring(kmCode, 0, 4);
if (codeMap.containsKey(kmCode)) {
getId(suppliesMap, codeMap, codeList1, codeList2, kmCode,codeList4);
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
map.put("制造费用原煤", codeList4);
voMap.put(code, map);
} else {
kmCode = StringUtils.substring(kmCode, 0, 2);
if (codeMap.containsKey(kmCode)) {
get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3,kmCode, codeList4);
} else {
//kmCode一律为10
Common(actSupplies, map, codeList1, codeList2, codeList3);
codeList4.put("一级分类", "其他材料");
codeList4.put("二级分类", "其他");
map.put("制造费用原煤", codeList4);
voMap.put(code, map);
}
}
}
} else {
Range<String> range = Range.between("30", "36");
String kmCode1 = StringUtils.substring(code, 0, 2);
String kmCode2 = StringUtils.substring(code, 0, 4);
if (mineId.equals("011704") && range.contains(kmCode1)) {
codeList1.put("一级分类", "配件");
codeList1.put("二级分类", "配件");
codeList2.put("一级分类", "配件");
codeList2.put("二级分类", "配件");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
} else if (mineId.equals("011704") && kmCode2.equals("6199")) {
codeList1.put("一级分类", "其他材料");
codeList1.put("二级分类", "其他");
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
} else {
String kmCode = StringUtils.substring(code, 0, 6);
if (codeMap.containsKey(kmCode)) {
get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3,kmCode, codeList4);
} else {
kmCode = StringUtils.substring(kmCode, 0, 4);
if (codeMap.containsKey(kmCode)) {
getId(suppliesMap, codeMap, codeList1, codeList2, kmCode,codeList4);
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
} else {
kmCode = StringUtils.substring(kmCode, 0, 2);
if (codeMap.containsKey(kmCode)) {
get(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3,kmCode, codeList4);
} else {
//kmCode一律为10
Common(actSupplies, map, codeList1, codeList2, codeList3);
voMap.put(code, map);
}
}
}
}
}
//存放suppliesList的一级分类和二级分类以及对应的id
suppliesList.forEach(supplies -> {
String oneLevel = supplies.getOneLevel();
String twoLevel = supplies.getTwoLevel();
Long id = supplies.getId();
String finalLevel = oneLevel + "_" + twoLevel;
suppliesMap.put(id, finalLevel);
});
List<ActSuppliesDetails> detailsList = asiccSuppliesMapper.select();
//存放detailsList中的code
Map<String, Object> codeMap = new HashMap<>();
detailsList.forEach(v -> {
String actCode = v.getCode();
Long sid = v.getSid();
codeMap.put(actCode, sid);
});
//特殊处理最后没有匹配上的数据的id为10
ActSupplies actSupplies = asiccSuppliesMapper.selectByNum();
for (String code : asiccDAO.getCodes()) {
Map<String, Object> map = new HashMap<>();
//存放基本生产原煤的一级、二级分类
Map<String, Object> codeList1 = new HashMap<>();
//存放基本生产洗煤的一级、二级分类
Map<String, Object> codeList2 = new HashMap<>();
//存放其他费用来源的一级、二级分类
Map<String, Object> codeList3 = new HashMap<>();
//存放制造费用-原煤
Map<String, Object> codeList4 = new HashMap<>();
String kmCode1 = StringUtils.substring(code, 0, 6);
String kmCode2 = StringUtils.substring(code, 0, 4);
String kmCode3 = StringUtils.substring(code, 0, 2);
//处理林西矿
if (mineId.equals("011704")) {
Range<String> codeList = Range.between("30", "36");
if (codeList.contains(code) || codeList.contains(kmCode3)) {
codeList1.put("一级类别", "配件");
codeList1.put("二级类别", "配件");
codeList2.put("一级类别", "配件");
codeList2.put("二级类别", "配件");
codeList3.put("一级类别", "其他材料");
codeList3.put("二级类别", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
} else if (code.equals("6199") || kmCode2.equals("6199")) {
codeList1.put("一级类别", "其他材料");
codeList1.put("二级类别", "其他");
codeList2.put("一级类别", "其他材料");
codeList2.put("二级类别", "其他");
codeList3.put("一级类别", "其他材料");
codeList3.put("二级类别", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
//剩余情况(林西矿)
} else
getCode(voMap, suppliesMap, codeMap, actSupplies,
code, map, codeList1, codeList2,
codeList3, kmCode1, kmCode2, kmCode3);
}
} else {
suppliesList = asiccSuppliesMapper.select1();
suppliesList.forEach(supplies -> {
String oneLevel = supplies.getOneLevel();
String oneName = supplies.getSuppliesName();
suppliesMap.put(oneLevel, oneName);
});
for (String code : asiccDAO.getCodes()) {
boolean matched = false;
Map<String, Object> map = new HashMap<>();
//存放基本生产原煤的一级、二级分类
Map<String, Object> codeList1 = new HashMap<>();
//存放基本生产洗煤的一级、二级分类
Map<String, Object> codeList2 = new HashMap<>();
//存放其他费用来源的一级、二级分类
Map<String, Object> codeList3 = new HashMap<>();
for (ActSuppliesMaterialCode materialCode : materialCodeList) {
String kmCode = code;
String codeMin = materialCode.getCodeMin();
String codeMax = materialCode.getCodeMax();
Range<String> range = Range.between(codeMin, codeMax);
if (range.contains(kmCode)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
matched = true;
break; // 跳出内部循环
} else {
kmCode = StringUtils.substring(kmCode, 0, 6);
if (range.contains(kmCode)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
matched = true;
break; // 跳出内部循环
} else {
kmCode = StringUtils.substring(kmCode, 0, 4);
String[] number = {"6101", "6102"};
if (range.contains(kmCode)) {
// 跳出内部循环
if (mineId.equals("011702") && Arrays.asList(number).contains(kmCode)) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
codeList2.put("一级分类", "油脂及乳化液");
codeList2.put("二级分类", "油脂");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
} else {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
}
matched = true;
break; // 跳出内部循环
} else {
kmCode = StringUtils.substring(kmCode, 0, 2);
if (range.contains(kmCode)) {
String[] numbers = {"30", "31", "32", "34", "35"};
if (mineId.equals("011702") && Arrays.asList(numbers).contains(kmCode)) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
codeList2.put("一级分类", "配件");
codeList2.put("二级分类", "配件");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
} else {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
}
matched = true;
break; // 跳出内部循环
}
}
}
}
}
if (!matched) {
codeList1.put("一级分类", "其他材料");
codeList1.put("二级分类", "其他");
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
//处理东环坨
else if (mineId.equals("010102")) {
if (codeMap.containsKey(kmCode1)) {
disposeDong(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, codeList4, kmCode1);
} else if (codeMap.containsKey(kmCode2)) {
disposeDong(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, codeList4, kmCode2);
} else if (codeMap.containsKey(kmCode3)) {
disposeDong(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, codeList4, kmCode3);
} else {
getOtherTen(actSupplies, codeList1, codeList2, codeList3);
codeList4.put("一级分类", "其他材料");
codeList4.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
map.put("制造费用原煤", codeList4);
voMap.put(code, map);
}
voMap.put(code, map);
}
//其余情况
else {
getCode(voMap, suppliesMap, codeMap,
actSupplies, code, map,
codeList1, codeList2, codeList3,
kmCode1, kmCode2, kmCode3);
}
}
return voMap;
}
/**
* 处理特殊表不存在id,且最后匹配不出来,为10
* 处理东环坨剩余编码的匹配情况
*/
private void Common(ActSupplies actSupplies, Map<String, Object> map, Map<String, Object> codeList1, Map<String, Object> codeList2, Map<String, Object> codeList3) {
String oneLevel = actSupplies.getSuppliesName();
private void disposeDong(Map<String, Object> voMap,
Map<Object, String> suppliesMap,
Map<String, Object> codeMap,
String code, Map<String, Object> map,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3,
Map<String, Object> codeList4,
String kmCode) {
Object sid = codeMap.get(kmCode);
String finalLevel = suppliesMap.get(sid);
String[] part = finalLevel.split("_");
String oneLevel = part[0];
String twoLevel = part[1];
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", null);
if (oneLevel.equals("油脂") || oneLevel.equals("配件")) {
codeList1.put("二级分类", twoLevel);
if (oneLevel.equals("油脂及乳化液") || oneLevel.equals("配件")) {
codeList2.put("一级分类", oneLevel);
codeList2.put("二级分类", null);
codeList2.put("二级分类", twoLevel);
} else {
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
}
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
if (oneLevel.equals("木材") || oneLevel.equals("支护用品") || oneLevel.equals("大型材料") || oneLevel.equals("劳保用品")) {
codeList4.put("一级分类", oneLevel);
codeList4.put("二级分类", twoLevel);
} else {
codeList4.put("一级分类", "其他材料");
codeList4.put("二级分类", "其他");
}
codeList3.put("一级类别", "其他材料");
codeList3.put("二级类别", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
map.put("制造费用原煤", codeList4);
voMap.put(code, map);
}
/**
* 返回各个费用来源对应的一级、二级分类(处理矿id存在的规则)
* 处理剩余通用情况-处理特殊表不存在的矿id
*/
private void getLevelInfo(Map<String, Object> voMap, Map<Object, String> suppliesMap,
String code, Map<String, Object> map,
Map<String, Object> codeList1, Map<String, Object> codeList2,
Map<String, Object> codeList3, ActSuppliesMaterialCode materialCode) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
private void getCode(Map<String, Object> voMap,
Map<Object, String> suppliesMap,
Map<String, Object> codeMap,
ActSupplies actSupplies, String code,
Map<String, Object> map,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3,
String kmCode1, String kmCode2, String kmCode3) {
if (codeMap.containsKey(kmCode1)) {
disposeCode(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode1);
} else if (codeMap.containsKey(kmCode2)) {
disposeCode(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode2);
} else if (codeMap.containsKey(kmCode3)) {
disposeCode(voMap, suppliesMap, codeMap, code, map, codeList1, codeList2, codeList3, kmCode3);
} else {
getOtherTen(actSupplies, codeList1, codeList2, codeList3);
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
}
}
/**
* 处理编码-处理特殊表不存在的矿id
*/
private void disposeCode(Map<String, Object> voMap,
Map<Object, String> suppliesMap,
Map<String, Object> codeMap, String code,
Map<String, Object> map,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3,
String kmCode) {
Object sid = codeMap.get(kmCode);
String finalLevel = suppliesMap.get(sid);
String[] part = finalLevel.split("_");
String oneLevel = part[0];
String twoLevel = part[1];
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
if (oneLevel.equals("油脂及乳化液") || oneLevel.equals("配件")) {
......@@ -293,43 +238,164 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
}
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
codeList3.put("一级类别", "其他材料");
codeList3.put("二级类别", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
}
/**
* 返回各个费用来源对应的一级、二级分类(处理矿id不存在的规则)
* 处理特殊表不存在的矿id,然后最后处理完编码为10的情况
*/
private void get(Map<String, Object> voMap, Map<Object, String> suppliesMap,
Map<String, Object> codeMap, String code, Map<String, Object> map,
Map<String, Object> codeList1, Map<String, Object> codeList2,
Map<String, Object> codeList3, String kmCode,
Map<String,Object> codeList4) {
getId(suppliesMap, codeMap, codeList1, codeList2, kmCode,codeList4);
private void getOtherTen(ActSupplies actSupplies,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3) {
String oneLevel = actSupplies.getSuppliesName();
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", null);
if (oneLevel.equals("油脂") || oneLevel.equals("配件")) {
codeList2.put("一级分类", oneLevel);
codeList2.put("二级分类", null);
} else {
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
}
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
map.put("制造费用原煤", codeList4);
voMap.put(code, map);
}
/**
* 处理原煤和洗煤的一级和二级分类(处理矿id不存在)
* 处理特殊表存在的矿id情况
* @param mineId 矿id
* @return 一级,二级分类
*/
private void getId(Map<Object, String> suppliesMap, Map<String, Object> codeMap,
Map<String, Object> codeList1, Map<String, Object> codeList2, String kmCode,
Map<String,Object> codeList4) {
Object sid = codeMap.get(kmCode);
String finalLevel = suppliesMap.get(sid);
String[] part = finalLevel.split("_");
String oneLevel = part[0];
String twoLevel = part[1];
private Map<String, Object> getElseByCode(String mineId, AsiccDAO asiccDAO,
List<ActSuppliesMaterialCode> materialCodeList) {
Map<String, Object> voMap = new HashMap<>();
Map<Object, String> suppliesMap = new HashMap<>();
List<ActSupplies> suppliesList = asiccSuppliesMapper.select1();
suppliesList.forEach(supplies -> {
String oneLevel = supplies.getOneLevel();
String oneName = supplies.getSuppliesName();
suppliesMap.put(oneLevel, oneName);
});
for (String code : asiccDAO.getCodes()) {
Map<String, Object> map = new HashMap<>();
//存放基本生产原煤的一级、二级分类
Map<String, Object> codeList1 = new HashMap<>();
//存放基本生产洗煤的一级、二级分类
Map<String, Object> codeList2 = new HashMap<>();
//存放其他费用来源的一级、二级分类
Map<String, Object> codeList3 = new HashMap<>();
for (ActSuppliesMaterialCode materialCode : materialCodeList) {
String kmCode1 = StringUtils.substring(code, 0, 6);
String kmCode2 = StringUtils.substring(code, 0, 4);
String kmCode3 = StringUtils.substring(code, 0, 2);
String codeMin = materialCode.getCodeMin();
String codeMax = materialCode.getCodeMax();
Range<String> range = Range.between(codeMin, codeMax);
String[] number1 = {"6101", "6102"};
String[] number2 = {"30", "31", "32", "34", "35"};
//处理吕家坨
if (mineId.equals("011702")) {
//特殊情况
if (Arrays.asList(number1).contains(code) || Arrays.asList(number1).contains(kmCode2)) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
codeList2.put("一级分类", "油脂及乳化液");
codeList2.put("二级分类", "油脂");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code,map);
} else if (Arrays.asList(number2).contains(code) || Arrays.asList(number2).contains(kmCode3)) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
codeList2.put("一级分类", "配件");
codeList2.put("二级分类", "配件");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code,map);
} else {
getInfo(voMap, suppliesMap, code, map,
codeList1, codeList2, codeList3,
materialCode, kmCode1, kmCode2, kmCode3, range);
}
}
//其他情况
else {
getInfo(voMap, suppliesMap, code, map,
codeList1, codeList2, codeList3,
materialCode, kmCode1, kmCode2, kmCode3, range);
}
}
}
return voMap;
}
/**
* 处理特殊表中存在的矿-一级、二级分类
*/
private void getInfo(Map<String, Object> voMap,
Map<Object, String> suppliesMap,
String code, Map<String, Object> map,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3,
ActSuppliesMaterialCode materialCode,
String kmCode1, String kmCode2,
String kmCode3, Range<String> range) {
if (range.contains(code)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
} else if (range.contains(kmCode1)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
} else if (range.contains(kmCode2)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
} else if (range.contains(kmCode3)) {
getLevelInfo(voMap, suppliesMap, code, map, codeList1, codeList2, codeList3, materialCode);
} else {
codeList1.put("一级分类", "其他材料");
codeList1.put("二级分类", "其他");
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
}
}
/**
* 获得一、二级分类的名称-特殊表存在矿id的情况
*/
private void getLevelInfo(Map<String, Object> voMap,
Map<Object, String> suppliesMap,
String code, Map<String, Object> map,
Map<String, Object> codeList1,
Map<String, Object> codeList2,
Map<String, Object> codeList3,
ActSuppliesMaterialCode materialCode) {
String twoLevel = materialCode.getMaterialName();
String codeType = materialCode.getMaterialCodeType();
String oneLevel = suppliesMap.get(codeType);
codeList1.put("一级分类", oneLevel);
codeList1.put("二级分类", twoLevel);
if (oneLevel.equals("油脂及乳化液") || oneLevel.equals("配件")) {
......@@ -339,13 +405,11 @@ public class AsiccSuppliesServiceImpl implements AsiccSuppliesService {
codeList2.put("一级分类", "其他材料");
codeList2.put("二级分类", "其他");
}
if (oneLevel.equals("木材")||oneLevel.equals("支护用品")||oneLevel.equals("大型材料")||oneLevel.equals("劳保用品")) {
codeList4.put("一级分类", oneLevel);
codeList4.put("二级分类", twoLevel);
} else {
codeList4.put("一级分类", "其他材料");
codeList4.put("二级分类", "其他");
}
codeList3.put("一级分类", "其他材料");
codeList3.put("二级分类", "其他");
map.put("基本生产原煤", codeList1);
map.put("基本生产洗煤", codeList2);
map.put("其他费用来源", codeList3);
voMap.put(code, map);
}
}
......@@ -26,7 +26,7 @@
</delete>
<select id="selectWagesConversionDataList" resultMap="WagesConversionData">
select id, if_generate_voucher, wage_month, create_date, update_date
select id, if_generate_voucher, wage_month, create_date, update_date,mine_id
from wages_conversion_data
where if_generate_voucher = 0 <if test="date != null"> and wage_month = #{date}</if>
<if test="mineId != null"> and mine_id = #{mineId}</if>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment