|
@@ -178,84 +178,123 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void dispatch(InsideInspectionDispatchRequest req) {
|
|
|
+ dispatchExecute(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 改派
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void reDispatch(InsideInspectionDispatchRequest req) {
|
|
|
+ dispatchExecute(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行:接收、有条件接收、拒收
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void execute(InsideInspectionDispatchRequest req) {
|
|
|
+ dispatchExecute(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 再次报验
|
|
|
+ * 1、复制一份作为历史记录
|
|
|
+ * 2、保存最新数据
|
|
|
+ * 3、更新报验次数
|
|
|
+ * 4、清空派单数据
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void reInspection(InsideInspectionReInspectionRequest req) {
|
|
|
if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
throw new CustomException("请联系管理员,暂无报验单");
|
|
|
}
|
|
|
|
|
|
- OperDto operDto;
|
|
|
- if(req.getDispatchFlag() == 1) {
|
|
|
- operDto = getOper("30");
|
|
|
- } else {
|
|
|
- operDto = getOper("40");
|
|
|
- }
|
|
|
-
|
|
|
- List<String> msgList = new ArrayList<>();
|
|
|
- List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
|
|
|
- List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
|
|
|
+ OperDto operDto = getOper("70");
|
|
|
+ Map<String, String> descMap = new HashMap<>();
|
|
|
|
|
|
- for(String insideId : req.getInsideIdList()) {
|
|
|
- InsideOperDto inOper = getInsideOperDto(insideId);
|
|
|
- inOper.setOperTime(operDto.getOperTime());
|
|
|
- inOper.setOperUser(operDto.getOperUser());
|
|
|
+ for(String inside : req.getInsideIdList()) {
|
|
|
+ List<String> editList = reInspection(inside, req.getMap().get(inside));
|
|
|
+ if(ObjectUtil.isNotEmpty(editList)) {
|
|
|
+ descMap.put(inside, StringUtils.join(editList, "; "));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //校验
|
|
|
- String msg = checkParam4Dispatch(inOper, req);
|
|
|
+ //添加日志
|
|
|
+ operLogService.saveOperLog(req, operDto, descMap);
|
|
|
+ }
|
|
|
|
|
|
- if(ObjectUtil.isNotEmpty(msg)) {
|
|
|
- msgList.add(msg);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 修改记录
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addModifyHistory(InsideInspectionModifyRecordRequest req) {
|
|
|
+ if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
+ throw new CustomException("请联系管理员,暂无报验单");
|
|
|
+ }
|
|
|
|
|
|
- //检验员
|
|
|
- SysUserDo userDo = userService.getById(req.getSupervisionId());
|
|
|
+ OperDto operDto = getOper("80");
|
|
|
+ Map<String, String> descMap = new HashMap<>();
|
|
|
|
|
|
- ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
|
|
|
- dispatch.setId(inOper.getDispatch().getId());
|
|
|
- dispatch.setDispatchstatus("20");
|
|
|
- dispatch.setSupervisionid(req.getSupervisionId());
|
|
|
- dispatch.setSupervision(userDo.getName());
|
|
|
- dispatch.setSupervisionphone(ObjectUtil.isEmpty(userDo.getMobile()) ? "" : userDo.getMobile());
|
|
|
- dispatchList.add(dispatch);
|
|
|
+ for(String inside : req.getInsideIdList()) {
|
|
|
+ ZhcxInsideInspectionDo insideObj = getById(inside);
|
|
|
|
|
|
- //更改检验室
|
|
|
- inspectionList.add(changeSupervision(inOper, req));
|
|
|
+ //非待报验不能添加修改记录
|
|
|
+ if(!"20".equals(insideObj.getInspectionstatus())) {
|
|
|
+ throw new CustomException("监理用户已报验完成,请刷新页面!");
|
|
|
+ }
|
|
|
|
|
|
+ List<String> editList = editColsHistory(insideObj, req.getMap().get(inside));
|
|
|
+ if(ObjectUtil.isNotEmpty(editList)) {
|
|
|
+ descMap.put(inside, StringUtils.join(editList, "; "));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtil.isNotEmpty(msgList)) {
|
|
|
- throw new CustomException(StringUtils.join(msgList, "<br>"));
|
|
|
+ //没有更改,不存修改日志
|
|
|
+ if(ObjectUtil.isEmpty(descMap)) {
|
|
|
+ return ;
|
|
|
}
|
|
|
|
|
|
- //批量派单
|
|
|
- dispatchService.updateBatchById(dispatchList);
|
|
|
-
|
|
|
- //批量更新
|
|
|
- updateBatchById(inspectionList);
|
|
|
-
|
|
|
- //操作日志
|
|
|
- operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
+ //添加日志
|
|
|
+ operLogService.saveOperLog(req, operDto, descMap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 改派
|
|
|
+ * 派单和执行
|
|
|
*
|
|
|
- * @param dto
|
|
|
+ * @param req
|
|
|
*/
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public void reDispatch(InsideInspectionDispatchRequest dto) {
|
|
|
- dispatch(dto);
|
|
|
+ private void dispatchExecute(InsideInspectionDispatchRequest req) {
|
|
|
+ //派单人存在,执行派单逻辑
|
|
|
+ if(ObjectUtil.isNotEmpty(req.getSupervisionId())) {
|
|
|
+ inSideDispatch(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行
|
|
|
+ if(ObjectUtil.isNotEmpty(req.getConclusion())
|
|
|
+ || ObjectUtil.isNotEmpty(req.getStartDate())
|
|
|
+ || ObjectUtil.isNotEmpty(req.getEndDate())) {
|
|
|
+ inSideExecute(req);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 执行:接收、有条件接收、拒收
|
|
|
+ * 执行
|
|
|
*
|
|
|
* @param req
|
|
|
*/
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public void execute(InsideInspectionExecuteRequest req) {
|
|
|
-
|
|
|
+ private void inSideExecute(InsideInspectionExecuteRequest req) {
|
|
|
if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
throw new CustomException("请联系管理员,暂无报验单");
|
|
|
}
|
|
@@ -269,7 +308,7 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
else if("20".equals(req.getConclusion())) {
|
|
|
operDto = getOper("20");
|
|
|
}
|
|
|
- //邮件接收
|
|
|
+ //有条件接收
|
|
|
else if("30".equals(req.getConclusion())) {
|
|
|
operDto = getOper("60");
|
|
|
}
|
|
@@ -297,10 +336,17 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
//派单
|
|
|
ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
|
|
|
dispatch.setId(inOper.getDispatch().getId());
|
|
|
- dispatch.setInspectionconclusion(req.getConclusion());
|
|
|
- dispatch.setRefusereason(req.getReason());
|
|
|
dispatch.setCheckstarttime(req.getStartDate());
|
|
|
dispatch.setCheckendtime(req.getEndDate());
|
|
|
+
|
|
|
+ //报验完成,只能修改时间
|
|
|
+ if("30".equals(inOper.getInspection().getInspectionstatus())) {
|
|
|
+ dispatchList.add(dispatch);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ dispatch.setInspectionconclusion(req.getConclusion());
|
|
|
+ dispatch.setRefusereason(req.getReason());
|
|
|
dispatch.setSfiles(req.getFiles());
|
|
|
dispatch.setCanvas(req.getCanvas());
|
|
|
dispatch.setSignature(req.getSignature());
|
|
@@ -320,80 +366,85 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
throw new CustomException(StringUtils.join(msgList, "<br>"));
|
|
|
}
|
|
|
|
|
|
- //批量派单
|
|
|
- dispatchService.updateBatchById(dispatchList);
|
|
|
+ //派单
|
|
|
+ if(ObjectUtil.isNotEmpty(dispatchList)) {
|
|
|
+ dispatchService.updateBatchById(dispatchList);
|
|
|
+ }
|
|
|
//修改
|
|
|
- updateBatchById(inspectionList);
|
|
|
+ if(ObjectUtil.isNotEmpty(inspectionList)) {
|
|
|
+ updateBatchById(inspectionList);
|
|
|
|
|
|
- //操作日志
|
|
|
- operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
+ //操作日志
|
|
|
+ operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 再次报验
|
|
|
- * 1、复制一份作为历史记录
|
|
|
- * 2、保存最新数据
|
|
|
- * 3、更新报验次数
|
|
|
- * 4、清空派单数据
|
|
|
+ * 派单
|
|
|
*
|
|
|
* @param req
|
|
|
*/
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public void reInspection(InsideInspectionReInspectionRequest req) {
|
|
|
+ private void inSideDispatch(InsideInspectionDispatchRequest req) {
|
|
|
+
|
|
|
if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
throw new CustomException("请联系管理员,暂无报验单");
|
|
|
}
|
|
|
|
|
|
- OperDto operDto = getOper("70");
|
|
|
- Map<String, String> descMap = new HashMap<>();
|
|
|
+ OperDto operDto = getOper("30");
|
|
|
|
|
|
- for(String inside : req.getInsideIdList()) {
|
|
|
- List<String> editList = reInspection(inside, req.getMap().get(inside));
|
|
|
- if(ObjectUtil.isNotEmpty(editList)) {
|
|
|
- descMap.put(inside, StringUtils.join(editList, "; "));
|
|
|
+ List<String> msgList = new ArrayList<>();
|
|
|
+ List<ZhcxInsideInspectionDispatchDo> dispatchList = new ArrayList<>();
|
|
|
+ List<ZhcxInsideInspectionDo> inspectionList = new ArrayList<>();
|
|
|
+
|
|
|
+ for(String insideId : req.getInsideIdList()) {
|
|
|
+ InsideOperDto inOper = getInsideOperDto(insideId);
|
|
|
+ inOper.setOperTime(operDto.getOperTime());
|
|
|
+ inOper.setOperUser(operDto.getOperUser());
|
|
|
+
|
|
|
+ if("20".equals(inOper.getDispatch().getDispatchstatus())) {
|
|
|
+ operDto.setOperType("40");
|
|
|
+ req.setDispatchFlag(2);
|
|
|
+ } else {
|
|
|
+ operDto = getOper("30");
|
|
|
+ req.setDispatchFlag(1);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //添加日志
|
|
|
- operLogService.saveOperLog(req, operDto, descMap);
|
|
|
- }
|
|
|
+ //校验
|
|
|
+ String msg = checkParam4Dispatch(inOper, req);
|
|
|
|
|
|
- /**
|
|
|
- * 修改记录
|
|
|
- *
|
|
|
- * @param req
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void addModifyHistory(InsideInspectionModifyRecordRequest req) {
|
|
|
- if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
- throw new CustomException("请联系管理员,暂无报验单");
|
|
|
- }
|
|
|
+ if(ObjectUtil.isNotEmpty(msg)) {
|
|
|
+ msgList.add(msg);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- OperDto operDto = getOper("80");
|
|
|
- Map<String, String> descMap = new HashMap<>();
|
|
|
+ //检验员
|
|
|
+ SysUserDo userDo = userService.getById(req.getSupervisionId());
|
|
|
|
|
|
- for(String inside : req.getInsideIdList()) {
|
|
|
- ZhcxInsideInspectionDo insideObj = getById(inside);
|
|
|
+ ZhcxInsideInspectionDispatchDo dispatch = new ZhcxInsideInspectionDispatchDo();
|
|
|
+ dispatch.setId(inOper.getDispatch().getId());
|
|
|
+ dispatch.setDispatchstatus("20");
|
|
|
+ dispatch.setSupervisionid(req.getSupervisionId());
|
|
|
+ dispatch.setSupervision(userDo.getName());
|
|
|
+ dispatch.setSupervisionphone(ObjectUtil.isEmpty(userDo.getMobile()) ? "" : userDo.getMobile());
|
|
|
+ dispatchList.add(dispatch);
|
|
|
|
|
|
- //非待报验不能添加修改记录
|
|
|
- if(!"20".equals(insideObj.getInspectionstatus())) {
|
|
|
- throw new CustomException("监理用户已报验完成,请刷新页面!");
|
|
|
- }
|
|
|
+ //更改检验室
|
|
|
+ inspectionList.add(changeSupervision(inOper, req));
|
|
|
|
|
|
- List<String> editList = editColsHistory(insideObj, req.getMap().get(inside));
|
|
|
- if(ObjectUtil.isNotEmpty(editList)) {
|
|
|
- descMap.put(inside, StringUtils.join(editList, "; "));
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- //没有更改,不存修改日志
|
|
|
- if(ObjectUtil.isEmpty(descMap)) {
|
|
|
- return ;
|
|
|
+ if(ObjectUtil.isNotEmpty(msgList)) {
|
|
|
+ throw new CustomException(StringUtils.join(msgList, "<br>"));
|
|
|
}
|
|
|
|
|
|
- //添加日志
|
|
|
- operLogService.saveOperLog(req, operDto, descMap);
|
|
|
+ //批量派单
|
|
|
+ dispatchService.updateBatchById(dispatchList);
|
|
|
+
|
|
|
+ //批量更新
|
|
|
+ updateBatchById(inspectionList);
|
|
|
+
|
|
|
+ //操作日志
|
|
|
+ operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -858,7 +909,10 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("未派单,请先派单再执行");
|
|
|
}
|
|
|
|
|
|
- if(!inOper.getOperUser().getId().equals(inOper.getDispatch().getSupervisionid())) {
|
|
|
+ //如果角色中存在站长或者主任
|
|
|
+ boolean match = inOper.getOperUser().getRoleDos().stream().anyMatch(item -> "role095".equals(item.getCode()) || "role080".equals(item.getCode()));
|
|
|
+ //非站长等角色且不是被分派的人,无执行权限
|
|
|
+ if(!match && !inOper.getOperUser().getId().equals(inOper.getDispatch().getSupervisionid())) {
|
|
|
return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("已被改派,不能操作,请刷新数据查看");
|
|
|
}
|
|
|
|
|
@@ -867,12 +921,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("已被取消,请刷新数据查看");
|
|
|
}
|
|
|
|
|
|
- //非待报验状态
|
|
|
- if(!"20".equals(inOper.getInspection().getInspectionstatus())) {
|
|
|
+ //待报验和报验完成才能执行
|
|
|
+ //待报验可以执行
|
|
|
+ //报验完成修改检查开始结束时间
|
|
|
+ if(!"20".equals(inOper.getInspection().getInspectionstatus()) && !"30".equals(inOper.getInspection().getInspectionstatus())) {
|
|
|
return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("已被执行,请刷新数据查看");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -890,6 +944,18 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("已派单");
|
|
|
}
|
|
|
|
|
|
+ //只有待报验的报验才能派单和改派
|
|
|
+ if(!"20".equals(inOper.getInspection().getInspectionstatus())) {
|
|
|
+ return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("不能派单或者改派");
|
|
|
+ }
|
|
|
+
|
|
|
+ //只有站长主任副主任有改派功能
|
|
|
+ //如果角色中存在站长或者主任
|
|
|
+ boolean match = inOper.getOperUser().getRoleDos().stream().anyMatch(item -> "role095".equals(item.getCode()) || "role080".equals(item.getCode()));
|
|
|
+ if(!match) {
|
|
|
+ return "单据号:".concat(inOper.getInspection().getInspectioncode()).concat("操作权限不足,不能派单或改派");
|
|
|
+ }
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|