|
|
|
@ -2,15 +2,22 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.MesWorkOrderCheckCompleteQtyStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -19,6 +26,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.StringJoiner;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -39,6 +47,9 @@ public class MesProductionDataSaveBeforeControlOrderStepService extends BaseStep
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesWorkOrderCheckCompleteQtyStepService workOrderCheckCompleteQtyStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionRecordService productionRecordService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
|
@ -57,17 +68,20 @@ public class MesProductionDataSaveBeforeControlOrderStepService extends BaseStep
|
|
|
|
|
|
|
|
|
|
//获取上下文产品加工规则数据信息集合
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
|
|
|
|
Map<Integer, MesProdRuleContext> prMap = CollectionUtils.isEmpty(prodRuleContextList) ? null : prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o));
|
|
|
|
|
//获取上下文产出条码数据信息集合
|
|
|
|
|
List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
|
|
|
|
|
if (CollectionUtils.isEmpty(prodRuleContextList) || CollectionUtils.isEmpty(productionPsOutContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
|
|
|
|
|
|
|
|
|
|
Map<Integer, MesProdRuleContext> prMap = CollectionUtils.isEmpty(prodRuleContextList) ? null : prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o));
|
|
|
|
|
if (CollectionUtils.isEmpty(prMap) || CollectionUtils.isEmpty(productionPsOutContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
|
|
|
|
|
//获取进料主条码数据信息
|
|
|
|
|
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
|
|
|
|
|
Map<Integer, MesProductionPsInContext> psiMap = CollectionUtils.isEmpty(productionPsInContextList) ? null : productionPsInContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProductionPsInContext::getForeignKey, o -> o));
|
|
|
|
|
|
|
|
|
|
synchronized (new StringJoiner(MesPcnExtConstWords.COLON).add(reqBean.getOrganizeCode()).add(reqBean.getWorkCenterCode()).add(MesPcnExtConstWords.WORK_ORDER_COMPLETE_CONTEXT).toString().intern()) {
|
|
|
|
|
|
|
|
|
|
productionPsOutContextList.stream().filter(o -> null != o).forEach(o ->
|
|
|
|
|
checkProductionRecordIsReport(reqBean, workCenter, scanMonitorContext, mouldNo, prodRuleContextList, productionProcessContext, o, prMap, cellEquipContext, CollectionUtils.isEmpty(psiMap) ? null : psiMap.get(o.getForeignKey()))
|
|
|
|
|
);
|
|
|
|
|
//验证是否需要汇报
|
|
|
|
|
productionPsOutContextList.stream().filter(o -> null != o).forEach(o -> checkProductionRecordIsReport(reqBean, o, prMap.get(o.getForeignKey()), CollectionUtils.isEmpty(psiMap) ? null : psiMap.get(o.getForeignKey())));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证加工单完成数量
|
|
|
|
|
workOrderCheckCompleteQtyStepService.dispatchWorkOrderCompleteQtyContext(
|
|
|
|
@ -93,4 +107,31 @@ public class MesProductionDataSaveBeforeControlOrderStepService extends BaseStep
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkProductionRecordIsReport(StationRequestBean reqBean, MesProductionPsOutContext productionPsOutContext, MesProdRuleContext prodRuleContext, MesProductionPsInContext productionPsInContext) {
|
|
|
|
|
Integer reportType = (null != prodRuleContext && !StringUtils.isEmpty(prodRuleContext.getReportType()) && prodRuleContext.getReportType().compareTo(MesPcnExtConstWords.ZERO) != 0) ? prodRuleContext.getReportType() : MesExtEnumUtil.NOSORT_REPORT_TYPE.NO_REPORT.getValue();
|
|
|
|
|
Integer reportStatus = reportType.compareTo(MesExtEnumUtil.NOSORT_REPORT_TYPE.NO_REPORT.getValue()) != 0 ? MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_10.getValue() : MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue();
|
|
|
|
|
if (reportStatus.compareTo(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_10.getValue()) == 0 && isSamePart(productionPsInContext, productionPsOutContext) &&
|
|
|
|
|
checkPsIsReported(reqBean.getOrganizeCode(), productionPsOutContext.getProductSn(), productionPsOutContext.getPartNo())) reportStatus = MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue();
|
|
|
|
|
if (reportStatus.compareTo(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_10.getValue()) == 0) productionPsOutContext.setIsCalcCompleteQty(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- MesProductionPsOutContext:{}",
|
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), JSONObject.toJSONString(productionPsOutContext));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//加工规则中进料零件与产出零件是否一致
|
|
|
|
|
private Boolean isSamePart(MesProductionPsInContext productionPsInContext, MesProductionPsOutContext productionPsOutContext) {
|
|
|
|
|
if (null == productionPsInContext) return false;
|
|
|
|
|
if (StringUtils.isEmpty(productionPsInContext.getPartNo())) return false;
|
|
|
|
|
if (null == productionPsOutContext) return false;
|
|
|
|
|
if (!productionPsInContext.getPartNo().equals(productionPsOutContext.getPartNo())) return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//验证是否存在产出零件条码+零件编码已经汇报的场景
|
|
|
|
|
private Boolean checkPsIsReported(String organizeCode, String productSn, String partNo) {
|
|
|
|
|
List<MesProductionRecord> productionRecordList = productionRecordService.findProductionRecordList(organizeCode, productSn, partNo);
|
|
|
|
|
if (CollectionUtils.isEmpty(productionRecordList)) return false;
|
|
|
|
|
Optional<MesProductionRecord> optional = productionRecordList.stream().filter(o -> (null != o && o.getReportStatus().compareTo(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue()) != 0)).findFirst();
|
|
|
|
|
return (null != optional && optional.isPresent()) ? true : false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|