|
@@ -2,20 +2,28 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
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.*;
|
|
|
import com.rongwei.bscommon.sys.utils.ZhcxCommon;
|
|
|
import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpDao;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
|
|
|
+import com.rongwei.bsentity.domain.ZhcxSupervisionCustomUserManageDo;
|
|
|
import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
|
|
|
+import com.rongwei.bsentity.vo.SupervisionVo;
|
|
|
import com.rongwei.commonservice.serial.service.SysSerialNumberService;
|
|
|
-import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysRoleDo;
|
|
|
+import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
|
|
|
import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
|
|
|
-import lombok.extern.java.Log;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -30,7 +38,7 @@ import java.util.*;
|
|
|
* @since 2023-12-26
|
|
|
*/
|
|
|
@Service
|
|
|
-@Log
|
|
|
+@Slf4j
|
|
|
public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutsideInspectionItpDao, ZhcxOutsideInspectionItpDo> implements ZhcxOutsideInspectionItpService {
|
|
|
|
|
|
@Autowired
|
|
@@ -51,6 +59,15 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
@Autowired
|
|
|
private ZhcxCommon zhcxCommon;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhcxOutsideInspectionItpDao dao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysGeneralCRUDService sysGeneralCRUDService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxSupervisionCustomUserManageService zhcxSupervisionCustomUserManageService;
|
|
|
+
|
|
|
/**
|
|
|
* 拆单
|
|
|
*
|
|
@@ -87,17 +104,11 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
for(int m = 0, n = structurNames.length; m < n; m++) {
|
|
|
for(String inspectionContent : inspectionContents) {
|
|
|
count++;
|
|
|
- SysSerialVo sysSerialVo = new SysSerialVo();
|
|
|
- sysSerialVo.setRuleTemplateStr("W@{date:yyyyMMdd}@{serialNumber:#0000}");
|
|
|
- sysSerialVo.setModulecode("ZHCX_OUTSIDE_INSPECTION_ITP_CODE");
|
|
|
- sysSerialVo.setIfautomaticreset("y");
|
|
|
- sysSerialVo.setResetrule("date:yyyyMMdd");
|
|
|
- sysSerialVo.setInitValue(0L);
|
|
|
- String code = serialNumberService.getCodeByTemplate(sysSerialVo);
|
|
|
+
|
|
|
if(count == 0) { //第一个做修改
|
|
|
itpDo.setStructurename(structurNames[m]);
|
|
|
itpDo.setInspectioncontent(inspectionContent);
|
|
|
- itpDo.setInspectioncode(code);
|
|
|
+ itpDo.setInspectioncode(genCode());
|
|
|
// itpDo.setStructureid(structureIds[m]);
|
|
|
updateList.add(itpDo);
|
|
|
continue;
|
|
@@ -108,7 +119,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
entity.setStructurename(structurNames[m]);
|
|
|
entity.setInspectioncontent(inspectionContent);
|
|
|
entity.setId(SecurityUtil.getUUID());
|
|
|
- entity.setInspectioncode(code);
|
|
|
+ entity.setInspectioncode(genCode());
|
|
|
// entity.setStructureid(structureIds[m]);
|
|
|
insertList.add(entity);
|
|
|
newItpIdList.add(entity.getId());
|
|
@@ -116,115 +127,372 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //钢结构
|
|
|
- if("10".equals(itpDo.getInspectiontype())) {
|
|
|
- itpNdtResultService.copyByItpId(id, newItpIdList);
|
|
|
- }
|
|
|
- String[] array = {"10", "20", "30"};
|
|
|
- List<String> qcTypeList = Arrays.asList(array);
|
|
|
- if(qcTypeList.contains(itpDo.getInspectiontype())) {
|
|
|
- qcItemResultService.copyByItpId(id, newItpIdList);
|
|
|
- }
|
|
|
+ insertChildren(itpDo, newItpIdList);
|
|
|
|
|
|
updateBatchById(updateList);
|
|
|
saveBatch(insertList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String OperInspectionStatus(OperOutsideInspectionVo vo) {
|
|
|
+ public R operInspectionStatus(List<OperOutsideInspectionVo> vo) {
|
|
|
/* 10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收 */
|
|
|
- String operType = vo.getOperType();
|
|
|
- log.info("执行OperInspectionStatus函数的"+operType+"操作, itpId="+vo.getItpId());
|
|
|
- log.info("10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收");
|
|
|
- ZhcxOutsideInspectionItpDo inspectionItpDo = getById(vo.getItpId());
|
|
|
- String inspectionStatus = inspectionItpDo.getInspectionstatus();
|
|
|
- String dispatchId = vo.getDispatchId();
|
|
|
- ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
|
|
|
-
|
|
|
+// String operType = vo.getOperType();
|
|
|
+// List<String> itpIds = vo.getItpIds();
|
|
|
+// List<String> dispatchIds = vo.getDispatchIds();
|
|
|
+ boolean hasDispatch ;
|
|
|
+ boolean hasUpdate ;
|
|
|
+ boolean hasQcRole = false ;
|
|
|
+ boolean hasZgRole = false ;
|
|
|
+ boolean hasJjyRole = false ;
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ List<ZhcxOutsideInspectionItpSupervisionDispatchDo> saveDispatchDos = new ArrayList<>();
|
|
|
+ List<ZhcxOutsideInspectionItpSupervisionDispatchDo> updateDispatchDos = new ArrayList<>();
|
|
|
+ List<ZhcxOutsideInspectionItpDo> inspectionItpDos = new ArrayList<>();
|
|
|
SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
log.info("当前登录用户ID"+user.getId());
|
|
|
- boolean hasDispatch = false;
|
|
|
- if (dispatchId == null) {
|
|
|
- log.info("没有Dispatch");
|
|
|
- dispatchDo.setId(SecurityUtil.getUUID());
|
|
|
- dispatchDo.setCreateuserid(user.getId());
|
|
|
- dispatchDo.setCreatedate(new Date());
|
|
|
- dispatchDo.setCreateusername(user.getName());
|
|
|
- dispatchDo.setItpid(vo.getItpId());
|
|
|
- } else {
|
|
|
- log.info("有Dispatch,有dispatchId="+dispatchId);
|
|
|
- dispatchDo = dispatchService.getById(dispatchId);
|
|
|
- hasDispatch = true;
|
|
|
+ List<SysRoleDo> roleDos = user.getRoleDos();
|
|
|
+ for (int x = 0; x < roleDos.size(); x++) {
|
|
|
+ if("role065".equals(roleDos.get(x).getCode())){
|
|
|
+ hasQcRole = true;
|
|
|
+ }else if("role061".equals(roleDos.get(x).getCode())){
|
|
|
+ hasZgRole = true;
|
|
|
+ }else if("role062".equals(roleDos.get(x).getCode())){
|
|
|
+ hasJjyRole = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int i =0;i<vo.size();i++){
|
|
|
+ String operType = vo.get(i).getOperType();
|
|
|
+ String itpId = vo.get(i).getItpId();
|
|
|
+ String dispatchId = vo.get(i).getDispatchId();
|
|
|
+ hasDispatch = false;
|
|
|
+ hasUpdate = false;
|
|
|
+ log.info("执行OperInspectionStatus函数的"+operType+"操作, itpId="+itpId);
|
|
|
+ log.info("10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收 70:修改检验开始结束时间");
|
|
|
+ ZhcxOutsideInspectionItpDo inspectionItpDo = getById(itpId);
|
|
|
+ String inspectionStatus = inspectionItpDo.getInspectionstatus();
|
|
|
+ String inspectioncode = inspectionItpDo.getInspectioncode();
|
|
|
+ LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid,itpId);
|
|
|
+ ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = dispatchService.getOne(wrapper);
|
|
|
+ //ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
|
|
|
+// if (dispatchId != null) {
|
|
|
+// dispatchDo = dispatchService.getById(dispatchId);
|
|
|
+// } else {
|
|
|
+// dispatchDo.setId(SecurityUtil.getUUID());
|
|
|
+// }
|
|
|
+
|
|
|
+ //10未派单 20已派单
|
|
|
+ if (dispatchDo != null && "20".equals(dispatchDo.getDispatchstatus())) {
|
|
|
+ log.info("有Dispatch,有dispatchId="+dispatchId);
|
|
|
+ hasDispatch = true;
|
|
|
+ hasUpdate = true;
|
|
|
+ }else if(dispatchDo != null && !"20".equals(dispatchDo.getDispatchstatus())){
|
|
|
+ hasUpdate = true;
|
|
|
+ } else {
|
|
|
+ log.info("没有Dispatch");
|
|
|
+ dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
|
|
|
+ dispatchDo.setId(SecurityUtil.getUUID());
|
|
|
+ dispatchDo.setCreateuserid(user.getId());
|
|
|
+ dispatchDo.setCreatedate(new Date());
|
|
|
+ dispatchDo.setCreateusername(user.getName());
|
|
|
+ dispatchDo.setItpid(itpId);
|
|
|
+ dispatchDo.setDispatchstatus("10");
|
|
|
+ dispatchDo.setDeleted("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(inspectionStatus) && inspectionStatus.equals("40")) {
|
|
|
+ //return "该报验单已取消";
|
|
|
+
|
|
|
+ sb.append("单据号:"+inspectioncode+"已取消<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* 取消 */
|
|
|
+ if ("10".equals(operType)) {
|
|
|
+ //监理检验员在执行任务页面只能操作自己的数据 PageType--页面入口 task -- 执行任务页面
|
|
|
+ if("task".equals(vo.get(i).getPageType()) && !user.getId().equals(dispatchDo.getSupervisionuserid())){
|
|
|
+ sb.append("单据号:"+inspectioncode+"已被改派,不能取消,请刷新数据查看<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* 10: QC 20: 监理 */
|
|
|
+ /* 10: 派单前监理取消 20: 派单后监理取消 30: 派单前QC取消 40: 派单后QC取消 */
|
|
|
+ String cancelSource = vo.get(i).getSource();
|
|
|
+ switch (cancelSource) {
|
|
|
+ case "10":
|
|
|
+ dispatchDo.setCanceltype(hasDispatch ? "40" : "30");
|
|
|
+ break;
|
|
|
+ case "20":
|
|
|
+ dispatchDo.setCanceltype(hasDispatch ? "20" : "10");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
+ dispatchDo.setDispatchstatus("30");
|
|
|
+ inspectionItpDo.setInspectionstatus("40");
|
|
|
+ } else if ("20".equals(operType)) {
|
|
|
+ if("task".equals(vo.get(i).getPageType()) && !user.getId().equals(dispatchDo.getSupervisionuserid())){
|
|
|
+ sb.append("单据号:"+inspectioncode+"已被改派,不能拒收,请刷新数据查看<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* 检验员才有拒收 */
|
|
|
+ dispatchDo.setInspectionconclusion("20");
|
|
|
+ dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
+ dispatchDo.setLastrefusereason(vo.get(i).getReason());
|
|
|
+ inspectionItpDo.setInspectionstatus("30");
|
|
|
+ } else if (Arrays.asList("30", "40").contains(operType)) {
|
|
|
+ //监理检验员只能操作自己的数据
|
|
|
+// if(!user.getId().equals(dispatchDo.getSupervisionuserid())){
|
|
|
+// sb.append("单据号:"+inspectioncode+"已被改派,不能取消,请刷新数据查看<br>");
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+ if ("30".equals(operType) && hasDispatch) {
|
|
|
+ //return "该报验单已派单";
|
|
|
+ sb.append("单据号:"+inspectioncode+"已派单<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //SysUserDo toUser = userService.getById(vo.get(i).getToUser());
|
|
|
+ SupervisionVo supervisionVo = vo.get(i).getSupervisionVo();
|
|
|
+ dispatchDo.setSupervisionid(supervisionVo.getId());
|
|
|
+ dispatchDo.setSupervision(supervisionVo.getName());
|
|
|
+ dispatchDo.setSupervisionphone(supervisionVo.getPhone());
|
|
|
+ dispatchDo.setSupervisionaccount(supervisionVo.getAccount());
|
|
|
+ dispatchDo.setSupervisionuserid(supervisionVo.getSupervisionuserid());
|
|
|
+ /* 已派单 */
|
|
|
+ dispatchDo.setDispatchstatus("20");
|
|
|
+ } else {
|
|
|
+ /* 接收/有条件接收 */
|
|
|
+ //不是本人的数据无法接收 Inspectionstatus=40代表取消
|
|
|
+ if("task".equals(vo.get(i).getPageType()) && !user.getId().equals(dispatchDo.getSupervisionuserid())){
|
|
|
+ sb.append("单据号:"+inspectioncode+"已被改派,不能接收,请刷新数据查看<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if("40".equals(inspectionItpDo.getInspectionstatus())){
|
|
|
+ sb.append("单据号:"+inspectioncode+"已被取消,请刷新数据查看<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Integer.valueOf(inspectionItpDo.getInspectionstatus()) == 20) {
|
|
|
+ dispatchDo.setInspectionconclusion(operType.equals("50") ? "10" : "30");
|
|
|
+ dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
+ inspectionItpDo.setInspectionstatus("30");
|
|
|
+ }else{
|
|
|
+ sb.append("单据号:"+inspectioncode+"已被接收,请刷新数据查看<br>");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* 检验员拒收和接收时会传回检验开始/结束时间和文件 */
|
|
|
+ if (Arrays.asList("20", "50", "60").contains(operType)) {
|
|
|
+ dispatchDo.setCheckstarttime(vo.get(i).getStartDate());
|
|
|
+ dispatchDo.setCheckendtime(vo.get(i).getEndDate());
|
|
|
+ dispatchDo.setSfiles(vo.get(i).getFiles());
|
|
|
+ dispatchDo.setCanvas(vo.get(i).getCanvas());
|
|
|
+ dispatchDo.setSignature(vo.get(i).getSignature());
|
|
|
+ }
|
|
|
+ /* 当前操作人 */
|
|
|
+ if (user != null && user.getId() != null) {
|
|
|
+ inspectionItpDo.setModifydate(new Date());
|
|
|
+ inspectionItpDo.setModifyuserid(user.getId());
|
|
|
+ inspectionItpDo.setModifyusername(user.getName());
|
|
|
+ dispatchDo.setModifydate(new Date());
|
|
|
+ dispatchDo.setModifyuserid(user.getId());
|
|
|
+ dispatchDo.setModifyusername(user.getName());
|
|
|
+ }
|
|
|
+ dispatchDo.setDeleted("0");
|
|
|
+ inspectionItpDo.setDeleted("0");
|
|
|
+ if(sb.length() > 0){
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ if (hasUpdate) {
|
|
|
+ updateDispatchDos.add(dispatchDo);
|
|
|
+ }else{
|
|
|
+ saveDispatchDos.add(dispatchDo);
|
|
|
+ }
|
|
|
+ inspectionItpDos.add(inspectionItpDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(sb.length()> 0){
|
|
|
+ return R.error(sb.toString());
|
|
|
+ }else{
|
|
|
+ if(saveDispatchDos.size() > 0){
|
|
|
+ dispatchService.saveBatch(saveDispatchDos);
|
|
|
+ }
|
|
|
+ if(updateDispatchDos.size() > 0){
|
|
|
+ dispatchService.updateBatchById(updateDispatchDos);
|
|
|
+ }
|
|
|
+ updateBatchById(inspectionItpDos);
|
|
|
+ }
|
|
|
+// if (hasDispatch) {
|
|
|
+// dispatchService.updateBatchById(dispatchDos);
|
|
|
+// } else {
|
|
|
+// dispatchService.saveBatch(dispatchDos);
|
|
|
+// }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 再次报验
|
|
|
+ * 1、复制一份作为历史记录
|
|
|
+ * 2、保存最新数据
|
|
|
+ * 3、更新报验次数
|
|
|
+ * 4、清空派单数据
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void reInspection(String id, MasterSlaveUpdateVo masterSlaveUpdate) {
|
|
|
+ ZhcxOutsideInspectionItpDo itpDo = getById(id);
|
|
|
+ if("99".equals(itpDo.getLifecycle())) {
|
|
|
+ throw new CustomException("该报验单不能再次报验");
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(inspectionStatus) && inspectionStatus.equals("40")) {
|
|
|
- return "该报验单已取消";
|
|
|
+ LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> dispatchLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
+ dispatchLambdaQueryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid, id);
|
|
|
+ ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = dispatchService.getOne(dispatchLambdaQueryWrapper);
|
|
|
+
|
|
|
+ //保存历史
|
|
|
+ saveHistory(itpDo, dispatchDo);
|
|
|
+
|
|
|
+ //新的报验单号
|
|
|
+ String newCode = genNewCode(itpDo, dispatchDo);
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONCODE", newCode);
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONSTATUS", "20");
|
|
|
+
|
|
|
+ //报验次数需要累计
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().remove("INSPECTIONCOUNT");
|
|
|
+ try {
|
|
|
+ sysGeneralCRUDService.generalMsUpdate(masterSlaveUpdate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("保存失败: {}", e);
|
|
|
}
|
|
|
- /* 取消 */
|
|
|
- if ("10".equals(operType)) {
|
|
|
- /* 10: QC 20: 监理主管 30: 监理检验员 */
|
|
|
- /* 10: 派单前监理取消 20: 派单后监理取消 30: 派单前QC取消 40: 派单后QC取消 */
|
|
|
- String cancelSource = vo.getSource();
|
|
|
- switch (cancelSource) {
|
|
|
- case "10":
|
|
|
- dispatchDo.setCanceltype(hasDispatch ? "40" : "30");
|
|
|
- break;
|
|
|
- case "20":
|
|
|
- dispatchDo.setCanceltype(hasDispatch ? "20" : "10");
|
|
|
- break;
|
|
|
- default:
|
|
|
- dispatchDo.setCanceltype("20");
|
|
|
- break;
|
|
|
+
|
|
|
+ //拒收,报验次数加+1
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", id);
|
|
|
+ dao.updateInspectionCount(map);
|
|
|
+
|
|
|
+ //更新
|
|
|
+ dispatchService.reInspection(dispatchDo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ *
|
|
|
+ * @param itpDo
|
|
|
+ * @param dispatchDo
|
|
|
+ */
|
|
|
+ private void saveHistory(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo) {
|
|
|
+
|
|
|
+ //保存报验单
|
|
|
+ ZhcxOutsideInspectionItpDo entity = new ZhcxOutsideInspectionItpDo();
|
|
|
+ BeanUtil.copyProperties(itpDo, entity);
|
|
|
+ //新的报验单
|
|
|
+ entity.setId(SecurityUtil.getUUID());
|
|
|
+ entity.setLifecycle("99");
|
|
|
+ save(entity);
|
|
|
+
|
|
|
+ //保存指派单
|
|
|
+ ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchEntity = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
|
|
|
+ BeanUtil.copyProperties(dispatchDo, dispatchEntity);
|
|
|
+ dispatchEntity.setId(SecurityUtil.getUUID());
|
|
|
+ dispatchEntity.setItpid(entity.getId());
|
|
|
+ dispatchService.save(dispatchEntity);
|
|
|
+
|
|
|
+ //报验单明细
|
|
|
+ List<String> newItpIdList = new ArrayList<>();
|
|
|
+ newItpIdList.add(entity.getId());
|
|
|
+ insertChildren(itpDo, newItpIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成新的单号
|
|
|
+ *
|
|
|
+ * @param itpDo
|
|
|
+ * @param dispatchDo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String genNewCode(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo) {
|
|
|
+ List<String> inspectionCodes = new ArrayList<>(Arrays.asList(itpDo.getInspectioncode().split("-")));;
|
|
|
+
|
|
|
+ //报验状态:取消状态
|
|
|
+ if("30".equals(dispatchDo.getDispatchstatus())) {
|
|
|
+ if(inspectionCodes.size() == 1) {
|
|
|
+ inspectionCodes.add("C1");
|
|
|
+ } else {
|
|
|
+ boolean flag = false;
|
|
|
+ for(int m = 0, n = inspectionCodes.size(); m < n; m++) {
|
|
|
+ if(inspectionCodes.get(m).startsWith("C")) {
|
|
|
+ Integer c = Integer.valueOf(inspectionCodes.get(m).replace("C", ""));
|
|
|
+ c += 1;
|
|
|
+ inspectionCodes.set(m, "C" + c);
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!flag) {
|
|
|
+ inspectionCodes.add("C1");
|
|
|
+ }
|
|
|
}
|
|
|
- dispatchDo.setRefusereason(vo.getReason());
|
|
|
- dispatchDo.setDispatchstatus("30");
|
|
|
- inspectionItpDo.setInspectionstatus("40");
|
|
|
- } else if ("20".equals(operType)) {
|
|
|
- /* 检验员才有拒收 */
|
|
|
- dispatchDo.setInspectionconclusion("20");
|
|
|
- dispatchDo.setRefusereason(vo.getReason());
|
|
|
- inspectionItpDo.setInspectionstatus("30");
|
|
|
- } else if (Arrays.asList("30", "40").contains(operType)) {
|
|
|
- if ("30".equals(operType) && hasDispatch) {
|
|
|
- return "该报验单已派单";
|
|
|
+ }
|
|
|
+
|
|
|
+ //报验结论:拒收状态
|
|
|
+ if("20".equals(dispatchDo.getInspectionconclusion())) {
|
|
|
+ if(inspectionCodes.size() == 1) {
|
|
|
+ inspectionCodes.add("R1");
|
|
|
+ } else {
|
|
|
+ boolean flag = false;
|
|
|
+ for(int m = 0, n = inspectionCodes.size(); m < n; m++) {
|
|
|
+ if(inspectionCodes.get(m).startsWith("R")) {
|
|
|
+ Integer c = Integer.valueOf(inspectionCodes.get(m).replace("R", ""));
|
|
|
+ c += 1;
|
|
|
+ inspectionCodes.set(m, "R" + c);
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!flag) {
|
|
|
+ inspectionCodes.add("R1");
|
|
|
+ }
|
|
|
}
|
|
|
- SysUserDo toUser = userService.getById(vo.getToUser());
|
|
|
- dispatchDo.setSupervisionid(toUser.getId());
|
|
|
- dispatchDo.setSupervision(toUser.getName());
|
|
|
- dispatchDo.setSupervisionphone(toUser.getMobile());
|
|
|
- dispatchDo.setSupervisionaccount(toUser.getAccount());
|
|
|
- /* 已派单 */
|
|
|
- dispatchDo.setDispatchstatus("20");
|
|
|
- } else {
|
|
|
- /* 接收/有条件接收 */
|
|
|
- dispatchDo.setInspectionconclusion(operType.equals("50") ? "10" : "30");
|
|
|
- dispatchDo.setRemark(vo.getReason());
|
|
|
- inspectionItpDo.setInspectionstatus("30");
|
|
|
}
|
|
|
- /* 检验员拒收和接收时会传回检验开始/结束时间和文件 */
|
|
|
- if (Arrays.asList("20", "50", "60").contains(operType)) {
|
|
|
- dispatchDo.setCheckstarttime(vo.getStartDate());
|
|
|
- dispatchDo.setCheckendtime(vo.getEndDate());
|
|
|
- dispatchDo.setSfiles(vo.getFiles());
|
|
|
+
|
|
|
+ return StringUtils.join(inspectionCodes, "-");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成单号
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String genCode() {
|
|
|
+ SysSerialVo sysSerialVo = new SysSerialVo();
|
|
|
+ sysSerialVo.setRuleTemplateStr("W@{date:yyyyMMdd}@{serialNumber:#0000}");
|
|
|
+ sysSerialVo.setModulecode("ZHCX_OUTSIDE_INSPECTION_ITP_CODE");
|
|
|
+ sysSerialVo.setIfautomaticreset("y");
|
|
|
+ sysSerialVo.setResetrule("date:yyyyMMdd");
|
|
|
+ sysSerialVo.setInitValue(0L);
|
|
|
+ return serialNumberService.getCodeByTemplate(sysSerialVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存子表
|
|
|
+ *
|
|
|
+ * @param itpDo
|
|
|
+ * @param newItpIdList
|
|
|
+ */
|
|
|
+ private void insertChildren(ZhcxOutsideInspectionItpDo itpDo, List<String> newItpIdList) {
|
|
|
+ if(ObjectUtil.isEmpty(newItpIdList)) {
|
|
|
+ return ;
|
|
|
}
|
|
|
- /* 当前操作人 */
|
|
|
- if (user != null && user.getId() != null) {
|
|
|
- inspectionItpDo.setModifydate(new Date());
|
|
|
- inspectionItpDo.setModifyuserid(user.getId());
|
|
|
- inspectionItpDo.setModifyusername(user.getName());
|
|
|
- dispatchDo.setModifydate(new Date());
|
|
|
- dispatchDo.setModifyuserid(user.getId());
|
|
|
- dispatchDo.setModifyusername(user.getName());
|
|
|
+
|
|
|
+ //钢结构
|
|
|
+ if("10".equals(itpDo.getInspectiontype())) {
|
|
|
+ itpNdtResultService.copyByItpId(itpDo.getId(), newItpIdList);
|
|
|
}
|
|
|
- dispatchDo.setDeleted("0");
|
|
|
- inspectionItpDo.setDeleted("0");
|
|
|
- if (hasDispatch) {
|
|
|
- dispatchService.updateById(dispatchDo);
|
|
|
- } else {
|
|
|
- dispatchService.save(dispatchDo);
|
|
|
+ String[] array = {"10", "20", "30"};
|
|
|
+ List<String> qcTypeList = Arrays.asList(array);
|
|
|
+ if(qcTypeList.contains(itpDo.getInspectiontype())) {
|
|
|
+ qcItemResultService.copyByItpId(itpDo.getId(), newItpIdList);
|
|
|
}
|
|
|
- updateById(inspectionItpDo);
|
|
|
- return "";
|
|
|
}
|
|
|
|
|
|
}
|