|
@@ -8,9 +8,11 @@ import com.rongwei.bscommon.sys.service.ReportCheckService;
|
|
|
import com.rongwei.bsentity.domain.*;
|
|
|
import com.rongwei.bsentity.vo.CancelProcessOperationVo;
|
|
|
import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import com.rongwei.wfentity.sys.RunTaskDo;
|
|
|
import com.rongwei.wfentity.sys.vo.RunTaskVo;
|
|
|
import com.rongwei.wfserver.wfcommon.core.service.impl.WorkFlowServiceImpl;
|
|
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.BiConsumer;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -54,6 +57,8 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
public static final String WORK_IN_PROCESS = "在制品";
|
|
|
public static final String MATERIAL_PREPARATION_ORDER = "备料订单";
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
+
|
|
|
+ private final ConcurrentHashMap<String, String> locks = new ConcurrentHashMap<>();
|
|
|
@Autowired
|
|
|
private ApsReportRecordsService apsReportRecordsService;
|
|
|
@Autowired
|
|
@@ -85,129 +90,143 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R updateRelevantInformation(String id) {
|
|
|
log.info("保存检验结果后更新相关信息");
|
|
|
- if (StringUtil.isBlank(id)) {
|
|
|
- log.debug("参数为空");
|
|
|
- return R.error("报工检验参数异常");
|
|
|
- }
|
|
|
- // 获取报工记录
|
|
|
- ApsReportRecordsDo reportRecordsDo = apsReportRecordsService.getById(id);
|
|
|
- if (reportRecordsDo == null) {
|
|
|
- log.error("无法根据ID:{}获取到报工记录", id);
|
|
|
- return R.error("无法获取到报工记录");
|
|
|
- }
|
|
|
- // 获取该工序生成的物料输出信息
|
|
|
- List<ApsReportOutputDo> reportOutputDos = apsReportOutputService.list(new LambdaQueryWrapper<ApsReportOutputDo>()
|
|
|
- .eq(ApsReportOutputDo::getMainid, id)
|
|
|
- .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
- if (reportOutputDos.isEmpty()) {
|
|
|
- log.error("无法根据ID:{}获取到输出物料信息", id);
|
|
|
- return R.error("无法获取到输出物料信息");
|
|
|
- }
|
|
|
- // 获取工序作业信息
|
|
|
- String currentProcessOperationId = reportRecordsDo.getProcessoperationid();
|
|
|
- if (StringUtils.isBlank(currentProcessOperationId)) {
|
|
|
- log.error("当前报工记录:{}无法获取到对应的工序作业信息!", id);
|
|
|
- return R.error("无法获取到工序作业信息,请联系系统管理员!");
|
|
|
- }
|
|
|
- // 获取工序作业主表信息
|
|
|
- ApsProcessOperationDo currentProcessOperationMainDo = apsProcessOperationService.getOne(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
- .eq(ApsProcessOperationDo::getId, currentProcessOperationId)
|
|
|
- .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
- if (currentProcessOperationMainDo == null) {
|
|
|
- log.error("无法根据ID:{}获取到工序作业信息", id);
|
|
|
- return R.error("无法获取到工序作业信息,请联系系统管理员!");
|
|
|
- }
|
|
|
- // 获取工序作业明细信息
|
|
|
- ApsProcessOperationProcessEquDo currentProcessOperationEqu = apsProcessOperationProcessEquService.getById(reportRecordsDo.getProcessequid());
|
|
|
- if (currentProcessOperationEqu == null) {
|
|
|
- log.error("无法找到当前报工记录对应的工序作业信息");
|
|
|
- return R.error("无法找到当前报工记录对应的工序作业信息");
|
|
|
- }
|
|
|
- // 获取工序作业对应的输出物料信息
|
|
|
- List<ApsProcessOperationOutMaterDo> operationOutMaterDoList = apsProcessOperationOutMaterService.list(new LambdaQueryWrapper<ApsProcessOperationOutMaterDo>()
|
|
|
- .eq(ApsProcessOperationOutMaterDo::getMainid, currentProcessOperationId)
|
|
|
- .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
- if (operationOutMaterDoList.isEmpty()) {
|
|
|
- log.error("无法根据工序作业ID:{}获取对应的输出物料信息", currentProcessOperationId);
|
|
|
- return R.error("无法获取到对应的输出物料信息");
|
|
|
- }
|
|
|
- // 工序作业明细ID
|
|
|
- String processOperationEquId = currentProcessOperationEqu.getId();
|
|
|
- // 前道工序作业ID
|
|
|
- String previousprocessid = currentProcessOperationMainDo.getPreviousprocessid();
|
|
|
- // 坯料计划ID
|
|
|
- String blankId = currentProcessOperationMainDo.getBlankid();
|
|
|
- if (StringUtils.isBlank(blankId)) {
|
|
|
- log.error("无法根据工序获取到生产订单信息");
|
|
|
- return R.error("无法获取到生产订单信息");
|
|
|
+ SysUserVo currentUser = CXCommonUtils.getCurrentUser();
|
|
|
+ if(locks.containsKey(id) && !locks.get(id).equals(currentUser.getId())){
|
|
|
+ log.error("该作业已被其他人:{}检验",locks.get(id));
|
|
|
+ return R.error("该作业已被其他人检验");
|
|
|
}
|
|
|
- // 获取坯料计划
|
|
|
- ApsBlankOrderDo blankOrderDo = apsBlankOrderService.getBaseMapper().selectById(blankId);
|
|
|
- if (blankOrderDo == null) {
|
|
|
- log.error("无法根据ID:{}找到对应的坯料计划信息", blankId);
|
|
|
- return R.error("无法获取到坯料计划信息");
|
|
|
- }
|
|
|
- // 获取订单记录
|
|
|
- String productionOrderId = blankOrderDo.getProductionorderid();
|
|
|
- if (StringUtils.isBlank(productionOrderId)) {
|
|
|
- log.error("坯料计划对应的订单ID为空");
|
|
|
- return R.error("无法通过坯料计划找到订单信息");
|
|
|
- }
|
|
|
- // 获取订单信息
|
|
|
- ApsProductionOrderDo productionOrderDo = apsProductionOrderService.getById(productionOrderId);
|
|
|
- if (productionOrderDo == null) {
|
|
|
- log.error("无法根据ID:{},获取到订单信息", productionOrderId);
|
|
|
- return R.error("无法找到订单信息");
|
|
|
- }
|
|
|
- // 获取当前报工作业对应的在制品信息
|
|
|
- List<ApsWorkInProgressInventoryDo> apsWorkInProgressInventoryDos = apsWorkInProgressInventoryService.list(new LambdaQueryWrapper<ApsWorkInProgressInventoryDo>()
|
|
|
- .eq(ApsWorkInProgressInventoryDo::getWorkreportrecordid, id).eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
- if (apsWorkInProgressInventoryDos.isEmpty()) {
|
|
|
- log.error("无法获取到当前工序对应的在制品信息");
|
|
|
- return R.error("无法获取在制品信息");
|
|
|
- }
|
|
|
- // 更新当前工序作业和作业明细的已检验卷数
|
|
|
+ try {
|
|
|
+ if (StringUtil.isBlank(id)) {
|
|
|
+ log.debug("参数为空");
|
|
|
+ return R.error("报工检验参数异常");
|
|
|
+ }
|
|
|
+ // 获取报工记录
|
|
|
+ ApsReportRecordsDo reportRecordsDo = apsReportRecordsService.getById(id);
|
|
|
+ if (reportRecordsDo == null) {
|
|
|
+ log.error("无法根据ID:{}获取到报工记录", id);
|
|
|
+ return R.error("无法获取到报工记录");
|
|
|
+ }
|
|
|
+ if (VERIFIED.equals(reportRecordsDo.getCheckstatus())) {
|
|
|
+ log.error("当前报工记录已检验无法再次检验");
|
|
|
+ return R.error("该作业已被其他人检验");
|
|
|
+ }
|
|
|
+ apsReportRecordsService.update(new LambdaUpdateWrapper<ApsReportRecordsDo>().eq(ApsReportRecordsDo::getId, id)
|
|
|
+ .set(ApsReportRecordsDo::getCheckstatus, VERIFIED));
|
|
|
+ // 获取该工序生成的物料输出信息
|
|
|
+ List<ApsReportOutputDo> reportOutputDos = apsReportOutputService.list(new LambdaQueryWrapper<ApsReportOutputDo>()
|
|
|
+ .eq(ApsReportOutputDo::getMainid, id)
|
|
|
+ .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
+ if (reportOutputDos.isEmpty()) {
|
|
|
+ log.error("无法根据ID:{}获取到输出物料信息", id);
|
|
|
+ return R.error("无法获取到输出物料信息");
|
|
|
+ }
|
|
|
+ // 获取工序作业信息
|
|
|
+ String currentProcessOperationId = reportRecordsDo.getProcessoperationid();
|
|
|
+ if (StringUtils.isBlank(currentProcessOperationId)) {
|
|
|
+ log.error("当前报工记录:{}无法获取到对应的工序作业信息!", id);
|
|
|
+ return R.error("无法获取到工序作业信息,请联系系统管理员!");
|
|
|
+ }
|
|
|
+ // 获取工序作业主表信息
|
|
|
+ ApsProcessOperationDo currentProcessOperationMainDo = apsProcessOperationService.getOne(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
+ .eq(ApsProcessOperationDo::getId, currentProcessOperationId)
|
|
|
+ .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
+ if (currentProcessOperationMainDo == null) {
|
|
|
+ log.error("无法根据ID:{}获取到工序作业信息", id);
|
|
|
+ return R.error("无法获取到工序作业信息,请联系系统管理员!");
|
|
|
+ }
|
|
|
+ // 获取工序作业明细信息
|
|
|
+ ApsProcessOperationProcessEquDo currentProcessOperationEqu = apsProcessOperationProcessEquService.getById(reportRecordsDo.getProcessequid());
|
|
|
+ if (currentProcessOperationEqu == null) {
|
|
|
+ log.error("无法找到当前报工记录对应的工序作业信息");
|
|
|
+ return R.error("无法找到当前报工记录对应的工序作业信息");
|
|
|
+ }
|
|
|
+ // 获取工序作业对应的输出物料信息
|
|
|
+ List<ApsProcessOperationOutMaterDo> operationOutMaterDoList = apsProcessOperationOutMaterService.list(new LambdaQueryWrapper<ApsProcessOperationOutMaterDo>()
|
|
|
+ .eq(ApsProcessOperationOutMaterDo::getMainid, currentProcessOperationId)
|
|
|
+ .eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
+ if (operationOutMaterDoList.isEmpty()) {
|
|
|
+ log.error("无法根据工序作业ID:{}获取对应的输出物料信息", currentProcessOperationId);
|
|
|
+ return R.error("无法获取到对应的输出物料信息");
|
|
|
+ }
|
|
|
+ // 工序作业明细ID
|
|
|
+ String processOperationEquId = currentProcessOperationEqu.getId();
|
|
|
+ // 前道工序作业ID
|
|
|
+ String previousprocessid = currentProcessOperationMainDo.getPreviousprocessid();
|
|
|
+ // 坯料计划ID
|
|
|
+ String blankId = currentProcessOperationMainDo.getBlankid();
|
|
|
+ if (StringUtils.isBlank(blankId)) {
|
|
|
+ log.error("无法根据工序获取到生产订单信息");
|
|
|
+ return R.error("无法获取到生产订单信息");
|
|
|
+ }
|
|
|
+ // 获取坯料计划
|
|
|
+ ApsBlankOrderDo blankOrderDo = apsBlankOrderService.getBaseMapper().selectById(blankId);
|
|
|
+ if (blankOrderDo == null) {
|
|
|
+ log.error("无法根据ID:{}找到对应的坯料计划信息", blankId);
|
|
|
+ return R.error("无法获取到坯料计划信息");
|
|
|
+ }
|
|
|
+ // 获取订单记录
|
|
|
+ String productionOrderId = blankOrderDo.getProductionorderid();
|
|
|
+ if (StringUtils.isBlank(productionOrderId)) {
|
|
|
+ log.error("坯料计划对应的订单ID为空");
|
|
|
+ return R.error("无法通过坯料计划找到订单信息");
|
|
|
+ }
|
|
|
+ // 获取订单信息
|
|
|
+ ApsProductionOrderDo productionOrderDo = apsProductionOrderService.getById(productionOrderId);
|
|
|
+ if (productionOrderDo == null) {
|
|
|
+ log.error("无法根据ID:{},获取到订单信息", productionOrderId);
|
|
|
+ return R.error("无法找到订单信息");
|
|
|
+ }
|
|
|
+ // 获取当前报工作业对应的在制品信息
|
|
|
+ List<ApsWorkInProgressInventoryDo> apsWorkInProgressInventoryDos = apsWorkInProgressInventoryService.list(new LambdaQueryWrapper<ApsWorkInProgressInventoryDo>()
|
|
|
+ .eq(ApsWorkInProgressInventoryDo::getWorkreportrecordid, id).eq(BaseDo::getDeleted, NO_DELETED));
|
|
|
+ if (apsWorkInProgressInventoryDos.isEmpty()) {
|
|
|
+ log.error("无法获取到当前工序对应的在制品信息");
|
|
|
+ return R.error("无法获取在制品信息");
|
|
|
+ }
|
|
|
+ // 更新当前工序作业和作业明细的已检验卷数
|
|
|
|
|
|
- // 当前工序名为小圈成退 检验卷数为 报工记录的BATCHNUMBER 数量
|
|
|
- if (SMALL_CIRCLE_PROCESSING_PROCESS_NAME.contains(currentProcessOperationMainDo.getProcess())) {
|
|
|
- String batchnumber = reportRecordsDo.getBatchnumber();
|
|
|
- if (StringUtils.isBlank(batchnumber)) {
|
|
|
- log.error("报工记录的批次号为空");
|
|
|
- throw new RuntimeException("报工记录的批次号为空");
|
|
|
+ // 当前工序名为小圈成退 检验卷数为 报工记录的BATCHNUMBER 数量
|
|
|
+ if (SMALL_CIRCLE_PROCESSING_PROCESS_NAME.contains(currentProcessOperationMainDo.getProcess())) {
|
|
|
+ String batchnumber = reportRecordsDo.getBatchnumber();
|
|
|
+ if (StringUtils.isBlank(batchnumber)) {
|
|
|
+ log.error("报工记录的批次号为空");
|
|
|
+ throw new RuntimeException("报工记录的批次号为空");
|
|
|
+ }
|
|
|
+ // inputBatchNum
|
|
|
+ int count = (int) Arrays.stream(batchnumber.split(",")).distinct().filter(StringUtils::isNotBlank).count();
|
|
|
+ currentProcessOperationMainDo.setCheckoutroll(currentProcessOperationMainDo.getCheckoutroll() + count);
|
|
|
+ currentProcessOperationEqu.setCheckoutroll(currentProcessOperationEqu.getCheckoutroll() + count);
|
|
|
+ } else {
|
|
|
+ currentProcessOperationMainDo.setCheckoutroll(currentProcessOperationMainDo.getCheckoutroll() + 1);
|
|
|
+ currentProcessOperationEqu.setCheckoutroll(currentProcessOperationEqu.getCheckoutroll() + 1);
|
|
|
}
|
|
|
- // inputBatchNum
|
|
|
- int count = (int) Arrays.stream(batchnumber.split(",")).distinct().filter(StringUtils::isNotBlank).count();
|
|
|
- currentProcessOperationMainDo.setCheckoutroll(currentProcessOperationMainDo.getCheckoutroll() + count);
|
|
|
- currentProcessOperationEqu.setCheckoutroll(currentProcessOperationEqu.getCheckoutroll() + count);
|
|
|
- } else {
|
|
|
- currentProcessOperationMainDo.setCheckoutroll(currentProcessOperationMainDo.getCheckoutroll() + 1);
|
|
|
- currentProcessOperationEqu.setCheckoutroll(currentProcessOperationEqu.getCheckoutroll() + 1);
|
|
|
- }
|
|
|
- currentProcessOperationEqu.setWorkstatus(JOBSTATUS_TO_BE_END);
|
|
|
- currentProcessOperationEqu.setBachmaterialprocess("");
|
|
|
- // 更新 更新该报工检验记录所有输出物料 以及待加工料卷批次号
|
|
|
- batchNumCirculation(apsWorkInProgressInventoryDos, reportOutputDos,
|
|
|
- operationOutMaterDoList,
|
|
|
- currentProcessOperationMainDo,
|
|
|
- currentProcessOperationEqu,
|
|
|
- reportRecordsDo,
|
|
|
- productionOrderDo);
|
|
|
+ currentProcessOperationEqu.setWorkstatus(JOBSTATUS_TO_BE_END);
|
|
|
+ currentProcessOperationEqu.setBachmaterialprocess("");
|
|
|
+ // 更新 更新该报工检验记录所有输出物料 以及待加工料卷批次号
|
|
|
+ batchNumCirculation(apsWorkInProgressInventoryDos, reportOutputDos,
|
|
|
+ operationOutMaterDoList,
|
|
|
+ currentProcessOperationMainDo,
|
|
|
+ currentProcessOperationEqu,
|
|
|
+ reportRecordsDo,
|
|
|
+ productionOrderDo);
|
|
|
// updateProcessOutputMater(apsWorkInProgressInventoryDos, reportOutputDos,
|
|
|
// operationOutMaterDoList,
|
|
|
// currentProcessOperationMainDo,
|
|
|
// currentProcessOperationEqu);
|
|
|
- // 更新当前工序作业和作业明细的数据
|
|
|
- apsProcessOperationService.updateById(currentProcessOperationMainDo);
|
|
|
- apsProcessOperationProcessEquService.updateById(currentProcessOperationEqu);
|
|
|
- // 更新报工输出物料 检验状态
|
|
|
- apsReportOutputService.update(new LambdaUpdateWrapper<ApsReportOutputDo>()
|
|
|
- .in(ApsReportOutputDo::getId, reportOutputDos.stream().map(ApsReportOutputDo::getId).collect(Collectors.toList()))
|
|
|
- .set(ApsReportOutputDo::getCheckstatus, VERIFIED));
|
|
|
- if (reportOutputDos.stream().anyMatch(info -> NO.equals(info.getQualified())) && "已发布计划".equals(productionOrderDo.getAuditstatus())) {
|
|
|
- goBackWf(processOperationEquId, blankId, productionOrderDo);
|
|
|
+ // 更新当前工序作业和作业明细的数据
|
|
|
+ apsProcessOperationService.updateById(currentProcessOperationMainDo);
|
|
|
+ apsProcessOperationProcessEquService.updateById(currentProcessOperationEqu);
|
|
|
+ // 更新报工输出物料 检验状态
|
|
|
+ apsReportOutputService.update(new LambdaUpdateWrapper<ApsReportOutputDo>()
|
|
|
+ .in(ApsReportOutputDo::getId, reportOutputDos.stream().map(ApsReportOutputDo::getId).collect(Collectors.toList()))
|
|
|
+ .set(ApsReportOutputDo::getCheckstatus, VERIFIED));
|
|
|
+ if (reportOutputDos.stream().anyMatch(info -> NO.equals(info.getQualified())) && "已发布计划".equals(productionOrderDo.getAuditstatus())) {
|
|
|
+ goBackWf(processOperationEquId, blankId, productionOrderDo);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ log.debug("从map中清空当前报工记录:{}",id);
|
|
|
+ locks.remove(id);
|
|
|
}
|
|
|
- apsReportRecordsService.update(new LambdaUpdateWrapper<ApsReportRecordsDo>().eq(ApsReportRecordsDo::getId, id)
|
|
|
- .set(ApsReportRecordsDo::getCheckstatus, VERIFIED));
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -261,6 +280,29 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R preSaveCheck(String id) {
|
|
|
+ log.info("报工检验前校验");
|
|
|
+ SysUserVo currentUser = CXCommonUtils.getCurrentUser();
|
|
|
+ if (locks.containsKey(id)) {
|
|
|
+ log.error("报工检验前校验失败,当前报工记录已被他人:{}检验", locks.get(id));
|
|
|
+ return R.error("该作业已被其他人检验");
|
|
|
+ }
|
|
|
+ locks.computeIfAbsent(id, k -> currentUser.getId());
|
|
|
+ // 获取报工记录
|
|
|
+ ApsReportRecordsDo reportRecordsDo = apsReportRecordsService.getById(id);
|
|
|
+ if (reportRecordsDo == null) {
|
|
|
+ log.error("无法根据ID:{}获取到报工记录", id);
|
|
|
+ return R.error("无法获取到报工记录");
|
|
|
+ }
|
|
|
+ if (VERIFIED.equals(reportRecordsDo.getCheckstatus())) {
|
|
|
+ log.error("当前报工记录已检验无法再次检验");
|
|
|
+ return R.error("该作业已被其他人检验");
|
|
|
+ }
|
|
|
+ log.debug("报工检验前校验成功");
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批次号流转相关逻辑
|
|
|
*
|