gaoxiong преди 1 година
родител
ревизия
5256185e8e
променени са 1 файла, в които са добавени 88 реда и са изтрити 32 реда
  1. 88 32
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java

+ 88 - 32
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java

@@ -104,7 +104,7 @@ public class ResumptionServiceImpl implements ResumptionService {
         boolean isExist = false;
         if (ResumptionStatus.NO_START.getCode().equals(status) || ResumptionStatus.OUT_DATE.getCode().equals(status)) {
             //待履职 和已过期的数据是没有保存过数据的只能根据计划获取
-            resumptionPlanVos = appPlanMapper.selectResumptionPlan(resumption.getPlanId(),resumption.getOrgId());
+            resumptionPlanVos = appPlanMapper.selectResumptionPlan(resumption.getPlanId(), resumption.getOrgId());
         } else {
             resumptionPlanVos = resumptionMapper.selectResumptionPlan(taskDetailVo.getTaskId());
             isExist = true;
@@ -281,13 +281,59 @@ public class ResumptionServiceImpl implements ResumptionService {
     }
 
 
+    private void getTaskNfc(List<ResumptionPlanVo> resumptionPlanVos,List<ResumptionNFCVo> nfcs,Resumption resumption){
+
+        if (ResumptionStatus.COMPLETED.getCode().equals(resumption.getStatus())) {
+            //已提交的只显示nfc扫描的记录
+            nfcs = nfcs.stream().filter(n -> n.getStatus() == 1).collect(Collectors.toList());
+        }
+        if(ResumptionStatus.PROGRESS.getCode().equals(resumption.getStatus())){
+            //已保存时,只显示保存后的记录
+            nfcs = nfcs.stream().filter(n -> n.getStatus() != null).collect(Collectors.toList());
+        }
+
+        if(ResumptionStatus.NO_START.getCode().equals(resumption.getStatus()) ||
+                ResumptionStatus.OUT_DATE.getCode().equals(resumption.getStatus())){
+            //待履职时,需要对所有标签进行筛选
+            List<ResumptionNFCVo> news = new ArrayList<>();
+            Set<Long> areaIds = new HashSet<>();
+            Set<String> acs = new HashSet<>();
+            for (ResumptionPlanVo vo : resumptionPlanVos) {
+                Long areaId = vo.getAreaId();
+                Long checkId = vo.getCheckId();
+
+                if(areaId != null && checkId == null){
+                    areaIds.add(areaId);
+                }
+
+                if(areaId!=null && checkId != null){
+                    acs.add(areaId + "_" + checkId);
+                }
+
+            }
+
+            for (ResumptionNFCVo nfc : nfcs) {
+                if(areaIds.contains(nfc.getAreaId())){
+                    news.add(nfc);
+                }
+
+                if(acs.contains(nfc.getAreaId() + "_"+ nfc.getCheckId())){
+                    news.add(nfc);
+                }
+            }
+            nfcs.clear();;
+            nfcs.addAll(news);
+
+        }
+    }
 
 
     /**
      * 组装数据
+     *
      * @param resumptionPlanVos 履职具体内容数据
-     * @param isExist 是否已保存或者提交数据
-     * @param resumption 履职任务信息
+     * @param isExist           是否已保存或者提交数据
+     * @param resumption        履职任务信息
      * @return 封装后的履职数据
      */
     private ResumptionTaskDetailVo assemblyData(List<ResumptionPlanVo> resumptionPlanVos, boolean isExist, Resumption resumption) {
@@ -304,11 +350,18 @@ public class ResumptionServiceImpl implements ResumptionService {
         taskVo.setTaskName(resumption.getName());
         taskVo.setStatus(resumption.getStatus());
 
-        //获取任务的所有NFC信息
+        /**
+         * 获取 机构下所有nfc数据
+         */
         List<ResumptionNFCVo> nfcs = resumptionMapper.selectNFCOfOrg(resumption.getId(), resumption.getOrgId());
-        if(ResumptionStatus.COMPLETED.getCode().equals(resumption.getStatus())){
-            nfcs = nfcs.stream().filter(n -> n.getStatus() == 1).collect(Collectors.toList());
-        }
+        getTaskNfc(resumptionPlanVos,nfcs,resumption);
+
+        /**
+         * nfc按区域分组,并统计已扫描和未扫描的数量
+         */
+        Map<String,Integer> nfcGroupCount = new HashMap<>();
+        groupNFCByAreaId(nfcs,nfcGroupCount);
+
 
         //获取任务的所有图片信息
         Map<Long, List<AppResumptionDataRemarkimg>> imgMap = new HashMap<>();
@@ -328,19 +381,20 @@ public class ResumptionServiceImpl implements ResumptionService {
         //区域数据
         Map<Long, AreaResumptionVo> map = new HashMap<>();
 
-        dealData(resumptionPlanVos, imgMap, itemMap, itComMap, map, noPointNum, yesPointNum,isExist);
+        dealData(resumptionPlanVos, imgMap, itemMap, itComMap, map, noPointNum, yesPointNum, isExist);
 
-        Map<String, Integer> groupNFC = groupNFCByAreaId(nfcs);
 
         int yesNFC = 0;
         int noNFC = 0;
         List<AreaResumptionVo> areas = new ArrayList<>();
+        List<ResumptionNFCVo> taskNfc = new ArrayList<>();
         for (Map.Entry<Long, AreaResumptionVo> entry : map.entrySet()) {
             AreaResumptionVo vo = entry.getValue();
             Long areaId = entry.getKey();
-            Integer unScan = groupNFC.get(areaId + "_0");
-            Integer scan = groupNFC.get(areaId + "_1");
-            if(unScan == null){
+            Integer unScan = nfcGroupCount.get(areaId + "_0");
+            Integer scan = nfcGroupCount.get(areaId + "_1");
+
+            if (unScan == null) {
                 unScan = 0;
             }
             if (scan == null) {
@@ -369,50 +423,52 @@ public class ResumptionServiceImpl implements ResumptionService {
         taskVo.setYesPointNums(yesPointNum);
         taskVo.setAreas(areas);
         taskVo.setChecks(ListUtil.toList(itemMap.values()));
-        taskVo.setNfcs(nfcs);
+        taskVo.setNfcs(nfcs );
         return taskVo;
     }
 
     /**
      * 区域统计NFC扫描未扫描的数量
+     *
      * @param nfcs
      * @return
      */
-    private Map<String,Integer> groupNFCByAreaId(List<ResumptionNFCVo> nfcs){
-        Map<String,Integer> map = new HashMap<>();
+
+    private void groupNFCByAreaId(List<ResumptionNFCVo> nfcs,Map<String,Integer> map) {
+
         for (ResumptionNFCVo nfc : nfcs) {
             Integer status = nfc.getStatus();
-            if(status == 0){
+            if (status == 0) {
                 Integer count = map.get(nfc.getAreaId() + "_0");
-                if(count == null){
+                if (count == null) {
                     count = 0;
                 }
                 count++;
-                map.put(nfc.getAreaId() + "_0",count);
+                map.put(nfc.getAreaId() + "_0", count);
             }
-            if(status == 1){
+            if (status == 1) {
                 Integer count = map.get(nfc.getAreaId() + "_1");
-                if(count == null){
+                if (count == null) {
                     count = 0;
                 }
                 count++;
-                map.put(nfc.getAreaId() + "_1",count);
+                map.put(nfc.getAreaId() + "_1", count);
             }
         }
-        return map;
     }
 
 
     /**
      * 封装处理数据
+     *
      * @param resumptionPlanVos 任务检查数据
-     * @param imgMap 图片数据
-     * @param itemMap 要点数据
-     * @param itComMap 区域数据
-     * @param map 区域数据
-     * @param noPointNum 未执行的检查要点
-     * @param yesPointNum 已执行的检查要点
-     * @param isExist 是否已完成
+     * @param imgMap            图片数据
+     * @param itemMap           要点数据
+     * @param itComMap          区域数据
+     * @param map               区域数据
+     * @param noPointNum        未执行的检查要点
+     * @param yesPointNum       已执行的检查要点
+     * @param isExist           是否已完成
      */
     private void dealData(List<ResumptionPlanVo> resumptionPlanVos,
                           Map<Long, List<AppResumptionDataRemarkimg>> imgMap,
@@ -420,7 +476,7 @@ public class ResumptionServiceImpl implements ResumptionService {
                           Map<Long, Map<String, Integer>> itComMap,
                           Map<Long, AreaResumptionVo> map,
                           Integer noPointNum,
-                          Integer yesPointNum,boolean isExist){
+                          Integer yesPointNum, boolean isExist) {
 
         for (ResumptionPlanVo vo : resumptionPlanVos) {
 
@@ -500,13 +556,13 @@ public class ResumptionServiceImpl implements ResumptionService {
     }
 
 
-
     /**
      * 根据履职任务id,获取履职过程中产生的图片数据
+     *
      * @param resumptionId 履职任务id
      * @return 按照履职data数据id为key的map数据
      */
-    private  Map<Long, List<AppResumptionDataRemarkimg>> getResumptionDataImg(Long resumptionId){
+    private Map<Long, List<AppResumptionDataRemarkimg>> getResumptionDataImg(Long resumptionId) {
         Map<Long, List<AppResumptionDataRemarkimg>> imgMap = new HashMap<>();
         QueryWrapper<AppResumptionDataRemarkimg> qw = new QueryWrapper<>();
         qw.lambda().eq(AppResumptionDataRemarkimg::getResumptionId, resumptionId);