Przeglądaj źródła

内部报验功能-重新报验

wangming 1 rok temu
rodzic
commit
219eee8c79

+ 12 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxInsideInspectionDao.java

@@ -2,6 +2,9 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +16,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ZhcxInsideInspectionDao extends BaseMapper<ZhcxInsideInspectionDo> {
 
+    /**
+     * 拒收的报验单报验次数+1
+     *
+     * @param map
+     */
+    @Update("update INCONTROL.ZHCX_INSIDE_INSPECTION i, INCONTROL.ZHCX_INSIDE_INSPECTION_DISPATCH d set i.INSPECTIONCOUNT = ifnull(i.INSPECTIONCOUNT, 0) + 1" +
+            " where i.ID = d.INSIDEID and d.INSPECTIONCONCLUSION = '20' and i.ID = #{id}")
+    void updateInspectionCount(Map<String, String> map);
+
 }

+ 13 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxInsideInspectionDispatchDao.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDispatchDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Update;
 
 /**
  * <p>
@@ -13,4 +14,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ZhcxInsideInspectionDispatchDao extends BaseMapper<ZhcxInsideInspectionDispatchDo> {
 
+    /**
+     * 清空
+     *
+     * @param entity
+     */
+    @Update("update INCONTROL.ZHCX_INSIDE_INSPECTION_DISPATCH " +
+            "set SFILES = '', CANVAS = '', SIGNATURE = '', DISPATCHSTATUS = '10', CANCELTYPE = '', CANCELREASON = '', " +
+            "INSPECTIONCONCLUSION = '',REFUSEREASON='',SUPERVISIONUSERID = '',SUPERVISIONID = '',SUPERVISIONACCOUNT = ''," +
+            "SUPERVISION = '',SUPERVISIONPHONE = '',CHECKSTARTTIME = '', CHECKENDTIME = '' " +
+            "where ID = #{id}")
+    void reInspection(ZhcxInsideInspectionDispatchDo entity);
+
 }

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxInsideInspectionOperLogDao.java

@@ -2,6 +2,9 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Insert;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ZhcxInsideInspectionOperLogDao extends BaseMapper<ZhcxInsideInspectionOperLogDo> {
 
+    @Insert("INSERT INTO INCONTROL.ZHCX_INSIDE_INSPECTION_OPER_LOG(ID,TENANTID,ROPTION,DELETED,REMARK,CREATEUSERID,CREATEUSERNAME,CREATEDATE,MODIFYUSERID,MODIFYUSERNAME,MODIFYDATE,INSIDEID,OPERTYPE,OPERDESCRIPTION,OPERSOURCE,OPERTIME, OPERUSERID, OPERUSERNAME) " +
+            "SELECT guid(),TENANTID,ROPTION,DELETED,REMARK,CREATEUSERID,CREATEUSERNAME,CREATEDATE,MODIFYUSERID,MODIFYUSERNAME,MODIFYDATE,#{newItpId},OPERTYPE,OPERDESCRIPTION,OPERSOURCE,OPERTIME, OPERUSERID, OPERUSERNAME FROM INCONTROL.ZHCX_INSIDE_INSPECTION_OPER_LOG WHERE ITPID = #{itpId}")
+    int insertBySelect(Map<String, String> map);
 }

+ 12 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionDispatchService.java

@@ -20,4 +20,16 @@ public interface ZhcxInsideInspectionDispatchService extends IService<ZhcxInside
      * @param inspectionDo
      */
     void genDispatch(ZhcxInsideInspectionDo inspectionDo);
+
+
+    /**
+     * 重新报验
+     *
+     * 清空监理用户信息
+     * 更新派单状态
+     *
+     * @param id
+     * @param refuseReason
+     */
+    void reInspection(String id, String refuseReason);
 }

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

@@ -6,6 +6,7 @@ import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
 import com.rongwei.bsentity.dto.InsideOperLogDto;
 import com.rongwei.bsentity.dto.OperDto;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -42,4 +43,12 @@ public interface ZhcxInsideInspectionOperLogService extends IService<ZhcxInsideI
      * @return
      */
     void saveOperLog(InsideInspectionOperBaseDto dto, OperDto operDto, Map<String, String> descMap);
