Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

zhuang 1 rok pred
rodič
commit
04d04993cc

+ 6 - 0
business-common/pom.xml

@@ -22,6 +22,12 @@
             <version>1.0-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>rw-admin-common</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-generator</artifactId>

+ 12 - 5
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxOutsideInspectionItpService.java

@@ -4,23 +4,30 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
 
 import java.util.List;
 
 public interface ZhcxOutsideInspectionItpService extends IService<ZhcxOutsideInspectionItpDo> {
 
+    /**
+     * 拆单
+     *
+     * @param id
+     */
     void splitOrder(String id);
 
     R operInspectionStatus(List<OperOutsideInspectionVo> vo);
 
     /**
      * 再次报验
-     * 1、报验结论拒收,报验次数+1,修改报验单号
-     * 2、清空派单信息
-     * 3、添加历史记录
+     * 1、复制一份作为历史记录
+     * 2、保存最新数据
+     * 3、更新报验次数
+     * 4、清空派单数据
      *
      * @param id
      */
-    void reInspection(String id);
-
+    void reInspection(String id, MasterSlaveUpdateVo masterSlaveUpdate);
 }
+

+ 78 - 42
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -15,13 +15,15 @@ import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo
 import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
 import com.rongwei.bsentity.vo.SupervisionVo;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
-import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
+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 lombok.extern.java.Log;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -37,7 +39,7 @@ import java.util.*;
  * @since 2023-12-26
  */
 @Service
-@Log
+@Slf4j
 public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutsideInspectionItpDao, ZhcxOutsideInspectionItpDo> implements ZhcxOutsideInspectionItpService {
 
     @Autowired
@@ -61,6 +63,9 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
     @Autowired
     private ZhcxOutsideInspectionItpDao dao;
 
+    @Autowired
+    private SysGeneralCRUDService sysGeneralCRUDService;
+
     /**
      * 拆单
      *
@@ -278,35 +283,92 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
     /**
      * 再次报验
-     * 1、报验结论拒收,报验次数+1,修改报验单号
-     * 2、清空派单信息
+     * 1、复制一份作为历史记录
+     * 2、保存最新数据
+     * 3、更新报验次数
+     * 4、清空派单数据
      *
      * @param id
      */
     @Override
-    public void reInspection(String id) {
+    public void reInspection(String id, MasterSlaveUpdateVo masterSlaveUpdate) {
         ZhcxOutsideInspectionItpDo itpDo = getById(id);
+        if("99".equals(itpDo.getLifecycle())) {
+            throw new CustomException("该报验单不能再次报验");
+        }
+
+        LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> dispatchLambdaQueryWrapper = Wrappers.lambdaQuery();
+        dispatchLambdaQueryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid, id);
+        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = dispatchService.getOne(dispatchLambdaQueryWrapper);
+
+        //保存历史
+        saveHistory(itpDo, dispatchDo);
+
+        //新的报验单号
+        String newCode = genNewCode(itpDo, dispatchDo);
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONCODE", newCode);
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONSTATUS", "20");
+
+        //报验次数需要累计
+        masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().remove("INSPECTIONCOUNT");
+        try {
+            sysGeneralCRUDService.generalMsUpdate(masterSlaveUpdate);
+        } catch (Exception e) {
+            log.error("保存失败: {}", e);
+        }
 
         //拒收,报验次数加+1
         Map<String, String> map = new HashMap<>();
         map.put("id", id);
         dao.updateInspectionCount(map);
 
-        LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> dispatchLambdaQueryWrapper = Wrappers.lambdaQuery();
-        dispatchLambdaQueryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid, id);
-        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchServiceOne = dispatchService.getOne(dispatchLambdaQueryWrapper);
+        //更新
+        dispatchService.reInspection(dispatchDo.getId());
+    }
 
