feat(打印): 工序打印

1. 打印规则新增检验等级配置及匹配
2. 当通过销售订单行获取的标签模版的“标签类别编号”与工序打印场景下获取的标签模版的“标签类别编号”是同一个的情况下,销售订单行的标签模版不进行打印
This commit is contained in:
syngna_qiao 2024-12-26 20:15:12 +08:00
parent c7d1f15069
commit c8d2f66052
6 changed files with 94 additions and 26 deletions

View File

@ -23,6 +23,12 @@ public class PrintRuleDTO extends PrintRule {
@ApiModelProperty(value="标签编号")
private String templateCode;
/**
* 质检等级
*/
@ApiModelProperty(value="质检等级")
private String inspecLevel;
/**
* 打印场景
*/

View File

@ -60,6 +60,12 @@ public class PrintPages extends Model<PrintPages> {
@ApiModelProperty(value="标签编号")
private String templateCode;
/**
* 质检等级
*/
@ApiModelProperty(value="质检等级")
private String inspecLevel;
/**
* 打印场景
*/

View File

@ -83,6 +83,7 @@ public class PrintRuleServiceImpl extends ServiceImpl<PrintRuleMapper, PrintRule
printPages.setLabelCategory(printRuleDTO.getLabelCategory() == null ? "" : printRuleDTO.getLabelCategory());
printPages.setTemplateCode(printRuleDTO.getTemplateCode() == null ? "" : printRuleDTO.getTemplateCode());
printPages.setPrintScenario(printRuleDTO.getPrintScenario() == null ? "" : printRuleDTO.getPrintScenario());
printPages.setInspecLevel(printRuleDTO.getInspecLevel() == null ? "" : printRuleDTO.getInspecLevel());
printPagesList.add(printPages);
}
}

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.foreverwin.iep.common.constant.BaseConstants;
import com.foreverwin.iep.prd.entity.CustomFields;
@ -262,10 +263,37 @@ public class PrintServiceImpl implements PrintService {
baseData.put("shopOrderCustomData", customFieldsMap);
baseData.put("itemCustomData", itemCustomFieldsMap);
}
// 获取质检等级
String inspecLevel = "";
LotState lotState = (LotState)baseData.get("lotStateData");
if(lotState != null) {
inspecLevel = lotState.getInspectionLevel();
}
List<Map<String, Object>> baseDataList = Arrays.asList(baseData);
try {
//获取打印模板和打印次数
List<Map<String, Object>> templateAndPrintCntMapList = getTemplatesByPrintRule(site, customer, fabNo, operation, lotNo, externalLabelFlag, false);
List<Map<String, Object>> templateAndPrintCntMapList = getTemplatesByPrintRule(site, customer, fabNo, operation, lotNo, inspecLevel, externalLabelFlag, false);
if(CollectionUtils.isEmpty(templateAndPrintCntMapList)) {
throw BusinessException.build("车间[" + fabNo + "],工序[" + operation + "],等级[" + inspecLevel + "]匹配不到对应的打印模板");
}
// 获取工序场景的模板类别
List<String> LabelTemplateCategoryList = new ArrayList<>();
for(Map<String, Object> m : templateAndPrintCntMapList) {
String printScenario = m.get("printScenario") == null ? null : m.get("printScenario").toString();
if("operation".equals(printScenario)) {
String templateCategory = m.get("templateCategory") == null ? null : m.get("templateCategory").toString();
String templateName = m.get("template") == null ? null : m.get("template").toString();
if(templateCategory == null && templateName != null) {
PrintLabelTemplate printLabelTemplate = printLabelTemplateService.getById(PrintLabelTemplate.genHandle(site, templateName));
if(printLabelTemplate != null) {
templateCategory = printLabelTemplate.getTemplateCategory();
}
}
if(StrUtil.isNotBlank(templateCategory)) {
LabelTemplateCategoryList.add(templateCategory);
}
}
}
//依据打印模板和打印次数,统计 PrintRequest 列表
List<PrintRequest> printRequests = new ArrayList<>();
for (Map<String, Object> m : templateAndPrintCntMapList) {
@ -275,7 +303,7 @@ public class PrintServiceImpl implements PrintService {
boolean extRule = BaseConstants.Y.equals(externalLabelFlag) && "package".equals(printScenario);
String printerName = getPrinter(site, printScenario, operation, resource);
if(extRule) {
List<PrintRequest> printRequestList = getExtRulePrintRequest(site, user, printScenario, printerName, printCount, operationPrintRequest, baseDataList);
List<PrintRequest> printRequestList = getExtRulePrintRequest(site, user, printScenario, printerName, printCount, operationPrintRequest, baseDataList, LabelTemplateCategoryList);
printRequests.addAll(printRequestList);
} else {
PrintRequest printRequest = getPrintData(site, user, operationPrintRequest.getShopOrder(), lotNo, Integer.valueOf(printCount), operation, printScenario, printerName, templateName, baseDataList);
@ -462,7 +490,7 @@ public class PrintServiceImpl implements PrintService {
return printResult;
}
public List<Map<String, Object>> getTemplatesByPrintRule(String site, String customer, String fabNo, String operation, String barcodeNumber, String externalLabelFlag, boolean reprint) {
public List<Map<String, Object>> getTemplatesByPrintRule(String site, String customer, String fabNo, String operation, String barcodeNumber, String inspectLevel, String externalLabelFlag, boolean reprint) {
// 会存在多个打印模板的情况,而且每个模式打印次数是通过人员设置的
List<Map<String, Object>> templateAndPrintCntList = new ArrayList<>();
@ -490,7 +518,21 @@ public class PrintServiceImpl implements PrintService {
}
for(PrintPages pp : printPagesList) {
boolean extPackageRule = BaseConstants.Y.equals(externalLabelFlag) && "package".equals(pp.getPrintScenario());
if(StrUtil.isBlank(pp.getTemplateCode()) && StrUtil.isNotBlank(pp.getLabelCategory()) && !extPackageRule) {
// 检验等级匹配
boolean inspectLevelMatches = false;
String ppInspectLevel = pp.getInspecLevel();
if(StrUtil.isBlank(ppInspectLevel)) {
inspectLevelMatches = true;
} else {
String[] ppInspectLevelArray = ppInspectLevel.split(",");
if(StrUtil.isBlank(inspectLevel)) {
inspectLevelMatches = false;
} else {
// 如果ppInspectLevelArray中包含inspectLevel, 则inspectLevelMatches=true
inspectLevelMatches = Arrays.stream(ppInspectLevelArray).anyMatch(inspectLevel::equals);
}
}
if(StrUtil.isBlank(pp.getTemplateCode()) && StrUtil.isNotBlank(pp.getLabelCategory()) && inspectLevelMatches && !extPackageRule) {
LambdaQueryWrapper<PrintLabelTemplate> printLabelTemplateQueryWrapper = Wrappers.<PrintLabelTemplate>lambdaQuery()
.eq(PrintLabelTemplate::getSite, site)
.eq(PrintLabelTemplate::getTemplateCategory, pp.getLabelCategory())
@ -503,19 +545,22 @@ public class PrintServiceImpl implements PrintService {
}
for (PrintLabelTemplate plt : printLabelTemplates) {
Map<String, Object> templateMap = new HashMap<>();
templateMap.put("templateCategory", plt.getTemplateCategory());
templateMap.put("template", plt.getTemplateCode());
templateMap.put("printCount", pp.getPrintPages());
templateMap.put("printScenario", pp.getPrintScenario());
templateAndPrintCntList.add(templateMap);
}
} else if (extPackageRule) {
} else if (extPackageRule && inspectLevelMatches) {
Map<String, Object> templateMap = new HashMap<>();
templateMap.put("templateCategory", pp.getLabelCategory());
templateMap.put("template", pp.getTemplateCode());
templateMap.put("printCount", pp.getPrintPages());
templateMap.put("printScenario", pp.getPrintScenario());
templateAndPrintCntList.add(templateMap);
} else if (StrUtil.isNotBlank(pp.getTemplateCode())) {
} else if (StrUtil.isNotBlank(pp.getTemplateCode()) && inspectLevelMatches) {
Map<String, Object> templateMap = new HashMap<>();
templateMap.put("templateCategory", pp.getLabelCategory());
templateMap.put("template", pp.getTemplateCode());
templateMap.put("printCount", pp.getPrintPages());
templateMap.put("printScenario", pp.getPrintScenario());
@ -774,7 +819,7 @@ public class PrintServiceImpl implements PrintService {
return printRequest;
}
private List<PrintRequest> getExtRulePrintRequest(String site, String user, String printScenario, String printerName, String printCount, OperationPrintRequest operationPrintRequest, List<Map<String, Object>> baseDataList) {
private List<PrintRequest> getExtRulePrintRequest(String site, String user, String printScenario, String printerName, String printCount, OperationPrintRequest operationPrintRequest, List<Map<String, Object>> baseDataList, List<String> LabelTemplateCategoryList) {
List<PrintRequest> result = new ArrayList<>();
String salesOrder = operationPrintRequest.getSalesOrder();
String salesOrderLine = operationPrintRequest.getSalesOrderLine();
@ -796,6 +841,10 @@ public class PrintServiceImpl implements PrintService {
if(StrUtil.isBlank(dto.getLabelTempleCode())) {
throw BusinessException.build(tempUnKnow);
}
// 当通过销售订单行获取的标签模版的“标签类别编号”与工序打印场景下获取的标签模版的“标签类别编号”是同一个的情况下,销售订单行的标签模版不进行打印
if(StrUtil.isNotBlank(dto.getTemplateCategory()) && LabelTemplateCategoryList != null && LabelTemplateCategoryList.contains(dto.getTemplateCategory())) {
continue;
}
// 获取值集号
String templateCode = dto.getLabelTempleCode();
String configItem = dto.getConfigItem();

View File

@ -10,6 +10,7 @@
<result property="printRuleBo" column="PRINT_RULE_BO"/>
<result property="labelCategory" column="LABEL_CATEGORY"/>
<result property="templateCode" column="TEMPLATE_CODE"/>
<result property="inspecLevel" column="INSPEC_LEVEL"/>
<result property="printScenario" column="PRINT_SCENARIO"/>
<result property="printPages" column="PRINT_PAGES"/>
<result property="creator" column="CREATOR"/>

View File

@ -73,26 +73,31 @@
</select>
<select id="getSoLineLabelTemplate" resultType="com.foreverwin.nlv.print.dto.SoLineLabelTemplateDTO">
SELECT SOL.HANDLE AS SALES_ORDER_LINE_BO, SOL.DELIVERY_PLANT, SO.SO_NUMBER, SOL.SO_LINE_ID, SOL.QTY, SOL.UOM, SO.SO_CREATE_TIME, SO.SO_ASSISTANT, SO.SO_CUSTOMER_CODE,
SELECT A.*, PLT.TEMPLATE_CATEGORY
FROM(
SELECT SO.SITE, SOL.HANDLE AS SALES_ORDER_LINE_BO, SOL.DELIVERY_PLANT, SO.SO_NUMBER, SOL.SO_LINE_ID, SOL.QTY, SOL.UOM, SO.SO_CREATE_TIME, SO.SO_ASSISTANT, SO.SO_CUSTOMER_CODE,
CASE WHEN LLVC.LABEL_TEMPLE_CODE IS NOT NULL THEN LLVC.LABEL_TEMPLE_CODE ELSE SOLC.CONFIG_ITEM_VALUE END AS LABEL_TEMPLE_CODE, solc.CONFIG_ITEM
FROM Z_SALES_ORDER SO
INNER JOIN Z_SALES_ORDER_LINE SOL
ON SOL.SALES_ORDER_BO = SO.HANDLE
INNER JOIN (
SELECT SALES_ORDER_LINE_BO, CONFIG_ITEM, CONFIG_ITEM_VALUE
FROM Z_SALES_ORDER_LINE_CONFIG SOLC
WHERE CONFIG_ITEM IN('ZCT_GXMYS','ZCT_WXBQYS','ZCT_ZXBQYS')
) SOLC
ON SOLC.SALES_ORDER_LINE_BO = SOL.HANDLE
LEFT JOIN (
SELECT LABEL_TEMPLE_CODE, SALES_ORDER_LINE_BO, CONFIG_ITEM
FROM Z_SALES_ORDER_LINE_LABEL_VALUE_CONFIG
GROUP BY LABEL_TEMPLE_CODE, SALES_ORDER_LINE_BO, CONFIG_ITEM
) LLVC
ON LLVC.SALES_ORDER_LINE_BO = SOL.HANDLE AND LLVC.CONFIG_ITEM = SOLC.CONFIG_ITEM
WHERE SOL.DELIVERY_PLANT = #{site}
AND SO.SO_NUMBER = #{soNumber}
AND SOL.SO_LINE_ID = #{soLineId}
FROM Z_SALES_ORDER SO
INNER JOIN Z_SALES_ORDER_LINE SOL
ON SOL.SALES_ORDER_BO = SO.HANDLE
INNER JOIN (
SELECT SALES_ORDER_LINE_BO, CONFIG_ITEM, CONFIG_ITEM_VALUE
FROM Z_SALES_ORDER_LINE_CONFIG SOLC
WHERE CONFIG_ITEM IN('ZCT_GXMYS','ZCT_WXBQYS','ZCT_ZXBQYS')
) SOLC
ON SOLC.SALES_ORDER_LINE_BO = SOL.HANDLE
LEFT JOIN (
SELECT LABEL_TEMPLE_CODE, SALES_ORDER_LINE_BO, CONFIG_ITEM
FROM Z_SALES_ORDER_LINE_LABEL_VALUE_CONFIG
GROUP BY LABEL_TEMPLE_CODE, SALES_ORDER_LINE_BO, CONFIG_ITEM
) LLVC
ON LLVC.SALES_ORDER_LINE_BO = SOL.HANDLE AND LLVC.CONFIG_ITEM = SOLC.CONFIG_ITEM
WHERE SOL.DELIVERY_PLANT = #{site}
AND SO.SO_NUMBER = #{soNumber}
AND SOL.SO_LINE_ID = #{soLineId}
)A
LEFT JOIN print_label_template plt
ON PLT.SITE = A.SITE AND A.LABEL_TEMPLE_CODE = PLT.TEMPLATE_CODE
</select>
<select id="selectSoLineLabelValueSet" resultType="com.foreverwin.nlv.print.dto.SoLineLabelValueSetDTO">