|
@@ -127,7 +127,10 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
/*获取meterTreeProjects差集*/
|
|
|
List<MeterTreeProject> difference = meterTreeProjects.stream()
|
|
|
.filter(project -> meterTreeContracts.stream()
|
|
|
- .noneMatch(contract -> contract.getSourceNodeId().equals(project.getId())))
|
|
|
+ .noneMatch(contract -> contract != null
|
|
|
+ && ObjectUtil.isNotEmpty(contract.getSourceNodeId())
|
|
|
+ && ObjectUtil.isNotEmpty(project.getId())
|
|
|
+ && contract.getSourceNodeId().equals(project.getId())))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
/*原始数据类型*/
|
|
@@ -999,7 +1002,7 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
Map<String, MeterTreeContract> rootNodeChildMap = new HashMap<>();
|
|
|
try {
|
|
|
rootNodeChildMap = rootNodeChild.stream().collect(Collectors.toMap(MeterTreeContract::getNodeCode, Function.identity()));
|
|
|
- }catch (IllegalStateException e){
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
throw new ServiceException("树节点的工程编号存在重复,请检查后再重新导入");
|
|
|
}
|
|
|
//获取所有子节点id
|
|
@@ -1078,76 +1081,76 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
for (Map<String, String> map : map6) {
|
|
|
MeterTreeContract node = map7.get(map.get("节点编号"));
|
|
|
//判断是否已经存在于合同段
|
|
|
- if (node == null){
|
|
|
- map.put("id",SnowFlakeUtil.getId()+"");
|
|
|
- map.put("status",0+"");
|
|
|
- }else {
|
|
|
- map.put("id",node.getId()+"");
|
|
|
- map.put("parentId",node.getParentId()+"");
|
|
|
- map.put("ancestors",node.getAncestor());
|
|
|
- map.put("status",1+"");
|
|
|
+ if (node == null) {
|
|
|
+ map.put("id", SnowFlakeUtil.getId() + "");
|
|
|
+ map.put("status", 0 + "");
|
|
|
+ } else {
|
|
|
+ map.put("id", node.getId() + "");
|
|
|
+ map.put("parentId", node.getParentId() + "");
|
|
|
+ map.put("ancestors", node.getAncestor());
|
|
|
+ map.put("status", 1 + "");
|
|
|
}
|
|
|
//保存每个首节点位置
|
|
|
- if (map.get("节点编号").split("-").length == 2){
|
|
|
+ if (map.get("节点编号").split("-").length == 2) {
|
|
|
firstNode.add(map6.indexOf(map));
|
|
|
}
|
|
|
}
|
|
|
int size = firstNode.size();
|
|
|
- if (size == 0){
|
|
|
+ if (size == 0) {
|
|
|
throw new ServiceException("未找到首节点,请检查后重新导入");
|
|
|
}
|
|
|
//根据首节点分成多个数组
|
|
|
List<List<Map<String, String>>> lists = new ArrayList<>();
|
|
|
//只有一个节点,直接单独处理
|
|
|
- if (size == 1){
|
|
|
+ if (size == 1) {
|
|
|
lists.add(map6);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//规则是首节点下跟着子节点
|
|
|
- for (int i = 0; i < size-1; i++) {
|
|
|
- lists.add(map6.subList(firstNode.get(i),firstNode.get(i+1)));
|
|
|
+ for (int i = 0; i < size - 1; i++) {
|
|
|
+ lists.add(map6.subList(firstNode.get(i), firstNode.get(i + 1)));
|
|
|
}
|
|
|
- lists.add(map6.subList(firstNode.get(size-1),map6.size()));
|
|
|
+ lists.add(map6.subList(firstNode.get(size - 1), map6.size()));
|
|
|
}
|
|
|
- Map<String,Map<String, String>> lastMap = new HashMap<>();
|
|
|
- Map<String,Map<String, String>> thisMap = new HashMap<>();
|
|
|
+ Map<String, Map<String, String>> lastMap = new HashMap<>();
|
|
|
+ Map<String, Map<String, String>> thisMap = new HashMap<>();
|
|
|
//循环保存
|
|
|
for (List<Map<String, String>> list : lists) {
|
|
|
Map<String, String> form = list.get(0);
|
|
|
String number = form.get("节点编号");
|
|
|
if (form.get("status").equals("0")) {
|
|
|
- form.put("parentId",treeContract.getId()+"");
|
|
|
- form.put("ancestors",treeContract.getAncestor()+","+treeContract.getId());
|
|
|
+ form.put("parentId", treeContract.getId() + "");
|
|
|
+ form.put("ancestors", treeContract.getAncestor() + "," + treeContract.getId());
|
|
|
}
|
|
|
- lastMap.put(number,form);
|
|
|
+ lastMap.put(number, form);
|
|
|
//循环判断层级
|
|
|
for (Map<String, String> fo : list) {
|
|
|
String num = fo.get("节点编号");
|
|
|
int i = num.split("-").length - 2;
|
|
|
- fo.put("nodeTier",i+"");
|
|
|
+ fo.put("nodeTier", i + "");
|
|
|
//设置父编号
|
|
|
if (i != 0) {
|
|
|
fo.put("parentNumber", num.substring(0, num.lastIndexOf("-")));
|
|
|
}
|
|
|
}
|
|
|
- Map<String, List<Map<String, String>>> listMap = list.parallelStream().collect(Collectors.groupingBy(l->l.get("nodeTier")));
|
|
|
+ Map<String, List<Map<String, String>>> listMap = list.parallelStream().collect(Collectors.groupingBy(l -> l.get("nodeTier")));
|
|
|
//根据层级循环,为每一层设置数据
|
|
|
for (int i = 1; i < listMap.size(); i++) {
|
|
|
- List<Map<String, String>> forms = listMap.get(i+"");
|
|
|
+ List<Map<String, String>> forms = listMap.get(i + "");
|
|
|
//如果当前层级不存在数据直接跳出
|
|
|
- if (forms == null || forms.size() == 0){
|
|
|
+ if (forms == null || forms.size() == 0) {
|
|
|
break;
|
|
|
}
|
|
|
for (Map<String, String> f : forms) {
|
|
|
Map<String, String> fo = lastMap.get(f.get("parentNumber"));
|
|
|
- if (fo == null){
|
|
|
- throw new ServiceException("节点:"+f.get("工程名称")+",未找到上级节点");
|
|
|
+ if (fo == null) {
|
|
|
+ throw new ServiceException("节点:" + f.get("工程名称") + ",未找到上级节点");
|
|
|
}
|
|
|
if (f.get("status").equals("0")) {
|
|
|
//设置父id和祖级id
|
|
|
- f.put("parentId",fo.get("id")+"");
|
|
|
- f.put("ancestors",fo.get("ancestors")+","+fo.get("id"));
|
|
|
+ f.put("parentId", fo.get("id") + "");
|
|
|
+ f.put("ancestors", fo.get("ancestors") + "," + fo.get("id"));
|
|
|
}
|
|
|
- thisMap.put(f.get("节点编号"),f);
|
|
|
+ thisMap.put(f.get("节点编号"), f);
|
|
|
}
|
|
|
lastMap = thisMap;
|
|
|
thisMap = new HashMap<>();
|
|
@@ -1157,16 +1160,16 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
//判断是否有节点没有找到上级节点
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (Map<String, String> excel : map6) {
|
|
|
- if (StringUtils.isBlank(excel.get("parentId"))){
|
|
|
- sb.append(excel.get("工程名称")+",");
|
|
|
+ if (StringUtils.isBlank(excel.get("parentId"))) {
|
|
|
+ sb.append(excel.get("工程名称") + ",");
|
|
|
}
|
|
|
}
|
|
|
- if (sb.length() > 0){
|
|
|
- throw new ServiceException("以下工程名称:"+sb.deleteCharAt(sb.length()-1)+"。未找到上级节点,请修改excel后重新导入");
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ throw new ServiceException("以下工程名称:" + sb.deleteCharAt(sb.length() - 1) + "。未找到上级节点,请修改excel后重新导入");
|
|
|
}
|
|
|
|
|
|
List<Map<String, String>> map5 = projectCodeGroup.stream().filter(l -> StringUtils.isNotBlank(l.get("清单编号"))).collect(Collectors.toList());
|
|
|
- map5.stream().forEach(l->l.put("id",SnowFlakeUtil.getId()+""));
|
|
|
+ map5.stream().forEach(l -> l.put("id", SnowFlakeUtil.getId() + ""));
|
|
|
map6.addAll(map5);
|
|
|
projectCodeGroup = map6;
|
|
|
|
|
@@ -1313,86 +1316,86 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (Map<String, String> map : rows) {
|
|
|
- String formCode = map.get("清单编号");
|
|
|
- if (formCode.isEmpty()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String buildPictureTotal = map.get("施工图数量");
|
|
|
+ for (Map<String, String> map : rows) {
|
|
|
+ String formCode = map.get("清单编号");
|
|
|
+ if (formCode.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String buildPictureTotal = map.get("施工图数量");
|
|
|
|
|
|
- /*获取原始清单详细详细*/
|
|
|
- ContractInventoryForm contractInventoryForm = ysContractInventoryFormMapsByFormNumber.getOrDefault(formCode, null);
|
|
|
- if (contractInventoryForm != null) {
|
|
|
- //相同清单编号,则同步累加
|
|
|
- if (contractInventoryForm.getFormNumber().equals(formCode)) {
|
|
|
- /*获取到对应的中间关联清单信息*/
|
|
|
- String key = contractInventoryForm.getId() + ":" + orDefault.getId();
|
|
|
- InventoryFormMeter formUpdate = inventoryFormMeterMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
- if (formUpdate != null) {
|
|
|
-
|
|
|
- /*判断是否被引用、变更*/
|
|
|
- ChangeTokenInventory orDefault1 = changeTokenInventoryMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
- InventoryFormApply orDefault2 = inventoryFormApplyMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
- if (orDefault1 != null || orDefault2 != null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ /*获取原始清单详细详细*/
|
|
|
+ ContractInventoryForm contractInventoryForm = ysContractInventoryFormMapsByFormNumber.getOrDefault(formCode, null);
|
|
|
+ if (contractInventoryForm != null) {
|
|
|
+ //相同清单编号,则同步累加
|
|
|
+ if (contractInventoryForm.getFormNumber().equals(formCode)) {
|
|
|
+ /*获取到对应的中间关联清单信息*/
|
|
|
+ String key = contractInventoryForm.getId() + ":" + orDefault.getId();
|
|
|
+ InventoryFormMeter formUpdate = inventoryFormMeterMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
+ if (formUpdate != null) {
|
|
|
|
|
|
- //累加
|
|
|
- BigDecimal bigDecimal = this.parseString(buildPictureTotal);
|
|
|
- formUpdate.setBuildPictureTotal(formUpdate.getBuildPictureTotal().add(bigDecimal));
|
|
|
+ /*判断是否被引用、变更*/
|
|
|
+ ChangeTokenInventory orDefault1 = changeTokenInventoryMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
+ InventoryFormApply orDefault2 = inventoryFormApplyMapsByFormIdAndMeterId.getOrDefault(key, null);
|
|
|
+ if (orDefault1 != null || orDefault2 != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- formUpdate.setChangeBuildPictureTotal(formUpdate.getBuildPictureTotal());
|
|
|
+ //累加
|
|
|
+ BigDecimal bigDecimal = this.parseString(buildPictureTotal);
|
|
|
+ formUpdate.setBuildPictureTotal(formUpdate.getBuildPictureTotal().add(bigDecimal));
|
|
|
|
|
|
- formUpdate.setBuildPictureMoney(formUpdate.getBuildPictureTotal().multiply(contractInventoryForm.getChangePrice())); //数量*变更后单价
|
|
|
+ formUpdate.setChangeBuildPictureTotal(formUpdate.getBuildPictureTotal());
|
|
|
|
|
|
- formUpdate.setChangeBuildPictureMoney(formUpdate.getBuildPictureMoney());
|
|
|
+ formUpdate.setBuildPictureMoney(formUpdate.getBuildPictureTotal().multiply(contractInventoryForm.getChangePrice())); //数量*变更后单价
|
|
|
|
|
|
- /*更改数量*/
|
|
|
- resultFormListUpdate.add(formUpdate);
|
|
|
+ formUpdate.setChangeBuildPictureMoney(formUpdate.getBuildPictureMoney());
|
|
|
|
|
|
- /*更新节点金额*/
|
|
|
- updateNodeSet.add(orDefault.getId());
|
|
|
+ /*更改数量*/
|
|
|
+ resultFormListUpdate.add(formUpdate);
|
|
|
+
|
|
|
+ /*更新节点金额*/
|
|
|
+ updateNodeSet.add(orDefault.getId());
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- //没有获取到,那么证明是不相同清单编号,则获取对应的清单数据,进行新增清单
|
|
|
- ContractInventoryForm contractInventoryFormAdd = contractInventoryFormMapsByFormNumber.getOrDefault(formCode, null);
|
|
|
- if (contractInventoryFormAdd != null) {
|
|
|
- InventoryFormMeter formAdd = new InventoryFormMeter();
|
|
|
- formAdd.setId(SnowFlakeUtil.getId());
|
|
|
- formAdd.setProjectId(orDefault.getProjectId());
|
|
|
- formAdd.setContractId(orDefault.getContractId());
|
|
|
+ //没有获取到,那么证明是不相同清单编号,则获取对应的清单数据,进行新增清单
|
|
|
+ ContractInventoryForm contractInventoryFormAdd = contractInventoryFormMapsByFormNumber.getOrDefault(formCode, null);
|
|
|
+ if (contractInventoryFormAdd != null) {
|
|
|
+ InventoryFormMeter formAdd = new InventoryFormMeter();
|
|
|
+ formAdd.setId(SnowFlakeUtil.getId());
|
|
|
+ formAdd.setProjectId(orDefault.getProjectId());
|
|
|
+ formAdd.setContractId(orDefault.getContractId());
|
|
|
|
|
|
- if (ObjectUtil.isNotEmpty(SecureUtil.getUser())) {
|
|
|
- formAdd.setCreateUser(SecureUtil.getUserId());
|
|
|
- formAdd.setUpdateUser(SecureUtil.getUserId());
|
|
|
- if (SecureUtil.getDeptId().contains(",")) {
|
|
|
- formAdd.setCreateDept(Long.parseLong(SecureUtil.getDeptId().split(",")[0]));
|
|
|
- } else {
|
|
|
- formAdd.setCreateDept(Long.parseLong(SecureUtil.getDeptId()));
|
|
|
- }
|
|
|
+ if (ObjectUtil.isNotEmpty(SecureUtil.getUser())) {
|
|
|
+ formAdd.setCreateUser(SecureUtil.getUserId());
|
|
|
+ formAdd.setUpdateUser(SecureUtil.getUserId());
|
|
|
+ if (SecureUtil.getDeptId().contains(",")) {
|
|
|
+ formAdd.setCreateDept(Long.parseLong(SecureUtil.getDeptId().split(",")[0]));
|
|
|
+ } else {
|
|
|
+ formAdd.setCreateDept(Long.parseLong(SecureUtil.getDeptId()));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- formAdd.setContractMeterId(orDefault.getId());
|
|
|
- formAdd.setContractFormId(contractInventoryFormAdd.getId());
|
|
|
+ formAdd.setContractMeterId(orDefault.getId());
|
|
|
+ formAdd.setContractFormId(contractInventoryFormAdd.getId());
|
|
|
|
|
|
- formAdd.setBuildPictureTotal(this.parseString(buildPictureTotal));
|
|
|
- formAdd.setChangeBuildPictureTotal(formAdd.getBuildPictureTotal());
|
|
|
- formAdd.setBuildPictureMoney(formAdd.getBuildPictureTotal().multiply(contractInventoryFormAdd.getChangePrice())); //数量*变更后单价
|
|
|
- formAdd.setChangeBuildPictureMoney(formAdd.getBuildPictureMoney());
|
|
|
+ formAdd.setBuildPictureTotal(this.parseString(buildPictureTotal));
|
|
|
+ formAdd.setChangeBuildPictureTotal(formAdd.getBuildPictureTotal());
|
|
|
+ formAdd.setBuildPictureMoney(formAdd.getBuildPictureTotal().multiply(contractInventoryFormAdd.getChangePrice())); //数量*变更后单价
|
|
|
+ formAdd.setChangeBuildPictureMoney(formAdd.getBuildPictureMoney());
|
|
|
|
|
|
- /*新增清单*/
|
|
|
- resultFormListAdd.add(formAdd);
|
|
|
+ /*新增清单*/
|
|
|
+ resultFormListAdd.add(formAdd);
|
|
|
|
|
|
- /*更新节点金额*/
|
|
|
- updateNodeSet.add(orDefault.getId());
|
|
|
+ /*更新节点金额*/
|
|
|
+ updateNodeSet.add(orDefault.getId());
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1404,10 +1407,10 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
|
|
|
if (resultNodeListAdd.size() > 0) {
|
|
|
//判断要新增的数据中,清单编号是否已经存在
|
|
|
List<String> collect = resultNodeListAdd.stream().map(l -> l.getNodeCode()).collect(Collectors.toList());
|
|
|
- if (collect.size() > 0){
|
|
|
- List<String> numbers = baseMapper.getAllEqualsNumber(meterTreeContract.getContractId(),collect);
|
|
|
- if (numbers.size() > 0){
|
|
|
- throw new ServiceException("以下节点编号已经存在:["+StringUtils.join(numbers,",")+"],请修改excel后重新导入");
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<String> numbers = baseMapper.getAllEqualsNumber(meterTreeContract.getContractId(), collect);
|
|
|
+ if (numbers.size() > 0) {
|
|
|
+ throw new ServiceException("以下节点编号已经存在:[" + StringUtils.join(numbers, ",") + "],请修改excel后重新导入");
|
|
|
}
|
|
|
}
|
|
|
this.saveBatch(resultNodeListAdd, 1000);
|