-        List<String> inspectionCodes = new ArrayList<>(Arrays.asList(itpDo.getInspectioncode().split("-")));;
+    /**
+     * 保存
+     *
+     * @param itpDo
+     * @param dispatchDo
+     */
+    private void saveHistory(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo) {
 
+        //保存报验单
         ZhcxOutsideInspectionItpDo entity = new ZhcxOutsideInspectionItpDo();
         BeanUtil.copyProperties(itpDo, entity);
+        //新的报验单
+        entity.setId(SecurityUtil.getUUID());
+        entity.setLifecycle("99");
+        save(entity);
+
+        //保存指派单
+        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchEntity = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
+        BeanUtil.copyProperties(dispatchDo, dispatchEntity);
+        dispatchEntity.setId(SecurityUtil.getUUID());
+        dispatchEntity.setItpid(entity.getId());
+        dispatchService.save(dispatchEntity);
+
+        //报验单明细
+        List<String> newItpIdList = new ArrayList<>();
+        newItpIdList.add(entity.getId());
+        insertChildren(itpDo, newItpIdList);
+    }
+
+    /**
+     * 生成新的单号
+     *
+     * @param itpDo
+     * @param dispatchDo
+     * @return
+     */
+    private String genNewCode(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo) {
+        List<String> inspectionCodes = new ArrayList<>(Arrays.asList(itpDo.getInspectioncode().split("-")));;
 
         //报验状态:取消状态
-        if("30".equals(dispatchServiceOne.getDispatchstatus())) {
+        if("30".equals(dispatchDo.getDispatchstatus())) {
             if(inspectionCodes.size() == 1) {
                 inspectionCodes.add("C1");
-                entity.setSourceid(itpDo.getId());
-                entity.setSourcecode(itpDo.getInspectioncode());
             } else {
                 boolean flag = false;
                 for(int m = 0, n = inspectionCodes.size(); m < n; m++) {
@@ -326,16 +388,14 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         }
 
         //报验结论:拒收状态
-        if("20".equals(dispatchServiceOne.getInspectionconclusion())) {
+        if("20".equals(dispatchDo.getInspectionconclusion())) {
             if(inspectionCodes.size() == 1) {
                 inspectionCodes.add("R1");
-                entity.setSourceid(itpDo.getId());
-                entity.setSourcecode(itpDo.getInspectioncode());
             } 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("C", ""));
+                        Integer c = Integer.valueOf(inspectionCodes.get(m).replace("R", ""));
                         c += 1;
                         inspectionCodes.set(m, "R" + c);
                         flag = true;
@@ -349,31 +409,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
             }
         }
 
-        //新的报验单
-        entity.setId(SecurityUtil.getUUID());
-        entity.setInspectioncode(StringUtils.join(inspectionCodes, "-"));
-        save(entity);
-
-        //指派单
-        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchEntity = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
-        BeanUtil.copyProperties(dispatchServiceOne, dispatchEntity);
-        dispatchEntity.setId(SecurityUtil.getUUID());
-        dispatchEntity.setItpid(entity.getId());
-        dispatchService.save(dispatchEntity);
-
-        //报验单明细
-        List<String> newItpIdList = new ArrayList<>();
-        newItpIdList.add(entity.getId());
-        insertChildren(itpDo, newItpIdList);
-
-        //以前报验单弃用
-        ZhcxOutsideInspectionItpDo itpDoTemp = new ZhcxOutsideInspectionItpDo();
-        itpDoTemp.setId(id);
-        itpDoTemp.setLifecycle("99");
-        updateById(itpDoTemp);
-
-        //更新
-        dispatchService.reInspection(dispatchServiceOne.getId());
+        return StringUtils.join(inspectionCodes, "-");
     }
 
     /**

+ 10 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/ReInspectionRequest.java

@@ -0,0 +1,10 @@
+package com.rongwei.bsentity.dto;
+
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
+import lombok.Data;
+
+@Data
+public class ReInspectionRequest {
+    private MasterSlaveUpdateVo masterSlaveUpdate;
+    private String id;
+}

+ 3 - 2
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxOutsideInspectionItpController.java

@@ -2,6 +2,7 @@ package com.rongwei.bsserver.controller;
 
 
 import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpService;
+import com.rongwei.bsentity.dto.ReInspectionRequest;
 import com.rongwei.rwcommon.base.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -33,8 +34,8 @@ public class ZhcxOutsideInspectionItpController {
     }
 
     @PostMapping("/reInspection")
-    public R reInspection(@RequestBody Map<String, String> map){
-        service.reInspection(map.get("id"));
+    public R reInspection(@RequestBody ReInspectionRequest res){
+        service.reInspection(res.getId(), res.getMasterSlaveUpdate());
         return R.ok();
     }
 }