tags/yfai-pcn-ext-v1.0
王杰 11 months ago
parent 433d5eb232
commit de1b3c22db

@ -71,7 +71,6 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
//从上下文中取出生产线对象 //从上下文中取出生产线对象
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip(); MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//获取上下文产出零件数据信息集合 //获取上下文产出零件数据信息集合
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean); List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);

@ -0,0 +1,135 @@
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.pojo.context.*;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
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.MesProductionAssemblyRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
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.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesAssemblySaveNosortStepService")
public class MesAssemblySaveNosortStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private MesProductionAssemblyRepository productionAssemblyRepository;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//存储生产过程上下文对象
productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
if (CollectionUtils.isEmpty(prodRuleContextList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前上下文中不存在非排序加工规则数据,请重置工序!");
//获取上下文产出条码数据信息集合
List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
if (CollectionUtils.isEmpty(productionPsOutContextList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "上下文中不存在产出零件条码信息,请重置工序解决!");
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
Map<Integer, MesProductionPsOutContext> ppMap = CollectionUtils.isEmpty(productionPsOutContextList) ? null : productionPsOutContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProductionPsOutContext::getForeignKey, o -> o));
prodRuleContextList.stream().filter(o -> null != o).forEach(o -> saveProductionAssemblyData(reqBean, resultBean, stepResult, productionProcessContext, o, ppMap, cellEquipContext));
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "保存装配记录成功!");
}
private void saveProductionAssemblyData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesProdRuleContext prodRuleContext, Map<Integer, MesProductionPsOutContext> ppMap, MesCellEquipContext cellEquipContext) {
if (StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) return;
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = prodRuleContext.getNosortAssemblyDataContext();
MesProductionPsOutContext productionPsOutContext = CollectionUtils.isEmpty(ppMap) ? null : ppMap.get(prodRuleContext.getForeignKey());
for (MesProductionAssemblyNosortContext productionAssemblyNosortContext : productionAssemblyNosortContextList) {
if (null == productionAssemblyNosortContext) continue;
MesProductionAssembly productionAssembly = new MesProductionAssembly();
BeanUtils.copyProperties(productionAssemblyNosortContext, productionAssembly);
productionAssembly.setDataSource(MesExtEnumUtil.PRODUCTION_ASSEMBLY_DATA_SOURCE.NOSORT.getValue());
productionAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
productionAssembly.setAreaCode(reqBean.getWorkCenterCode());
productionAssembly.setWorkCenterCode(reqBean.getWorkCenterCode());
productionAssembly.setWorkCellCode(reqBean.getWorkCellCode());
productionAssembly.setProcessCode(reqBean.getProcessCode());
productionAssembly.setProcessName(productionProcessContext.getProcessName());
productionAssembly.setCraftCode(productionProcessContext.getCraftCode());
productionAssembly.setCraftName(productionProcessContext.getCraftName());
productionAssembly.setEquipmentCode(cellEquipContext.getEquipmentCode());
productionAssembly.setProductionRecordId(prodRuleContext.getProductionRecordId());
productionAssembly.setMouldNo(prodRuleContext.getMouldNo());
if (null != productionPsOutContext) {
productionAssembly.setPartNo(productionPsOutContext.getPartNo());
productionAssembly.setPartName(productionPsOutContext.getPartName());
productionAssembly.setSerialNumber(productionPsOutContext.getSerialNumber());
productionAssembly.setProductSn(productionPsOutContext.getProductSn());
productionAssembly.setCustSn(productionPsOutContext.getCustSn());
}
//TODO 装配零件类型
//productionAssembly.setAssemblyPartType();
//TODO 赋开模记录ID
//productionAssembly.setMouldRecordId();
productionAssembly.setOrganizeCode(reqBean.getOrganizeCode());
ConvertBean.serviceModelInitialize(productionAssembly, reqBean.getUserInfo());
productionAssemblyRepository.insert(productionAssembly);
}
}
}

@ -0,0 +1,55 @@
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.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
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.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesAssemblySaveStepService")
public class MesAssemblySaveStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
//配置错误 抛出异常
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 ((IStepService) SpringContextsUtil.getBean("mesAssemblySaveSortStepService")).execute(reqBean);
//非排序线 保存装配记录工步
return ((IStepService) SpringContextsUtil.getBean("mesAssemblySaveNosortStepService")).execute(reqBean);
}
}

@ -31,7 +31,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @Description : * @Description :
* @Author : wangjie * @Author : wangjie
**/ **/
@Slf4j @Slf4j

@ -1,105 +0,0 @@
/*
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
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.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
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 com.google.common.base.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
*/
/**
* @Description :
* @Author : zxw
**//*
@Slf4j
@Service
public class MesSaveAssemblyStepService extends BaseStepService {
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private ActorSystem actorSystem;
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private MesVariableWhenFinishedReadStepService mesVariableWhenFinishedReadStepService;
@Autowired
private MesMouldRecordGenerateStepService mesMouldRecordGenerateStepService;
@Autowired
private MesProductSnSaveStepService MesProductSnSaveStepService;
@Autowired
private MesProductionReocrdGenerateStepService mesProductionReocrdGenerateStepService;
@Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
@Autowired
private MesProductResultErrorHandleStepService mesProductResultErrorHandleStepService;
@Autowired
private MesReportGenerateStepService mesReportGenerateStepService;
public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT";
private static final Map<String, ActorRef> refMap = new ConcurrentHashMap<>(200);
@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());
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
List<MesProductionPsOutContext> mesProduceSnContexts = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
mesProduceSnContexts.forEach(mesProductionPsOutContext -> {
MesProductionRecord mesProductionRecord = getMesProductionRecord(productionProcessContext, mesProductionPsOutContext, reqBean);
ConvertBean.serviceModelInitialize(mesProductionRecord, reqBean.getUserInfo());
mesProductionRecords.add(mesProductionRecord);
});
mesProductionRecordRepository.saveAll(mesProductionRecords);
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) {
// 保存班次加工数量上下文
productionCustomContextStepService.addProductionStatisticsContext(reqBean,mesProduceSnContexts.size());
}
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成加工记录成功");
}
}
*/

