Преглед на файлове

内部报验功能-派单,改派

wangming преди 1 година
родител
ревизия
68d690a445

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

@@ -3,6 +3,8 @@ 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.InsideInspectionCancelDto;
+import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
 
 /**
  * <p>
@@ -20,4 +22,25 @@ public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspecti
      * @param req
      */
     void launch(InsideInspectionOperRequest req);
+
+    /**
+     * 取消报验单
+     *
+     * @param dto
+     */
+    void cancel(InsideInspectionCancelDto dto);
+
+    /**
+     * 派单
+     *
+     * @param dto
+     */
+    void dispatch(InsideInspectionDispatchRequest dto);
+
+    /**
+     * 改派
+     *
+     * @param dto
+     */
+    void reDispatch(InsideInspectionDispatchRequest dto);
 }

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

@@ -1,22 +1,35 @@
 package com.rongwei.bscommon.sys.service.impl;
 
 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.bscommon.sys.dao.ZhcxInsideInspectionDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
 import com.rongwei.bsentity.dto.InsideOperLogDto;
+import com.rongwei.bsentity.dto.OperDto;
+import com.rongwei.bsentity.dto.inside.InsideInspectionCancelDto;
+import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
+import com.rongwei.bsentity.dto.inside.InsideOperDto;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+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.StringUtils;
 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.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -36,11 +49,14 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
     private SysSerialNumberService serialNumberService;
 
     @Autowired
-    private ZhcxInsideInspectionOperLogService zhcxInsideInspectionOperLogService;
+    private ZhcxInsideInspectionOperLogService operLogService;
 
     @Autowired
     private ZhcxCommon zhcxCommon;
 
+    @Autowired
+    private SysUserService userService;
+
     /**
      * 保存后操作
      *
@@ -63,7 +79,170 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
                 .build();
         operLogDto.setOperUser(user);
         operLogDto.setOperTime(new Date());
-        zhcxInsideInspectionOperLogService.saveOperLog(operLogDto);
+        operLogService.saveOperLog(operLogDto);
+    }
+
+    /**
+     * 取消报验单
+     *
+     * @param dto
+     */
+    @Override
+    public void cancel(InsideInspectionCancelDto dto) {
+
+        if(ObjectUtil.isEmpty(dto.getInsideIdList())) {
+            return ;
+        }
+
+        OperDto operDto = getOper();
+
+        List<String> msgList = new ArrayList<>();
+        List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
+        List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
+
+        for(String insideId : dto.getInsideIdList()) {
+            InsideOperDto inOper = getInsideOperDto(insideId);
+            inOper.setOperTime(operDto.getOperTime());
+            inOper.setOperUser(operDto.getOperUser());
+
+            //校验
+            String msg = checkParam4Cancel(inOper, dto);
+
+            if(ObjectUtil.isNotEmpty(msg)) {
+                msgList.add(msg);
+                continue;
+            }
+
+            //派单取消
+            ZhcxInsideInspectionDispatchDo dispatchDo = new ZhcxInsideInspectionDispatchDo();
+            dispatchDo.setId(inOper.getDispatch().getId());
+
+        }
+    }
+
+    /**
+     * 派单
+     *
+     * @param dto
+     */
+    @Override
+    public void dispatch(InsideInspectionDispatchRequest dto) {
+        if(ObjectUtil.isEmpty(dto.getInsideIdList())) {
+            return ;
+        }
+
+        OperDto operDto = getOper();
+
+        List<String> msgList = new ArrayList<>();
+        List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
+        for(String insideId : dto.getInsideIdList()) {
+            InsideOperDto inOper = getInsideOperDto(insideId);
+            inOper.setOperTime(operDto.getOperTime());
+            inOper.setOperUser(operDto.getOperUser());
+
+            //校验
+            String msg = checkParam4Dispatch(inOper, dto);
+
+            if(ObjectUtil.isNotEmpty(msg)) {
+                msgList.add(msg);
+                continue;
+            }
+
+            //检验员
+            SysUserDo userDo = userService.getById(dto.getSupervisionId());
+
+            ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
+            dispatch.setId(inOper.getDispatch().getId());
+            dispatch.setDispatchstatus("20");
+            dispatch.setSupervisionid(dto.getSupervisionId());
+            dispatch.setSupervision(userDo.getName());
+            dispatch.setSupervisionphone(userDo.getMobile());
+
+            dispatchList.add(dispatch);
+        }
+
+        if(ObjectUtil.isNotEmpty(msgList)) {
+            throw new CustomException(StringUtils.join(msgList, "<br>"));
+        }
+
+        //批量派单
+        dispatchService.updateBatchById(dispatchList);
+    }
+
+    /**
+     * 改派
+     *
+     * @param dto
+     */
+    @Override
+    public void reDispatch(InsideInspectionDispatchRequest dto) {
+        dispatch(dto);
+    }
+
+    /**
+     * 派单校验
+     *
+     * @param inOper
+     * @param dto
+     * @return
+     */
+    private String checkParam4Dispatch(InsideOperDto inOper, InsideInspectionDispatchRequest dto) {
+
+        //10未派单,20已派单
+        if(dto.getDispatchFlag() == 1 && "20".equals(inOper.getDispatch().getDispatchstatus())) {
+            return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("已派单");
+        }
+
+        return null;
+    }
+
+    private InsideOperDto getInsideOperDto(String insideId) {
+        //报验单
+        ZhcxInsideInspectionDo inspectionDo = getById(insideId);
+
+        //派单
+        LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> dispatchQueryWrapper = Wrappers.lambdaQuery();
+        dispatchQueryWrapper.eq(ZhcxInsideInspectionDispatchDo::getInsideid, insideId);
+        ZhcxInsideInspectionDispatchDo dispatchDo = dispatchService.getOne(dispatchQueryWrapper);
+
+        return InsideOperDto.builder()
+                .dispatch(dispatchDo)
+                .inspection(inspectionDo)
+                .build();
+    }
+
+    /**
+     * 获取操作人信息
+     *
+     * @return
+     */
+    private OperDto getOper() {
+        SysUserVo user = zhcxCommon.getCurrentUser();
+        OperDto operDto = new OperDto();
+        operDto.setOperUser(user);
+        operDto.setOperTime(new Date());
+        return operDto;
+    }
+
+    /**
+     * 取消校验
+     *
+     * @param operDto
+     * @param dto
+     * @return
+     */
+    private String checkParam4Cancel(InsideOperDto operDto, InsideInspectionCancelDto dto) {
+        if("task".equals(dto.getPageType()) && !operDto.getOperUser().getId().equals(operDto.getDispatch().getSupervisionid())) {
+            return "单据号:" + operDto.getInspection().getInspectioncode() + "已被改派,不能取消,请刷新数据查看";
+        }
+
+        if("10".equals(dto.getSource()) && "20".equals(operDto.getDispatch().getDispatchstatus())){
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已被派单,不能取消,请刷新数据查看");
+        }
+        if("task".equals(dto.getPageType()) && "30".equals(dto.getSource())){
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已被拒收,不能取消,请刷新数据查看");
+        }
+        return null;
     }
 
     /**

+ 20 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/InsideInspectionOperBaseDto.java

@@ -0,0 +1,20 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsideInspectionOperBaseDto {
+
+    /**
+     * 内部报验单id
+     */
+    private List<String> insideIdList;
+}

