tags/yfai-pcn-ext-v1.0
王杰 11 months ago
commit 628b8b1fc6

@ -20,6 +20,7 @@ public interface IMesEquipVariableRwExtService {
@ApiOperation(value = "写值")
MesEquipVariableRwResult writeVariable(MesEquipmentVariableCfg equipmentVariableCfg, MesEquipmentVariable equipmentVariable, String kepwareFlag);
@ApiOperation(value = "写值")
MesEquipVariableRwResult writeVariable(String value, MesEquipmentVariable equipmentVariable, String kepwareFlag);
}

@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import java.util.List;
import java.util.Map;
/**
* @Description : , content dataList
@ -18,5 +19,5 @@ public interface IPrintTemplateStrategyService {
* @param sn
* @return
*/
List<Object> execute(MesProductionPsOutContext sn , String organizeCode);
Map<String,Object> execute(MesProductionPsOutContext sn , String organizeCode);
}

@ -0,0 +1,96 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerOriganze;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerOriganizeRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* @Description : 广使
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/6 17:03
* @Modify:
**/
@Service
@Slf4j
public class AionPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private MesPartRepository mesPartRao;
@Override
public Map<String,Object> execute(MesProductionPsOutContext sn, String organizeCode) {
//零件条码中获取 serialNo
String productSn = sn.getProductSn();
//构造标签
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = AuthUtil.getOrganize().getName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
int no = 1;
String noStr = String.format("%07d", no);
//构造二维码
StringBuilder barcode = new StringBuilder();
barcode.append("+");
//第二位 是零件简号 零件扩展信息中的 零件条码参数 字段
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo,"partNo",partPackBean);
List<MesPart> parts = mesPartRao.findByHqlWhere(partPackBean);
if (!parts.isEmpty()){
MesPart mesPart = parts.get(0);
String partSnParam = mesPart.getPartSnParam();
if (partSnParam!=null && !partSnParam.isEmpty()){
barcode.append(partSnParam);
}else {
log.error("零件号:{},缺少配置零件扩展属性的 零件条码参数",partNo);
}
}
//第三位 供应商代码 // 配置表
String supplierCode = "VD501";
barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
String workCenterCode = "1";
barcode.append(workCenterCode);
//第五位 生产年月日
int year = now.getYear();
int month = now.getMonth().getValue();
int day = now.getDayOfMonth();
String yearStr = MesExtEnumUtil.YEAR_SHORT.valueOfDescription(year);
String monthStr = MesExtEnumUtil.MONTH_SHORT.valueOfDescription(month);
String dayStr = MesExtEnumUtil.NUM_SCALE_34.valueOfDescription(day);
barcode.append(yearStr);
barcode.append(monthStr);
barcode.append(dayStr);
//第六位 供应商生产流水号
//第七位 软件版本代号
map.put("partNo",partNo);
map.put("partName",partName);
map.put("factoryName",factoryName);
map.put("productDate",productDate);
map.put("no",noStr);
map.put("barcode",barcode.toString());
return map;
}
}

@ -0,0 +1,55 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/17 16:10
* @Modify:
**/
@Service
@Slf4j
public class GqaaPrintStrategy implements IPrintTemplateStrategyService {
@Override
public Map<String, Object> execute(MesProductionPsOutContext sn, String organizeCode) {
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = AuthUtil.getOrganize().getName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
//构造二维码
StringBuilder barcode = new StringBuilder();
//第三位 供应商代码 // 配置表
String supplierCode = "VD501";
barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
String workCenterCode = "1";
barcode.append(workCenterCode);
int no = 1;
String noStr = String.format("%07d", no);
map.put("no",noStr);
map.put("partNo", partNo);
map.put("partName", partName);
map.put("factoryName", factoryName);
map.put("productDate", productDate);
map.put("barcode", barcode.toString());
return map;
}
}

@ -0,0 +1,55 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/17 16:10
* @Modify:
**/
@Service
@Slf4j
public class GqxnyPrintStrategy implements IPrintTemplateStrategyService {
@Override
public Map<String, Object> execute(MesProductionPsOutContext sn, String organizeCode) {
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = AuthUtil.getOrganize().getName();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy/MM/dd");
LocalDateTime now = LocalDateTime.now();
String productDate = now.format(formatter);
//构造二维码
StringBuilder barcode = new StringBuilder();
//第三位 供应商代码 // 配置表
String supplierCode = "VD501";
barcode.append(supplierCode);
//第四位 生产线代号 // 配置表
String workCenterCode = "1";
barcode.append(workCenterCode);
int no = 1;
String noStr = String.format("%07d", no);
map.put("no",noStr);
map.put("partNo", partNo);
map.put("partName", partName);
map.put("factoryName", factoryName);
map.put("productDate", productDate);
map.put("barcode", barcode.toString());
return map;
}
}

@ -1,29 +0,0 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description : 广使
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/6 17:03
* @Modify:
**/
@Service
@Slf4j
public class GzPrintSnStrategy implements IPrintTemplateStrategyService {
@Autowired
private MesLabelTemplateRepository labelTemplateRao;
@Override
public List<Object> execute(MesProductionPsOutContext sn, String organizeCode) {
//1.根据 templateCode
return null;
}
}

