From 9d6cb93e570198303e2791e83ddd4d30f04bf11b Mon Sep 17 00:00:00 2001 From: yinq Date: Wed, 15 Jan 2025 13:56:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=98=E5=8C=96=E3=80=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=BC=96=E5=8F=B7=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/utils/StringUtils.java | 22 + .../common/core/utils/uuid/IdUtils.java | 49 ++ .../dromara/common/core/utils/uuid/Seq.java | 134 +++++ .../dromara/common/core/utils/uuid/UUID.java | 486 ++++++++++++++++++ .../dromara/mes/domain/bo/ProdPlanInfoBo.java | 8 +- .../dromara/mes/domain/vo/ProdPlanInfoVo.java | 2 + .../impl/ProdMaterialBomServiceImpl.java | 28 + .../service/impl/ProdPlanInfoServiceImpl.java | 3 + .../mapper/mes/ProdPlanInfoMapper.xml | 4 + 9 files changed, 732 insertions(+), 4 deletions(-) create mode 100644 ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/IdUtils.java create mode 100644 ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/Seq.java create mode 100644 ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/UUID.java diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StringUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StringUtils.java index dd6ebb11..f959383e 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StringUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StringUtils.java @@ -320,4 +320,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { .collect(Collectors.toList()); } + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) + { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) + { + return !isNull(object); + } + } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/IdUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/IdUtils.java new file mode 100644 index 00000000..29f7d960 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/IdUtils.java @@ -0,0 +1,49 @@ +package org.dromara.common.core.utils.uuid; + +/** + * ID生成器工具类 + * + * @author ruoyi + */ +public class IdUtils +{ + /** + * 获取随机UUID + * + * @return 随机UUID + */ + public static String randomUUID() + { + return UUID.randomUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线 + * + * @return 简化的UUID,去掉了横线 + */ + public static String simpleUUID() + { + return UUID.randomUUID().toString(true); + } + + /** + * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 随机UUID + */ + public static String fastUUID() + { + return UUID.fastUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 简化的UUID,去掉了横线 + */ + public static String fastSimpleUUID() + { + return UUID.fastUUID().toString(true); + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/Seq.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/Seq.java new file mode 100644 index 00000000..5b145c10 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/Seq.java @@ -0,0 +1,134 @@ +package org.dromara.common.core.utils.uuid; + + +import org.dromara.common.core.utils.DateUtils; +import org.dromara.common.core.utils.StringUtils; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author ruoyi 序列生成类 + */ +public class Seq { + // 通用序列类型 + public static final String commSeqType = "COMMON"; + + // 上传序列类型 + public static final String uploadSeqType = "UPLOAD"; + + // 通用接口序列数 + private static AtomicInteger commSeq = new AtomicInteger(1); + + // 上传接口序列数 + private static AtomicInteger uploadSeq = new AtomicInteger(1); + + // 机器标识 + private static final String machineCode = "A"; + + // 计划编号记录标识 + public static final String mesPlanCodeSeqType = "MES_PLAN_CODE"; + + // 计划编号序列数 + private static AtomicInteger mesPlanCodeSeq = new AtomicInteger(1); + + // 计划编号标识 + public static final String mesPlanCodeCode = "PL"; + + /** + * 获取通用序列号 + * + * @return 序列值 + */ + public static String getId() { + return getId(commSeqType); + } + + /** + * 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串 + * + * @return 序列值 + */ + public static String getId(String type) { + AtomicInteger atomicInt = commSeq; + if (uploadSeqType.equals(type)) { + atomicInt = uploadSeq; + } + return getId(atomicInt, 3); + } + + /** + * 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串 + * + * @param atomicInt 序列数 + * @param length 数值长度 + * @return 序列值 + */ + public static String getId(AtomicInteger atomicInt, int length) { + String result = DateUtils.dateTimeNow(); + result += machineCode; + result += getSeq(atomicInt, length); + return result; + } + + /** + * 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数 + * + * @return 序列值 + */ + private synchronized static String getSeq(AtomicInteger atomicInt, int length) { + // 先取值再+1 + int value = atomicInt.getAndIncrement(); + + // 如果更新后值>=10 的 (length)幂次方则重置为1 + int maxSeq = (int) Math.pow(10, length); + if (atomicInt.get() >= maxSeq) { + atomicInt.set(1); + } + // 转字符串,用0左补齐 + return StringUtils.padl(value, length); + } + + + /** + * 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串 + * + * @return 序列值 + */ + public static String getId(String type,String code) { + AtomicInteger atomicInt = commSeq; + if (mesPlanCodeSeqType.equals(type)) { + atomicInt = mesPlanCodeSeq; + } + return getId(atomicInt, 4, code); + } + + + /** + * 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串 + * + * @param atomicInt 序列数 + * @param length 数值长度 + * @return 序列值 + */ + public static String getId(AtomicInteger atomicInt, int length, String code) { + String result = DateUtils.dateTimeNow(); + result += code; + result += getSeq(atomicInt, length); + return result; + } + + /** + * 通用接口序列号 前缀+yyMMdd + length长度循环递增字符串 + * + * @param atomicInt 序列数 + * @param length 数值长度 + * @return 序列值 + */ + public static String getNewId(AtomicInteger atomicInt, int length, String code) { + String result = code; + result += DateUtils.dateTime(); + result += getSeq(atomicInt, length); + return result; + } + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/UUID.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/UUID.java new file mode 100644 index 00000000..660683aa --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/uuid/UUID.java @@ -0,0 +1,486 @@ +package org.dromara.common.core.utils.uuid; + + +import cn.hutool.core.exceptions.UtilException; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +/** + * 提供通用唯一识别码(universally unique identifier)(UUID)实现 + * + * @author ruoyi + */ +public final class UUID implements java.io.Serializable, Comparable +{ + private static final long serialVersionUID = -1185015143654744140L; + + /** + * SecureRandom 的单例 + * + */ + private static class Holder + { + static final SecureRandom numberGenerator = getSecureRandom(); + } + + /** 此UUID的最高64有效位 */ + private final long mostSigBits; + + /** 此UUID的最低64有效位 */ + private final long leastSigBits; + + /** + * 私有构造 + * + * @param data 数据 + */ + private UUID(byte[] data) + { + long msb = 0; + long lsb = 0; + assert data.length == 16 : "data must be 16 bytes in length"; + for (int i = 0; i < 8; i++) + { + msb = (msb << 8) | (data[i] & 0xff); + } + for (int i = 8; i < 16; i++) + { + lsb = (lsb << 8) | (data[i] & 0xff); + } + this.mostSigBits = msb; + this.leastSigBits = lsb; + } + + /** + * 使用指定的数据构造新的 UUID。 + * + * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 + * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位 + */ + public UUID(long mostSigBits, long leastSigBits) + { + this.mostSigBits = mostSigBits; + this.leastSigBits = leastSigBits; + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID fastUUID() + { + return randomUUID(false); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID() + { + return randomUUID(true); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能 + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID(boolean isSecure) + { + final Random ng = isSecure ? Holder.numberGenerator : getRandom(); + + byte[] randomBytes = new byte[16]; + ng.nextBytes(randomBytes); + randomBytes[6] &= 0x0f; /* clear version */ + randomBytes[6] |= 0x40; /* set to version 4 */ + randomBytes[8] &= 0x3f; /* clear variant */ + randomBytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(randomBytes); + } + + /** + * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。 + * + * @param name 用于构造 UUID 的字节数组。 + * + * @return 根据指定数组生成的 {@code UUID} + */ + public static UUID nameUUIDFromBytes(byte[] name) + { + MessageDigest md; + try + { + md = MessageDigest.getInstance("MD5"); + } + catch (NoSuchAlgorithmException nsae) + { + throw new InternalError("MD5 not supported"); + } + byte[] md5Bytes = md.digest(name); + md5Bytes[6] &= 0x0f; /* clear version */ + md5Bytes[6] |= 0x30; /* set to version 3 */ + md5Bytes[8] &= 0x3f; /* clear variant */ + md5Bytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(md5Bytes); + } + + /** + * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。 + * + * @param name 指定 {@code UUID} 字符串 + * @return 具有指定值的 {@code UUID} + * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 + * + */ + public static UUID fromString(String name) + { + String[] components = name.split("-"); + if (components.length != 5) + { + throw new IllegalArgumentException("Invalid UUID string: " + name); + } + for (int i = 0; i < 5; i++) + { + components[i] = "0x" + components[i]; + } + + long mostSigBits = Long.decode(components[0]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[1]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[2]).longValue(); + + long leastSigBits = Long.decode(components[3]).longValue(); + leastSigBits <<= 48; + leastSigBits |= Long.decode(components[4]).longValue(); + + return new UUID(mostSigBits, leastSigBits); + } + + /** + * 返回此 UUID 的 128 位值中的最低有效 64 位。 + * + * @return 此 UUID 的 128 位值中的最低有效 64 位。 + */ + public long getLeastSignificantBits() + { + return leastSigBits; + } + + /** + * 返回此 UUID 的 128 位值中的最高有效 64 位。 + * + * @return 此 UUID 的 128 位值中最高有效 64 位。 + */ + public long getMostSignificantBits() + { + return mostSigBits; + } + + /** + * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。 + *

+ * 版本号具有以下含意: + *

+ * + * @return 此 {@code UUID} 的版本号 + */ + public int version() + { + // Version is bits masked by 0x000000000000F000 in MS long + return (int) ((mostSigBits >> 12) & 0x0f); + } + + /** + * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。 + *

+ * 变体号具有以下含意: + *

+ * + * @return 此 {@code UUID} 相关联的变体号 + */ + public int variant() + { + // This field is composed of a varying number of bits. + // 0 - - Reserved for NCS backward compatibility + // 1 0 - The IETF aka Leach-Salz variant (used by this class) + // 1 1 0 Reserved, Microsoft backward compatibility + // 1 1 1 Reserved for future definition. + return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63)); + } + + /** + * 与此 UUID 相关联的时间戳值。 + * + *

+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。 + * + *

+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。 + */ + public long timestamp() throws UnsupportedOperationException + { + checkTimeBase(); + return (mostSigBits & 0x0FFFL) << 48// + | ((mostSigBits >> 16) & 0x0FFFFL) << 32// + | mostSigBits >>> 32; + } + + /** + * 与此 UUID 相关联的时钟序列值。 + * + *

+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。 + *

+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出 + * UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的时钟序列 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public int clockSequence() throws UnsupportedOperationException + { + checkTimeBase(); + return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); + } + + /** + * 与此 UUID 相关的节点值。 + * + *

+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。 + *

+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的节点值 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public long node() throws UnsupportedOperationException + { + checkTimeBase(); + return leastSigBits & 0x0000FFFFFFFFFFFFL; + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @return 此{@code UUID} 的字符串表现形式 + * @see #toString(boolean) + */ + @Override + public String toString() + { + return toString(false); + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 + * @return 此{@code UUID} 的字符串表现形式 + */ + public String toString(boolean isSimple) + { + final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); + // time_low + builder.append(digits(mostSigBits >> 32, 8)); + if (false == isSimple) + { + builder.append('-'); + } + // time_mid + builder.append(digits(mostSigBits >> 16, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // time_high_and_version + builder.append(digits(mostSigBits, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // variant_and_sequence + builder.append(digits(leastSigBits >> 48, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // node + builder.append(digits(leastSigBits, 12)); + + return builder.toString(); + } + + /** + * 返回此 UUID 的哈希码。 + * + * @return UUID 的哈希码值。 + */ + @Override + public int hashCode() + { + long hilo = mostSigBits ^ leastSigBits; + return ((int) (hilo >> 32)) ^ (int) hilo; + } + + /** + * 将此对象与指定对象比较。 + *

+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 + * + * @param obj 要与之比较的对象 + * + * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} + */ + @Override + public boolean equals(Object obj) + { + if ((null == obj) || (obj.getClass() != UUID.class)) + { + return false; + } + UUID id = (UUID) obj; + return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); + } + + // Comparison Operations + + /** + * 将此 UUID 与指定的 UUID 比较。 + * + *

+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 + * + * @param val 与此 UUID 比较的 UUID + * + * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。 + * + */ + @Override + public int compareTo(UUID val) + { + // The ordering is intentionally set up so that the UUIDs + // can simply be numerically compared as two numbers + return (this.mostSigBits < val.mostSigBits ? -1 : // + (this.mostSigBits > val.mostSigBits ? 1 : // + (this.leastSigBits < val.leastSigBits ? -1 : // + (this.leastSigBits > val.leastSigBits ? 1 : // + 0)))); + } + + // ------------------------------------------------------------------------------------------------------------------- + // Private method start + /** + * 返回指定数字对应的hex值 + * + * @param val 值 + * @param digits 位 + * @return 值 + */ + private static String digits(long val, int digits) + { + long hi = 1L << (digits * 4); + return Long.toHexString(hi | (val & (hi - 1))).substring(1); + } + + /** + * 检查是否为time-based版本UUID + */ + private void checkTimeBase() + { + if (version() != 1) + { + throw new UnsupportedOperationException("Not a time-based UUID"); + } + } + + /** + * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) + * + * @return {@link SecureRandom} + */ + public static SecureRandom getSecureRandom() + { + try + { + return SecureRandom.getInstance("SHA1PRNG"); + } + catch (NoSuchAlgorithmException e) + { + throw new UtilException(e); + } + } + + /** + * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 + * + * @return {@link ThreadLocalRandom} + */ + public static ThreadLocalRandom getRandom() + { + return ThreadLocalRandom.current(); + } +} diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/bo/ProdPlanInfoBo.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/bo/ProdPlanInfoBo.java index 5e3c1c7f..e2871a5c 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/bo/ProdPlanInfoBo.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/bo/ProdPlanInfoBo.java @@ -45,7 +45,7 @@ public class ProdPlanInfoBo extends BaseEntity { /** * 工单编号 */ - @NotBlank(message = "工单编号不能为空", groups = { AddGroup.class, EditGroup.class }) +// @NotBlank(message = "工单编号不能为空", groups = { AddGroup.class, EditGroup.class }) private String planCode; /** @@ -56,13 +56,13 @@ public class ProdPlanInfoBo extends BaseEntity { /** * 物料ID;成品ID */ - @NotNull(message = "物料ID;成品ID不能为空", groups = { AddGroup.class, EditGroup.class }) + @NotNull(message = "物料不能为空", groups = { AddGroup.class, EditGroup.class }) private Long materialId; /** * 物料BOM_ID */ - @NotNull(message = "物料BOM_ID不能为空", groups = { AddGroup.class, EditGroup.class }) + @NotNull(message = "物料BOM不能为空", groups = { AddGroup.class, EditGroup.class }) private Long materialBomId; /** @@ -109,7 +109,7 @@ public class ProdPlanInfoBo extends BaseEntity { /** * 派工数量 */ - @NotNull(message = "派工数量不能为空", groups = { AddGroup.class, EditGroup.class }) +// @NotNull(message = "派工数量不能为空", groups = { AddGroup.class, EditGroup.class }) private Long dispatchAmount; /** diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/ProdPlanInfoVo.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/ProdPlanInfoVo.java index 6ba1fad5..cbb406f1 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/ProdPlanInfoVo.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/vo/ProdPlanInfoVo.java @@ -227,4 +227,6 @@ public class ProdPlanInfoVo implements Serializable { private String processName; private String shiftName; private String teamName; + private String materialBomName; + private String releaseName; } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdMaterialBomServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdMaterialBomServiceImpl.java index 344669de..bb32d5da 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdMaterialBomServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdMaterialBomServiceImpl.java @@ -83,6 +83,13 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService { */ @Override public Boolean insertByBo(ProdMaterialBomBo bo) { + isTopFlag(bo); + ProdMaterialBomVo info = baseMapper.selectVoById(bo.getParentId()); + if (StringUtils.isNull(info)) { + bo.setAncestors(bo.getParentId().toString()); + } else { + bo.setAncestors(info.getAncestors() + "," + bo.getParentId()); + } ProdMaterialBom add = MapstructUtils.convert(bo, ProdMaterialBom.class); validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; @@ -100,6 +107,11 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService { */ @Override public Boolean updateByBo(ProdMaterialBomBo bo) { + isTopFlag(bo); + ProdMaterialBomVo info = baseMapper.selectVoById(bo.getParentId()); + if (StringUtils.isNotNull(info)) { + bo.setAncestors(info.getAncestors() + "," + bo.getParentId()); + } ProdMaterialBom update = MapstructUtils.convert(bo, ProdMaterialBom.class); validEntityBeforeSave(update); return baseMapper.updateById(update) > 0; @@ -126,4 +138,20 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService { } return baseMapper.deleteByIds(ids) > 0; } + + /** + * SET顶级标识 + * 判断是否顶级BOM + * + * @param mesMaterialBom + */ + private void isTopFlag(ProdMaterialBomBo mesMaterialBom) { + // 顶级标识1=是,0=否 + if (StringUtils.isNull(mesMaterialBom.getParentId()) || mesMaterialBom.getParentId() == 0L) { + mesMaterialBom.setTopFlag(1L); + } else { + mesMaterialBom.setTopFlag(0L); + } + } + } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdPlanInfoServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdPlanInfoServiceImpl.java index 049a493f..c71e31b9 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdPlanInfoServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdPlanInfoServiceImpl.java @@ -2,6 +2,7 @@ package org.dromara.mes.service.impl; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.core.utils.uuid.Seq; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.PageQuery; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -114,6 +115,8 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService { */ @Override public Boolean insertByBo(ProdPlanInfoBo bo) { + String planCode = Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode); + bo.setPlanCode(planCode); ProdPlanInfo add = MapstructUtils.convert(bo, ProdPlanInfo.class); validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; diff --git a/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdPlanInfoMapper.xml b/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdPlanInfoMapper.xml index c8cc5294..43427da6 100644 --- a/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdPlanInfoMapper.xml +++ b/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdPlanInfoMapper.xml @@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${ew.getSqlSelect}, bmi.material_code, bmi.material_name, + bomi.material_name material_bom_name, + pbsi.station_name release_name, pbpi.process_name, bsi.shift_name, bcti.team_name @@ -19,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from prod_plan_info t left join base_material_info bmi on bmi.material_id = t.material_id + left join base_material_info bomi on bomi.material_id = t.material_bom_id + left join prod_base_station_info pbsi on pbsi.station_id = t.release_id left join prod_base_process_info pbpi on pbpi.process_id = t.process_id left join base_shift_info bsi on bsi.shift_id = t.shift_id left join base_class_team_info bcti on bcti.class_team_id = t.class_team_id