+
+    /**
+     * 复制报验单操作记录
+     *
+     * @param insideId
+     * @param newIinsideIdList
+     */
+    void copyByInsideId(String insideId, List<String> newIinsideIdList);
 }

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

@@ -3,9 +3,11 @@ package com.rongwei.bscommon.sys.service;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
+import com.rongwei.bsentity.dto.inside.InsideInspectionReInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionExecuteRequest;
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
 
 /**
  * <p>
@@ -51,4 +53,15 @@ public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspecti
      * @param req
      */
     void execute(InsideInspectionExecuteRequest req);
+
+    /**
+     * 再次报验
+     * 1、复制一份作为历史记录
+     * 2、保存最新数据
+     * 3、更新报验次数
+     * 4、清空派单数据
+     *
+     * @param req
+     */
+    void reInspection(InsideInspectionReInspectionRequest req);
 }

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

@@ -8,7 +8,9 @@ import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDispatchDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -22,6 +24,9 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxInsideInspectionDispatchServiceImpl extends ServiceImpl<ZhcxInsideInspectionDispatchDao, ZhcxInsideInspectionDispatchDo> implements ZhcxInsideInspectionDispatchService {
 
+    @Autowired
+    private ZhcxInsideInspectionDispatchDao dao;
+
     /**
      * 生成空派单
      *
@@ -58,4 +63,33 @@ public class ZhcxInsideInspectionDispatchServiceImpl extends ServiceImpl<ZhcxIns
 
         save(dispatchDo);
     }
+
+    /**
+     * 重新报验
+     *
+     * 清空监理用户信息
+     * 更新派单状态
+     *
+     * @param id
+     * @param refuseReason
+     */
+    @Override
+    public void reInspection(String id, String refuseReason) {
+        if(ObjectUtil.isEmpty(id)) {
+            return ;
+        }
+
+        //上次拒收原因
+        ZhcxInsideInspectionDispatchDo entity;
+        if(ObjectUtil.isNotEmpty(refuseReason)) {
+            entity = new ZhcxInsideInspectionDispatchDo();
+            entity.setId(id);
+            entity.setLastrefusereason(refuseReason);
+            updateById(entity);
+        }
+
+        entity = new ZhcxInsideInspectionDispatchDo();
+        entity.setId(id);
+        dao.reInspection(entity);
+    }
 }

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

@@ -1,5 +1,6 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionOperLogDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
@@ -8,9 +9,11 @@ import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
 import com.rongwei.bsentity.dto.InsideOperLogDto;
 import com.rongwei.bsentity.dto.OperDto;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -25,6 +28,9 @@ import java.util.Map;
 @Service
 public class ZhcxInsideInspectionOperLogServiceImpl extends ServiceImpl<ZhcxInsideInspectionOperLogDao, ZhcxInsideInspectionOperLogDo> implements ZhcxInsideInspectionOperLogService {
 
+    @Autowired
+    private ZhcxInsideInspectionOperLogDao dao;
+
     /**
      * 操作记录
      *
@@ -98,5 +104,25 @@ public class ZhcxInsideInspectionOperLogServiceImpl extends ServiceImpl<ZhcxInsi
         saveBatch(logList);
     }
 
+    /**
+     * 复制报验单操作记录
+     *
+     * @param insideId
+     * @param newIinsideIdList
+     */
+    @Override
+    public void copyByInsideId(String insideId, List<String> newIinsideIdList) {
+        if(ObjectUtil.isEmpty(newIinsideIdList)) {
+            return ;
+        }
+
+        for(String newItpId : newIinsideIdList) {
+            Map<String, String> map = new HashMap<>();
+            map.put("itpId", insideId);
+            map.put("newItpId", newItpId);
+            dao.insertBySelect(map);
+        }
+    }
+
 
 }

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

@@ -1,41 +1,36 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
 import com.rongwei.bscommon.sys.utils.ZhcxCommon;
-import com.rongwei.bsentity.domain.ZhcxInsideInspectionDispatchDo;
-import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
+import com.rongwei.bsentity.domain.*;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
 import com.rongwei.bsentity.dto.InsideOperLogDto;
 import com.rongwei.bsentity.dto.OperDto;
