Browse Source

物料取编号BUG处理

guq 7 years ago
parent
commit
0ab9d02b8e

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

@@ -526,13 +526,17 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
      * @Author: chenwei
      * @Date: 2018/10/26
      */
-    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)) ? getMapper().validateCodeWhenInsert(code, companyId) :
-                getMapper().validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PRODUCT.getCaller()).getData();
+        String billCode = null;
+        synchronized (ProductServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                    getMapper().validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PRODUCT.getCaller()).getData();
+        }
+        return billCode;
     }
 }