sola 1 rok temu
rodzic
commit
e6527c74f8

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

@@ -2,6 +2,9 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -19,4 +22,6 @@ public interface ZhcxOutsideInspectionItpService extends IService<ZhcxOutsideIns
      * @param id
      */
     void splitOrder(String id);
+
+    String OperInspectionStatus(OperOutsideInspectionVo vo);
 }

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

@@ -2,21 +2,24 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpNdtResultService;
-import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpQcItemResultService;
+import com.rongwei.bscommon.sys.service.*;
+import com.rongwei.bscommon.sys.utils.ZhcxCommon;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpDao;
-import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
+import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
+import lombok.extern.java.Log;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 
 /**
  * <p>
@@ -27,15 +30,27 @@ import java.util.List;
  * @since 2023-12-26
  */
 @Service
+@Log
 public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutsideInspectionItpDao, ZhcxOutsideInspectionItpDo> implements ZhcxOutsideInspectionItpService {
 
     @Autowired
     private ZhcxOutsideInspectionItpNdtResultService itpNdtResultService;
+
     @Autowired
     private ZhcxOutsideInspectionItpQcItemResultService qcItemResultService;
+
     @Autowired
     private SysSerialNumberService serialNumberService;
 
+    @Autowired
+    private ZhcxOutsideInspectionItpSupervisionDispatchService dispatchService;
+
+    @Autowired
+    private ZhcxSubcontractorUserService userService;
+
+    @Autowired
+    private ZhcxCommon zhcxCommon;
+
     /**
      * 拆单
      *
@@ -114,4 +129,102 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         updateBatchById(updateList);
         saveBatch(insertList);
     }
+
+    @Override
+    public String OperInspectionStatus(OperOutsideInspectionVo vo) {
+        /* 10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收 */
+        String operType = vo.getOperType();
+        log.info("执行OperInspectionStatus函数的"+operType+"操作, itpId="+vo.getItpId());
+        log.info("10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收");
+        ZhcxOutsideInspectionItpDo inspectionItpDo = getById(vo.getItpId());
+        String inspectionStatus = inspectionItpDo.getInspectionstatus();
+        String dispatchId = vo.getDispatchId();
+        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
+
+        SysUserVo user = zhcxCommon.getCurrentUser();
+        log.info("当前登录用户ID"+user.getId());
+        boolean hasDispatch = false;
+        if (dispatchId == null) {
+            log.info("没有Dispatch");
+            dispatchDo.setId(SecurityUtil.getUUID());
+            dispatchDo.setCreateuserid(user.getId());
+            dispatchDo.setCreatedate(new Date());
+            dispatchDo.setCreateusername(user.getName());
+            dispatchDo.setItpid(vo.getItpId());
+        } else {
+            log.info("有Dispatch,有dispatchId="+dispatchId);
+            dispatchDo = dispatchService.getById(dispatchId);
+            hasDispatch = true;
+        }
+
+        if (StringUtils.isNotEmpty(inspectionStatus) && inspectionStatus.equals("40")) {
+            return "该报验单已取消";
+        }
+        /* 取消 */
+        if ("10".equals(operType)) {
+            /* 10: QC 20: 监理主管 30: 监理检验员 */
+            /* 10: 派单前监理取消 20: 派单后监理取消 30: 派单前QC取消 40: 派单后QC取消 */
+            String cancelSource = vo.getSource();
+            switch (cancelSource) {
+                case "10":
+                    dispatchDo.setCanceltype(hasDispatch ? "40" : "30");
+                    break;
+                case "20":
+                    dispatchDo.setCanceltype(hasDispatch ? "20" : "10");
+                    break;
+                default:
+                    dispatchDo.setCanceltype("20");
+                    break;
+            }
+            dispatchDo.setRefusereason(vo.getReason());
+            dispatchDo.setDispatchstatus("30");
+            inspectionItpDo.setInspectionstatus("40");
+        } else if ("20".equals(operType)) {
+            /* 检验员才有拒收 */
+            dispatchDo.setInspectionconclusion("20");
+            dispatchDo.setRefusereason(vo.getReason());
+            inspectionItpDo.setInspectionstatus("30");
+        } else if (Arrays.asList("30", "40").contains(operType)) {
+            if ("30".equals(operType) && hasDispatch) {
+                return "该报验单已派单";
+            }
+            SysUserDo toUser = userService.getById(vo.getToUser());
+            dispatchDo.setSupervisionid(toUser.getId());
+            dispatchDo.setSupervision(toUser.getName());
+            dispatchDo.setSupervisionphone(toUser.getMobile());
+            dispatchDo.setSupervisionaccount(toUser.getAccount());
+            /* 已派单 */
+            dispatchDo.setDispatchstatus("20");
+        } else {
+            /* 接收/有条件接收 */
+            dispatchDo.setInspectionconclusion(operType.equals("50") ? "10" : "30");
+            dispatchDo.setRemark(vo.getReason());
+            inspectionItpDo.setInspectionstatus("30");
+        }
+        /* 检验员拒收和接收时会传回检验开始/结束时间和文件 */
+        if (Arrays.asList("20", "50", "60").contains(operType)) {
+            dispatchDo.setCheckstarttime(vo.getStartDate());
+            dispatchDo.setCheckendtime(vo.getEndDate());
+            dispatchDo.setSfiles(vo.getFiles());
+        }
+        /* 当前操作人 */
+        if (user != null && user.getId() != null) {
+            inspectionItpDo.setModifydate(new Date());
+            inspectionItpDo.setModifyuserid(user.getId());
+            inspectionItpDo.setModifyusername(user.getName());
+            dispatchDo.setModifydate(new Date());
+            dispatchDo.setModifyuserid(user.getId());
+            dispatchDo.setModifyusername(user.getName());
+        }
+        dispatchDo.setDeleted("0");
+        inspectionItpDo.setDeleted("0");
+        if (hasDispatch) {
+            dispatchService.updateById(dispatchDo);
+        } else {
+            dispatchService.save(dispatchDo);
+        }
+        updateById(inspectionItpDo);
+        return "";
+    }
+
 }

