SPS单据打印优化,增加每次查询条数

tags/yfai-pcn-ext-v2.3
jun 6 months ago
parent 872f8e9413
commit c31a240bbc

@ -72,6 +72,7 @@ public class MesPullingOrderInfoController {
if (StringUtils.isEmpty(mesPullingOrderInfo.getWorkCenterCode())) { if (StringUtils.isEmpty(mesPullingOrderInfo.getWorkCenterCode())) {
throw new ImppBusiException("产线不能为空"); throw new ImppBusiException("产线不能为空");
} }
mesPullingOrderInfo.setOrganizeCode(StringUtil.isEmpty(mesPullingOrderInfo.getOrganizeCode()) ? AuthUtil.getOrganizeCode() : mesPullingOrderInfo.getOrganizeCode());
List<MesPullingOrderInfo> pullingOrderInfos = mesPullingOrderInfoService.doMesPullingOrderInfoPrint(mesPullingOrderInfo, AuthUtil.getSessionUser().getUserName()); List<MesPullingOrderInfo> pullingOrderInfos = mesPullingOrderInfoService.doMesPullingOrderInfoPrint(mesPullingOrderInfo, AuthUtil.getSessionUser().getUserName());
return ResultBean.success("拉动单打印成功") return ResultBean.success("拉动单打印成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())

@ -180,7 +180,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService {
DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBean); DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue(), "printStatus", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue(), "printStatus", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
List<MesPullingOrderInfo> pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBean); List<MesPullingOrderInfo> pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlTopWhere(packBean, MesPcnExtConstWords.THREE);
if (!CollectionUtils.isEmpty(pullingOrderInfos)) { if (!CollectionUtils.isEmpty(pullingOrderInfos)) {
//根据车型代码查询车型信息 //根据车型代码查询车型信息
Map<String, List<MesCustomerCarModel>> mesCustomerCarModelMap = getMesCustomerCarModelMap(bean.getOrganizeCode(), pullingOrderInfos.stream().map(MesPullingOrderInfo::getCarModelCode).distinct().collect(Collectors.toList())); Map<String, List<MesCustomerCarModel>> mesCustomerCarModelMap = getMesCustomerCarModelMap(bean.getOrganizeCode(), pullingOrderInfos.stream().map(MesPullingOrderInfo::getCarModelCode).distinct().collect(Collectors.toList()));

@ -0,0 +1,50 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : junsheng.li
* @CreateDate 2024/11/16 10:56
* @Modify:
**/
@Component
public class MesNoSortCustSnNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
@Autowired
private IMesCustomerPartService mesCustomerPartService;
@Override
public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
Map<String, Object> dataMap = genSerialNoModel.getDataMap();
MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ?
(MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo());
if (null != customerPart) {
genSerialNoModel.setCustPartNo(customerPart.getCustPartNo());
}else {
MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", genSerialNoModel.getPartNo());
}
Calendar custCalendar = Calendar.getInstance();
custCalendar.setTime(new Date());
String partNo = customerPart.getCustPartNo();
String prefix = partNo.substring(0, partNo.length() - 4);
String partNo4 = partNo.substring(partNo.length() - 4).toUpperCase();
genSerialNoModel.setPartNo(prefix+partNo4);
String year = custCalendar.get(Calendar.YEAR)+"";
genSerialNoModel.setYear(year.substring(2));
genSerialNoModel.setDay(String.format("%03d",custCalendar.get(Calendar.DAY_OF_YEAR)));
return genSerialNoModel;
}
}

@ -1,8 +1,10 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy; package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
@ -12,10 +14,7 @@ import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule; import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
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.StepResult; import cn.estsh.i3plus.pojo.mes.model.StepResult;
@ -27,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -56,14 +56,21 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService {
@Autowired @Autowired
private ISyncFuncService syncFuncService; private ISyncFuncService syncFuncService;
@Autowired
private IMesCustomerPartService mesCustomerPartService;
@Override @Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model, public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model,
MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean,
Boolean isStep) { Boolean isStep) {
//物料信息 //物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(model.getPartNo(), model.getOrganizeCode()); MesPart mesPart = mesPartService.getMesPartByPartNo(model.getPartNo(), model.getOrganizeCode());
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(model.getOrganizeCode(),model.getPartNo());
if(Objects.isNull(customerPart)){
MesPcnException.throwMesBusiException("零件号:%s客户物料信息不存在",model.getPartNo());
}
// 客户零件号 // 客户零件号
String custPartNo = model.getCustPartNo(); String custPartNo = customerPart.getCustPartNo();
// 客户零件号 前缀 排除后四位 // 客户零件号 前缀 排除后四位
String custPartNoPrefix = StringUtils.isEmpty(custPartNo) ? "" : custPartNo.substring(0, custPartNo.length() - 4); String custPartNoPrefix = StringUtils.isEmpty(custPartNo) ? "" : custPartNo.substring(0, custPartNo.length() - 4);
// 客户零件号 后四位 // 客户零件号 后四位
@ -73,6 +80,7 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService {
// 返回的结果集合 // 返回的结果集合
List<Map<String, Object>> printDataMapList = new ArrayList<>(); List<Map<String, Object>> printDataMapList = new ArrayList<>();
if (!isStep) { if (!isStep) {
genSerialNoModel.putDataMap(MesCustomerPart.class.getSimpleName(),customerPart);
for (int i = 0; i < model.getPrintQty(); i++) { for (int i = 0; i < model.getPrintQty(); i++) {
//保存条码信息 //保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel, model.getUserName(), model.getOrganizeCode(), 1).getResultList().get(0).toString(), model.getUserName(), model.getQty()); MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel, model.getUserName(), model.getOrganizeCode(), 1).getResultList().get(0).toString(), model.getUserName(), model.getQty());
@ -97,7 +105,7 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService {
} }
private MesNumberRule getMesNumberRule(MesPart mesPart) { private MesNumberRule getMesNumberRule(MesPart mesPart) {
String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule(); String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_NO_SORT_CUST_SN_RULE" : mesPart.getCustMatchRule();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesPart.getOrganizeCode()); DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesPart.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean); DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean);
return numberRuleRepository.getByProperty(packBean); return numberRuleRepository.getByProperty(packBean);

Loading…
Cancel
Save