@ -0,0 +1,41 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/17 16:43
* @Modify:
**/
@Service
@Slf4j
public class NoSortBarCodeGzNewStrategy implements IPrintTemplateStrategyService {
@Override
public Map<String, Object> execute(MesProductionPsOutContext sn, String organizeCode) {
//从条码中截取流水号,流水号 后四位
String productSn = sn.getProductSn();
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
String productDateTime = now.format(formatter);
map.put("partNo",partNo);
map.put("partName",partName);
map.put("productDateTime",productDateTime);
map.put("barcode",productSn);
return map;
}
}

@ -0,0 +1,54 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2024/6/17 16:31
* @Modify:
**/
@Service
@Slf4j
public class NoSortBarCodeGzStrategy implements IPrintTemplateStrategyService {
@Override
public Map<String, Object> execute(MesProductionPsOutContext sn, String organizeCode) {
Map<String,Object> map = new HashMap<>();
String partNo = sn.getPartNo();
String partName = sn.getPartName();
String factoryName = AuthUtil.getOrganize().getName();
String supplierCode = "VD501";
int no = 1;
String noStr = String.format("%04d", no);
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
String productDateTime = now.format(formatter);
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String productDate = now.format(dateFormatter);
StringBuilder barcode = new StringBuilder(partNo);
barcode.append(partName);
barcode.append(productDate);
barcode.append(noStr);
map.put("partNo", partNo);
map.put("partName", partName);
map.put("factoryName", factoryName);
map.put("supplierCode", supplierCode);
map.put("productDate", productDateTime);
map.put("no", noStr);
map.put("barcode", barcode.toString());
return map;
}
}

@ -18,10 +18,7 @@ import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Description :
@ -43,13 +40,20 @@ public class MesProductSnPrintStepService extends BaseStepService {
@Override
public StepResult execute(StationRequestBean reqBean) {
/**
* List<Map<String,Object>>
* Map<String,Object>
* String:
* content :
* data : List<Map<String,Object>> map
*/
String organizeCode = reqBean.getOrganizeCode();
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//需要打印的数据
Map<String,List<Object>> resultData = new HashMap<>();
//需要打印的数据 String 是打印模板code
Map<String, List<Map<String, Object>>> resultData = new HashMap<>();
//用于保存客户模板代码 和 模板信息关系
Map<String,MesLabelTemplate> labelTemplateMap = new HashMap<>();
Map<String, MesLabelTemplate> labelTemplateMap = new HashMap<>();
//返回打印标识 给前端
//1. 获取上下文中生成的主条码
List<MesProductionPsOutContext> productionPsOutContextList = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
@ -59,49 +63,64 @@ public class MesProductSnPrintStepService extends BaseStepService {
MesLabelTemplate labelTemplate;
// 查模板代码
if (!labelTemplateMap.containsKey(custLabelTemplate)) {
labelTemplate = getLabelTemplate(custLabelTemplate, organizeCode);
labelTemplate = getLabelTemplate(custLabelTemplate, organizeCode);
//模板信息丢失抛出异常
if (labelTemplate == null) {
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(),custLabelTemplate));
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), custLabelTemplate));
}
labelTemplateMap.put(custLabelTemplate, labelTemplate);
}else {
} else {
labelTemplate = labelTemplateMap.get(custLabelTemplate);
}
//根据反射获取策略类--封装打印数据
String methodCode = labelTemplate.getMethodCode();
//模板信息丢失抛出异常
if (methodCode == null) {
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(),custLabelTemplate));
execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), custLabelTemplate));
}
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
List<Object> snData = strategyService.execute(sn, organizeCode);
if (resultData.containsKey(labelTemplate.getTemplateCode())){
List<Object> printData = resultData.get(labelTemplate.getTemplateCode());
printData.addAll(snData);
}else {
resultData.put(labelTemplate.getTemplateCode(),snData);
}
Map<String, Object> snData = strategyService.execute(sn, organizeCode);
List<Map<String, Object>> printData;
if (resultData.containsKey(labelTemplate.getTemplateCode())) {
printData = resultData.get(labelTemplate.getTemplateCode());
printData.add(snData);
} else {
printData = new ArrayList<>();
printData.add(snData);
resultData.put(labelTemplate.getTemplateCode(), printData);
}
}
List<Map<String, Object>> printData = new ArrayList<>();
Set<String> labelKeys = labelTemplateMap.keySet();
for (String labelKey : labelKeys) {
List<Map<String, Object>> dataMaps = resultData.get(labelKey);
MesLabelTemplate mesLabelTemplate = labelTemplateMap.get(labelKey);
String templateContent = mesLabelTemplate.getTemplateContent();
Map<String, Object> data = new HashMap<>();
data.put("templateContent", templateContent);
data.put("data", dataMaps);
printData.add(data);
}
//前端接收到busiTyep是customComponent并且 dataType是file类型的消息就需要打印后续消息里的数据一个模板对应多个打印数据
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue());
resultBean.setResultObj(resultData);
resultBean.setResultObj(printData);
//3. 发送数据给到前端
this.sendMessage(reqBean,resultBean);
this.sendMessage(reqBean, resultBean);
return stepResult;
}
/**
* templateCode
*
* @param templateCode
* @param organizeCode
* @return
*/
private MesLabelTemplate getLabelTemplate(String templateCode,String organizeCode) {
private MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode) {
DdlPackBean templatePackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(templateCode,"templateCode",templatePackBean);
DdlPreparedPack.getStringEqualPack(templateCode, "templateCode", templatePackBean);
List<MesLabelTemplate> mesLabelTemplateList = labelTemplateRao.findByHqlWhere(templatePackBean);
return mesLabelTemplateList.isEmpty() ? null : mesLabelTemplateList.get(0);
}

