Browse Source

修改采购模块

zhoudw 7 years ago
parent
commit
0f19a65744

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

@@ -161,6 +161,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             }
 
             baseDTO = getBaseDTOById(pi_id,pi_class,pi_inoutno);
+            //计算金额,未税单价,未税金额等
+            calcProdInout(pi_id,pi_class);
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;

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

@@ -142,6 +142,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
                 purchasedetailMapper.batchInsert(insertDetails);
             }
             baseDTO = getBaseDTOById(pu_id);
+            //计算金额,未税单价,未税金额等
+            calcPurchase(pu_id);
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;
@@ -171,9 +173,10 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
             purchasedetailMapper.batchUpdate(updateDetails);
         }
         baseDTO = getBaseDTOById(pu_id);
-        //日志
+
         //计算金额,未税单价,未税金额等
         calcPurchase(pu_id);
+        //日志
         messageLogService.save(baseDTO);
         return baseDTO;
     }

+ 4 - 4
applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -739,15 +739,15 @@
   </delete>
 
   <update id="calcProdIn">
-    update prodiodetail set pd_netprice = pd_orderprice/(1+pd_taxrate/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
-    update prodiodetail set pd_total = pd_orderprice*pd_inqty,pd_nettotal = pd_netprice*pd_inqty where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_netprice = ifnull(pd_orderprice,0)/(1+ifnull(pd_taxrate,0)/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_total = ifnull(pd_orderprice,0)*ifnull(pd_inqty,0),pd_nettotal = pd_netprice*ifnull(pd_inqty,0) where pd_piid = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_total = (select sum(pd_total) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_nettotal = (select sum(pd_nettotal) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
   </update>
 
   <update id="calcProdOut">
-    update prodiodetail set pd_netprice = pd_orderprice/(1+pd_taxrate/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
-    update prodiodetail set pd_total = pd_orderprice*pd_outqty,pd_nettotal = pd_netprice*pd_outqty where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_netprice = ifnull(pd_orderprice,0)/(1+ifnull(pd_taxrate,0)/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_total = ifnull(pd_orderprice,0)*ifnull(pd_outqty,0),pd_nettotal = pd_netprice*ifnull(pd_outqty,0) where pd_piid = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_total = (select sum(pd_total) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_nettotal = (select sum(pd_nettotal) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
   </update>

+ 2 - 2
applications/purchase/purchase-server/src/main/resources/mapper/PurchasedetailMapper.xml

@@ -409,8 +409,8 @@
 
 
   <update id="calcPurchase" parameterType="long" >
-    update purchasedetail set pd_taxprice = PD_PRICE/(1+pd_taxrate/100) where pd_puid = #{pu_id,jdbcType=INTEGER};
-    update purchasedetail set pd_total = PD_PRICE*pd_qty,pd_taxtotal = pd_taxprice*pd_qty where pd_puid = #{pu_id,jdbcType=INTEGER};
+    update purchasedetail set pd_taxprice = ifnull(PD_PRICE,0)/(1+ifnull(pd_taxrate,0)/100) where pd_puid = #{pu_id,jdbcType=INTEGER};
+    update purchasedetail set pd_total = ifnull(PD_PRICE,0)*ifnull(pd_qty,0),pd_taxtotal = pd_taxprice*ifnull(pd_qty,0) where pd_puid = #{pu_id,jdbcType=INTEGER};
     update purchase set pu_total = (select sum(pd_total) from purchasedetail where pd_puid = #{pi_id,jdbcType=INTEGER} ) where pu_id = #{pu_id,jdbcType=INTEGER};
     update purchase set PU_TAXTOTAL = (select sum(pd_taxtotal) from purchasedetail where pd_puid = #{pi_id,jdbcType=INTEGER} ) where pu_id = #{pu_id,jdbcType=INTEGER};
   </update>

+ 3 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/ProdInOutServiceImpl.java

@@ -156,6 +156,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             }
 
             baseDTO = getBaseDTOById(pi_id,pi_class,pi_inoutno);
+            //计算金额,未税单价,未税金额等
+            calcProdInout(pi_id,pi_class);
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;
@@ -464,6 +466,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     private void calcProdInout(Long pi_id, String pi_class) {
+        Integer id = pi_id.intValue();
         if ("其它入库单".equals(pi_class)) {
             prodIODetailMapper.calcProdIn(pi_id);
         } else if ("其它出库单".equals(pi_class)) {

+ 1 - 1
applications/storage/storage-server/src/main/resources/application.yml

@@ -9,7 +9,7 @@ spring:
       password: select111***
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://192.168.253.12:3306/saas_biz?characterEncoding=utf-8&useSSL=false
+    url: jdbc:mysql://192.168.253.12:3306/saas_biz?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
     username: root
     password: select111***
     hikari:

+ 8 - 9
applications/storage/storage-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -721,11 +721,10 @@
   </update>
 
   <update id="updatePurchaseYqty" parameterType="java.lang.Integer">
-
-update prodiodetail a
-set a.pd_yqty =ifnull((select  b.pd_outqty  from  (select pd_ioid,sum(pd_outqty) pd_outqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='采购验退单'
-and pi_puid=#{id,jdbcType=INTEGER}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
-where a.pd_piid = (select pi_id from prodinout where pi_puid=#{id,jdbcType=INTEGER} and pi_class='采购验收单')
+  update prodiodetail a
+  set a.pd_yqty =ifnull((select  b.pd_outqty  from  (select pd_ioid,sum(pd_outqty) pd_outqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='采购验退单'
+  and pi_puid=#{id,jdbcType=INTEGER}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
+  where a.pd_piid = (select pi_id from prodinout where pi_puid=#{id,jdbcType=INTEGER} and pi_class='采购验收单')
   </update>
 
 
@@ -740,15 +739,15 @@ where a.pd_piid = (select pi_id from prodinout where pi_puid=#{id,jdbcType=INTEG
   </delete>
 
   <update id="calcProdIn">
-    update prodiodetail set pd_netprice = pd_orderprice/(1+pd_taxrate/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
-    update prodiodetail set pd_total = pd_orderprice*pd_inqty,pd_nettotal = pd_netprice*pd_inqty where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_netprice = ifnull(pd_orderprice,0)/(1+ifnull(pd_taxrate,0)/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_total = ifnull(pd_orderprice,0)*ifnull(pd_inqty,0),pd_nettotal = pd_netprice*ifnull(pd_inqty,0) where pd_piid = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_total = (select sum(pd_total) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_nettotal = (select sum(pd_nettotal) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
   </update>
 
   <update id="calcProdOut">
-    update prodiodetail set pd_netprice = pd_orderprice/(1+pd_taxrate/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
-    update prodiodetail set pd_total = pd_orderprice*pd_outqty,pd_nettotal = pd_netprice*pd_outqty where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_netprice = ifnull(pd_orderprice,0)/(1+ifnull(pd_taxrate,0)/100) where pd_piid = #{pi_id,jdbcType=INTEGER};
+    update prodiodetail set pd_total = ifnull(pd_orderprice,0)*ifnull(pd_outqty,0),pd_nettotal = pd_netprice*ifnull(pd_outqty,0) where pd_piid = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_total = (select sum(pd_total) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
     update prodinout set pi_nettotal = (select sum(pd_nettotal) from prodiodetail where pd_piid = #{pi_id,jdbcType=INTEGER} ) where pi_id = #{pi_id,jdbcType=INTEGER};
   </update>

+ 7 - 0
applications/storage/storage-server/src/test/com/usoftchina/saas/storage/mapper/ProdIODetailMapperTest.java

@@ -80,4 +80,11 @@ public class ProdIODetailMapperTest {
     public void selectByFK() throws Exception {
     }
 
+    @Test
+    public void calcProdIn() throws Exception {
+//        prodIODetailMapper.calcProdIn(486);
+
+    }
+
+
 }