Browse Source

报验点状态报表

wangming 11 months ago
parent
commit
1354f646a8

+ 3 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxItpProjectNodeStateInsideDao.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateInsideDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
 
 /**
  * <p>
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ZhcxItpProjectNodeStateInsideDao extends BaseMapper<ZhcxItpProjectNodeStateInsideDo> {
 
+    @Delete("delete from ZHCX_ITP_PROJECT_NODE_STATE_INSIDE where INSIDEID = #{insideid} and STATEID = #{stateid}")
+    void delByInside(ZhcxItpProjectNodeStateInsideDo entity);
 }

+ 3 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxItpProjectNodeStateOutsideDao.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateOutsideDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
 
 /**
  * <p>
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ZhcxItpProjectNodeStateOutsideDao extends BaseMapper<ZhcxItpProjectNodeStateOutsideDo> {
 
+    @Delete("delete from ZHCX_ITP_PROJECT_NODE_STATE_OUTSIDE where OUTSIDEID = #{outsideid} and STATEID = #{stateid}")
+    void delByInside(ZhcxItpProjectNodeStateOutsideDo entity);
 }

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

@@ -13,4 +13,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxItpProjectNodeStateInsideService extends IService<ZhcxItpProjectNodeStateInsideDo> {
 
+    /**
+     * 删除报验点明细
+     *
+     * @param inspectionId
+     * @param stateId
+     */
+    void delBySide(String inspectionId, String stateId);
 }

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

@@ -13,4 +13,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxItpProjectNodeStateOutsideService extends IService<ZhcxItpProjectNodeStateOutsideDo> {
 
+    /**
+     * 删除报验点明细
+     *
+     * @param inspectionId
+     * @param stateId
+     */
+    void delBySide(String inspectionId, String stateId);
 }

+ 7 - 2
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxItpProjectNodeStateService.java

@@ -43,8 +43,13 @@ public interface ZhcxItpProjectNodeStateService extends IService<ZhcxItpProjectN
     void relationInspection(RelationInspectionRequest req);
 
     /**
-     * 初始化
+     * 初始化-外部报验单
      *
      */
-    void initRelationInspection();
+    void initRelationOutSide();
+
+    /**
+     * 初始化-内部报验单
+     */
+    void initRelationInSide();
 }

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

@@ -4,6 +4,7 @@ import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateInsideDo;
 import com.rongwei.bscommon.sys.dao.ZhcxItpProjectNodeStateInsideDao;
 import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateInsideService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +18,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxItpProjectNodeStateInsideServiceImpl extends ServiceImpl<ZhcxItpProjectNodeStateInsideDao, ZhcxItpProjectNodeStateInsideDo> implements ZhcxItpProjectNodeStateInsideService {
 
+    @Autowired
+    private ZhcxItpProjectNodeStateInsideDao dao;
+
+    /**
+     * 删除报验点明细
+     *
+     * @param inspectionId
+     * @param stateId
+     */
+    @Override
+    public void delBySide(String inspectionId, String stateId) {
+        ZhcxItpProjectNodeStateInsideDo delEntity = new ZhcxItpProjectNodeStateInsideDo();
+        delEntity.setStateid(stateId);
+        delEntity.setInsideid(inspectionId);
+        dao.delByInside(delEntity);
+    }
 }

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

@@ -4,6 +4,7 @@ import com.rongwei.bsentity.domain.ZhcxItpProjectNodeStateOutsideDo;
 import com.rongwei.bscommon.sys.dao.ZhcxItpProjectNodeStateOutsideDao;
 import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodeStateOutsideService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +18,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxItpProjectNodeStateOutsideServiceImpl extends ServiceImpl<ZhcxItpProjectNodeStateOutsideDao, ZhcxItpProjectNodeStateOutsideDo> implements ZhcxItpProjectNodeStateOutsideService {
 
+    @Autowired
+    private ZhcxItpProjectNodeStateOutsideDao dao;
+
+    /**
+     * 删除报验点明细
+     *
+     * @param inspectionId
+     * @param stateId
+     */
+    @Override
+    public void delBySide(String inspectionId, String stateId) {
+        ZhcxItpProjectNodeStateOutsideDo delEntity = new ZhcxItpProjectNodeStateOutsideDo();
+        delEntity.setStateid(stateId);
+        delEntity.setOutsideid(inspectionId);
+        dao.delByInside(delEntity);
+    }
 }

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

@@ -182,25 +182,35 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
      *
      */
     @Override