@ -49,7 +49,6 @@ public class MesAssemblyShowContext implements Serializable {
@ApiParam("序号") @ApiParam("序号")
private Integer index; private Integer index;
public MesAssemblyShowContext index(Integer index){ public MesAssemblyShowContext index(Integer index){
this.index = index; this.index = index;
return this; return this;

@ -30,6 +30,12 @@ public class MesProdRuleContext implements Serializable {
@ApiParam(name = "数据关联键") @ApiParam(name = "数据关联键")
private Integer foreignKey; private Integer foreignKey;
@ApiParam("加工记录ID")
private Long productionRecordId;
@ApiParam("模具号")
private String mouldNo;
@ApiParam(name = "工单号,不一定有值") @ApiParam(name = "工单号,不一定有值")
private String workOrderNo; private String workOrderNo;
@ -139,6 +145,11 @@ public class MesProdRuleContext implements Serializable {
return this; return this;
} }
public MesProdRuleContext productionRecordId(Long productionRecordId) {
this.productionRecordId = productionRecordId;
return this;
}
public MesProdRuleContext inPartIsEmpty() { public MesProdRuleContext inPartIsEmpty() {
this.inPartIsEmpty = true; this.inPartIsEmpty = true;
return this; return this;

@ -14,9 +14,6 @@ public class MesProductionAssemblyContext implements Serializable {
private static final long serialVersionUID = 2382117884422723639L; private static final long serialVersionUID = 2382117884422723639L;
@ApiParam("加工记录ID")
public Long productionRecordId;
@ApiParam("装配件零件编码") @ApiParam("装配件零件编码")
public String assemblyPartNo; public String assemblyPartNo;
@ -26,15 +23,6 @@ public class MesProductionAssemblyContext implements Serializable {
@ApiParam("装配件条码") @ApiParam("装配件条码")
public String assemblySn; public String assemblySn;
@ApiParam("过程条码")
public String serialNumber;
@ApiParam("零件条码")
public String productSn;
@ApiParam("客户条码")
public String custSn;
@ApiParam("生产工单零件号") @ApiParam("生产工单零件号")
public String partNo; public String partNo;
@ -50,21 +38,12 @@ public class MesProductionAssemblyContext implements Serializable {
@ApiParam("是否跳过") @ApiParam("是否跳过")
public Integer isSkip; public Integer isSkip;
@ApiParam("开模记录ID")
public String mouldRecordId;
@ApiParam("模具号")
public String mouldNo;
@ApiParam("装配件条码确认方式") @ApiParam("装配件条码确认方式")
public Integer matchType; public Integer matchType;
@ApiParam("扫描规则") @ApiParam("扫描规则")
public String matchRule; public String matchRule;
@ApiParam("数据来源")
public Integer dataSource;
@ApiParam("来源ID") @ApiParam("来源ID")
public Long sourceId; public Long sourceId;
@ -80,31 +59,4 @@ public class MesProductionAssemblyContext implements Serializable {
@ApiParam(value = "装备序号") @ApiParam(value = "装备序号")
public Integer routeSeq; public Integer routeSeq;
@ApiParam("组织代码")
public String organizeCode;
@ApiParam("区域代码")
public String areaCode;
@ApiParam("生产线代码")
public String workCenterCode;
@ApiParam("工位代码")
public String workCellCode;
@ApiParam("设备代码")
public String equipmentCode;
@ApiParam("工序代码")
public String processCode;
@ApiParam("工序名称")
public String processName;
@ApiParam("工艺代码")
public String craftCode;
@ApiParam("工艺名称")
public String craftName;
} }

@ -33,8 +33,9 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon
public MesProductionAssemblyNosortContext() {} public MesProductionAssemblyNosortContext() {}
public MesProductionAssemblyNosortContext copy(MesAssemblyNosortCfg assemblyNosortCfg, MesProdRuleContext prodRuleContext) { public MesProductionAssemblyNosortContext copy(MesAssemblyNosortCfg assemblyNosortCfg, MesProdRuleContext prodRuleContext) {
if (null != assemblyNosortCfg) BeanUtils.copyProperties(assemblyNosortCfg, this); BeanUtils.copyProperties(assemblyNosortCfg, this);
if (null != prodRuleContext) BeanUtils.copyProperties(prodRuleContext, this); BeanUtils.copyProperties(prodRuleContext, this);
this.sourceId = assemblyNosortCfg.getId();
this.partNo = prodRuleContext.getOutPartNo(); this.partNo = prodRuleContext.getOutPartNo();
if (StringUtils.isEmpty(this.routeSeq)) this.routeSeq = MesPcnExtConstWords.ZERO; if (StringUtils.isEmpty(this.routeSeq)) this.routeSeq = MesPcnExtConstWords.ZERO;
this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue(); this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue();

Loading…
Cancel
Save