|
@@ -1,41 +1,36 @@
|
|
|
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.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.bsentity.domain.*;
|
|
|
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.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.bsentity.dto.inside.*;
|
|
|
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.SysGeneralCRUDService;
|
|
|
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.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
|
|
|
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.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -63,6 +58,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
@Autowired
|
|
|
private SysUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysGeneralCRUDService generalCRUDService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxInsideInspectionDao dao;
|
|
|
+
|
|
|
/**
|
|
|
* 保存后操作
|
|
|
*
|
|
@@ -238,6 +239,7 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
*/
|
|
|
@Override
|
|
|
public void execute(InsideInspectionExecuteRequest req) {
|
|
|
+
|
|
|
if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
throw new CustomException("请联系管理员,暂无报验单");
|
|
|
}
|
|
@@ -311,6 +313,188 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
|
|
|
operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 再次报验
|
|
|
+ * 1、复制一份作为历史记录
|
|
|
+ * 2、保存最新数据
|
|
|
+ * 3、更新报验次数
|
|
|
+ * 4、清空派单数据
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void reInspection(InsideInspectionReInspectionRequest req) {
|
|
|
+ if(ObjectUtil.isEmpty(req.getInsideIdList())) {
|
|
|
+ throw new CustomException("请联系管理员,暂无报验单");
|
|
|
+ }
|
|
|
+
|
|
|
+ OperDto operDto = getOper("70");
|
|
|
+
|
|
|
+ for(String inside : req.getInsideIdList()) {
|
|
|
+ reInspection(inside, req.getMap().get(inside));
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加日志
|
|
|
+ operLogService.saveOperLog(req, operDto, Collections.emptyMap());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 再次报验
|
|
|
+ * 1、复制一份作为历史记录
|
|
|
+ * 2、保存最新数据
|
|
|
+ * 3、更新报验次数
|
|
|
+ * 4、清空派单数据
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @param masterSlaveUpdate
|
|
|
+ */
|
|
|
+ private void reInspection(String id, MasterSlaveUpdateVo masterSlaveUpdate) {
|
|
|
+ ZhcxInsideInspectionDo inside = getById(id);
|
|
|
+ if("99".equals(inside.getLifecycle())) {
|
|
|
+ throw new CustomException("该报验单不能再次报验");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> dispatchLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
+ dispatchLambdaQueryWrapper.eq(ZhcxInsideInspectionDispatchDo::getInsideid, id)
|
|
|
+ .eq(ZhcxInsideInspectionDispatchDo::getDeleted, "0");
|
|
|
+ ZhcxInsideInspectionDispatchDo dispatch = dispatchService.getOne(dispatchLambdaQueryWrapper);
|
|
|
+
|
|
|
+ //保存历史
|
|
|
+ saveReHistory(inside, dispatch);
|
|
|
+
|
|
|
+ //保存新的报验单
|
|
|
+ saveReNew(inside, dispatch, masterSlaveUpdate);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存新的报验单
|
|
|
+ *
|
|
|
+ * @param inside
|
|
|
+ * @param dispatch
|
|
|
+ * @param masterSlaveUpdate
|
|
|
+ */
|
|
|
+ private void saveReNew(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch, MasterSlaveUpdateVo masterSlaveUpdate) {
|
|
|
+
|
|
|
+ //新的报验单号
|
|
|
+ String newCode = genNewCode(inside, dispatch);
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONCODE", newCode);
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().put("INSPECTIONSTATUS", "20");
|
|
|
+
|
|
|
+ //报验次数需要累计
|
|
|
+ masterSlaveUpdate.getMasterUpdate().getUpdatecolumns().remove("INSPECTIONCOUNT");
|
|
|
+ try {
|
|
|
+ generalCRUDService.generalMsUpdate(masterSlaveUpdate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("保存失败: {}", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ //拒收,报验次数加+1
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", inside.getId());
|
|
|
+ dao.updateInspectionCount(map);
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(dispatch.getInspectionconclusion()) && "20".equals(dispatch.getInspectionconclusion())) {
|
|
|
+ //更新
|
|
|
+ dispatchService.reInspection(dispatch.getId(), dispatch.getRefusereason());
|
|
|
+ } else {
|
|
|
+ dispatchService.reInspection(dispatch.getId(), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成新的编码
|
|
|
+ *
|
|
|
+ * @param inside
|
|
|
+ * @param dispatch
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String genNewCode(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch) {
|
|
|
+
|
|
|
+ //如果单号不存在重新生成一个
|
|
|
+ if(ObjectUtil.isEmpty(inside.getInspectioncode())) {
|
|
|
+ return genCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> inspectionCodes = new ArrayList<>(Arrays.asList(inside.getInspectioncode().split("-")));;
|
|
|
+
|
|
|
+ //报验状态:取消状态
|
|
|
+ if("30".equals(dispatch.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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //报验结论:拒收状态
|
|
|
+ if("20".equals(dispatch.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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return StringUtils.join(inspectionCodes, "-");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存历史
|
|
|
+ *
|
|
|
+ * @param inside
|
|
|
+ * @param dispatch
|
|
|
+ */
|
|
|
+ private void saveReHistory(ZhcxInsideInspectionDo inside, ZhcxInsideInspectionDispatchDo dispatch) {
|
|
|
+
|
|
|
+ //保存报验单
|
|
|
+ ZhcxInsideInspectionDo entity = new ZhcxInsideInspectionDo();
|
|
|
+ BeanUtil.copyProperties(inside, entity);
|
|
|
+ //新的报验单
|
|
|
+ entity.setId(SecurityUtil.getUUID());
|
|
|
+ entity.setLifecycle("99");
|
|
|
+ save(entity);
|
|
|
+
|
|
|
+ //保存指派单
|
|
|
+ ZhcxInsideInspectionDispatchDo dispatchEntity = new ZhcxInsideInspectionDispatchDo();
|
|
|
+ BeanUtil.copyProperties(dispatch, dispatchEntity);
|
|
|
+ dispatchEntity.setId(SecurityUtil.getUUID());
|
|
|
+ dispatchEntity.setInsideid(entity.getId());
|
|
|
+ dispatchService.save(dispatchEntity);
|
|
|
+
|
|
|
+ //报验单明细
|
|
|
+ List<String> newItpIdList = new ArrayList<>();
|
|
|
+ newItpIdList.add(entity.getId());
|
|
|
+
|
|
|
+ //保存操作记录
|
|
|
+ operLogService.copyByInsideId(inside.getId(), newItpIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 执行校验
|
|
|
*
|