@ -1,38 +1,21 @@
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.api.busi.IMesWorkOrderService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
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.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
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.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
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.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.List;
/**
* @Description :
@ -46,6 +29,9 @@ public class MesReportGenerateStepService extends BaseStepService {
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private MesReportNoSortStepService reportNoSortStepService;
@Autowired
@ -56,15 +42,16 @@ public class MesReportGenerateStepService extends BaseStepService {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
// todo 根据产线判断是排序还是非排序,然后调用排序或者非排序的报工工步
// //产品加工规则
// List<MesProdRuleContext> prodRuleDataContext = mesProductionDispatchContextStepService.getProdRuleDataContext(reqBean);
// //获取产成零件信息
// List<MesProductionPartContext> productionPartContext = mesProductionDispatchContextStepService.getProductionPartContext(reqBean);
//产品加工规则
// List<MesProdRuleContext> prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//获取产成零件信息
// List<MesProductionPartContext> productionPartContext = productionDispatchContextStepService.getProductionPartContext(reqBean);
//1. 校验当前有没有工单---只有有工单才能报工
//如果产品加工规则中的foreignKey 和 产成零件信息 一一对应的,查询MesProductionPartContext的工单号
// List<MesProductionPsOutContext> mesProduceSns = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);

@ -1,6 +1,7 @@
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.pojo.context.MesProdRuleContext;
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;
@ -56,16 +57,31 @@ public class MesReportNoSortStepService extends BaseStepService {
@Autowired
private MesProductPlanRepository mesProductPlanRDao;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
// todo 先不使用缓存中的数据
//1. 校验当前有没有工单---只有有工单才能报工
//如果产品加工规则中的foreignKey 和 产成零件信息 一一对应的,查询MesProductionPartContext的工单号
//产品加工规则
List<MesProdRuleContext> prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//如果产品加工规则中的foreignKey 和 mesProduceSns 一一对应的,
List<MesProductionPsOutContext> mesProduceSns = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
this.doProductReport(mesProduceSns, reqBean.getOrganizeCode(), reqBean.getUserInfo(),reqBean,resultBean);
//需要报工的条码
List<MesProductionPsOutContext> needReportSn = new ArrayList<>();
for (MesProductionPsOutContext sn : mesProduceSns) {
Integer foreignKey = sn.getForeignKey();
List<MesProdRuleContext> ruleContextList = prodRuleDataContext.stream().filter(rule -> Objects.equals(rule.getForeignKey(), foreignKey)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(ruleContextList)) {
Integer reportType = ruleContextList.get(0).getReportType();
if (MesExtEnumUtil.NOSORT_REPORT_TYPE.REPORT.getValue() == reportType){
needReportSn.add(sn);
}
}
}
this.doProductReport(needReportSn, reqBean.getOrganizeCode(), reqBean.getUserInfo(),reqBean,resultBean);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "报工成功");
}

@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepServ
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
@ -35,11 +36,21 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//1. 获取上下文中的MesProductionPartContext
//1. 获取上下文中的MesProductionPartContext 产出零件
List<MesProductionPartContext> productionPartContext = productionDispatchContextStepService.getProductionPartContext(reqBean);
if (productionPartContext.isEmpty()){
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "没有可保存的加工单信息");
}
// 判断为空腔 isFinishedCode = true 就是空腔
// stream 过滤 isFinishedCode = false 并且 foreignKey != null 并且 加工单code 为不为空;
List<MesProductionPartContext> filteredPartContext = productionPartContext.stream().filter(item -> item.getIsFinishCode() == CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue() && item.getForeignKey() != null && item.getWorkOrderNo() != null).collect(Collectors.toList());
if (filteredPartContext.isEmpty()){
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "过滤后,没有可保存的加工单信息");
}
// 怎么判断条码生成过了? 看产出零件和入料in 要判端relateId有值也需要新增, out生成条码 上下文
// 如果没有in 需要加,
// 如果有out条码,则判断id是否为空不为空则是新生成的
//2. 判断是否为空,id是否为空如果没有则返回,id为工单id
List<MesProductionPartContext> collectContext = productionPartContext.stream().filter(item -> item.getId() != null).collect(Collectors.toList());
//3. 如果id不为空查询工单信息

Loading…
Cancel
Save