-import com.rongwei.bsentity.dto.inside.InsideInspectionRequest;
-import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
-import com.rongwei.bsentity.dto.inside.InsideInspectionExecuteRequest;
-import com.rongwei.bsentity.dto.inside.InsideOperDto;
+import com.rongwei.bsentity.dto.inside.*;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.rwadmincommon.system.domain.SysRoleDo;
 import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
 import com.rongwei.rwadmincommon.system.service.SysUserService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
 import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * <p>
@@ -63,6 +58,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
     @Autowired
     private SysUserService userService;
 
+    @Autowired
+    private SysGeneralCRUDService generalCRUDService;
+
+    @Autowired
+    private ZhcxInsideInspectionDao dao;
+
     /**
      * 保存后操作
      *
@@ -238,6 +239,7 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
      */
     @Override
     public void execute(InsideInspectionExecuteRequest req) {
+
         if(ObjectUtil.isEmpty(req.getInsideIdList())) {
             throw  new CustomException("请联系管理员,暂无报验单");
         }
@@ -311,6 +313,188 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         operLogService.saveOperLog(req, operDto, Collections.emptyMap());
     }
 
+    /**
+     * 再次报验
+     * 1、复制一份作为历史记录
+     * 2、保存最新数据
+     * 3、更新报验次数
+     * 4、清空派单数据
+     *
+     * @param req
+     */
+    @Override
+    public void reInspection(InsideInspectionReInspectionRequest req) {
+        if(ObjectUtil.isEmpty(req.getInsideIdList())) {
+            throw  new CustomException("请联系管理员,暂无报验单");
+        }
+
+        OperDto operDto = getOper("70");
+
+        for(String inside : req.getInsideIdList()) {
+            reInspection(inside, req.getMap().get(inside));
+        }
+
+        //添加日志
+        operLogService.saveOperLog(req, operDto, Collections.emptyMap());
+    }
+
+    /**
+     * 再次报验
+     * 1、复制一份作为历史记录
+     * 2、保存最新数据
+     * 3、更新报验次数
+     * 4、清空派单数据
+     *
+     * @param id
+     * @param masterSlaveUpdate
+     */
+    private void reInspection(String id, MasterSlaveUpdateVo masterSlaveUpdate) {
+        ZhcxInsideInspectionDo inside = getById(id);
+        if("99".equals(inside.getLifecycle())) {
+            throw new CustomException("该报验单不能再次报验");
+        }
+        LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> dispatchLambdaQueryWrapper = Wrappers.lambdaQuery();
+        dispatchLambdaQueryWrapper.eq(ZhcxInsideInspectionDispatchDo::getInsideid, id)
+                .eq(ZhcxInsideInspectionDispatchDo::getDeleted, "0");
+        ZhcxInsideInspectionDispatchDo dispatch = dispatchService.getOne(dispatchLambdaQueryWrapper);
+
+        //保存历史
+        saveReHistory(inside, dispatch);
+
+        //保存新的报验单
+        saveReNew(inside, dispatch, masterSlaveUpdate);
+    }
+
+    /**
+     * 保存新的报验单
+     *
+     * @param inside
+     * @param dispatch
+     * @param masterSlaveUpdate
+     */
+    private void saveReNew(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch, MasterSlaveUpdateVo masterSlaveUpdate) {
+
+        //新的报验单号
+        String newCode = genNewCode(inside, dispatch);
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONCODE", newCode);
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONSTATUS", "20");
+
+        //报验次数需要累计
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().remove("INSPECTIONCOUNT");
+        try {
+            generalCRUDService.generalMsUpdate(masterSlaveUpdate);
+        } catch (Exception e) {
+            log.error("保存失败: {}", e);
+        }
+
+        //拒收,报验次数加+1
+        Map<String, String> map = new HashMap<>();
+        map.put("id", inside.getId());
+        dao.updateInspectionCount(map);
+
+        if(ObjectUtil.isNotEmpty(dispatch.getInspectionconclusion()) && "20".equals(dispatch.getInspectionconclusion())) {
+            //更新
+            dispatchService.reInspection(dispatch.getId(), dispatch.getRefusereason());
+        } else {
+            dispatchService.reInspection(dispatch.getId(), null);
+        }
+    }
+
+    /**
+     * 生成新的编码
+     *
+     * @param inside
+     * @param dispatch
+     * @return
+     */
+    private String genNewCode(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch) {
+
+        //如果单号不存在重新生成一个
+        if(ObjectUtil.isEmpty(inside.getInspectioncode())) {
+            return genCode();
+        }
+
+        List<String> inspectionCodes = new ArrayList<>(Arrays.asList(inside.getInspectioncode().split("-")));;
+
+        //报验状态:取消状态
+        if("30".equals(dispatch.getDispatchstatus())) {
+            if(inspectionCodes.size() == 1) {
+                inspectionCodes.add("C1");
+            } else {
+                boolean flag = false;
+                for(int m = 0, n = inspectionCodes.size(); m < n; m++) {
+                    if(inspectionCodes.get(m).startsWith("C")) {
+                        Integer c = Integer.valueOf(inspectionCodes.get(m).replace("C", ""));
+                        c += 1;
+                        inspectionCodes.set(m, "C" + c);
+                        flag = true;
+                        break;
+                    }
+                }
+
+                if(!flag) {
+                    inspectionCodes.add("C1");
+                }
+            }
+        }
+
+        //报验结论:拒收状态
+        if("20".equals(dispatch.getInspectionconclusion())) {
+            if(inspectionCodes.size() == 1) {
+                inspectionCodes.add("R1");
+            } else {
+                boolean flag = false;
+                for(int m = 0, n = inspectionCodes.size(); m < n; m++) {
+                    if(inspectionCodes.get(m).startsWith("R")) {
+                        Integer c = Integer.valueOf(inspectionCodes.get(m).replace("R", ""));
+                        c += 1;
+                        inspectionCodes.set(m, "R" + c);
+                        flag = true;
+                        break;
+                    }
+                }
+
+                if(!flag) {
+                    inspectionCodes.add("R1");
+                }
+            }
+        }
+
+        return StringUtils.join(inspectionCodes, "-");
+    }
+
+    /**
+     * 保存历史
+     *
+     * @param inside
+     * @param dispatch
+     */
+    private void saveReHistory(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch) {
+
+        //保存报验单
+        ZhcxInsideInspectionDo entity = new ZhcxInsideInspectionDo();
+        BeanUtil.copyProperties(inside, entity);
+        //新的报验单
+        entity.setId(SecurityUtil.getUUID());
+        entity.setLifecycle("99");
+        save(entity);
+
+        //保存指派单
+        ZhcxInsideInspectionDispatchDo dispatchEntity = new ZhcxInsideInspectionDispatchDo();
+        BeanUtil.copyProperties(dispatch, dispatchEntity);
+        dispatchEntity.setId(SecurityUtil.getUUID());
+        dispatchEntity.setInsideid(entity.getId());
+        dispatchService.save(dispatchEntity);
+
+        //报验单明细
+        List<String> newItpIdList = new ArrayList<>();
+        newItpIdList.add(entity.getId());
+
+        //保存操作记录
+        operLogService.copyByInsideId(inside.getId(), newItpIdList);
+    }
+
+
     /**
      * 执行校验
      *

+ 22 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/InsideInspectionReInspectionRequest.java

@@ -0,0 +1,22 @@
+package com.rongwei.bsentity.dto.inside;
+
+import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.Map;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsideInspectionReInspectionRequest extends InsideInspectionOperBaseDto {
+
+    /**
+     * 保存数据
+     */
+    private Map<String, MasterSlaveUpdateVo> map;
+}

+ 13 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxInsideInspectionController.java

@@ -3,6 +3,7 @@ package com.rongwei.bsserver.controller;
 
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
+import com.rongwei.bsentity.dto.inside.InsideInspectionReInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionExecuteRequest;
@@ -89,5 +90,17 @@ public class ZhcxInsideInspectionController {
         zhcxInsideInspectionService.cancel(req);
         return R.ok();
     }
+
+    /**
+     * 重新报验
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/reInspection")
+    public R reInspection(@RequestBody InsideInspectionReInspectionRequest req){
+        zhcxInsideInspectionService.reInspection(req);
+        return R.ok();
+    }
 }