Jelajahi Sumber

报验点状态报表数据初始化

wangming 11 bulan lalu
induk
melakukan
6384d88f9e

+ 26 - 14
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxInsideInspectionDao.java

@@ -1,5 +1,6 @@
 package com.rongwei.bscommon.sys.dao;
 
+import com.alibaba.fastjson.JSONObject;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwei.bsentity.vo.ZhcxInsideInspectionVo;
@@ -31,20 +32,20 @@ public interface ZhcxInsideInspectionDao extends BaseMapper<ZhcxInsideInspection
             " where i.ID = d.INSIDEID and d.INSPECTIONCONCLUSION = '20' and i.ID = #{id}")
     void updateInspectionCount(Map<String, String> map);
 
-    @Select("SELECT\n" +
-            "      o.*,\n" +
-            "      parento.FULLNAME AS PFULLNAME,\n" +
-            "      parento.SHORTNAME AS PSHORTNAME,\n" +
-            "      parento.FULLPID AS PFULLPID\n" +
-            "    FROM\n" +
-            "      INCONTROL.SYS_ORGANIZATION o\n" +
-            "    JOIN INCONTROL.SYS_USER_ORG uo ON\n" +
-            "      uo.ORGID = o.ID\n" +
-            "      AND uo.DELETED = '0'\n" +
-            "    JOIN INCONTROL.SYS_ORGANIZATION parento ON\n" +
-            "      parento.ID = o.PID  AND parento.DELETED = '0'\n" +
-            "    JOIN SYS_USER u ON u.ID = uo.USERID AND u.DELETED = '0'\n" +
-            "    WHERE\n" +
+    @Select("SELECT " +
+            "      o.*, " +
+            "      parento.FULLNAME AS PFULLNAME, " +
+            "      parento.SHORTNAME AS PSHORTNAME, " +
+            "      parento.FULLPID AS PFULLPID " +
+            "    FROM " +
+            "      INCONTROL.SYS_ORGANIZATION o " +
+            "    JOIN INCONTROL.SYS_USER_ORG uo ON " +
+            "      uo.ORGID = o.ID " +
+            "      AND uo.DELETED = '0' " +
+            "    JOIN INCONTROL.SYS_ORGANIZATION parento ON " +
+            "      parento.ID = o.PID  AND parento.DELETED = '0' " +
+            "    JOIN SYS_USER u ON u.ID = uo.USERID AND u.DELETED = '0' " +
+            "    WHERE " +
             "      u.ID = #{checkerId}" +
             "      AND uo.DELETED = '0'")
     List<Map<String, String>> getLaboratoryByCheckId(@Param("checkerId") String checkerId);
@@ -68,4 +69,15 @@ public interface ZhcxInsideInspectionDao extends BaseMapper<ZhcxInsideInspection
             "where 1=1")
     @MapKey("name")
     Map<String, SysUserDo> selectSupervision();
+
+
+    @Select("SELECT   " +
+            "  zii.*,   " +
+            "  ziid.INSPECTIONCONCLUSION   " +
+            " FROM   " +
+            "  ZHCX_INSIDE_INSPECTION zii  " +
+            " JOIN ZHCX_INSIDE_INSPECTION_DISPATCH ziid ON ziid.INSIDEID = zii.ID AND ziid.DELETED = '0'   " +
+            " WHERE zii.DELETED = '0'   " +
+            " AND zii.INSPECTIONSTATUS IN ('30', '40')")
+    List<JSONObject> getInitNodeStateInspection();
 }

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionService.java

@@ -1,5 +1,6 @@
 package com.rongwei.bscommon.sys.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
@@ -95,4 +96,10 @@ public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspecti
     int downloadFile(ZhcxInsideExportRequest exportReq, HttpServletResponse response);
 
     void updateSupervision(List<ZhcxInsideInspectionVo> list);
+
+
+    /**
+     * 获取初始化报验点状态报验单
+     */
+    List<JSONObject> getInitNodeStateInspection();
 }

+ 9 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionServiceImpl.java

@@ -8,6 +8,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -625,6 +626,14 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         }
     }
 
