瀏覽代碼

内部报验功能-取消/操作日志

wangming 1 年之前
父節點
當前提交
283c07f7eb

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

@@ -2,7 +2,11 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.dto.InsideInspectionOperBaseDto;
 import com.rongwei.bsentity.dto.InsideOperLogDto;
+import com.rongwei.bsentity.dto.OperDto;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -20,4 +24,22 @@ public interface ZhcxInsideInspectionOperLogService extends IService<ZhcxInsideI
      * @param req
      */
     void saveOperLog(InsideOperLogDto req);
+
+    /**
+     * 获取日志对象
+     *
+     * @param req
+     * @return
+     */
+    ZhcxInsideInspectionOperLogDo getOperLog(InsideOperLogDto req);
+
+    /**
+     * 保存日志
+     *
+     * @param dto
+     * @param operDto
+     * @param  descMap 取消描述,key:内部报验id,value:取消描述
+     * @return
+     */
+    void saveOperLog(InsideInspectionOperBaseDto dto, OperDto operDto, Map<String, String> descMap);
 }

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

@@ -3,7 +3,7 @@ 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.InsideInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionExecuteRequest;
 
@@ -29,7 +29,7 @@ public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspecti
      *
      * @param dto
      */
-    void cancel(InsideInspectionCancelDto dto);
+    void cancel(InsideInspectionRequest dto);
 
     /**
      * 派单

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

@@ -4,10 +4,16 @@ import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionOperLogDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 内部报验-报验操作日志 服务实现类
@@ -26,6 +32,18 @@ public class ZhcxInsideInspectionOperLogServiceImpl extends ServiceImpl<ZhcxInsi
      */
     @Override
     public void saveOperLog(InsideOperLogDto req) {
+        ZhcxInsideInspectionOperLogDo entity = getOperLog(req);
+        save(entity);
+    }
+
+    /**
+     * 获取日志对象
+     *
+     * @param req
+     * @return
+     */
+    @Override
+    public ZhcxInsideInspectionOperLogDo getOperLog(InsideOperLogDto req) {
 
         ZhcxInsideInspectionOperLogDo entity = new ZhcxInsideInspectionOperLogDo();
         entity.setId(SecurityUtil.getUUID());
@@ -41,7 +59,43 @@ public class ZhcxInsideInspectionOperLogServiceImpl extends ServiceImpl<ZhcxInsi
         entity.setOperuserid(req.getOperUser().getId());
         entity.setOperusername(req.getOperUser().getName());
 
-        save(entity);
+        return entity;
+    }
+
+    /**
+     * 保存日志
+     *
+     * @param dto
+     * @param operDto
+     * @return
+     */
+    @Override
+    public void saveOperLog(InsideInspectionOperBaseDto dto, OperDto operDto, Map<String, String> descMap) {
+
+        List<ZhcxInsideInspectionOperLogDo> logList = new ArrayList<>();
+
+        for(String inSideId : dto.getInsideIdList()) {
+
+            ZhcxInsideInspectionOperLogDo entity = new ZhcxInsideInspectionOperLogDo();
+
+            entity.setId(SecurityUtil.getUUID());
+            entity.setDeleted("0");
+
+
+            entity.setInsideid(inSideId);
+            entity.setOpertime(operDto.getOperTime());
+            entity.setOpertype(operDto.getOperType());
+            entity.setOpersource(dto.getLaunchSource());
+            entity.setOpertime(operDto.getOperTime());
+            entity.setOperuserid(operDto.getOperUser().getId());
+            entity.setOperusername(operDto.getOperUser().getName());
+
+            entity.setOperdescription(descMap.get(inSideId));
+
+            logList.add(entity);
+        }
+
+        saveBatch(logList);
     }
 
 

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

@@ -11,14 +11,16 @@ 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.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.InsideInspectionCancelDto;
+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.commonservice.serial.service.SysSerialNumberService;
+import com.rongwei.rwadmincommon.system.domain.SysRoleDo;
 import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwadmincommon.system.service.SysUserService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
@@ -29,8 +31,11 @@ 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.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -86,28 +91,29 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
     /**
      * 取消报验单
      *
-     * @param dto
+     * @param req
      */
     @Override
