diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesLabelTemplateExtController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesLabelTemplateExtController.java index ebd3a24..4f0eeff 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesLabelTemplateExtController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesLabelTemplateExtController.java @@ -4,6 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService; +import cn.estsh.i3plus.pojo.mes.bean.MesConfig; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ResultBean; @@ -11,12 +12,16 @@ import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Arrays; +import java.util.List; import java.util.Map; +import java.util.Optional; @Api("获取系统配置的模版信息") @RestController @@ -54,4 +59,31 @@ public class MesLabelTemplateExtController { } } + @GetMapping("/label-template/by-module-or-template/get-custom") + @ApiOperation(value = "获取系统配置的模版信息") + public ResultBean queryModuleCodeCfg(String organizeCode, String moduleCode, String chooseCodes, String templateCode) { + try { + ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空"); + if (StringUtils.isEmpty(moduleCode) && StringUtils.isEmpty(templateCode)) { + ValidatorBean.checkNotNull(moduleCode, "模版配置代码不能为空"); + } + + if (StringUtils.isEmpty(chooseCodes)) return queryMesLabelTemplate(organizeCode, moduleCode, templateCode); + + List chooseCodeList = Arrays.asList(chooseCodes.split(MesPcnExtConstWords.COMMA)); + + List configList = configService.getMesConfigListByCfgCodeKey(moduleCode, MesPcnExtConstWords.CUSTOM_CFG, organizeCode); + Optional optional = CollectionUtils.isEmpty(configList) ? null : + configList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCfgValue()) + && !StringUtils.isEmpty(o.getCfgType()) && chooseCodeList.contains(o.getCfgType()))).findFirst(); + + return queryMesLabelTemplate(organizeCode, (null == optional || !optional.isPresent()) ? moduleCode : optional.get().getCfgValue(), templateCode); + + } catch (ImppBusiException imppException) { + return ResultBean.fail(imppException); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java index 6b69b21..94b0094 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java @@ -28,8 +28,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.Optional; @Service @Slf4j @@ -71,7 +73,14 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService @Override public ResultBean doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean) { - MesConfig config = configService.getMesConfigByCfgCode(MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE, bean.getOrganizeCode()); + List chooseCodeList = Arrays.asList(bean.getShippingGroupCode().split(MesPcnExtConstWords.COMMA)); + List configList = configService.getMesConfigListByCfgCodeKey(MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE, MesPcnExtConstWords.CUSTOM_CFG, bean.getOrganizeCode()); + Optional optional = CollectionUtils.isEmpty(configList) ? null : + configList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCfgValue()) + && !StringUtils.isEmpty(o.getCfgType()) && chooseCodeList.contains(o.getCfgType()))).findFirst(); + + String templeteCodeCfg = (null == optional || !optional.isPresent()) ? MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE : optional.get().getCfgValue(); + MesConfig config = configService.getMesConfigByCfgCodeKeyOrg(templeteCodeCfg, MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE, bean.getOrganizeCode()); if (null == config || StringUtils.isEmpty(config.getCfgValue())) MesPcnException.throwBusiException("未配置排序发运全局打印配置[%s]", MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE); MesLabelTemplate labelTemplate = templateService.getMesLabelTemplate(config.getCfgValue(), bean.getOrganizeCode()); diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index fc0d89a..4d0cb4c 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -925,6 +925,8 @@ public class MesPcnExtConstWords { public static final String SORT_SHIPPING_PRINT_TEMPLATE = "SORT_SHIPPING_PRINT_TEMPLATE"; //由前端直接渲染模版的标志 public static final String TEMPLATE_CUSTOM_HTML = "TEMPLATE_CUSTOM_HTML"; + //客制化配置 + public static final String CUSTOM_CFG = "CUSTOM_CFG"; //生产过程控制非排序打印机配置【物料级别=1, 默认打印机=2】 public static final String PRODUCTION_CONTROL_NOSORT_PRINTER_CFG = "PRODUCTION_CONTROL_NOSORT_PRINTER_CFG";