diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesConfigService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesConfigService.java index a9315a3..2053fc5 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesConfigService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesConfigService.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation; * @Author: simon.song */ public interface IMesConfigService { + @ApiOperation(value = "获取配置表模板代码") String getCfgValue(String org, String key); @@ -18,5 +19,10 @@ public interface IMesConfigService { @ApiOperation(value = "获取配置表模板代码") MesConfig getMesConfig(String org, String key); + @ApiOperation(value = "根据分隔符验证是否存在元素的配置") + Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item); + + @ApiOperation(value = "验证分表配置") + Boolean checkShardingTablesObjectCfg(String organizeCode, String cfgKey, String item); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesConfigService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesConfigService.java index 8ac5ace..5234a31 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesConfigService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesConfigService.java @@ -1,13 +1,21 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.MesConfig; import cn.estsh.i3plus.pojo.mes.repository.MesConfigRepository; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import lombok.extern.slf4j.Slf4j; 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.Arrays; +import java.util.List; /** * @Description: @@ -55,4 +63,23 @@ public class MesConfigService implements IMesConfigService { } return config; } + + @Override + public Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(cfgCode, MesPcnExtConstWords.CFG_CODE, packBean); + DdlPreparedPack.getStringEqualPack(cfgKey, MesPcnExtConstWords.CFG_KEY, packBean); + DdlPreparedPack.getStringEqualPack(cfgType, MesPcnExtConstWords.CFG_TYPE, packBean); + MesConfig config = configRepository.getByProperty(packBean); + if (null == config || StringUtils.isEmpty(config.getCfgValue())) return false; + List cfgValueList = Arrays.asList(config.getCfgValue().split(splitStr)); + return (!CollectionUtils.isEmpty(cfgValueList) && cfgValueList.contains(item)) ? true : false; + } + + @Override + public Boolean checkShardingTablesObjectCfg(String organizeCode, String cfgKey, String item) { + return checkCfgValueIsContainItem(organizeCode, MesPcnExtConstWords.MES_SHARDING_TABLES_OBJECT_CFG, cfgKey, CommonEnumUtil.SOFT_TYPE.MES_PCN.name(), MesPcnExtConstWords.SEMICOLON, item); + } + + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index 8c9850d..ede5021 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -675,18 +675,26 @@ public class MesWorkOrderService implements IMesWorkOrderService { MesShift currentShift = shifts.stream().filter(mesShift -> Objects.equals(mesShift.getShiftCode(), shiftCode)).findFirst().orElse(null); - String beginTime =productionRecord.getLotNo() + " " + currentShift.getStartTime(); - Date beginDate = transfer(beginTime); - - /*MesWorkOrder found = null; - for (MesWorkOrder oldMesWorkOrder : oldMesWorkOrders) { - if (beginDate.getTime() >= transfer(oldMesWorkOrder.getPlanStartTime()).getTime() && beginDate.getTime() < transfer(oldMesWorkOrder.getPlanEndTime()).getTime()) { - found = oldMesWorkOrder; - break; + + String orderDate = productionRecord.getLotNo(); + if (currentShift.getStartTime().compareTo(currentShift.getEndTime()) > 0){ + // 如果比0点大,需要找日期前一天的班次的工单号,如果是0点前,date =lotNO 如果是0点后,则找lot的前一天 + int hours = transfer(productionRecord.getCompleteDateTime()).getHours(); + if (hours < 12) { + orderDate = getDate(productionRecord.getLotNo(), 1); + } else { + orderDate = getDate(productionRecord.getLotNo(), 0); + } + } + + List list = new ArrayList<>(); + for (MesWorkOrder oldMesWorkOrder : oldMesWorkOrders) { + if (Objects.equals(oldMesWorkOrder.getShiftCode(), productionRecord.getShiftCode()) && Objects.equals(oldMesWorkOrder.getProduceTime(), orderDate)) { + list.add(oldMesWorkOrder); + } } - }*/ + workOrders = list; - workOrders = oldMesWorkOrders.stream().filter(workOrder -> beginDate.getTime() >= transfer(workOrder.getPlanStartTime()).getTime() && beginDate.getTime() <= transfer(workOrder.getPlanEndTime()).getTime()).collect(Collectors.toList()); MesWorkOrder bestWorkOrder = getBestWorkOrder(productionRecord, workOrders, mesWorkCenter); @@ -798,7 +806,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { List centerList = Arrays.asList(workCenterCodes.split(",")); DdlPreparedPack.getNotInPack(centerList, "workCenterCode", ddlPackBean); } - /*String workCenterCodes ="C06CK01B"; + /*String workCenterCodes ="B19CK01A"; if (!StringUtils.isEmpty(workCenterCodes)) { List centerList = Arrays.asList(workCenterCodes.split(",")); DdlPreparedPack.getInPack(centerList, "workCenterCode", ddlPackBean); 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 98eff65..ddb2446 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 @@ -33,6 +33,10 @@ public class MesPcnExtConstWords { public static final String SUPPLIER_CODE_NO_SORT_GZ = "SUPPLIER_CODE_NO_SORT_GZ"; // 系统配置代码 public static final String CFG_CODE = "cfgCode"; + // 系统配置键 + public static final String CFG_KEY = "cfgKey"; + // 系统配置类型 + public static final String CFG_TYPE = "cfgType"; // 用户ID public static final String USER_ID = "userId"; // 区域代码 @@ -284,7 +288,8 @@ public class MesPcnExtConstWords { //_ public static final String E_UNDERLINE = "_"; - + // 分表配置 + public static final String MES_SHARDING_TABLES_OBJECT_CFG = "MES_SHARDING_TABLES_OBJECT_CFG"; //过程条码默认生成规则 public static final String DEFAULT_SERIAL_NUMBER_RULE = "DEFAULT_SERIAL_NUMBER_RULE";