|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|