|
@@ -3,6 +3,7 @@
|
|
|
*/
|
|
|
package com.jeeplus.modules.sg.balancedlibrary.onPassageMaterials.service;
|
|
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
import com.jeeplus.core.service.CrudService;
|
|
|
import com.jeeplus.modules.sg.balancedlibrary.onPassageMaterials.entity.MaterialInformation;
|
|
|
import com.jeeplus.modules.sg.balancedlibrary.onPassageMaterials.entity.OnPassageMaterials;
|
|
@@ -21,6 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
/**
|
|
|
* 在途物资Service
|
|
|
+ *
|
|
|
* @author 徐滕
|
|
|
* @version 1.0
|
|
|
*/
|
|
@@ -31,7 +33,7 @@ public class OnPassageMaterialsService extends CrudService<OnPassageMaterialsMap
|
|
|
@Autowired
|
|
|
private ReportPersonMapper reportPersonMapper;
|
|
|
|
|
|
- public void comparativeData(List<OnPassageMaterials> onPassageMaterialsList, List<MaterialInformation> materialInformationList){
|
|
|
+ public void comparativeData(List<OnPassageMaterials> onPassageMaterialsList, List<MaterialInformation> materialInformationList) {
|
|
|
|
|
|
//在途物资统计表 key=统计物料编码-部门 去重汇总统计
|
|
|
Map<String, BigDecimal> onPassageMaterialsMap = new HashMap<>();
|
|
@@ -51,62 +53,73 @@ public class OnPassageMaterialsService extends CrudService<OnPassageMaterialsMap
|
|
|
|
|
|
//在途物资统计表 去重汇总统计
|
|
|
onPassageMaterialsList.forEach(opm -> {
|
|
|
+ if (StringUtils.isBlank(opm.getContractCount())) {
|
|
|
+ opm.setContractCount("0");
|
|
|
+ }
|
|
|
//根据提报人 找到对应部门
|
|
|
String reportPersonOfDepartment = reportPersonMap.get(opm.getPlanner());
|
|
|
//如果没有部门 表示空部门 物料编码-部门
|
|
|
- String key = opm.getMaterialCode() + "-" + reportPersonOfDepartment;
|
|
|
+ String key = "";
|
|
|
+ if (reportPersonOfDepartment == null) {
|
|
|
+ key = opm.getMaterialCode() + "-";
|
|
|
+ } else {
|
|
|
+ key = opm.getMaterialCode() + "-" + reportPersonOfDepartment;
|
|
|
+ }
|
|
|
if (onPassageMaterialsMap.containsKey(key)) {
|
|
|
onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()).add(onPassageMaterialsMap.get(key)));
|
|
|
} else {
|
|
|
- onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
+ if (StringUtils.isNotBlank(opm.getMaterialCode())) {
|
|
|
+ onPassageMaterialsMap.put(key, new BigDecimal(opm.getContractCount()));
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//项目物资需求表 去重汇总统计
|
|
|
materialInformationList.forEach(m -> {
|
|
|
+ if (StringUtils.isBlank(m.getTotal())) {
|
|
|
+ m.setTotal("0");
|
|
|
+ }
|
|
|
//物料编码-部门
|
|
|
String key = m.getMaterialCode() + "-" + m.getReportingDepartment();
|
|
|
if (materialInformationMap.containsKey(key)) {
|
|
|
- materialInformationMap.put(key, new BigDecimal(m.getTotal()).add(materialInformationMap.get(key)));
|
|
|
+ materialInformationMap.put(key, new BigDecimal(m.getTotal()).add(materialInformationMap.get(key)));
|
|
|
} else {
|
|
|
- if(!m.getMaterialCode().isEmpty()&&!m.getTotal().isEmpty()){
|
|
|
+ if (StringUtils.isNotBlank(m.getMaterialCode())) {
|
|
|
materialInformationMap.put(key, new BigDecimal(m.getTotal()));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//两表比较 添加标识
|
|
|
- materialInformationMap.forEach((k,v)->{
|
|
|
- if(onPassageMaterialsMap.containsKey(k)){
|
|
|
- if(onPassageMaterialsMap.get(k).compareTo(v)>=0){
|
|
|
+ materialInformationMap.forEach((k, v) -> {
|
|
|
+ if (onPassageMaterialsMap.containsKey(k)) {
|
|
|
+ if (onPassageMaterialsMap.get(k).compareTo(v) >= 0) {
|
|
|
flagList.add(k);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//根据标识在原表中追加备注
|
|
|
- materialInformationList.forEach(l->{
|
|
|
+ materialInformationList.forEach(l -> {
|
|
|
String key = l.getMaterialCode() + "-" + l.getReportingDepartment();
|
|
|
- if(flagList.contains(key)){
|
|
|
- l.setRemarkText("在途已有" + onPassageMaterialsMap.get(key)+"单位,请核实本次需求");
|
|
|
+ if (flagList.contains(key)) {
|
|
|
+ l.setRemarkText("在途已有" + onPassageMaterialsMap.get(key) + "单位,请核实本次需求");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询数据库获取对应的部门及部门下的人
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String,String> getReportPerson(){
|
|
|
- Map<String,String> map = new HashMap<>();
|
|
|
+ private Map<String, String> getReportPerson() {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
List<ReportPerson> departmentGroupByPerson = reportPersonMapper.findDepartmentGroupByPerson();
|
|
|
- departmentGroupByPerson.forEach(l->{
|
|
|
- map.put(l.getReportPerson(),l.getReportDepartment());
|
|
|
+ departmentGroupByPerson.forEach(l -> {
|
|
|
+ map.put(l.getReportPerson(), l.getReportDepartment());
|
|
|
});
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|