diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/constant/CockpitConstants.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/constant/CockpitConstants.java new file mode 100644 index 0000000..125a8ac --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/constant/CockpitConstants.java @@ -0,0 +1,24 @@ +package org.nl.wms.cockpit.constant; + +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * 大屏常量类 + * + * @author zhangjiangwei + * @date 2023/07/03 16:58 + */ +public class CockpitConstants { + + // 入窑输送线及窑内数据 + public static CopyOnWriteArrayList kilnData = new CopyOnWriteArrayList<>(new String[44]); + + // 入窑输送线及窑内数据 redis key + public static final String KILN_DATA_KEY = "KILN_DATA_KEY"; + + // 冷却道数据 + public static CopyOnWriteArrayList coolingData = new CopyOnWriteArrayList<>(new String[46]); + + // 冷却道数据 redis key + public static final String COOLING_DATA_KEY = "COOLING_DATA_KEY"; +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java index 9146f5f..b9214a1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java @@ -4,12 +4,17 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.wms.cockpit.constant.CockpitConstants; import org.nl.wms.common.PickType; import org.nl.wms.sch.manage.*; @@ -239,17 +244,17 @@ public class TaskUtils { /** * 生成喷码内容,祥见 SVN 项目文档信息。 * - * @param vd 组盘对象 + * @param vd 组盘对象 * @param yjCode 压机编码 * @return 喷码内容 */ public static String codingCode(JSONObject vd, String yjCode) { try { JSONObject material = WQLObject.getWQLObject("md_me_materialbase").query("material_id = " + vd.getString("material_id")).uniqueResult(0); - + // 使用部位2位。从物料编码截取使用部位。 String partUsed = material.getString("material_code").substring(21, 23); - + // 砖型5位。一般砖型如"22/30"不需要处理,但如果'/'右边到达了3位数,需要特殊处理成"1H"。 String brickType = material.getString("brick_type"); int slashIndex = brickType.lastIndexOf("/"); @@ -279,4 +284,45 @@ public class TaskUtils { return null; } } + + public static void inKiln(String vehicleCode) { + if (StrUtil.isBlank(CockpitConstants.kilnData.get(0))) { + CockpitConstants.kilnData.set(0, vehicleCode); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); + } else { + for (int i = CockpitConstants.kilnData.size() - 1; i > 0; i--) { + CockpitConstants.kilnData.set(i, CockpitConstants.kilnData.get(i - 1)); + } + CockpitConstants.kilnData.set(0, vehicleCode); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); + } + } + + public static void outKiln(String vehicleCode) { + if (vehicleCode.equals(CockpitConstants.kilnData.get(CockpitConstants.kilnData.size() - 1))) { + for (int i = CockpitConstants.kilnData.size() - 1; i > 0; i--) { + CockpitConstants.kilnData.set(i, CockpitConstants.kilnData.get(i - 1)); + } + CockpitConstants.kilnData.set(0, null); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); + } + } + + public static void inCooling(String vehicleCode) { + for (int i = CockpitConstants.coolingData.size() - 1; i > 0; i--) { + CockpitConstants.coolingData.set(i, CockpitConstants.coolingData.get(i - 1)); + } + CockpitConstants.coolingData.set(0, vehicleCode); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.COOLING_DATA_KEY, JSON.toJSONString(CockpitConstants.coolingData, SerializerFeature.WriteMapNullValue)); + } + + public static void outCooling(String vehicleCode) { + if (vehicleCode.equals(CockpitConstants.coolingData.get(CockpitConstants.coolingData.size() - 1))) { + for (int i = CockpitConstants.coolingData.size() - 1; i > 0; i--) { + CockpitConstants.coolingData.set(i, CockpitConstants.coolingData.get(i - 1)); + } + CockpitConstants.coolingData.set(0, null); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.COOLING_DATA_KEY, JSON.toJSONString(CockpitConstants.coolingData, SerializerFeature.WriteMapNullValue)); + } + } }