|
|
@ -1,41 +1,33 @@
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPojoVersionService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
|
|
|
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.IMesProductionProcessContextStepService;
|
|
|
|
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.context.MesProductionPartContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersion;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
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.repository.MesProduceSnRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -43,158 +35,180 @@ import java.util.stream.Collectors;
|
|
|
|
* @Author : wangjie
|
|
|
|
* @Author : wangjie
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@Service("mesProductSnGenerateStepService")
|
|
|
|
public class MesProductSnGenerateStepService extends BaseStepService {
|
|
|
|
public class MesProductSnGenerateStepService extends BaseStepService {
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesPartRepository mesPartRepository;
|
|
|
|
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesProduceSnRepository mesProduceSnRepository;
|
|
|
|
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
private MesFirstMouldNoReadStepService firstMouldNoReadStepService;
|
|
|
|
|
|
|
|
|
|
|
|
public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT";
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
|
|
|
private IMesProduceSnExtService produceSnExtService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesPojoVersionService mesPojoVersionService;
|
|
|
|
private MesProduceSnRepository produceSnRepository;
|
|
|
|
|
|
|
|
|
|
|
|
/**todo 有产成无进料场景
|
|
|
|
|
|
|
|
* todo 根据装配件条码没有找到加工规则,如果需要跳过装配件绑定,直接生成条码,就需要不看加工规则,直接根据产成零件生成条码,当前设计方式就需要变更。
|
|
|
|
|
|
|
|
* @param reqBean
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
|
|
|
|
|
|
|
StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
String result = mesProductionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
|
|
|
|
//获取上下文信息
|
|
|
|
//获取上下文信息
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
|
|
|
|
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
|
|
|
|
|
|
|
|
// 获取产出零件信息
|
|
|
|
|
|
|
|
List<MesProductionPartContext> productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(productionPartContextList)) {
|
|
|
|
|
|
|
|
foundExThrow(reqBean, "必过工步不允许跳过");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取零件号,可能存在多个
|
|
|
|
|
|
|
|
List<String> partNoList = productionPartContextList.stream().map(MesProductionPartContext::getPartNo).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 根据零件号组装产品条码信息
|
|
|
|
|
|
|
|
List<MesProduceSn> mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result);
|
|
|
|
|
|
|
|
// 保存条码信息
|
|
|
|
|
|
|
|
mesProduceSnRepository.saveAll(mesProduceSns);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
savePojoVersion(mesProduceSns);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MesProductionPsOutContext> mesProductionPsOutContexts = new ArrayList<>();
|
|
|
|
|
|
|
|
for (MesProduceSn mesProduceSn : mesProduceSns) {
|
|
|
|
|
|
|
|
MesProductionPsOutContext mesProductionPsOutContext = new MesProductionPsOutContext();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(mesProduceSn, mesProductionPsOutContext);
|
|
|
|
|
|
|
|
mesProductionPsOutContexts.add(mesProductionPsOutContext);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 放到上下文
|
|
|
|
|
|
|
|
mesProductionDispatchContextStepService.saveProductionPsOutContext(reqBean, mesProductionPsOutContexts);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成零件条码成功");
|
|
|
|
//配置错误 抛出异常
|
|
|
|
}
|
|
|
|
if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//存储生产过程上下文对象
|
|
|
|
|
|
|
|
productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从上下文中取出生产线对象
|
|
|
|
|
|
|
|
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排序线 直接跳过
|
|
|
|
|
|
|
|
if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) return stepResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//已经生成过零件条码
|
|
|
|
|
|
|
|
if (productionDispatchContextStepService.checkProductionPsOutIsExistContext(reqBean)) return stepResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取上下文产品加工规则数据信息集合
|
|
|
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
private void savePojoVersion(List<MesProduceSn> mesProduceSns) {
|
|
|
|
if (CollectionUtils.isEmpty(prodRuleContextList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "上下文中不存在加工规则信息,请重置工序解决!");
|
|
|
|
mesProduceSns.forEach(mesProduceSn -> {
|
|
|
|
|
|
|
|
MesPojoVersion version = new MesPojoVersion();
|
|
|
|
//获取生产线的当前班组班次信息
|
|
|
|
version.setRefId(mesProduceSn.getId());
|
|
|
|
MesProdShiftContext prodShiftContext = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
|
|
|
version.setRefClass(mesProduceSn.getClass().getName());
|
|
|
|
|
|
|
|
version.setBean(JsonUtilTool.encode(mesProduceSn));
|
|
|
|
if (null == prodShiftContext) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "上下文中不存在生产开班记录,请重新开班!");
|
|
|
|
version.setCreateUser(version.getCreateUser());
|
|
|
|
|
|
|
|
version.setModifyUser(version.getModifyUser());
|
|
|
|
//获取上下文产出零件数据信息集合
|
|
|
|
version.setVersionMethodName("insert");
|
|
|
|
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
|
|
|
|
version.setOrganizeCode(mesProduceSn.getOrganizeCode());
|
|
|
|
|
|
|
|
mesPojoVersionService.recordPojoVersion(version);
|
|
|
|
//获取上下文进料零件条码信息集合
|
|
|
|
|
|
|
|
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取上下文零件数据信息
|
|
|
|
|
|
|
|
List<String> partNoList = (prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getOutPartNo()))).map(MesProdRuleContext::getOutPartNo).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
firstMouldNoReadStepService.savePartDataMap(reqBean, resultBean, stepResult, partNoList, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取上下文加工结果
|
|
|
|
|
|
|
|
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<Integer, MesProductionPartContext> ppMap = CollectionUtils.isEmpty(productionPartContextList) ? null : productionPartContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o));
|
|
|
|
|
|
|
|
Map<Integer, MesProductionPsInContext> psMap = CollectionUtils.isEmpty(productionPsInContextList) ? null : productionPsInContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProductionPsInContext::getForeignKey, o -> o));
|
|
|
|
|
|
|
|
Map<String, MesPart> partMap = (Map<String, MesPart>) stepResult.getObj();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//循环生成零件条码,并写入产出零件
|
|
|
|
|
|
|
|
List<MesProductionPsOutContext> productionPsOutContextList = new ArrayList<>();
|
|
|
|
|
|
|
|
prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()) && !StringUtils.isEmpty(o.getOutPartNo()))).forEach(o -> {
|
|
|
|
|
|
|
|
MesProductionPsOutContext productionPsOutContext = insertProduceSnData(reqBean, resultBean, stepResult, productionProcessContext, o, ppMap, psMap, partMap, prodShiftContext, productResult);
|
|
|
|
|
|
|
|
if (null != productionPsOutContext) productionPsOutContextList.add(productionPsOutContext);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
//保存上下文产出条码数据信息集合
|
|
|
|
* 根据零件号组装产品条码信息
|
|
|
|
productionDispatchContextStepService.saveProductionPsOutContext(reqBean, productionPsOutContextList);
|
|
|
|
* @param reqBean
|
|
|
|
|
|
|
|
* @param productionProcessContext
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成零件条码成功!");
|
|
|
|
* @param mesWorkCell
|
|
|
|
|
|
|
|
* @param partNoList
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private List<MesProduceSn> generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List<String> partNoList, String result) {
|
|
|
|
|
|
|
|
List<MesProduceSn> mesProduceSns = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String partNo : partNoList) {
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
|
|
|
|
|
|
|
|
MesPart mesPart = mesPartRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
if (mesPart == null) {
|
|
|
|
|
|
|
|
MesPcnException.throwFlowException("零件号不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 根据条码规则生成条码
|
|
|
|
|
|
|
|
String sn = generateByRule(mesPart);
|
|
|
|
//生成零件条码
|
|
|
|
// 组装条码信息
|
|
|
|
private MesProductionPsOutContext insertProduceSnData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesProdRuleContext prodRuleContext,
|
|
|
|
MesProduceSn mesProduceSn = generateMesProduceSn(mesPart, sn, mesWorkCell, productionProcessContext, reqBean, result);
|
|
|
|
Map<Integer, MesProductionPartContext> ppMap, Map<Integer, MesProductionPsInContext> psMap, Map<String, MesPart> partMap, MesProdShiftContext prodShiftContext, String productResult) {
|
|
|
|
ConvertBean.serviceModelInitialize(mesProduceSn, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
mesProduceSns.add(mesProduceSn);
|
|
|
|
//产出零件数据信息
|
|
|
|
|
|
|
|
MesProductionPartContext productionPartContext = !CollectionUtils.isEmpty(ppMap) ? ppMap.get(prodRuleContext.getForeignKey()) : null;
|
|
|
|
|
|
|
|
//料零件条码
|
|
|
|
|
|
|
|
MesProductionPsInContext productionPsInContext = !CollectionUtils.isEmpty(psMap) ? psMap.get(prodRuleContext.getForeignKey()) : null;
|
|
|
|
|
|
|
|
//零件信息
|
|
|
|
|
|
|
|
MesPart part = partMap.get(prodRuleContext.getOutPartNo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加工规则中进料零件与产出零件是否一致
|
|
|
|
|
|
|
|
Boolean isSamePart = isSamePart(prodRuleContext.getInPartNo(), prodRuleContext.getOutPartNo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//进出一致, 无需生成
|
|
|
|
|
|
|
|
if (isSamePart) return new MesProductionPsOutContext().copy(produceSnExtService.getProduceSn(reqBean.getOrganizeCode(), null != productionPsInContext ? productionPsInContext.getId() : null), prodRuleContext.getForeignKey());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断存在主条码的时候是否此前已生成当前工位的未知条码
|
|
|
|
|
|
|
|
MesProduceSn produceSn = (null == productionPsInContext || StringUtils.isEmpty(productionPsInContext.getRelateId())) ? null : produceSnExtService.getProduceSn(reqBean.getOrganizeCode(), productionPsInContext.getRelateId());
|
|
|
|
|
|
|
|
if (null == produceSn) produceSn = new MesProduceSn();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setProductSn((null != productionPsInContext && !StringUtils.isEmpty(productionPsInContext.getProductSn())) ? productionPsInContext.getProductSn() :
|
|
|
|
|
|
|
|
syncFuncService.syncSerialNo(new GenSerialNoModel(getProduceSnNumberRule(reqBean, resultBean, part)).partNo(part.getPartNo()), reqBean.getUserInfo(), reqBean.getOrganizeCode(), 1).getResultList().get(0).toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setSerialNumber(syncFuncService.syncSerialNo(new GenSerialNoModel(MesPcnExtConstWords.DEFAULT_SERIAL_NUMBER_RULE).prodLocation(reqBean.getWorkCenterCode()), reqBean.getUserInfo(), reqBean.getOrganizeCode(), 1).getResultList().get(0).toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), e.getErrorDetail());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mesProduceSns;
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setCustSn(produceSn.getProductSn());
|
|
|
|
|
|
|
|
produceSn.setQty(new Double(1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null != productionPartContext && !StringUtils.isEmpty(productionPartContext.getWorkOrderNo())) {
|
|
|
|
|
|
|
|
produceSn.setWorkOrderNo(productionPartContext.getWorkOrderNo());
|
|
|
|
|
|
|
|
produceSn.setCustCode(productionPartContext.getCustCode());
|
|
|
|
|
|
|
|
produceSn.setCustPartNo(productionPartContext.getCustPartNo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
produceSn.setAreaCode(reqBean.getAreaCode());
|
|
|
|
* 生成条码
|
|
|
|
produceSn.setWorkCenterCode(reqBean.getWorkCenterCode());
|
|
|
|
* @param mesPart
|
|
|
|
produceSn.setWorkCellCode(reqBean.getWorkCellCode());
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
produceSn.setPartNo(part.getPartNo());
|
|
|
|
private String generateByRule(MesPart mesPart) {
|
|
|
|
produceSn.setPartName(part.getPartName());
|
|
|
|
//生成工单号
|
|
|
|
produceSn.setProcessLabelTemplate(part.getProcessLabelTemplate());
|
|
|
|
GenSerialNoModel genSerialNoModel = new GenSerialNoModel(ORDER_NO_JIS_SORT);
|
|
|
|
produceSn.setProdLabelTemplate(part.getProductLabelTemplate());
|
|
|
|
genSerialNoModel.setPartNo(mesPart.getPartNo());
|
|
|
|
produceSn.setCustLabelTemplate(part.getCustLabelTemplate());
|
|
|
|
List<String> resultList = syncFuncService.syncSerialNo(genSerialNoModel, mesPart.getCreateUser(), mesPart.getOrganizeCode(), 1).getResultList();
|
|
|
|
|
|
|
|
return resultList.get(0);
|
|
|
|
produceSn.setSnType(MesExtEnumUtil.PRODUCE_SN_TYPE.STANDARD.getValue());
|
|
|
|
|
|
|
|
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.UNKNOW.getValue());
|
|
|
|
|
|
|
|
produceSn.setQcStatus(!StringUtils.isEmpty(productResult) ? Integer.valueOf(productResult) : MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setShiftCode(prodShiftContext.getShiftCode());
|
|
|
|
|
|
|
|
produceSn.setShiftGroup(prodShiftContext.getShiftGroup());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setPrintCount(MesPcnExtConstWords.ZERO);
|
|
|
|
|
|
|
|
produceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setOrganizeCode(reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(produceSn.getId())) ConvertBean.serviceModelInitialize(produceSn, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
else ConvertBean.serviceModelUpdate(produceSn, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
produceSn.setInWorkCenterTime(produceSn.getModifyDatetime());
|
|
|
|
|
|
|
|
produceSn.setLotNo(produceSn.getModifyDatetime().substring(0, 10));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(produceSn.getId())) produceSn = produceSnRepository.insert(produceSn);
|
|
|
|
|
|
|
|
else produceSnRepository.save(produceSn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new MesProductionPsOutContext().copy(produceSn, prodRuleContext.getForeignKey()).isCalcCompleteQty(produceSn.getWorkOrderNo());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, MesWorkCell mesWorkCell,MesProductionProcessContext productionProcessContext, StationRequestBean reqBean, String result) {
|
|
|
|
private String getProduceSnNumberRule(StationRequestBean reqBean, StationResultBean resultBean, MesPart part) {
|
|
|
|
long serialNum = snowflakeIdMaker.nextId();
|
|
|
|
if (StringUtils.isEmpty(part.getProductMatchRule())) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查零件信息,零件[%s]信息未维护零件条码编码规则!", part.getPartNo()));
|
|
|
|
|
|
|
|
return part.getProductMatchRule();
|
|
|
|
MesProduceSn mesProduceSn = new MesProduceSn();
|
|
|
|
|
|
|
|
mesProduceSn.setSerialNumber(serialNum + "");
|
|
|
|
|
|
|
|
mesProduceSn.setProductSn(sn);
|
|
|
|
|
|
|
|
mesProduceSn.setCustSn(sn);
|
|
|
|
|
|
|
|
mesProduceSn.setPartNo(mesPart.getPartNo());
|
|
|
|
|
|
|
|
mesProduceSn.setPartName(mesPart.getPartName());
|
|
|
|
|
|
|
|
mesProduceSn.setAreaCode(mesWorkCell.getAreaCode());
|
|
|
|
|
|
|
|
mesProduceSn.setWorkCenterCode(mesWorkCell.getWorkCenterCode());
|
|
|
|
|
|
|
|
mesProduceSn.setWorkCellCode(mesWorkCell.getWorkCellCode());
|
|
|
|
|
|
|
|
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
|
|
|
|
|
|
|
|
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
|
|
|
|
|
|
|
|
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
|
|
|
|
|
|
|
|
mesProduceSn.setQty(1d);
|
|
|
|
|
|
|
|
mesProduceSn.setSnStatus(10);
|
|
|
|
|
|
|
|
Integer qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue();
|
|
|
|
|
|
|
|
if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) {
|
|
|
|
|
|
|
|
qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue();
|
|
|
|
|
|
|
|
} else if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SUSPICIOUS.getValue(), result)) {
|
|
|
|
|
|
|
|
qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mesProduceSn.setQcStatus(qcStatus);
|
|
|
|
|
|
|
|
mesProduceSn.setLotNo(DateUtil.format(new Date(), "YYYYMMDD"));
|
|
|
|
private Boolean isSamePart(String inPartNo, String outPartNo) {
|
|
|
|
mesProduceSn.setRouteCode(reqBean.getRouteCode());
|
|
|
|
if (!StringUtils.isEmpty(inPartNo) && inPartNo.equals(outPartNo)) return true;
|
|
|
|
mesProduceSn.setProcessCode(productionProcessContext.getProcessCode());
|
|
|
|
else return false;
|
|
|
|
mesProduceSn.setCraftCode(productionProcessContext.getCraftCode());
|
|
|
|
|
|
|
|
mesProduceSn.setPrintCount(0);
|
|
|
|
|
|
|
|
mesProduceSn.setPrintStatus(10);
|
|
|
|
|
|
|
|
mesProduceSn.setOrganizeCode(reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mesProduceSn;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|