|
@@ -438,7 +438,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
editPrivateNode.setInitTableName(templateNode.getInitTableName());
|
|
|
|
|
|
if (StringUtil.isBlank(templateNode.getHtmlUrl())) {
|
|
|
- throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
|
|
|
+ throw new ServiceException(templateNode.getNodeName() + "( " + templateNode.getPKeyId() + ")HTML文件不存在");
|
|
|
}
|
|
|
//封装Html路径 根据模板html copy一份到自己项目节点上
|
|
|
String[] split = templateNode.getHtmlUrl().split("/");
|
|
@@ -455,7 +455,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
if (!file_in.exists() || file_in.length() == 0) {
|
|
|
//如果本地服务器上没有
|
|
|
- throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
|
|
|
+ throw new ServiceException(templateNode.getNodeName() + "( " + templateNode.getPKeyId() + ")HTML文件不存在");
|
|
|
}
|
|
|
File file_out = ResourceUtil.getFile(htmlUrl);
|
|
|
//查询父级文件夹
|
|
@@ -598,6 +598,8 @@ public class WbsSynchronousServiceImpl {
|
|
|
List<ContractInfo> contractInfos = contractInfoMapper.selectContractIdByProjectId(String.valueOf(wbsTreeSynchronousRecord.getProjectId()));
|
|
|
|
|
|
List<WbsTreeContract> editData = new ArrayList<>();
|
|
|
+ List<WbsTreeContract> oldHtml = new ArrayList<>();
|
|
|
+ StringBuilder errorMsg = new StringBuilder("");
|
|
|
for (String primaryKeyId : nodeIds) {
|
|
|
|
|
|
//获取当前节点对应节点信息
|
|
@@ -616,6 +618,9 @@ public class WbsSynchronousServiceImpl {
|
|
|
.eq(WbsTreePrivate::getType, 2)
|
|
|
.eq(WbsTreePrivate::getIsDeleted, 0)
|
|
|
.apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreePrivate.getPKeyId());
|
|
|
+ if(CollectionUtil.isNotEmpty(formList)){
|
|
|
+ wrapperPrivate.in(WbsTreePrivate::getPKeyId, formList);
|
|
|
+ }
|
|
|
//当前项目的子节点数据
|
|
|
List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectList(wrapperPrivate);
|
|
|
wbsTreePrivates.add(wbsTreePrivate);
|
|
@@ -633,7 +638,8 @@ public class WbsSynchronousServiceImpl {
|
|
|
//如果没有查询到,表示该合同下不存在该节点
|
|
|
if (CollectionUtil.isEmpty(startContacts)) {
|
|
|
//不能抛异常 不然就会中止程序 开发阶段先抛异常,后续统一处理
|
|
|
- throw new ServiceException("当前节点不存在");
|
|
|
+// throw new ServiceException("当前节点不存在");
|
|
|
+ continue;
|
|
|
}
|
|
|
for (WbsTreeContract wbsTreeContract : startContacts) {
|
|
|
//获取合同 当前节点的所有子节点数据
|
|
@@ -642,73 +648,98 @@ public class WbsSynchronousServiceImpl {
|
|
|
.eq(WbsTreeContract::getContractId, contractInfo.getId())
|
|
|
.eq(WbsTreeContract::getIsDeleted, 0)
|
|
|
.apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreeContract.getPKeyId());
|
|
|
- wrapperContract.apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreeContract.getPKeyId());
|
|
|
+ if(CollectionUtil.isNotEmpty(formList)){
|
|
|
+ wrapperContract.in(WbsTreeContract::getIsTypePrivatePid, formList);
|
|
|
+ }
|
|
|
|
|
|
//当前合同的子节点数据
|
|
|
List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(wrapperContract);
|
|
|
wbsTreeContracts.add(wbsTreeContract);
|
|
|
|
|
|
+
|
|
|
+ //获取所有表单的父节点
|
|
|
+ List<Long> pIds = wbsTreeContracts.stream().filter(f -> f.getType() == 2).map(WbsTreeContract::getPId).collect(Collectors.toList());
|
|
|
HashMap<Long, Integer> informationQueryMap = new HashMap<>();
|
|
|
- //查询质检合同节点填表信息
|
|
|
- String sql = "SELECT b.wbs_id, b.STATUS FROM" +
|
|
|
- "( SELECT p_key_id FROM m_wbs_tree_contract WHERE is_deleted = 0 AND contract_id = " + contractInfo.getId() + " AND FIND_IN_SET( " + wbsTreeContract.getPKeyId() + ", ancestors_p_id ) ) a" +
|
|
|
- " INNER JOIN ( SELECT c.wbs_id, c.STATUS FROM u_information_query c" +
|
|
|
- " JOIN ( SELECT wbs_id, MAX( update_time ) AS max_update_time FROM u_information_query WHERE contract_id = " + contractInfo.getId() + " GROUP BY wbs_id ) subquery ON c.wbs_id = subquery.wbs_id " +
|
|
|
- " AND c.update_time = subquery.max_update_time WHERE c.contract_id = " + contractInfo.getId() + " and c.is_deleted = 0 ) b ON a.p_key_id = b.wbs_id";
|
|
|
-
|
|
|
- List<InformationQuery> informationQueries = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
- //质检节点填报信息
|
|
|
-
|
|
|
- for (InformationQuery informationQuery : informationQueries) {
|
|
|
- informationQueryMap.put(informationQuery.getWbsId(), informationQuery.getStatus());
|
|
|
+ if(CollectionUtil.isNotEmpty(pIds)){
|
|
|
+ //查询质检合同节点填表信息
|
|
|
+ String sql = "SELECT c.wbs_id, c.STATUS FROM u_information_query c" +
|
|
|
+ " JOIN ( SELECT wbs_id, MAX( update_time ) AS max_update_time FROM u_information_query WHERE contract_id = " + contractInfo.getId() + " GROUP BY wbs_id ) subquery ON c.wbs_id = subquery.wbs_id " +
|
|
|
+ " AND c.update_time = subquery.max_update_time WHERE c.contract_id = " + contractInfo.getId() + " and c.is_deleted = 0 and c.wbs_id in(" + StringUtil.join(pIds,",") +")";
|
|
|
+
|
|
|
+ List<InformationQuery> informationQueries = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ //质检节点填报信息
|
|
|
+
|
|
|
+ for (InformationQuery informationQuery : informationQueries) {
|
|
|
+ informationQueryMap.put(informationQuery.getWbsId(), informationQuery.getStatus());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//合同段节点对应的项目id
|
|
|
List<Long> typePrivateIds = wbsTreeContracts.stream().map(WbsTreeContract::getIsTypePrivatePid).collect(Collectors.toList());
|
|
|
|
|
|
//需要新增的表单
|
|
|
List<WbsTreePrivate> addPrivateNodes = wbsTreePrivates.stream().filter(f -> !typePrivateIds.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
|
|
|
- //如果没有选中 则默认同步所有
|
|
|
- if (CollectionUtil.isNotEmpty(formList)) {
|
|
|
- //二次筛选 只保留任务选中的表单 但可能新增的数据包含新节点
|
|
|
- addPrivateNodes = addPrivateNodes.stream().filter(f -> formList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
//筛选出需要更新的节点 同时做数据隔离
|
|
|
List<WbsTreeContract> editContractNodes = new ArrayList<>();
|
|
|
for (WbsTreePrivate templateNode : wbsTreePrivates) {
|
|
|
//更新只跟新表单
|
|
|
for (WbsTreeContract editContractNode : wbsTreeContracts) {
|
|
|
|
|
|
+
|
|
|
// 判断模板表与项目表 html是否一致
|
|
|
if (ObjectUtils.equals(templateNode.getPKeyId(), editContractNode.getIsTypePrivatePid())) {
|
|
|
if (templateNode.getType() == 2) {
|
|
|
//同步范围 当前节点是否允许修改
|
|
|
Boolean isSync = false;
|
|
|
+
|
|
|
+ //是否记录历史html
|
|
|
+ Boolean isOldHtml = false;
|
|
|
+
|
|
|
if (CollectionUtil.isNotEmpty(contractRanges)) {
|
|
|
switch (Integer.valueOf(wbsTreePrivate.getWbsType())) {
|
|
|
//质检
|
|
|
case 1:
|
|
|
- Integer submit = informationQueryMap.get(editContractNode.getPKeyId());
|
|
|
+ //判断是否已保存
|
|
|
+ if(StringUtils.isEmpty(editContractNode.getInitTableName())){
|
|
|
+ throw new ServiceException(editContractNode.getNodeName() + "( " + editContractNode.getPKeyId() + ")--实体表不存在");
|
|
|
+ }
|
|
|
+ String isSave = "select count(0) from " + editContractNode.getInitTableName() + " where p_key_id = " + editContractNode.getPKeyId();
|
|
|
+ Integer i = jdbcTemplate.queryForObject(isSave, Integer.class);
|
|
|
+
|
|
|
+ //判断是否上报审批
|
|
|
+ Integer submit = informationQueryMap.get(editContractNode.getPId());
|
|
|
|
|
|
if (submit == null && contractRanges.contains(WbsSyncTypeEnum.NOT_FILLED_IN.code)) {
|
|
|
- //未审批 101
|
|
|
+ //未填报 101
|
|
|
isSync = true;
|
|
|
} else {
|
|
|
- if (submit == null) {
|
|
|
- throw new ServiceException(wbsTreeContract.getNodeName() + "--下表单未查到填报信息");
|
|
|
+ if (i == 0) {
|
|
|
+ isSync = false;
|
|
|
+ errorMsg.append(editContractNode.getNodeName() + "(" + editContractNode.getPKeyId() + ")").append("未填报;");
|
|
|
}
|
|
|
- if (submit == 0 && contractRanges.contains(WbsSyncTypeEnum.ALREADY_FILLED_IN_NOT_REPORTED.code)) {
|
|
|
+ if (contractRanges.contains(WbsSyncTypeEnum.ALREADY_FILLED_IN_NOT_REPORTED.code) && (submit == null || submit == 0)) {
|
|
|
//已填报-未上报 102
|
|
|
isSync = true;
|
|
|
- } else if (submit == 1 && contractRanges.contains(WbsSyncTypeEnum.PENDING_APPROVAL.code)) {
|
|
|
- //待审批 104
|
|
|
- isSync = true;
|
|
|
- } else if (submit == 2 && contractRanges.contains(WbsSyncTypeEnum.APPROVED.code)) {
|
|
|
- //已审批 105
|
|
|
- isSync = true;
|
|
|
+ } else {
|
|
|
+ if (submit == null) {
|
|
|
+ isSync = false;
|
|
|
+ errorMsg.append(editContractNode.getNodeName() + "(" + editContractNode.getPKeyId() + ")").append("未上报;");
|
|
|
+ }else{
|
|
|
+ if (submit == 1 && contractRanges.contains(WbsSyncTypeEnum.PENDING_APPROVAL.code)) {
|
|
|
+ //待审批 104
|
|
|
+ isSync = true;
|
|
|
+ isOldHtml = true;
|
|
|
+ } else if (submit == 2 && contractRanges.contains(WbsSyncTypeEnum.APPROVED.code)) {
|
|
|
+ //已审批 105
|
|
|
+ isSync = true;
|
|
|
+ isOldHtml = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -734,6 +765,10 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
//清表 公式 元素
|
|
|
if (collect.contains(2) || collect.contains(3) || collect.contains(5)) {
|
|
|
+ if(collect.contains(2) && (templateNode.getHtmlUrl() == null || templateNode.getInitTableName() == null || templateNode.getExcelId() == null)){
|
|
|
+ errorMsg.append(editContractNode.getNodeName() + "(" + editContractNode.getPKeyId() + ")").append("未配置清表;");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
editContractNode.setExcelId(templateNode.getExcelId());
|
|
|
editContractNode.setInitTableName(templateNode.getInitTableName());
|
|
|
editContractNode.setHtmlUrl(templateNode.getHtmlUrl());
|
|
@@ -747,21 +782,15 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
|
|
|
//手动选中的表单 进行筛选
|
|
|
- if (CollectionUtil.isNotEmpty(formList)) {
|
|
|
- if (formList.contains(templateNode.getPKeyId())) {
|
|
|
- if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
|
|
|
- if (isSync) {
|
|
|
- editContractNodes.add(editContractNode);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
|
|
|
+ if (isSync) {
|
|
|
+ editContractNodes.add(editContractNode);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
|
|
|
- if (isSync) {
|
|
|
- editContractNodes.add(editContractNode);
|
|
|
- }
|
|
|
+ //记录历史html
|
|
|
+ if (isOldHtml) {
|
|
|
+ oldHtml.add(editContractNode);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
//找到了某个选中节点下与项目节点想同的节点了 提前结束循环,节省资源
|
|
|
break;
|
|
@@ -769,10 +798,6 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //修改数据二次筛选 只保留任务选中的表单 但可能新增的数据包含新节点
|
|
|
- if (CollectionUtil.isNotEmpty(formList)) {
|
|
|
- editContractNodes = editContractNodes.stream().filter(f -> formList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
- }
|
|
|
|
|
|
//合同段新增节点
|
|
|
List<WbsTreeContract> addContractNode = null;
|
|
@@ -818,20 +843,24 @@ public class WbsSynchronousServiceImpl {
|
|
|
Set<Long> pIds = collect1.keySet();
|
|
|
Integer nodeNumEnd = 0;
|
|
|
|
|
|
+ Map<Long, List<WbsTreeContract>> collect2 = oldHtml.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
+
|
|
|
for (Long pId : pIds) {
|
|
|
nodeNumEnd++;
|
|
|
List<WbsTreeContract> list = collect1.get(pId);
|
|
|
+ List<WbsTreeContract> oldHtmlPId = collect2.get(pId);
|
|
|
|
|
|
- wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list);
|
|
|
+ wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list, oldHtmlPId);
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getNodeNumEnd, nodeNumEnd)
|
|
|
.set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
.eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getStatus, 2)
|
|
|
- .set(WbsTreeSynchronousRecord::getErrorMsg, null)
|
|
|
+ .set(WbsTreeSynchronousRecord::getErrorMsg, errorMsg.toString())
|
|
|
.set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
.eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
}
|
|
@@ -867,7 +896,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
//如果现在还找不到当前节点的父节点就表示数据有问题
|
|
|
if (addPrivateParentNodes.isEmpty()) {
|
|
|
- throw new ServiceException(addPrivateNode.getNodeName() + "-找不到父节点");
|
|
|
+ throw new ServiceException(addPrivateNode.getNodeName() + "( " + addPrivateNode.getPKeyId() + ")-找不到父节点");
|
|
|
}
|
|
|
//当前新增节点的父节点
|
|
|
WbsTreePrivate parent = addPrivateParentNodes.get(0);
|
|
@@ -902,7 +931,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
File file_in = ResourceUtil.getFile(tree.getHtmlUrl());
|
|
|
if (!file_in.exists() || file_in.length() == 0) {
|
|
|
//如果本地服务器上没有
|
|
|
- throw new ServiceException(tree.getNodeName() + "HTML文件不存在");
|
|
|
+ throw new ServiceException(tree.getNodeName() + "( " + tree.getPKeyId() + ")HTML文件不存在");
|
|
|
}
|
|
|
File file_out = ResourceUtil.getFile(htmlUrl);
|
|
|
//查询父级文件夹
|
|
@@ -1041,7 +1070,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
//如果现在还找不到当前节点的父节点就表示数据有问题
|
|
|
if (addContractParentNodes.isEmpty()) {
|
|
|
//TODO
|
|
|
- throw new ServiceException(addContractNode.getNodeName() + "-找不到父节点");
|
|
|
+ throw new ServiceException(addContractNode.getNodeName() + "( " + addContractNode.getPKeyId() + ")-找不到父节点");
|
|
|
}
|
|
|
//当前新增节点的父节点
|
|
|
WbsTreeContract parent = addContractParentNodes.get(0);
|