+ 36 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/InsideInspectionCancelDto.java

@@ -0,0 +1,36 @@
+package com.rongwei.bsentity.dto.inside;
+
+import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsideInspectionCancelDto extends InsideInspectionOperBaseDto {
+
+    /**
+     * 补充说明
+     */
+    private String reason;
+
+    /**
+     * 10: QC
+     * 20: 监理主管
+     * 30: 监理检验员
+     * */
+    private String source;
+
+    /**
+     *
+     * checker: 检验员页面
+     * supermanager: 监理主管派单
+     * task: 监理执行任务
+     *
+     * 页面类型
+     */
+    private String pageType;
+}

+ 26 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/InsideInspectionDispatchRequest.java

@@ -0,0 +1,26 @@
+package com.rongwei.bsentity.dto.inside;
+
+import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsideInspectionDispatchRequest extends InsideInspectionOperBaseDto {
+
+    /**
+     * 检验员id
+     */
+    private String supervisionId;
+
+    /**
+     * 派单标识
+     * 1、表示派派
+     * 2、表示改单
+     */
+    private Integer dispatchFlag;
+}

+ 24 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/InsideOperDto.java

@@ -0,0 +1,24 @@
+package com.rongwei.bsentity.dto.inside;
+
+import com.rongwei.bsentity.domain.ZhcxInsideInspectionDispatchDo;
+import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
+import com.rongwei.bsentity.dto.OperDto;
+import lombok.*;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class InsideOperDto extends OperDto {
+
+    /**
+     * 报验单
+     */
+    private ZhcxInsideInspectionDo inspection;
+
+    /**
+     * 派单
+     */
+    private ZhcxInsideInspectionDispatchDo dispatch;
+}

+ 27 - 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.InsideInspectionDispatchRequest;
 import com.rongwei.rwcommon.base.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -36,5 +37,31 @@ public class ZhcxInsideInspectionController {
         zhcxInsideInspectionService.launch(req);
         return R.ok();
     }
+
+    /**
+     * 派单
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/dispacth")
+    public R dispacth(@RequestBody InsideInspectionDispatchRequest req){
+        req.setDispatchFlag(1);
+        zhcxInsideInspectionService.dispatch(req);
+        return R.ok();
+    }
+
+    /**
+     * 派单
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/reDispatch")
+    public R reDispatch(@RequestBody InsideInspectionDispatchRequest req){
+        req.setDispatchFlag(2);
+        zhcxInsideInspectionService.reDispatch(req);
+        return R.ok();
+    }
 }