+    /**
+     * 获取初始化报验点状态报验单
+     */
+    @Override
+    public List<JSONObject> getInitNodeStateInspection() {
+        return dao.getInitNodeStateInspection();
+    }
+
     /**
      * 保存历史记录
      *

+ 85 - 2
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxItpProjectNodeStateServiceImpl.java

@@ -1,6 +1,7 @@
 package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.service.*;
@@ -101,7 +102,7 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
                 dto.setSaveType("update");
             }
             entity.setOuttimes(itpDo.getInspectioncount());
-//取消
+            //取消
             if("10".equals(operType)) {
                 entity.setOutstate("40");
             }
@@ -183,15 +184,97 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
     @Override
     public void initRelationInspection() {
         //外部报验单
+        List<RelactionNodeStateBo> nodeStaeList = initNodeStatusOutside();
 
         //内部报验单
+        List<RelactionNodeStateBo> nodeStateInsideList = initNodeStatusInside();
+
+        nodeStaeList.addAll(nodeStateInsideList);
+
+
+        SysUserVo user = zhcxCommon.getCurrentUser();
+
+        OperDto oper = new OperDto();
+        oper.setOperTime(new Date());
+        oper.setOperUser(user);
+
+        //保存关联关系
+        relationInspection(nodeStaeList, oper);
+
     }
 
     /**
      * 保存外部报验单
      */
-    private void saveNodeStatusOutside() {
+    private List<RelactionNodeStateBo> initNodeStatusInside() {
+        List<JSONObject> inspectionList = insideInspectionService.getInitNodeStateInspection();
 
+        return assembleInitNodeStatusList(inspectionList);
+    }
+
+    /**
+     * 保存外部报验单
+     */
+    private List<RelactionNodeStateBo> initNodeStatusOutside() {
+        List<JSONObject> inspectionList = outsideInspectionItpService.getInitNodeStateInspection();
+
+        return assembleInitNodeStatusList(inspectionList);
+    }
+
+    /**
+     * 组装保存数据
+     *
+     * @param inspectionList
+     * @return
+     */
+    private List<RelactionNodeStateBo> assembleInitNodeStatusList(List<JSONObject> inspectionList) {
+        if(ObjectUtil.isEmpty(inspectionList)) {
+            return Collections.emptyList();
+        }
+
+        List<RelactionNodeStateBo> list = new ArrayList<>();
+        for(JSONObject inspection : inspectionList) {
+            String machineNoStr = inspection.getString("MACHINENO");
+            if(ObjectUtil.isEmpty(machineNoStr)) {
+                machineNoStr = inspection.getString("STRUCTUREMACHINENO");
+            }
+            if(ObjectUtil.isEmpty(machineNoStr)) {
+                continue;
+            }
+
+            String[] machinenos = machineNoStr.split(",");
+
+            for(String machineNo : machinenos) {
+
+                RelactionNodeStateBo nodeStateBo = RelactionNodeStateBo.builder()
+                        .projectId(inspection.getString("PROJECTID"))
+                        .projectCode(inspection.getString("PROJECTCODE"))
+                        .projectName(inspection.getString("PROJECTNAME"))
+                        .nodeId(inspection.getString("INSPECTIONCONTENTID"))
+                        .machineNo(machineNo)
+                        .conclusion(inspection.getString("INSPECTIONCONCLUSION"))
+                        .inspectionCount(inspection.getInteger("INSPECTIONCOUNT"))
+                        .complateTime(inspection.getDate("INSPECTIONCOMPLATETIME"))
+                        .type("outside")
+                        .build();
+                if("40".equals(inspection.getString("INSPECTIONSTATUS"))) {
+                    nodeStateBo.setConclusion("40");
+                }
+
+                List<RelactionNodeStateInspectionBo> stateInspectionList = new ArrayList<>(1);
+                stateInspectionList.add(RelactionNodeStateInspectionBo.builder()
+                        .inspectionId(inspection.getString("ID"))
+                        .inspectionCode(inspection.getString("INSPECTIONCODE"))
+                        .launchType(inspection.getString("LAUNCHTYPE"))
+                        .build());
+
+                nodeStateBo.setInspectionList(stateInspectionList);
+
+                list.add(nodeStateBo);
+            }
+        }
+
+        return list;
     }
 
     /**

+ 12 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxItpProjectNodeStateController.java

@@ -31,4 +31,16 @@ public class ZhcxItpProjectNodeStateController {
         service.relationInspection(req);
         return R.ok();
     }
+
+    /**
+     * 关联报验单
+     *
+     * @return
+     */
+    @ApiOperation("初始化报验点下的报验单")
+    @PostMapping("/init/relation")
+    public R initRelationInspection(){
+        service.initRelationInspection();
+        return R.ok();
+    }
 }