+ 33 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/ZhcxCommon.java

@@ -0,0 +1,33 @@
+package com.rongwei.bscommon.sys.utils;
+
+import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Component
+public class ZhcxCommon {
+
+    @Autowired
+    private RedisService redisService;
+
+    public SysUserVo getCurrentUser() {
+        // 获取当前登录人信息
+        SysUserVo currUser = null;
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (attributes != null) {
+            HttpServletRequest request = attributes.getRequest();
+            if (request != null) {
+                String token = request.getHeader("token");
+                if (com.rongwei.rwcommon.utils.StringUtils.isNotEmpty(token)) {
+                    currUser = redisService.getLoginUser(token);
+                }
+            }
+        }
+        return currUser;
+    }
+}

+ 61 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/OperOutsideInspectionVo.java

@@ -0,0 +1,61 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class OperOutsideInspectionVo {
+    /**
+     * 10: 取消
+     * 20: 拒收
+     * 30: 派单
+     * 40: 转派
+     * 50: 接收
+     * 60: 有条件接收
+     * */
+    private String operType;
+
+    /**
+     * ZHCX_OUTSIDE_INSPECTION_ITP表主键
+     * */
+    private String itpId;
+
+    /**
+     * ZHCX_OUTSIDE_INSPECTION_ITP_SUPERVISION_DISPATCH表主键
+     * */
+    private String dispatchId;
+
+    /**
+     * 取消/拒收原因
+     *  */
+    private String reason;
+
+    /**
+     * 10: QC
+     * 20: 监理主管
+     * 30: 监理检验员
+     * */
+    private String source;
+
+    /**
+     * 派单/转派的用户ID
+     * */
+    private String toUser;
+
+    /**
+     * 开始时间
+     * */
+    private Date startDate;
+
+    /**
+     * 结束时间
+     */
+    private Date endDate;
+
+    /**
+     * 附件
+     */
+    private String files;
+
+}

+ 24 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxOperOutsideInspectionController.java

@@ -0,0 +1,24 @@
+package com.rongwei.bsserver.controller;
+
+import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpService;
+import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
+import com.rongwei.rwcommon.base.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("/zhcxOperOutsideInspection")
+public class ZhcxOperOutsideInspectionController {
+    @Autowired
+    private ZhcxOutsideInspectionItpService inspectionService;
+
+    @RequestMapping("/OperInspectionStatus")
+    public R OperInspectionStatus(@RequestBody OperOutsideInspectionVo vo) {
+        String msg = inspectionService.OperInspectionStatus(vo);
+        return R.ok(msg);
+    }
+}