wangxin 5 сар өмнө
parent
commit
541257dddd

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

@@ -165,11 +165,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);