Browse Source

单据编号重复bug修改

guq 7 năm trước cách đây
mục cha
commit
c577e343c7

+ 4 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java

@@ -6,6 +6,7 @@ import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
 import com.usoftchina.saas.purchase.mapper.ProdInOutMapper;
@@ -77,7 +78,9 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
 
     void calcProdInout(Long pi_id, String pi_class);
 
-    String pushMaxnubmer(ProdInOut prodInOut);
+    //String pushMaxnubmer(DocBaseDTO baseDTO);
+
+    String getMaxnumber(BillCodeSeq bill);
 
     void getDefaultWarehouseByProduct(Long pi_id);
 }

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

@@ -143,8 +143,11 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         prodInOut.setPi_date(new Date());
         prodInOut.setPi_puid(main.getPi_puid());
         prodInOut.setPi_pucode(main.getPi_pucode());
+        baseDTO.setCode(pi_inoutno);
+        baseDTO.setId(pi_id);
+        baseDTO.setName(pi_class);
         //编号获取
-        pi_inoutno = pushMaxnubmer(prodInOut);
+        pi_inoutno = pushMaxnubmer(baseDTO);
         prodInOut.setPi_inoutno(pi_inoutno);
 
         //判断更新与保存动作
@@ -428,7 +431,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入验退单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASEOUT.getCaller(),true).getData();
+        String piInoutno = getMaxnumber(BillCodeSeq.PURCHASEOUT);
         targetPi.setPi_inoutno(piInoutno);
         targetPi.setPi_class(BillCodeSeq.PURCHASEOUT.getName());
         targetPi.setPi_date(new Date());
@@ -546,7 +549,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return docBaseDTO;
     }
 
-
     @Override
     public DocBaseDTO open(long id) {
         return singleOpen(id);
@@ -575,26 +577,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
-
-    public String pushMaxnubmer(ProdInOut prodInOut) {
-        String pi_inoutno = prodInOut.getPi_inoutno();
-        String pi_class = prodInOut.getPi_class();
-        Long id = prodInOut.getId();
-        if (null == pi_inoutno) {
-            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();
-    }
-
     @Override
     @Transactional
     public void getDefaultWarehouseByProduct(Long pi_id) {
@@ -613,5 +595,29 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return prodInOut;
     }
 
+    @Override
+    public String getMaxnumber(BillCodeSeq bill) {
+        String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
+        DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
+        return pushMaxnubmer(base);
+    }
 
+    public synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
+        String pi_inoutno = baseDTO.getCode();
+        String pi_class = baseDTO.getName();
+        Long id = baseDTO.getId();
+        if (null == pi_inoutno) {
+            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();
+    }
 }

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

@@ -416,7 +416,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         //插入验收单主表
         ProdInOut prodInOut = new ProdInOut();
         //生成单号
-        String piInoutno =maxnumberService.getMaxnumber(BillCodeSeq.PURCHASEIN.getCaller(),true).getData();
+        String piInoutno = prodInOutService.getMaxnumber(BillCodeSeq.PURCHASEIN);
         prodInOut.setPi_inoutno(piInoutno);
         prodInOut.setPi_class("采购验收单");
         prodInOut.setPi_date(new Date());
@@ -561,7 +561,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     * @Author: guq
     * @Date: 2018/10/19
     */
-    private String pushMaxnubmer(String code, Long id) {
+    private synchronized String pushMaxnubmer(String code, Long id) {
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }

+ 2 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SalerecView.java

@@ -34,5 +34,7 @@ public class SalerecView {
 
     private String rb_remark;
 
+    private Double rbd_amount;
+
     private Integer companyid;
 }

+ 3 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/ProdInOutService.java

@@ -7,6 +7,7 @@ import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.page.PageRequest;
 
 import com.usoftchina.saas.sale.dto.ProdInOutFormDTO;
@@ -119,4 +120,6 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      * @param id
      */
     DocBaseDTO turnProdin(Long id);
+
+    String getMaxnumber(BillCodeSeq bill);
 }

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

@@ -99,8 +99,11 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if(prodInOut.getPi_date() == null){
             prodInOut.setPi_date(new Date());
         }
+        baseDTO.setName(pi_class);
+        baseDTO.setId(pi_id);
+        baseDTO.setCode(pi_inoutno);
         //编号获取
-        pi_inoutno = pushMaxnubmer(prodInOut);
+        pi_inoutno = pushMaxnubmer(baseDTO);
         prodInOut.setPi_inoutno(pi_inoutno);
         prodInOut.setPi_class(main.getPi_class());
         prodInOut.setPi_said(main.getPi_said());
@@ -405,10 +408,10 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入销售退货单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno  =
-                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
+       /* String piInoutno  =
+                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();*/
                // BillCodeSeq.SALEIN.getCaller()+Math.abs(Math.random()*100);
-
+        String piInoutno = getMaxnumber(BillCodeSeq.SALEIN);
         //设置公司id
         targetPi.setCompanyId(sourcePi.getCompanyId());
         targetPi.setCreateTime(new Date());
@@ -563,10 +566,10 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private String pushMaxnubmer(ProdInOut prodInOut) {
-        String code = prodInOut.getPi_inoutno();
-        Long id = prodInOut.getId();
-        String pi_class = prodInOut.getPi_class();
+    private synchronized 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);
         }
