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