|
@@ -71,8 +71,16 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
// 将NX系统数据写入ZHCX_PMQ_MANAGEMENT和ZHCX_PMQ_MANAGEMENT_RECORD
|
|
|
Map<String, List<ZhcxPmqManagementSourceDo>> groupedByOrderNo = nxSystemData.stream()
|
|
|
.collect(Collectors.groupingBy(ZhcxPmqManagementSourceDo::getOrderno));
|
|
|
+ // 按编号分组
|
|
|
groupedByOrderNo.forEach((orderNo, items) -> {
|
|
|
+ Map<String, String> queryPRowMap = new HashMap<>();
|
|
|
+ queryPRowMap.put("orderno", orderNo);
|
|
|
+ List<ZhcxPmqManagementDo> queryParentRows = managementDao.getByCode(queryPRowMap);
|
|
|
String pid = SecurityUtil.getUUID();
|
|
|
+ // 搜索该编号是否已存在
|
|
|
+ if (!queryParentRows.isEmpty()) {
|
|
|
+ pid = queryParentRows.get(0).getId();
|
|
|
+ }
|
|
|
ZhcxPmqManagementSourceDo tempRow1 = items.get(0);
|
|
|
ZhcxPmqManagementDo pRow = new ZhcxPmqManagementDo();
|
|
|
pRow.setId(pid);
|
|
@@ -84,13 +92,22 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
pRow.setProjectno(tempRow1.getProjectno());
|
|
|
pRow.setProjectname(tempRow1.getProjectname());
|
|
|
pRow.setThemepoint(tempRow1.getThemepoint());
|
|
|
+ // 搜索最大的下发时间
|
|
|
Optional<ZhcxPmqManagementSourceDo> maxEtimeObj = items.stream()
|
|
|
.filter(obj -> obj.getDistributetime() != null) // 过滤掉etime为null的对象
|
|
|
.max(Comparator.comparing(ZhcxPmqManagementSourceDo::getDistributetime));
|
|
|
Date maxDistributetime = maxEtimeObj.map(ZhcxPmqManagementSourceDo::getDistributetime).orElse(null);
|
|
|
pRow.setDistributetime(maxDistributetime);
|
|
|
- managementDao.insert(pRow);
|
|
|
- int i = 1;
|
|
|
+ // 编号不存在则新增
|
|
|
+ if (queryParentRows.isEmpty()) {
|
|
|
+ managementDao.insert(pRow);
|
|
|
+ } else {
|
|
|
+ // 编号已存在则更新最近下发时间
|
|
|
+ ZhcxPmqManagementDo saveRow = queryParentRows.get(0);
|
|
|
+ saveRow.setDistributetime(maxDistributetime);
|
|
|
+ managementDao.updateById(saveRow);
|
|
|
+ }
|
|
|
+
|
|
|
for (ZhcxPmqManagementSourceDo item : items) {
|
|
|
ZhcxPmqManagementRecoredDo recordDo = new ZhcxPmqManagementRecoredDo();
|
|
|
recordDo.setId(SecurityUtil.getUUID());
|
|
@@ -99,7 +116,6 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
recordDo.setModifydate(currentDate);
|
|
|
recordDo.setPmqmid(pid);
|
|
|
recordDo.setSeqno(item.getSeqno());
|
|
|
- recordDo.setOrderno(i);
|
|
|
recordDo.setDistributetime(item.getDistributetime());
|
|
|
recordDo.setCurrenttimes(item.getCurrenttimes());
|
|
|
recordDo.setTotaltimes(item.getTotaltimes());
|
|
@@ -130,11 +146,68 @@ public class ZhcxPMQMServiceImpl implements ZhcxPMQMService {
|
|
|
recordDo.setQcusername(String.join(",", qcNames));
|
|
|
}
|
|
|
}
|
|
|
- i += 1;
|
|
|
recoredDao.insert(recordDo);
|
|
|
}
|
|
|
});
|
|
|
sourceDao.updateProjectId();
|
|
|
+
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新关闭状态
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ void updateCloseStatusBySeq(String id) {
|
|
|
+ ZhcxPmqManagementDo row = managementDao.selectById(id);
|
|
|
+ Map<String, String> queryMap = new HashMap<>();
|
|
|
+ queryMap.put("pid", id);
|
|
|
+ List<ZhcxPmqManagementRecoredDo> list = recoredDao.getByPid(queryMap);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ // 搜索最大的下发时间
|
|
|
+ Optional<ZhcxPmqManagementRecoredDo> maxEtimeObj = list.stream()
|
|
|
+ .filter(obj -> obj.getDistributetime() != null) // 过滤掉etime为null的对象
|
|
|
+ .max(Comparator.comparing(ZhcxPmqManagementRecoredDo::getDistributetime));
|
|
|
+ Date maxDistributetime = maxEtimeObj.map(ZhcxPmqManagementRecoredDo::getDistributetime).orElse(null);
|
|
|
+
|
|
|
+ for (ZhcxPmqManagementRecoredDo item : list) {
|
|
|
+ Date newDate = item.getDistributetime();
|
|
|
+ if (newDate.before(maxDistributetime)) {
|
|
|
+ String closeStatusStr = item.getClosestatus();
|
|
|
+ if (StringUtils.isBlank(closeStatusStr) || (StringUtils.isNotBlank(closeStatusStr) && closeStatusStr.equals("未关闭"))) {
|
|
|
+ item.setClosestatus("NA");
|
|
|
+ recoredDao.updateById(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ZhcxPmqManagementRecoredDo> closeList = list.stream().filter(
|
|
|
+ obj -> StringUtils.isNotBlank(obj.getClosestatus()) && (obj.getClosestatus().equals("已关闭") || obj.getClosestatus().equals("NA"))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ if (closeList.size() == list.size()) {
|
|
|
+ row.setClosestatus("已关闭");
|
|
|
+ } else {
|
|
|
+ row.setClosestatus("未关闭");
|
|
|
+ }
|
|
|
+ managementDao.updateById(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateCloseStatusSimple(String id) {
|
|
|
+ ZhcxPmqManagementDo row = managementDao.selectById(id);
|
|
|
+ Map<String, String> queryMap = new HashMap<>();
|
|
|
+ queryMap.put("pid", id);
|
|
|
+ List<ZhcxPmqManagementRecoredDo> list = recoredDao.getByPid(queryMap);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ List<ZhcxPmqManagementRecoredDo> closeList = list.stream().filter(
|
|
|
+ obj -> StringUtils.isNotBlank(obj.getClosestatus()) && (obj.getClosestatus().equals("已关闭") || obj.getClosestatus().equals("NA"))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ if (closeList.size() == list.size()) {
|
|
|
+ row.setClosestatus("已关闭");
|
|
|
+ } else {
|
|
|
+ row.setClosestatus("未关闭");
|
|
|
+ }
|
|
|
+ managementDao.updateById(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|