|
|
|
@ -3,18 +3,25 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
|
|
|
|
|
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.IMesTimeEfficientCfgMatchService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
|
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.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawSnWeightRecord;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
|
|
|
|
|
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.repository.MesProduceSnRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesRawSnWeightRecordRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -25,7 +32,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 匹配调配原料条码工步
|
|
|
|
|
* @Description : 原料调配原料条码工步
|
|
|
|
|
* @Author : jason.niu
|
|
|
|
|
**/
|
|
|
|
|
@Slf4j
|
|
|
|
@ -41,6 +48,10 @@ public class MesAssemblyMatchRawMixStepService extends BaseStepService {
|
|
|
|
|
private MesAssemblyShowNosortStepService assemblyShowNosortStepService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProduceSnRepository produceSnRDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesTimeEfficientCfgMatchService timeEfficientCfgMatchService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesRawSnWeightRecordRepository rawSnWeightRecordRDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
@ -72,6 +83,7 @@ public class MesAssemblyMatchRawMixStepService extends BaseStepService {
|
|
|
|
|
}
|
|
|
|
|
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
|
|
|
|
|
|
|
|
|
|
// 是否所有装配件均已扫描过
|
|
|
|
|
if (isAllAssemblyMatchRawMix(workCenter, prodRuleContextList)) {
|
|
|
|
|
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "调配原料装配成功!");
|
|
|
|
|
}
|
|
|
|
@ -148,6 +160,20 @@ public class MesAssemblyMatchRawMixStepService extends BaseStepService {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesContainerPackageDetailContext containerPackageDetailContext = new MesContainerPackageDetailContext();
|
|
|
|
|
containerPackageDetailContext.setPartNo(productionAssemblyNosortContext.getAssemblyPartNo());
|
|
|
|
|
containerPackageDetailContext.setBarCode(barcode);
|
|
|
|
|
String firstOpenTime = getRawSnWeightRecordFirstOpenTime(reqBean.getOrganizeCode(), barcode);
|
|
|
|
|
containerPackageDetailContext.setCreateDatetime(firstOpenTime);
|
|
|
|
|
|
|
|
|
|
//验证时效性
|
|
|
|
|
Map<String, Object> timeEfficientResult = timeEfficientCfgMatchService.checkSnTimelinessContainerMatch(reqBean.getOrganizeCode(), containerPackageDetailContext, productionAssemblyNosortContext.getSourceId());
|
|
|
|
|
if (!(Boolean)timeEfficientResult.get(MesPcnExtConstWords.RESULT)) {
|
|
|
|
|
String msg = (String) timeEfficientResult.get(MesPcnExtConstWords.MESSAGE);
|
|
|
|
|
stepResult.setMsg(msg);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//验证返回result里面是否存在assemblySn,存在特殊的规则会转换成新的条码
|
|
|
|
|
String assemblySn = !result.containsKey(MesPcnExtConstWords.ASSEMBLY_SN) ? barcode : (String) result.get(MesPcnExtConstWords.ASSEMBLY_SN);
|
|
|
|
|
MesProductionAssemblyNosortContext filter = (MesProductionAssemblyNosortContext) result.get(MesPcnExtConstWords.DATA);
|
|
|
|
@ -170,6 +196,20 @@ public class MesAssemblyMatchRawMixStepService extends BaseStepService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取调配原料首次开罐时间,即首次被装配的时间。
|
|
|
|
|
* @param organizeCode
|
|
|
|
|
* @param barCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String getRawSnWeightRecordFirstOpenTime(String organizeCode, String barCode) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barCode, "barCode", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), packBean);
|
|
|
|
|
MesRawSnWeightRecord record = rawSnWeightRecordRDao.getByProperty(packBean);
|
|
|
|
|
return record != null ? record.getCreateDatetime() : TimeTool.getNowTime(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> checkProductSnRule(String organizeCode, String barcode) {
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put(MesPcnExtConstWords.RESULT, false);
|
|
|
|
|