|
@@ -33,97 +33,80 @@ public class OnPassageMaterialsService extends CrudService<OnPassageMaterialsMap
|
|
|
|
|
|
public void comparativeData(List<OnPassageMaterials> onPassageMaterialsList, List<MaterialInformation> materialInformationList){
|
|
|
|
|
|
- //计划编制人为空
|
|
|
- List<OnPassageMaterials> isEmptyList = new ArrayList<>();
|
|
|
- //统计物料编码 部门
|
|
|
- Map<String, BigDecimal> materialCountMap = new HashMap<>();
|
|
|
- //统计物料编码 计划编制人相同合同数量
|
|
|
- Map<String, BigDecimal> sameMap = new HashMap<>();
|
|
|
- //统计计划编制人为空合同数量
|
|
|
- Map<String, BigDecimal> isEmptyMap = new HashMap<>();
|
|
|
- //两表比较
|
|
|
- List<String> compareList = new ArrayList<>();
|
|
|
+ //在途物资统计表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> onPassageMaterialsMap = new HashMap<>();
|
|
|
+ //项目物资需求表 key=统计物料编码-部门 去重汇总统计
|
|
|
+ Map<String, BigDecimal> materialInformationMap = new HashMap<>();
|
|
|
+
|
|
|
+ //在途物资统计表 如果计划编制人为空存储
|
|
|
+ //Map<String, BigDecimal> isEmptyMap = new HashMap<>();
|
|
|
+
|
|
|
+ //在途物资统计表与项目物资需求表比较 在途物资统计表J列>=项目物资需求表H列 标识
|
|
|
+ List<String> flagList = new ArrayList<>();
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
- //从数据库中索取所有部门及提报人
|
|
|
- Map<String, List<ReportPerson>> reportPersonMap = getReportPerson();
|
|
|
+ //从数据库中获取所有的提报人与部门
|
|
|
+ Map<String, String> reportPersonMap = getReportPerson();
|
|
|
|
|
|
- //循环比较找出 计划编制人为空添加isEmptyMap 根据计划编制人找出所在部门 物料编码-部门为去重条件
|
|
|
+ //在途物资统计表 去重汇总统计
|
|
|
onPassageMaterialsList.forEach(opm -> {
|
|
|
- //找到对应部门
|
|
|
- String reportPersonOfDepartment = getReportPersonOfDepartment(reportPersonMap,opm.getPlanner());
|
|
|
- //如果没有部门 表示空部门
|
|
|
+ //根据提报人 找到对应部门
|
|
|
+ String reportPersonOfDepartment = reportPersonMap.get(opm.getPlanner());
|
|
|
+ //如果没有部门 表示空部门 物料编码-部门
|
|
|
String key = opm.getMaterialCode() + "-" + reportPersonOfDepartment;
|
|
|
- if (sameMap.containsKey(key)) {
|
|
|
- sameMap.put(key, new BigDecimal(opm.getContractCount()).add(sameMap.get(key)));
|
|
|
+ if (onPassageMaterialsMap.containsKey(key)) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()).add(onPassageMaterialsMap.get(key)));
|
|
|
} else {
|
|
|
- sameMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
+ //项目物资需求表 去重汇总统计
|
|
|
materialInformationList.forEach(m -> {
|
|
|
+ //物料编码-部门
|
|
|
String key = m.getMaterialCode() + "-" + m.getReportingDepartment();
|
|
|
- if (materialCountMap.containsKey(key)) {
|
|
|
- materialCountMap.put(key, new BigDecimal(m.getTotal()).add(materialCountMap.get(key)));
|
|
|
+ if (materialInformationMap.containsKey(key)) {
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()).add(materialInformationMap.get(key)));
|
|
|
} else {
|
|
|
if(!m.getMaterialCode().isEmpty()&&!m.getTotal().isEmpty()){
|
|
|
-
|
|
|
- materialCountMap.put(key, new BigDecimal(m.getTotal()));
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- materialCountMap.forEach((k,v)->{
|
|
|
- if(sameMap.containsKey(k)){
|
|
|
- if(sameMap.get(k).compareTo(v)>=0){
|
|
|
- compareList.add(k);
|
|
|
+ //两表比较 添加标识
|
|
|
+ materialInformationMap.forEach((k,v)->{
|
|
|
+ if(onPassageMaterialsMap.containsKey(k)){
|
|
|
+ if(onPassageMaterialsMap.get(k).compareTo(v)>=0){
|
|
|
+ flagList.add(k);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ //根据标识在原表中追加备注
|
|
|
materialInformationList.forEach(l->{
|
|
|
String key = l.getMaterialCode() + "-" + l.getReportingDepartment();
|
|
|
- if(compareList.contains(key)){
|
|
|
- l.setRemarkText("在途已有" + sameMap.get(key)+"单位,请核实本次需求");
|
|
|
+ if(flagList.contains(key)){
|
|
|
+ l.setRemarkText("在途已有" + onPassageMaterialsMap.get(key)+"单位,请核实本次需求");
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询数据库获取对应的部门及部门下的人
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String,List<ReportPerson>> getReportPerson(){
|
|
|
- Map<String,List<ReportPerson>> map = new HashMap<>();
|
|
|
+ private Map<String,String> getReportPerson(){
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
List<ReportPerson> departmentGroupByPerson = reportPersonMapper.findDepartmentGroupByPerson();
|
|
|
departmentGroupByPerson.forEach(l->{
|
|
|
- if(map.containsKey(l.getReportDepartment())){
|
|
|
- map.get(l.getReportDepartment()).add(l);
|
|
|
- }else{
|
|
|
- List<ReportPerson> reportPeople = new ArrayList<>();
|
|
|
- reportPeople.add(l);
|
|
|
- map.put(l.getReportDepartment(),reportPeople);
|
|
|
- }
|
|
|
+ map.put(l.getReportPerson(),l.getReportDepartment());
|
|
|
});
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取提报人部门
|
|
|
- */
|
|
|
- private String getReportPersonOfDepartment(Map<String, List<ReportPerson>> reportPerson,String name){
|
|
|
- AtomicReference<String> departmentName = new AtomicReference<>();
|
|
|
- reportPerson.forEach((k,v)->{
|
|
|
- v.forEach(l->{
|
|
|
- if(l.getReportPerson().equals(name)){
|
|
|
- departmentName.set(k);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- return departmentName.get();
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|