瀏覽代碼

Merge remote-tracking branch 'origin/master'

ezhizao_zx 5 月之前
父節點
當前提交
8bdcd027c4

+ 40 - 16
src/main/java/cn/ezhizao/project/business/controller/BizOutsourcedOrderController.java

@@ -506,10 +506,16 @@ public class BizOutsourcedOrderController extends BaseController {
                 }
             } else {
                 codeValue = previous;
-                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-                lastFourDigits += 1; // 加1
-                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-                previous = codeValue;
+                String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+                //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+                if(codeYear.equals(formattedDate)){
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous = codeValue;
+                }else{
+                    previous = ("WFD" + formattedDate + "00001");
+                }
             }
             //存到redis中
             redisCache.setCacheObject(codeType, previous);
@@ -582,10 +588,16 @@ public class BizOutsourcedOrderController extends BaseController {
                 }
             } else {
                 codeValue = previous;
-                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-                lastFourDigits += 1; // 加1
-                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-                previous = codeValue;
+                String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+                //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+                if(codeYear.equals(formattedDate)){
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous = codeValue;
+                }else{
+                    previous = ("WFD" + formattedDate + "00001");
+                }
             }
             //存到redis中
             redisCache.setCacheObject(codeType, previous);
@@ -1096,10 +1108,16 @@ public class BizOutsourcedOrderController extends BaseController {
                 }
             } else {
                 codeValue = previous;
-                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-                lastFourDigits += 1; // 加1
-                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-                previous = codeValue;
+                String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+                //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+                if(codeYear.equals(formattedDate)){
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous = codeValue;
+                }else{
+                    previous = ("WFD" + formattedDate + "00001");
+                }
             }
             //存到redis中
             redisCache.setCacheObject(codeType, previous);
@@ -1392,10 +1410,16 @@ public class BizOutsourcedOrderController extends BaseController {
             }
         } else {
             codeValue = previous;
-            int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-            lastFourDigits += 1; // 加1
-            codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-            previous = codeValue;
+            String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+            //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+            if(codeYear.equals(formattedDate)){
+                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                lastFourDigits += 1; // 加1
+                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                previous = codeValue;
+            }else{
+                previous = ("WFD" + formattedDate + "00001");
+            }
         }
         //存到redis中
         redisCache.setCacheObject(codeType, previous);

+ 33 - 11
src/main/java/cn/ezhizao/project/business/controller/BizReturnReceiptController.java

@@ -268,11 +268,17 @@ public class BizReturnReceiptController extends BaseController
                     previous = ("SHD" + formattedDate + "000001");
                 }
             } else {
-                codeValue=previous;
-                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-                lastFourDigits += 1; // 加1
-                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-                previous=codeValue;
+                codeValue = previous;
+                String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+                //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+                if(codeYear.equals(formattedDate)){
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous=codeValue;
+                }else{
+                    previous = ("SHD" + formattedDate + "000001");
+                }
             }
             //存到redis中
             redisCache.setCacheObject(codeType, previous);
@@ -432,18 +438,34 @@ public class BizReturnReceiptController extends BaseController
             String previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) :"";
             //若不存在,则直接存入
             if (previous.isEmpty()) {
-                previous = ("SHD" + formattedDate + "000001");
+                List<BizReturnReceipt> returnReceiptList = bizReturnReceiptService.getAllList();
+                if(!returnReceiptList.isEmpty()) {
+                    codeValue = returnReceiptList.get(0).getFormCode();
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous = codeValue;
+                }else{
+                    previous = ("SHD" + formattedDate + "000001");
+                }
             } else {
-                codeValue=previous;
-                int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
-                lastFourDigits += 1; // 加1
-                codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
-                previous=codeValue;
+                codeValue = previous;
+                String codeYear=codeValue.substring(4, 5);//取出当前外协单号年份
+                //如果年份一致表示是当前年的发出单,如果不一致则表示已经进入了新的一年则重置发出单号
+                if(codeYear.equals(formattedDate)){
+                    int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
+                    lastFourDigits += 1; // 加1
+                    codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
+                    previous=codeValue;
+                }else{
+                    previous = ("SHD" + formattedDate + "000001");
+                }
             }
             //存到redis中
             redisCache.setCacheObject(codeType, previous);
             bizReturnReceipt.setFormCode(previous);
         }
+
         bizReturnReceipt.setStatus(1);
         bizReturnReceipt.setIsSubmit(1);
         //向收回单主表存