-    public void initRelationInspection() {
+    public void initRelationOutSide() {
         //外部报验单
         List<RelactionNodeStateBo> nodeStaeList = initNodeStatusOutside();
 
-        //内部报验单
-        List<RelactionNodeStateBo> nodeStateInsideList = initNodeStatusInside();
+        SysUserVo user = zhcxCommon.getCurrentUser();
+        OperDto oper = new OperDto();
+        oper.setOperTime(new Date());
+        oper.setOperUser(user);
 
-        nodeStaeList.addAll(nodeStateInsideList);
+        //保存关联关系
+        relationInspection4Init(nodeStaeList, oper);
 
+    }
 
-        SysUserVo user = zhcxCommon.getCurrentUser();
+    /**
+     * 初始化-内部报验单
+     */
+    @Override
+    public void initRelationInSide() {
+        //内部报验单
+        List<RelactionNodeStateBo> nodeStateInsideList = initNodeStatusInside();
 
+        SysUserVo user = zhcxCommon.getCurrentUser();
         OperDto oper = new OperDto();
         oper.setOperTime(new Date());
         oper.setOperUser(user);
 
         //保存关联关系
-        relationInspection(nodeStaeList, oper);
-
+        relationInspection4Init(nodeStateInsideList, oper);
     }
 
     /**
@@ -415,6 +425,110 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
         return result;
     }
 
+    /**
+     * 初始化-关联报验单
+     *
+     * @param list
+     * @param oper
+     */
+    private void relationInspection4Init(List<RelactionNodeStateBo> list, OperDto oper) {
+        if(ObjectUtil.isEmpty(list)) {
+            return ;
+        }
+
+        ProjectNodeStateBo prjNodeState = ProjectNodeStateBo.builder()
+                .insertList(new ArrayList<>())
+                .updateList(new ArrayList<>())
+                .insideStateList(new ArrayList<>())
+                .outsideStateList(new ArrayList<>())
+                .build();
+        for(RelactionNodeStateBo state : list) {
+            LambdaQueryWrapper<ZhcxItpProjectNodeStateDo> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.eq(ZhcxItpProjectNodeStateDo::getPrjid, state.getProjectId())
+                    .eq(ZhcxItpProjectNodeStateDo::getMathinecode, state.getMachineNo())
+                    .eq(ZhcxItpProjectNodeStateDo::getNodeid, state.getNodeId());
+            List<ZhcxItpProjectNodeStateDo> stateList = list(queryWrapper);
+            ZhcxItpProjectNodeStateDo stateDo = BusinessFunUtils.getPrjNodeState(stateList);
+
+            ZhcxItpProjectNodeStateDo entity = new ZhcxItpProjectNodeStateDo();
+            //内部报验单
+            if("inside".equals(state.getType())) {
+                entity.setIntimes(state.getInspectionCount());
+                entity.setInstate(state.getConclusion());
+
+                if("10".equals(state.getConclusion()) || "30".equals(state.getConclusion())) {
+                    entity.setIncompletetime(state.getComplateTime());
+                }
+            }
+            //外部
+            else {
+                entity.setOuttimes(state.getInspectionCount());
+                entity.setOutstate(state.getConclusion());
+
+                if("10".equals(state.getConclusion()) || "30".equals(state.getConclusion())) {
+                    entity.setOutcompletetime(state.getComplateTime());
+                }
+            }
+
+            if(ObjectUtil.isNull(stateDo)) {
+                entity.setId(SecurityUtil.getUUID());
+                entity.setMathinecode(state.getMachineNo());
+                entity.setPrjid(state.getProjectId());
+                entity.setNodeid(state.getNodeId());
+                entity.setDeleted("0");
+                prjNodeState.getInsertList().add(entity);
+            } else {
+                entity.setId(stateDo.getId());
+                prjNodeState.getUpdateList().add(entity);
+            }
+
+            if("inside".equals(state.getType())) {
+                //内部报验报验点明细
+                for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
+                    //同一个报验点,只能存一份
+//                    LambdaQueryWrapper<ZhcxItpProjectNodeStateInsideDo> delWrapper = Wrappers.lambdaQuery();
+//                    delWrapper.eq(ZhcxItpProjectNodeStateInsideDo::getInsideid, nodeInspection.getInspectionId())
+//                            .eq(ZhcxItpProjectNodeStateInsideDo::getStateid, entity.getId());
+//                    nodeStateInsideService.remove(delWrapper);
+//                    nodeStateInsideService.delBySide(nodeInspection.getInspectionId(), entity.getId());
+
+                    ZhcxItpProjectNodeStateInsideDo insideState = new ZhcxItpProjectNodeStateInsideDo();
+                    insideState.setId(SecurityUtil.getUUID());
+                    insideState.setInspectioncode(nodeInspection.getInspectionCode());
+                    insideState.setLaunchtype(nodeInspection.getLaunchType());
+                    insideState.setDeleted("0");
+                    insideState.setStateid(entity.getId());
+                    insideState.setInsideid(nodeInspection.getInspectionId());
+
+                    prjNodeState.getInsideStateList().add(insideState);
+                }
+            } else {
+                //外部报验报验点明细
+                for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
+                    //同一个报验点,只能存一份
+//                    LambdaQueryWrapper<ZhcxItpProjectNodeStateOutsideDo> delWrapper = Wrappers.lambdaQuery();
+//                    delWrapper.eq(ZhcxItpProjectNodeStateOutsideDo::getOutsideid, nodeInspection.getInspectionId())
+//                            .eq(ZhcxItpProjectNodeStateOutsideDo::getStateid, entity.getId());
+//                    nodeStateOutsideService.remove(delWrapper);
+//                    nodeStateOutsideService.delBySide(nodeInspection.getInspectionId(), entity.getId());
+
+                    ZhcxItpProjectNodeStateOutsideDo outsideState = new ZhcxItpProjectNodeStateOutsideDo();
+                    outsideState.setId(SecurityUtil.getUUID());
+                    outsideState.setInspectioncode(nodeInspection.getInspectionCode());
+                    outsideState.setLaunchtype(nodeInspection.getLaunchType());
+                    outsideState.setDeleted("0");
+                    outsideState.setStateid(entity.getId());
+                    outsideState.setOutsideid(nodeInspection.getInspectionId());
+
+                    prjNodeState.getOutsideStateList().add(outsideState);
+                }
+            }
+        }
+
+        //持久化
+        saveNode(prjNodeState);
+    }
+
     /**
      * 关联报验单
      *
@@ -476,10 +590,11 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
                 //内部报验报验点明细
                 for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
                     //同一个报验点,只能存一份
-                    LambdaQueryWrapper<ZhcxItpProjectNodeStateInsideDo> delWrapper = Wrappers.lambdaQuery();
-                    delWrapper.eq(ZhcxItpProjectNodeStateInsideDo::getInsideid, nodeInspection.getInspectionId())
-                            .eq(ZhcxItpProjectNodeStateInsideDo::getStateid, entity.getId());
-                    nodeStateInsideService.remove(delWrapper);
+//                    LambdaQueryWrapper<ZhcxItpProjectNodeStateInsideDo> delWrapper = Wrappers.lambdaQuery();
+//                    delWrapper.eq(ZhcxItpProjectNodeStateInsideDo::getInsideid, nodeInspection.getInspectionId())
+//                            .eq(ZhcxItpProjectNodeStateInsideDo::getStateid, entity.getId());
+//                    nodeStateInsideService.remove(delWrapper);
+                    nodeStateInsideService.delBySide(nodeInspection.getInspectionId(), entity.getId());
 
                     ZhcxItpProjectNodeStateInsideDo insideState = new ZhcxItpProjectNodeStateInsideDo();
                     insideState.setId(SecurityUtil.getUUID());
@@ -495,10 +610,11 @@ public class ZhcxItpProjectNodeStateServiceImpl extends ServiceImpl<ZhcxItpProje
                 //外部报验报验点明细
                 for(RelactionNodeStateInspectionBo nodeInspection : state.getInspectionList()) {
                     //同一个报验点,只能存一份
-                    LambdaQueryWrapper<ZhcxItpProjectNodeStateOutsideDo> delWrapper = Wrappers.lambdaQuery();
-                    delWrapper.eq(ZhcxItpProjectNodeStateOutsideDo::getOutsideid, nodeInspection.getInspectionId())
-                            .eq(ZhcxItpProjectNodeStateOutsideDo::getStateid, entity.getId());
-                    nodeStateOutsideService.remove(delWrapper);
+//                    LambdaQueryWrapper<ZhcxItpProjectNodeStateOutsideDo> delWrapper = Wrappers.lambdaQuery();
+//                    delWrapper.eq(ZhcxItpProjectNodeStateOutsideDo::getOutsideid, nodeInspection.getInspectionId())
+//                            .eq(ZhcxItpProjectNodeStateOutsideDo::getStateid, entity.getId());
+//                    nodeStateOutsideService.remove(delWrapper);
+                    nodeStateOutsideService.delBySide(nodeInspection.getInspectionId(), entity.getId());
 
                     ZhcxItpProjectNodeStateOutsideDo outsideState = new ZhcxItpProjectNodeStateOutsideDo();
                     outsideState.setId(SecurityUtil.getUUID());

+ 15 - 3
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxItpProjectNodeStateController.java

@@ -38,9 +38,21 @@ public class ZhcxItpProjectNodeStateController {
      * @return
      */
     @ApiOperation("初始化报验点下的报验单")
-    @PostMapping("/init/relation")
-    public R initRelationInspection(){
-        service.initRelationInspection();
+    @PostMapping("/init/relationOutSide")
+    public R initRelationOutSide(){
+        service.initRelationOutSide();
+        return R.ok();
+    }
+
+    /**
+     * 关联报验单
+     *
+     * @return
+     */
+    @ApiOperation("初始化报验点下的报验单")
+    @PostMapping("/init/relationInSide")
+    public R initRelationInSide(){
+        service.initRelationInSide();
         return R.ok();
     }
 }