Forráskód Böngészése

修改:单据编号生成格式修改,获取最大单据编号SQL修改

GDW 4 hónapja
szülő
commit
a6898cb9a3

+ 1 - 1
src/main/java/cn/lttc/modules/lttcsamplescan/mapper/xml/SampleScanMapper.xml

@@ -66,7 +66,7 @@
     </insert>
 
     <select id="getMaxCode" resultType="String">
-        SELECT MAX(billNO)
+        SELECT MAX(TRY_CONVERT(BIGINT, RIGHT(billNO, LEN(billNO) - PATINDEX('%N%', billNO))))
         FROM lttc_info_main_new;
     </select>
 

+ 9 - 6
src/main/java/cn/lttc/modules/lttcsamplescan/service/impl/SampleScanServiceImpl.java

@@ -74,9 +74,9 @@ public class SampleScanServiceImpl implements ISampleScanService {
         String maxCode = sampleScanMapper.getMaxCode();
         if (maxCode != null && !maxCode.isEmpty()) {
             //如果N开头就先去除
-            if ("N".equals(String.valueOf(maxCode.charAt(0)))) {
-                maxCode = maxCode.substring(1);
-            }
+//            if ("N".equals(String.valueOf(maxCode.charAt(0)))) {
+//                maxCode = maxCode.substring(1);
+//            }
             // 截取字符串的前面部分和后四位 (前八位为 年 + 月 + 日 后四位为流水号)
             String frontPart = maxCode.substring(0, maxCode.length() - 4);
             String lastFourCharacters = maxCode.substring(maxCode.length() - 4);
@@ -89,18 +89,21 @@ public class SampleScanServiceImpl implements ISampleScanService {
                 for (int i = newCode.length(); i < 4; i++) {
                     newCode.insert(0, "0");
                 }
-                sampleScan.setBillNO("N" + now + newCode.toString());
+//                sampleScan.setBillNO("N" + now + newCode.toString());
+                sampleScan.setBillNO(now + newCode.toString());
             } else {
                 //若不相同则将当前日期拼接上0001
                 String newCode = now + "0001";
-                sampleScan.setBillNO("N" + newCode);
+//                sampleScan.setBillNO("N" + newCode);
+                sampleScan.setBillNO(newCode);
             }
         } else {
             //如果是新表无数据就走这里
             String now = currentYear + currentMonthStr + dayStr;
             //若不相同则将当前日期拼接上0001
             String newCode = now + "0001";
-            sampleScan.setBillNO("N" + newCode);
+//            sampleScan.setBillNO("N" + newCode);
+            sampleScan.setBillNO(newCode);
         }