Browse Source

企业台账新增产品信息表商品序号新增自动生成

heguanxun 4 months ago
parent
commit
ba661918f5

+ 21 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecordinfo/entity/BusinessIdGenerator.java

@@ -6,7 +6,9 @@ import java.util.Date;
 public class BusinessIdGenerator {
 
     private static final String PREFIX = "EPD";
+    private static final String PREFIX_P = "P";
     private static final String FIXED_MIDDLE_PART = "000";
+    private static final String FIXED_MIDDLE_PART_PRODUCT = "00";
     private static final int SERIAL_NUMBER_LENGTH = 1;
 
     private static final String PREFIX_ = "LHTWL";
@@ -27,6 +29,25 @@ public class BusinessIdGenerator {
         return businessId.toString();
     }
 
+    public static String generateBusinessIdForProduct(int currentSerialNumber) {
+        StringBuilder businessId = new StringBuilder();
+        businessId.append(PREFIX_P);
+        businessId.append(getDatePart());
+        businessId.append(FIXED_MIDDLE_PART_PRODUCT);
+        businessId.append(getSerialNumberPart(currentSerialNumber));
+        System.out.println(businessId);
+        return businessId.toString();
+    }
+
+    public static String generateBusinessIdForProductYl(int currentSerialNumber) {
+        StringBuilder businessId = new StringBuilder();
+        businessId.append(getDatePart());
+        businessId.append(FIXED_MIDDLE_PART);
+        businessId.append(getSerialNumberPart(currentSerialNumber));
+        System.out.println(businessId);
+        return businessId.toString();
+    }
+
     private static String getDatePart() {
         SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
         return sdf.format(new Date());

+ 6 - 2
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecordinfo/service/impl/QyRecordInfoServiceImpl.java

@@ -121,8 +121,10 @@ public class QyRecordInfoServiceImpl extends ServiceImpl<QyRecordInfoMapper, QyR
             AtomicInteger i = new AtomicInteger();
             qyRecordProductAddParams.stream().forEach(item -> {
                 item.setQyRecordInfoId(qyRecordInfo.getId());
-                String ylCode = BusinessIdGenerator.generateBusinessId(i.get());
+                String ylCode = BusinessIdGenerator.generateBusinessIdForProductYl(i.get());
+                String ylCodeProduce = BusinessIdGenerator.generateBusinessIdForProduct(i.get());
                 item.setYlCode(ylCode);
+                item.setProductCode(ylCodeProduce);
                 i.getAndIncrement();
                 QyRecordProduct qyRecordProduct = BeanUtil.toBean(item, QyRecordProduct.class);
                 qyRecordProductService.save(qyRecordProduct);
@@ -202,8 +204,10 @@ public class QyRecordInfoServiceImpl extends ServiceImpl<QyRecordInfoMapper, QyR
             AtomicInteger i = new AtomicInteger();
             productEditParams.stream().forEach(item -> {
                 item.setQyRecordInfoId(qyRecordInfo.getId());
-                String ylCode = BusinessIdGenerator.generateBusinessId(i.get());
+                String ylCode = BusinessIdGenerator.generateBusinessIdForProductYl(i.get());
+                String ylCodeProduce = BusinessIdGenerator.generateBusinessIdForProduct(i.get());
                 item.setYlCode(ylCode);
+                item.setProductCode(ylCodeProduce);
                 QyRecardBody qyRecardBody = BeanUtil.toBean(item, QyRecardBody.class);
                 qyRecardBody.setQyRecordInfoId(qyRecordInfo.getId());
                 qyRecardBody.setId(null);