|
|
@@ -1,8 +1,10 @@
|
|
|
package com.xunmei.core.resumption.gx.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.utils.DateHelper;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
@@ -15,11 +17,13 @@ import com.xunmei.core.resumption.mapper.*;
|
|
|
import com.xunmei.core.resumption.vo.ResumptionTaskNewDto;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service("gxResumptionService")
|
|
|
public class ResumptionServiceImpl implements ResumptionService {
|
|
|
@@ -91,7 +95,6 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
Long planId = resumption.getPlanId();
|
|
|
resumptionPlanVos = appPlanMapper.selectResumptionPlan(planId);
|
|
|
isExist = false;
|
|
|
-
|
|
|
} else {
|
|
|
resumptionPlanVos = resumptionMapper.selectResumptionPlan(taskDetailVo.getTaskId());
|
|
|
isExist = true;
|
|
|
@@ -148,6 +151,7 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
data.setDataStatus(point.getDataStatus());
|
|
|
data.setResumptionId(taskId);
|
|
|
data.setAreaId(check.getAreaId());
|
|
|
+ data.setCheckId(point.getCheckId());
|
|
|
data.setItemId(point.getPointId());
|
|
|
data.setRectificationDeadline(point.getRectificationDeadline());
|
|
|
data.setResRemark(point.getResRemark());
|
|
|
@@ -246,20 +250,57 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
QueryWrapper<AppResumptionDataRemarkimg> qw = new QueryWrapper<>();
|
|
|
qw.lambda().eq(AppResumptionDataRemarkimg::getResumptionId, resumption.getId());
|
|
|
List<AppResumptionDataRemarkimg> imgs = appResumptionDataRemarkimgMapper.selectList(qw);
|
|
|
- for (AppResumptionDataRemarkimg img : imgs) {
|
|
|
- Long resumptionDataId = img.getResumptionDataId();
|
|
|
- List<AppResumptionDataRemarkimg> paths = imgMap.get(resumptionDataId);
|
|
|
- if (paths == null) {
|
|
|
- paths = new ArrayList<>();
|
|
|
+ imgMap = imgs.stream().collect(Collectors.groupingBy(img -> img.getResumptionDataId()));
|
|
|
+// for (AppResumptionDataRemarkimg img : imgs) {
|
|
|
+// Long resumptionDataId = img.getResumptionDataId();
|
|
|
+// List<AppResumptionDataRemarkimg> paths = imgMap.get(resumptionDataId);
|
|
|
+// if (paths == null) {
|
|
|
+// paths = new ArrayList<>();
|
|
|
+// }
|
|
|
+// paths.add(img);
|
|
|
+// imgMap.put(resumptionDataId, paths);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ResumptionNFCVo> orgNFCs = resumptionMapper.selectNFCOfOrg(resumption.getId(), resumption.getOrgId());
|
|
|
+ if (!isExist) {
|
|
|
+ //未保存过时,根据NFC-点位-区域的关系,将绑定到点位的履职内容拆解到各个区域。
|
|
|
+ List<ResumptionPlanVo> supplementItems = new ArrayList<>();
|
|
|
+
|
|
|
+ for (ResumptionPlanVo resumptionPlanVo : resumptionPlanVos) {
|
|
|
+ if (ObjectUtil.isNotNull(resumptionPlanVo.getCheckId()) && ObjectUtil.isNull(resumptionPlanVo.getAreaId())) {
|
|
|
+ Map<Long, List<ResumptionNFCVo>> areaGroup = orgNFCs.stream()
|
|
|
+ .filter(n -> ObjectUtil.equal(n.getCheckId(), resumptionPlanVo.getCheckId()))
|
|
|
+ .collect(Collectors.groupingBy(n -> n.getAreaId()));
|
|
|
+ if (CollectionUtils.isEmpty(areaGroup)) {
|
|
|
+ ResumptionPlanVo newVo = new ResumptionPlanVo();
|
|
|
+ BeanUtils.copyProperties(resumptionPlanVo, newVo);
|
|
|
+ newVo.setAreaId(-1L);
|
|
|
+
|
|
|
+ supplementItems.add(newVo);
|
|
|
+ } else {
|
|
|
+ areaGroup.forEach((area, nfcs) -> {
|
|
|
+ ResumptionPlanVo newVo = new ResumptionPlanVo();
|
|
|
+ BeanUtils.copyProperties(resumptionPlanVo, newVo);
|
|
|
+ newVo.setAreaId(area);
|
|
|
+ newVo.setAreaName(nfcs.get(0).getAreaName());
|
|
|
+ supplementItems.add(newVo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果是绑定到区域的,直接使用
|
|
|
+ supplementItems.add(resumptionPlanVo);
|
|
|
}
|
|
|
- paths.add(img);
|
|
|
- imgMap.put(resumptionDataId, paths);
|
|
|
}
|
|
|
+
|
|
|
+ resumptionPlanVos = supplementItems;
|
|
|
}
|
|
|
+
|
|
|
Integer yesPointNum = 0;
|
|
|
Integer noPointNum = 0;
|
|
|
- Map<Long, ResumptionItemVo> itemMap = new HashMap<>();
|
|
|
+ Map<String, ResumptionItemVo> itemMap = new HashMap<>();
|
|
|
Map<Long, Map<String, Integer>> itComMap = new HashMap<>();
|
|
|
+ Map<Long, AreaResumptionVo> map = new HashMap<>();
|
|
|
for (ResumptionPlanVo vo : resumptionPlanVos) {
|
|
|
if (vo.getDataStatus() == 1) {
|
|
|
noPointNum++;
|
|
|
@@ -274,7 +315,17 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
vo.getImgs().addAll(imgs);
|
|
|
}
|
|
|
}
|
|
|
- ResumptionItemVo resumptionItemVo = itemMap.get(vo.getItemId());
|
|
|
+
|
|
|
+ AreaResumptionVo areaVo = map.get(vo.getAreaId());
|
|
|
+ if (ObjectUtil.isNull(areaVo)) {
|
|
|
+ areaVo = new AreaResumptionVo();
|
|
|
+ areaVo.setAreaId(vo.getAreaId());
|
|
|
+ areaVo.setAreaName(ObjectUtil.isNull(vo.getAreaName())?"其它":vo.getAreaName());
|
|
|
+ map.put(areaVo.getAreaId(), areaVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ResumptionItemVo resumptionItemVo = itemMap.get(vo.getItemId() + "_" + vo.getAreaId());
|
|
|
if (resumptionItemVo == null) {
|
|
|
resumptionItemVo = new ResumptionItemVo();
|
|
|
}
|
|
|
@@ -286,6 +337,7 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
ResumptionPointVo pointVo = new ResumptionPointVo();
|
|
|
pointVo.setPointName(vo.getPointName());
|
|
|
pointVo.setImgs(vo.getImgs());
|
|
|
+ pointVo.setCheckId(vo.getCheckId());
|
|
|
pointVo.setPointId(vo.getPointId());
|
|
|
pointVo.setResRemark(vo.getResRemark());
|
|
|
if (vo.getResValue() == null) {
|
|
|
@@ -313,23 +365,24 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- itemMap.put(vo.getItemId(), resumptionItemVo);
|
|
|
- }
|
|
|
|
|
|
- Map<Long, AreaResumptionVo> map = new HashMap<>();
|
|
|
- List<ResumptionItemVo> items = new ArrayList<>();
|
|
|
- for (Map.Entry<Long, ResumptionItemVo> entry : itemMap.entrySet()) {
|
|
|
- ResumptionItemVo itemVo = entry.getValue();
|
|
|
- AreaResumptionVo areaData = map.get(itemVo.getAreaId());
|
|
|
- if (areaData == null) {
|
|
|
- areaData = new AreaResumptionVo();
|
|
|
- areaData.setAreaId(itemVo.getAreaId());
|
|
|
- areaData.setAreaName(itemVo.getAreaName());
|
|
|
- map.put(itemVo.getAreaId(), areaData);
|
|
|
- }
|
|
|
- items.add(itemVo);
|
|
|
+ itemMap.put(vo.getItemId() + "_" + vo.getAreaId(), resumptionItemVo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// List<ResumptionItemVo> items = new ArrayList<>();
|
|
|
+// for (Map.Entry<Long, ResumptionItemVo> entry : itemMap.entrySet()) {
|
|
|
+// ResumptionItemVo itemVo = entry.getValue();
|
|
|
+// AreaResumptionVo areaData = map.get(itemVo.getAreaId());
|
|
|
+// if (areaData == null) {
|
|
|
+// areaData = new AreaResumptionVo();
|
|
|
+// areaData.setAreaId(itemVo.getAreaId());
|
|
|
+// areaData.setAreaName(itemVo.getAreaName());
|
|
|
+// map.put(itemVo.getAreaId(), areaData);
|
|
|
+// }
|
|
|
+// items.add(itemVo);
|
|
|
+// }
|
|
|
+
|
|
|
Integer yesNFC = 0;
|
|
|
Integer noNFC = 0;
|
|
|
|
|
|
@@ -340,7 +393,9 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
AreaResumptionVo vo = entry.getValue();
|
|
|
Long areaId = entry.getKey();
|
|
|
//获取每个区域下的nfc
|
|
|
- List<ResumptionNFCVo> resumptionNFCVos = resumptionMapper.selectResumptionNFC(resumption.getId(), areaId, resumption.getOrgId());
|
|
|
+ List<ResumptionNFCVo> resumptionNFCVos = orgNFCs.stream().filter(n -> ObjectUtil.equal(n.getAreaId(), areaId)).collect(Collectors.toList());
|
|
|
+ //resumptionMapper.selectResumptionNFC(resumption.getId(), areaId, resumption.getOrgId());
|
|
|
+
|
|
|
for (ResumptionNFCVo resumptionNFCVo : resumptionNFCVos) {
|
|
|
Integer status = resumptionNFCVo.getStatus();
|
|
|
Map<String, Integer> com = itComMap.get(resumptionNFCVo.getAreaId());
|
|
|
@@ -372,7 +427,7 @@ public class ResumptionServiceImpl implements ResumptionService {
|
|
|
taskVo.setNoPointNums(noPointNum);
|
|
|
taskVo.setYesPointNums(yesPointNum);
|
|
|
taskVo.setAreas(areas);
|
|
|
- taskVo.setChecks(items);
|
|
|
+ taskVo.setChecks(ListUtil.toList(itemMap.values()));
|
|
|
taskVo.setNfcs(nfcs);
|
|
|
return taskVo;
|
|
|
}
|