-    public void cancel(InsideInspectionCancelDto dto) {
+    public void cancel(InsideInspectionRequest req) {
 
-        if(ObjectUtil.isEmpty(dto.getInsideIdList())) {
+        if(ObjectUtil.isEmpty(req.getInsideIdList())) {
             throw  new CustomException("请联系管理员,暂无报验单");
         }
 
-        OperDto operDto = getOper();
+        OperDto operDto = getOper("10");
 
         List<String> msgList = new ArrayList<>();
         List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
         List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
+        List<ZhcxInsideInspectionOperLogDo> logList = new ArrayList<>();
 
-        for(String insideId : dto.getInsideIdList()) {
+        for(String insideId : req.getInsideIdList()) {
             InsideOperDto inOper = getInsideOperDto(insideId);
             inOper.setOperTime(operDto.getOperTime());
             inOper.setOperUser(operDto.getOperUser());
 
             //校验
-            String msg = checkParam4Cancel(inOper, dto);
+            String msg = checkParam4Cancel(inOper, req);
 
             if(ObjectUtil.isNotEmpty(msg)) {
                 msgList.add(msg);
@@ -115,34 +121,76 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
             }
 
             //派单取消
-            ZhcxInsideInspectionDispatchDo dispatchDo = new ZhcxInsideInspectionDispatchDo();
-            dispatchDo.setId(inOper.getDispatch().getId());
+            ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
+            dispatch.setId(inOper.getDispatch().getId());
+            dispatch.setDispatchstatus("30");
+            dispatch.setRefusereason(req.getReason());
+
+            //取消类型
+            //发起页面
+            if("self".equals(req.getPageType())) {
+                dispatch.setCanceltype("10"); //分包商取消
+            }
+            //执行页面
+            else if("execute".equals(req.getPageType())) {
+                //取消时,登录人与被指派检验员一致,不管该登录人是否具有站长或主任角色,都认定为检验员取消
+               if(operDto.getOperUser().equals(inOper.getDispatch().getSupervisionid())) {
+                   dispatch.setCanceltype("20");
+               } else {
+                   dispatch.setCanceltype("30");
+               }
+            } else {
+                msgList.add("服务器异常,请联系管理:未知取消页面");
+            }
 
+            dispatchList.add(dispatch);
+
+            ZhcxInsideInspectionDo inside = new ZhcxInsideInspectionDo();
+            inside.setId(insideId);
+            inside.setInspectionstatus("40");
+            inspectionList.add(inside);
+        }
+
+        if(ObjectUtil.isNotEmpty(msgList)) {
+            throw new CustomException(StringUtils.join(msgList, "<br>"));
         }
+
+        //批量派单
+        dispatchService.updateBatchById(dispatchList);
+        //修改
+        updateBatchById(inspectionList);
+
+        //操作日志
+        operLogService.saveOperLog(req, operDto, Collections.emptyMap());
     }
 
     /**
      * 派单
      *
-     * @param dto
+     * @param req
      */
     @Override
-    public void dispatch(InsideInspectionDispatchRequest dto) {
-        if(ObjectUtil.isEmpty(dto.getInsideIdList())) {
+    public void dispatch(InsideInspectionDispatchRequest req) {
+        if(ObjectUtil.isEmpty(req.getInsideIdList())) {
             throw  new CustomException("请联系管理员,暂无报验单");
         }
 
-        OperDto operDto = getOper();
+        OperDto operDto;
+        if(req.getDispatchFlag() == 1) {
+            operDto = getOper("30");
+        } else {
+            operDto = getOper("40");
+        }
 
         List<String> msgList = new ArrayList<>();
         List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
-        for(String insideId : dto.getInsideIdList()) {
+        for(String insideId : req.getInsideIdList()) {
             InsideOperDto inOper = getInsideOperDto(insideId);
             inOper.setOperTime(operDto.getOperTime());
             inOper.setOperUser(operDto.getOperUser());
 
             //校验
-            String msg = checkParam4Dispatch(inOper, dto);
+            String msg = checkParam4Dispatch(inOper, req);
 
             if(ObjectUtil.isNotEmpty(msg)) {
                 msgList.add(msg);
@@ -150,12 +198,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
             }
 
             //检验员
-            SysUserDo userDo = userService.getById(dto.getSupervisionId());
+            SysUserDo userDo = userService.getById(req.getSupervisionId());
 
             ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
             dispatch.setId(inOper.getDispatch().getId());
             dispatch.setDispatchstatus("20");
-            dispatch.setSupervisionid(dto.getSupervisionId());
+            dispatch.setSupervisionid(req.getSupervisionId());
             dispatch.setSupervision(userDo.getName());
             dispatch.setSupervisionphone(userDo.getMobile());
 
@@ -168,6 +216,9 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
 
         //批量派单
         dispatchService.updateBatchById(dispatchList);
+
+        //操作日志
+        operLogService.saveOperLog(req, operDto, Collections.emptyMap());
     }
 
     /**
@@ -191,7 +242,22 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
             throw  new CustomException("请联系管理员,暂无报验单");
         }
 
-        OperDto operDto = getOper();
+        OperDto operDto;
+        //接收
+        if("10".equals(req.getConclusion())) {
+            operDto = getOper("50");
+        }
+        //拒收
+        else if("20".equals(req.getConclusion())) {
+            operDto = getOper("20");
+        }
+        //邮件接收
+        else if("30".equals(req.getConclusion())) {
+            operDto = getOper("60");
+        }
+        else {
+            throw new CustomException("请填写报验结论!");
+        }
 
         List<String> msgList = new ArrayList<>();
         List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
@@ -240,6 +306,9 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         dispatchService.updateBatchById(dispatchList);
         //修改
         updateBatchById(inspectionList);
+
+        //操作日志
+        operLogService.saveOperLog(req, operDto, Collections.emptyMap());
     }
 
     /**
@@ -316,11 +385,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
      *
      * @return
      */
-    private OperDto getOper() {
+    private OperDto getOper(String operType) {
         SysUserVo user = zhcxCommon.getCurrentUser();
         OperDto operDto = new OperDto();
         operDto.setOperUser(user);
         operDto.setOperTime(new Date());
+        operDto.setOperType(operType);
         return operDto;
     }
 
@@ -331,17 +401,36 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
      * @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() + "已被改派,不能取消,请刷新数据查看";
+    private String checkParam4Cancel(InsideOperDto operDto, InsideInspectionRequest dto) {
+
+        //报验完成
+        if("30".equals(operDto.getInspection().getInspectioncomplatetime())) {
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("检验员已提交报验结论不能取消,请刷新数据查看");
+        }
+
+        //未提交
+        if("10".equals(operDto.getInspection().getInspectioncomplatetime())) {
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("未提交的数据可以直接删除,请刷新数据查看");
         }
 
-        if("10".equals(dto.getSource()) && "20".equals(operDto.getDispatch().getDispatchstatus())){
-            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已被派单,不能取消,请刷新数据查看");
+        //取消
+        if("40".equals(operDto.getInspection().getInspectioncomplatetime())) {
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已取消不能重复取消,请刷新数据查看");
         }
-        if("task".equals(dto.getPageType()) && "30".equals(dto.getSource())){
-            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已被拒收,不能取消,请刷新数据查看");
+
+        //既不是站长也不是被派检验员,不能执行取消操作
+        boolean leaderFlag = false;
+        //站长/主任/副主任
+        List<SysRoleDo> roleDos = operDto.getOperUser().getRoleDos().stream()
+                .filter(item -> "role080".equals(item.getCode()) || "role095".equals(item.getCode()))
+                .collect(Collectors.toList());
+        if(roleDos.size() > 0) {
+            leaderFlag = true;
         }
+        if(!leaderFlag && !operDto.getOperUser().getId().equals(operDto.getDispatch().getSupervisionid())) {
+            return "单据号:".concat(operDto.getInspection().getInspectioncode()).concat("已被改派或权限不够不能取消,请刷新数据查看");
+        }
+
         return null;
     }
 

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

@@ -17,4 +17,12 @@ public class InsideInspectionOperBaseDto {
      * 内部报验单id
      */
     private List<String> insideIdList;
+
+    /**
+     * 发起源
+     *
+     * pc
+     * mobile
+     */
+    private String launchSource;
 }

+ 5 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/OperDto.java

@@ -20,4 +20,9 @@ public class OperDto {
      * 操作时间
      */
     private Date operTime;
+
+    /**
+     * 操作类型
+     */
+    private String operType;
 }

+ 3 - 12
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/InsideInspectionCancelDto.java

@@ -10,7 +10,7 @@ import lombok.Setter;
 @Getter
 @NoArgsConstructor
 @AllArgsConstructor
-public class InsideInspectionCancelDto extends InsideInspectionOperBaseDto {
+public class InsideInspectionRequest extends InsideInspectionOperBaseDto {
 
     /**
      * 补充说明
@@ -18,17 +18,8 @@ public class InsideInspectionCancelDto extends InsideInspectionOperBaseDto {
     private String reason;
 
     /**
-     * 10: QC
-     * 20: 监理主管
-     * 30: 监理检验员
-     * */
-    private String source;
-
-    /**
-     *
-     * checker: 检验员页面
-     * supermanager: 监理主管派单
-     * task: 监理执行任务
+     * self 自检员发起页面
+     * execute  检验员执行页面
      *
      * 页面类型
      */

+ 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.InsideInspectionRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionDispatchRequest;
 import com.rongwei.bsentity.dto.inside.InsideInspectionExecuteRequest;
 import com.rongwei.rwcommon.base.R;
@@ -76,5 +77,17 @@ public class ZhcxInsideInspectionController {
         zhcxInsideInspectionService.execute(req);
         return R.ok("执行成功");
     }
+
+    /**
+     * 取消
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/cancel")
+    public R cancel(@RequestBody InsideInspectionRequest req){
+        zhcxInsideInspectionService.cancel(req);
+        return R.ok();
+    }
 }