Browse Source

单号重复BUG修改

guq 7 years ago
parent
commit
291e0669d7

+ 16 - 12
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -229,7 +229,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Transactional(propagation = Propagation.REQUIRED)
-    private void singleDelete(Long id) {
+    public void singleDelete(Long id) {
 
             ProdInOut prodInOut = checkAndReturnOrder(id);;
             //删除主键
@@ -261,7 +261,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Transactional(propagation = Propagation.REQUIRED)
-    private void singleAudit(ProdInOutDTO prodInOutDTO) {
+    public void singleAudit(ProdInOutDTO prodInOutDTO) {
         String pi_class= prodInOutDTO.getPi_class();
         String pi_inoutno = prodInOutDTO.getPi_inoutno();
         String pi_statuscode = prodInOutDTO.getPi_statuscode();
@@ -603,7 +603,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return pushMaxnubmer(base);
     }
 
-    public synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
+    public String pushMaxnubmer(DocBaseDTO baseDTO) {
         String pi_inoutno = baseDTO.getCode();
         String pi_class = baseDTO.getName();
         Long id = baseDTO.getId();
@@ -611,14 +611,18 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
-                getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
-        String caller ="";
-        if("采购验收单".equals(pi_class)){
-            caller = BillCodeSeq.PURCHASEIN.getCaller();
-        }else if("采购验退单".equals(pi_class)) {
-            caller = BillCodeSeq.PURCHASEOUT.getCaller();
-        }
-        return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        String billCode = null;
+        synchronized (ProdInOutServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
+                    getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
+            String caller ="";
+            if("采购验收单".equals(pi_class)){
+                caller = BillCodeSeq.PURCHASEIN.getCaller();
+            }else if("采购验退单".equals(pi_class)) {
+                caller = BillCodeSeq.PURCHASEOUT.getCaller();
+            }
+            billCode = maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        }
+        return billCode;
     }
 }

+ 8 - 4
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java

@@ -561,14 +561,18 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     * @Author: guq
     * @Date: 2018/10/19
     */
-    private synchronized String pushMaxnubmer(String code, Long id) {
+    private String pushMaxnubmer(String code, Long id) {
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? purchaseMapper.validateCodeWhenInsert(code, companyId) :
-                purchaseMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PURCHASE.getCaller()).getData();
+        String billCode = null;
+        synchronized (PurchaseServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? purchaseMapper.validateCodeWhenInsert(code, companyId) :
+                    purchaseMapper.validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PURCHASE.getCaller()).getData();
+        }
+        return billCode;
     }
     
     /** 

+ 13 - 9
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -562,22 +562,26 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
+    private String pushMaxnubmer(DocBaseDTO baseDTO) {
         String code = baseDTO.getCode();
         Long id = baseDTO.getId();
         String pi_class = baseDTO.getName();
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
-        Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
-                prodInOutMapper.validateCodeWhenUpdate(code, id);
-        String caller ="";
-        if(pi_class.equals("出货单")){
-            caller = BillCodeSeq.SALEOUT.getCaller();
-        }else {//销售退货单
-            caller = BillCodeSeq.SALEIN.getCaller();
+        String billCode = null;
+        synchronized (ProdInOutServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
+                    prodInOutMapper.validateCodeWhenUpdate(code, id);
+            String caller ="";
+            if(pi_class.equals("出货单")){
+                caller = BillCodeSeq.SALEOUT.getCaller();
+            }else {//销售退货单
+                caller = BillCodeSeq.SALEIN.getCaller();
+            }
+            billCode = maxnumberService.pushMaxnubmer(count, code, caller).getData();
         }
-        return maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        return billCode;
     }
 
     @Override

+ 8 - 4
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java

@@ -557,14 +557,18 @@ public class SaleServiceImpl implements SaleService{
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private synchronized String pushMaxnubmer(String code, Long id) {
+    private String pushMaxnubmer(String code, Long id) {
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? saleMapper.validateCodeWhenInsert(code, companyId) :
-                saleMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.SALE.getCaller()).getData();
+        String billCode = null;
+        synchronized(SaleServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? saleMapper.validateCodeWhenInsert(code, companyId) :
+                    saleMapper.validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.SALE.getCaller()).getData();
+        }
+        return billCode;
     }
 
     /**