Преглед на файлове

托书推送,费用支出单ID使用redis存储取值

zengtx преди 1 година
родител
ревизия
bec924ca79

+ 15 - 26
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/service/impl/SyShippingOrderServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.documents.letterDeposit.entity.SyRmb;
 import org.jeecg.modules.documents.letterDeposit.entity.SyUsd;
@@ -66,7 +67,8 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
     private SyPackingListTailoringItemServiceImpl syPackingListTailoringItemService;
     @Resource
     private PurchaseWarehousingMapper purchaseWarehousingMapper;
-
+    @Autowired
+    private RedisUtil redisUtil;
 
     /**
      * 分页列表查询
@@ -646,6 +648,8 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
 
         // ID= 年月日+毫秒
         SimpleDateFormat sf2 = new SimpleDateFormat("20MddSSS");
+        String setRedis = sf2.format(new Date())+"1";
+        redisUtil.set("salerID",setRedis);
         //记录每次单据号
         String cCode = "";
 
@@ -692,20 +696,14 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
         for(Map<String,Object> li: itemList){
 
             if(rmbList.size()!=0) {
-                int index = 0;
+
                 //人民币信息
                 for (Map<String, Object> rmb : rmbList) {
-                    String id = "";
-
-                    index++;
-                    //ID
-                    if(index < 10){
-                        Thread.sleep(500);
-                         id = sf2.format(new Date())+"0"+index;
-                    }else {
-                         Thread.sleep(500);
-                         id = sf2.format(new Date()) + index;
-                    }
+
+                    String redisId = redisUtil.get("salerID").toString();
+                    int addId = Integer.parseInt(redisId)+1;
+                    String id = String.valueOf(addId);
+                    redisUtil.set("salerID",id);
                     ii++;
                     Map<String, Object> map = new HashMap<>();
                     Map<String, Object> mapPo;
@@ -771,18 +769,10 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                 int index = 0;
                 //美元信息
                 for (Map<String, Object> usd : usdList) {
-                    String id = "";
-                    index++;
-                    //ID
-                    if(index < 10){
-					    Thread.sleep(500);
-                        id = sf2.format(new Date())+"0"+index;
-                        
-                    }else {
-                        Thread.sleep(500);
-                        id = sf2.format(new Date()) + index;
-                    }
-
+                    String redisId = redisUtil.get("salerID").toString();
+                    int addId = Integer.parseInt(redisId)+1;
+                    String id = String.valueOf(addId);
+                    redisUtil.set("salerID",id);
                     ii++;
                     Map<String, Object> map = new HashMap<>();
                     Map<String, Object> mapPo;
@@ -880,5 +870,4 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
 
     }
 
-
 }