@@ -578,8 +581,14 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         }else {//销售退货单
             caller = BillCodeSeq.SALEIN.getCaller();
         }
-        return //code;
-                maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        return maxnumberService.pushMaxnubmer(count, code, caller).getData();
+    }
+
+    @Override
+    public String getMaxnumber(BillCodeSeq bill) {
+        String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
+        DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
+        return pushMaxnubmer(base);
     }
 
     /**

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

@@ -21,6 +21,7 @@ import com.usoftchina.saas.sale.mapper.*;
 import com.usoftchina.saas.sale.po.Sale;
 import com.usoftchina.saas.sale.po.SaleDetail;
 import com.usoftchina.saas.sale.po.SaleList;
+import com.usoftchina.saas.sale.service.ProdInOutService;
 import com.usoftchina.saas.sale.service.SaleService;
 import com.usoftchina.saas.storage.po.ProdIODetail;
 import com.usoftchina.saas.storage.po.ProdInOut;
@@ -53,6 +54,8 @@ public class SaleServiceImpl implements SaleService{
     private ProdInOutMapper prodInOutMapper;
     @Autowired
     private ProdIODetailMapper prodIODetailMapper;
+    @Autowired
+    private ProdInOutService prodInOutService;
 
     @Override
     public PageInfo<SaleList> getListData(PageRequest page, ListReqDTO req) {
@@ -429,8 +432,9 @@ public class SaleServiceImpl implements SaleService{
         //插入验收单主表
         ProdInOut prodInOut = new ProdInOut();
         //生成单号
-        String pi_inoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEOUT.getCaller(),
-                true).getData();
+       /* String pi_inoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEOUT.getCaller(),
+                true).getData();*/
+        String pi_inoutno = prodInOutService.getMaxnumber(BillCodeSeq.SALEOUT);
         prodInOut.setPi_inoutno(pi_inoutno);
         prodInOut.setPi_class(BillCodeSeq.SALEOUT.getName());
         prodInOut.setPi_date(new Date());
@@ -553,7 +557,7 @@ public class SaleServiceImpl implements SaleService{
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private String pushMaxnubmer(String code, Long id) {
+    private synchronized String pushMaxnubmer(String code, Long id) {
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }

+ 1 - 0
applications/sale/sale-server/src/main/resources/mapper/SalerecViewMapper.xml

@@ -15,6 +15,7 @@
     <result column="rb_backrate" property="rb_backrate" jdbcType="DOUBLE" />
     <result column="rb_remark" property="rb_remark" jdbcType="VARCHAR" />
     <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="rbd_amount" property="rbd_amount" jdbcType="DOUBLE" />
   </resultMap>
   <select id="selectByCondition" resultMap="BaseResultMap">
     select  *  from Salerec_View

+ 1 - 1
base-servers/mail/mail-api/src/main/java/com/usoftchina/saas/mail/MailBuilder.java

@@ -185,7 +185,7 @@ public abstract class MailBuilder {
 
         @Override
         protected Result send(MailApi api) {
-            return api.sendTemplate(new TemplateMailMessage(templateId, to, cc, bcc, metadata));
+            return api.sendTemplate(new TemplateMailMessage(templateId, from, to, cc, bcc, metadata));
         }
     }
 }