|
@@ -11,9 +11,11 @@ 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.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.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
|
|
@@ -122,104 +124,142 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
|
|
|
}
|
|
|
|
|
|
@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();
|
|
|
- if (dispatchId != null) {
|
|
|
- dispatchDo = dispatchService.getById(dispatchId);
|
|
|
- } else {
|
|
|
- dispatchDo.setId(SecurityUtil.getUUID());
|
|
|
- }
|
|
|
- SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
- log.info("当前登录用户ID"+user.getId());
|
|
|
- boolean hasDispatch = false;
|
|
|
- if (dispatchId == null || (dispatchDo != null && dispatchDo.getSupervisionid() == null)) {
|
|
|
- log.info("没有Dispatch");
|
|
|
- dispatchDo.setCreateuserid(user.getId());
|
|
|
- dispatchDo.setCreatedate(new Date());
|
|
|
- dispatchDo.setCreateusername(user.getName());
|
|
|
- dispatchDo.setItpid(vo.getItpId());
|
|
|
- } else {
|
|
|
- log.info("有Dispatch,有dispatchId="+dispatchId);
|
|
|
- hasDispatch = true;
|
|
|
- }
|
|
|
+// String operType = vo.getOperType();
|
|
|
+// List<String> itpIds = vo.getItpIds();
|
|
|
+// List<String> dispatchIds = vo.getDispatchIds();
|
|
|
+ boolean hasDispatch ;
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ List<ZhcxOutsideInspectionItpSupervisionDispatchDo> saveDispatchDos = new ArrayList<>();
|
|
|
+ List<ZhcxOutsideInspectionItpSupervisionDispatchDo> updateDispatchDos = new ArrayList<>();
|
|
|
+ List<ZhcxOutsideInspectionItpDo> inspectionItpDos = new ArrayList<>();
|
|
|
+ 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;
|
|
|
+ log.info("执行OperInspectionStatus函数的"+operType+"操作, itpId="+itpId);
|
|
|
+ log.info("10: 取消 20: 拒收 30: 派单 40: 转派 50: 接收 60: 有条件接收");
|
|
|
+ ZhcxOutsideInspectionItpDo inspectionItpDo = getById(itpId);
|
|
|
+ String inspectionStatus = inspectionItpDo.getInspectionstatus();
|
|
|
+ String inspectioncode = inspectionItpDo.getInspectioncode();
|
|
|
+ ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
|
|
|
+ if (dispatchId != null) {
|
|
|
+ dispatchDo = dispatchService.getById(dispatchId);
|
|
|
+ } else {
|
|
|
+ dispatchDo.setId(SecurityUtil.getUUID());
|
|
|
+ }
|
|
|
+ SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
+ log.info("当前登录用户ID"+user.getId());
|
|
|
+
|
|
|
+ if (dispatchId == null || (dispatchDo != null && dispatchDo.getSupervisionid() == null)) {
|
|
|
+ log.info("没有Dispatch");
|
|
|
+ dispatchDo.setCreateuserid(user.getId());
|
|
|
+ dispatchDo.setCreatedate(new Date());
|
|
|
+ dispatchDo.setCreateusername(user.getName());
|
|
|
+ dispatchDo.setItpid(itpId);
|
|
|
+ } else {
|
|
|
+ log.info("有Dispatch,有dispatchId="+dispatchId);
|
|
|
+ hasDispatch = true;
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(inspectionStatus) && inspectionStatus.equals("40")) {
|
|
|
- return "该报验单已取消";
|
|
|
- }
|
|
|
- /* 取消 */
|
|
|
- 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;
|
|
|
+ if (StringUtils.isNotEmpty(inspectionStatus) && inspectionStatus.equals("40")) {
|
|
|
+ //return "该报验单已取消";
|
|
|
+
|
|
|
+ sb.append("单据号:"+inspectioncode+"已取消</br>");
|
|
|
}
|
|
|
- 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 ("10".equals(operType)) {
|
|
|
+ /* 10: QC 20: 监理主管 30: 监理检验员 */
|
|
|
+ /* 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;
|
|
|
+ default:
|
|
|
+ dispatchDo.setCanceltype("20");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
+ dispatchDo.setDispatchstatus("30");
|
|
|
+ inspectionItpDo.setInspectionstatus("40");
|
|
|
+ } else if ("20".equals(operType)) {
|
|
|
+ /* 检验员才有拒收 */
|
|
|
+ dispatchDo.setInspectionconclusion("20");
|
|
|
+ dispatchDo.setRefusereason(vo.get(i).getReason());
|
|
|
+ inspectionItpDo.setInspectionstatus("30");
|
|
|
+ } else if (Arrays.asList("30", "40").contains(operType)) {
|
|
|
+ if ("30".equals(operType) && hasDispatch) {
|
|
|
+ //return "该报验单已派单";
|
|
|
+ sb.append("单据号:"+inspectioncode+"已派单</br>");
|
|
|
+ }
|
|
|
+ //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.setDispatchstatus("20");
|
|
|
+ } else {
|
|
|
+ /* 接收/有条件接收 */
|
|
|
+ dispatchDo.setInspectionconclusion(operType.equals("50") ? "10" : "30");
|
|
|
+ dispatchDo.setRemark(vo.get(i).getReason());
|
|
|
+ inspectionItpDo.setInspectionstatus("30");
|
|
|
+ }
|
|
|
+ /* 检验员拒收和接收时会传回检验开始/结束时间和文件 */
|
|
|
+ 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 (hasDispatch) {
|
|
|
+ updateDispatchDos.add(dispatchDo);
|
|
|
+ }else{
|
|
|
+ saveDispatchDos.add(dispatchDo);
|
|
|
+ }
|
|
|
+ inspectionItpDos.add(inspectionItpDo);
|
|
|
}
|
|
|
- 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());
|
|
|
- dispatchDo.setCanvas(vo.getCanvas());
|
|
|
- dispatchDo.setSignature(vo.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 (hasDispatch) {
|
|
|
- dispatchService.updateById(dispatchDo);
|
|
|
- } else {
|
|
|
- dispatchService.save(dispatchDo);
|
|
|
+ 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);
|
|
|
}
|
|
|
- updateById(inspectionItpDo);
|
|
|
- return "";
|
|
|
+// if (hasDispatch) {
|
|
|
+// dispatchService.updateBatchById(dispatchDos);
|
|
|
+// } else {
|
|
|
+// dispatchService.saveBatch(dispatchDos);
|
|
|
+// }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|