guarantee-lsq il y a 2 ans
Parent
commit
9f78186fdd

+ 40 - 4
platform-service/src/main/java/com/platform/service/fill/impl/FillGatherTaskServiceImpl.java

@@ -1,5 +1,8 @@
 package com.platform.service.fill.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.cache.ConfigCache;
@@ -178,26 +181,59 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
         // 已填报数据
         FillGatherTask task = mapper.selectByPrimaryKey(model.getId());
         FillGatherTask updTask = new FillGatherTask();
-        int waitNum = task.getTotalNum() - model.getDetails().size();
+        int waitNum = task.getTotalNum() - getFilledDataNum(model.getDetails());
         updTask.setId(task.getId());
         updTask.setWaitNum(waitNum);
         if(waitNum == 0){
             updTask.setStatus(FillGatherTaskStatusEnum.COMPLETED.getValue());
         }
         mapper.updateByPrimaryKeySelective(updTask);
-        // 修正填报项,前端只传送填报的值集合
-        for(FillGatherTaskDetailDTO detail : model.getDetails()){
+    }
+
+    /**
+     * 保存填报内容
+     * @param details
+     * @return
+     */
+    private int getFilledDataNum(List<FillGatherTaskDetailDTO> details){
+        int num = 0;
+        for(FillGatherTaskDetailDTO detail : details){
             FillGatherTaskDetail updDetail = new FillGatherTaskDetail();
             updDetail.setId(detail.getId());
+            // 判断是否完成填报
+            isCompleted(detail.getContent());
             updDetail.setContent(detail.getContent());
             updDetail.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
             updDetail.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
             updDetail.setUpdateTime(LocalDateTime.now());
-            updDetail.setStatus(1);
+            if(isCompleted(detail.getContent())){
+                updDetail.setStatus(1);
+                num++;
+            }
             fillGatherTaskDetailMapper.updateByPrimaryKeySelective(updDetail);
         }
+        return num;
+    }
+
+    /**
+     * 单项是否完成填报
+     * @param content
+     * @return
+     */
+    private boolean isCompleted(String content){
+        boolean flag = Boolean.TRUE;
+        JSONArray array = JSON.parseArray(content);
+        for(int i=0;i<array.size();i++){
+            JSONObject jsonObject = array.getJSONObject(i);
+            if(StringUtils.isBlank(jsonObject.getString("fillValue"))){
+                flag = Boolean.FALSE;
+                break;
+            }
+        }
+        return flag;
     }
 
+
     @Override
     public FillGatherTaskVO getVOById(String id) {
         FillGatherTask task = mapper.selectByPrimaryKey(id);