forked from I3-YF/i3plus-mes-pcn-yfai
tags/yfai-pcn-ext-v1.0
parent
4376c15c51
commit
feb76a6014
@ -0,0 +1,100 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||||
|
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.MesEquipmentVariableCfg;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesModelMultiCavity;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
||||||
|
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.MesPartRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 生成零件条码
|
||||||
|
* @Author : wangjie
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Service("mesGenerateSnService")
|
||||||
|
public class MesGenerateSnService extends BaseStepService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesPartRepository mesPartRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesProduceSnRepository mesProduceSnRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISyncFuncService syncFuncService;
|
||||||
|
|
||||||
|
public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StepResult execute(StationRequestBean reqBean) {
|
||||||
|
|
||||||
|
StationResultBean resultBean = new StationResultBean();
|
||||||
|
|
||||||
|
StepResult stepResult = StepResult.getSuccessComplete();
|
||||||
|
|
||||||
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
|
||||||
|
|
||||||
|
List<MesModelMultiCavity> mesModelMultiCavities = productionProcessContext.getMesModelMultiCavities();
|
||||||
|
List<MesProduceSn> mesProduceSns = new ArrayList<>();
|
||||||
|
for (MesModelMultiCavity modelMultiCavity : mesModelMultiCavities) {
|
||||||
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
|
||||||
|
DdlPreparedPack.getStringEqualPack(modelMultiCavity.getPartNo(), "partNo", packBean);
|
||||||
|
MesPart mesPart = mesPartRepository.getByProperty(packBean);
|
||||||
|
if (mesPart == null) {
|
||||||
|
return execNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, "零件号不存在");
|
||||||
|
}
|
||||||
|
String sn = generateByRule(mesPart);
|
||||||
|
MesProduceSn mesProduceSn = generateMesProduceSn();
|
||||||
|
mesProduceSns.add(mesProduceSn);
|
||||||
|
}
|
||||||
|
mesProduceSnRepository.saveAll(mesProduceSns);
|
||||||
|
|
||||||
|
return StepResult.getSuccessComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String generateByRule(MesPart mesPart) {
|
||||||
|
//生成工单号
|
||||||
|
GenSerialNoModel genSerialNoModel = new GenSerialNoModel(ORDER_NO_JIS_SORT);
|
||||||
|
genSerialNoModel.setPartNo(mesPart.getPartNo());
|
||||||
|
List<String> resultList = syncFuncService.syncSerialNo(genSerialNoModel, mesPart.getCreateUser(), mesPart.getOrganizeCode(), 1).getResultList();
|
||||||
|
return resultList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MesProduceSn generateMesProduceSn(MesPart mesPart) {
|
||||||
|
MesProduceSn mesProduceSn = new MesProduceSn();
|
||||||
|
mesProduceSn.set
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue