Browse Source

修改采购模块

zhoudw 7 years ago
parent
commit
75250535eb

+ 14 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/PurchaseApplication.java

@@ -7,6 +7,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
 /**
  * @author yingp
@@ -18,8 +20,19 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableFeignClients("com.usoftchina.saas")
 //@EnableAuthClient
 @MapperScan("com.usoftchina.saas.purchase.mapper")
-public class PurchaseApplication   {
+public class PurchaseApplication   extends WebMvcConfigurerAdapter{
     public static void main(String[] args) {
         SpringApplication.run(PurchaseApplication.class, args);
     }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+
+        registry.addMapping("/**")
+                .allowCredentials(true)
+                .allowedHeaders("*")
+                .allowedOrigins("*")
+                .allowedMethods("*");
+    }
+
 }

+ 1 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/controller/ProdInOutController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
  * Created by zdw
  * 2018-10-17 11:41.
  */
+@CrossOrigin
 @RestController
 @RequestMapping("/prodinout")
 public class ProdInOutController {

+ 5 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java

@@ -2,6 +2,7 @@ package com.usoftchina.saas.purchase.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.purchase.po.ProdIODetail;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -29,4 +30,8 @@ public interface ProdIODetailMapper extends CommonBaseMapper<ProdIODetail> {
     List<ProdIODetail> selectByFK(Long id);
 
     void deleteByFK(Long id);
+
+    void calcProdIn(@Param("pi_id") Long pi_id,@Param("pi_class") String pi_class);
+
+    void calcProdOut(@Param("pi_id") Long pi_id,@Param("pi_class") String pi_class);
 }

+ 1 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/PurchasedetailMapper.java

@@ -30,4 +30,5 @@ public interface PurchasedetailMapper extends CommonBaseMapper<Purchase> {
     void updatePurchaseYqty(Integer pu_id);
 
 
+    void calcPurchase(Long pu_id);
 }

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

@@ -153,7 +153,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                 detail.setCompanyId(companyId);
                 detail.setCreatorId(userId);
                 detail.setCreateTime(new Date());
-
                 insertDetails.add(detail);
             }
             //插入从表
@@ -192,14 +191,15 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             prodIODetailMapper.batchUpdate(updateDetails);
         }
         baseDTO = getBaseDTOById(pi_id,pi_class,pi_inoutno);
+        //计算金额,未税单价,未税金额等
+        calcProdInout(pi_id,pi_class);
         //更新已转数
+        updateYqty(prodInOut);
         //日志记录
         messageLogService.update(baseDTO);
-        updateYqty(prodInOut);
         return baseDTO;
     }
 
-
     @Override
     @Transactional
     public void delete(Long id) {
@@ -341,6 +341,17 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         }
     }
 
+
+    private void calcProdInout(Long pi_id, String pi_class) {
+        if ("采购验收单".equals(pi_class)) {
+            prodIODetailMapper.calcProdIn(pi_id,pi_class);
+        } else if ("采购验退单".equals(pi_class)) {
+            prodIODetailMapper.calcProdOut(pi_id,pi_class);
+        }
+    }
+
+
+
     private void updateYqty(ProdInOut prodInOut) {
         //更新已转数
         if ("采购验收单".equals(prodInOut.getPi_class())){

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

@@ -172,6 +172,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         }
         baseDTO = getBaseDTOById(pu_id);
         //日志
+        //计算金额,未税单价,未税金额等
+        calcPurchase(pu_id);
         messageLogService.save(baseDTO);
         return baseDTO;
     }
@@ -505,4 +507,10 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.PURCHASE.getCaller());
         return baseDTO;
     }
+
+    @Transactional
+    private void calcPurchase(Long pu_id) {
+//        purchasedetailMapper.calcPurchase(pu_id);
+    }
+
 }

+ 21 - 5
applications/purchase/purchase-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>
 
 
@@ -739,4 +738,21 @@ where a.pd_piid = (select pi_id from prodinout where pi_puid=#{id,jdbcType=INTEG
     where pd_piid = #{id,jdbcType=INTEGER}
   </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 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 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>
+
+
+
+
 </mapper>

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

@@ -428,12 +428,25 @@
   </select>
 
   <update id="updatePurchaseYqty" parameterType="integer" >
-update purchasedetail
-set pd_yqty=ifnull((select sum(IFNULL(pd_inqty,0)-IFNULL(pd_outqty,0))
-from prodiodetail
-where ((pd_piclass='采购验退单'  and pd_status=99 ) or pd_piclass='采购验收单') and IFNULL(pd_orderid,0)=purchasedetail.pd_id),0)
-where pd_puid=#{pu_id}
+    update purchasedetail
+    set pd_yqty=ifnull((select sum(IFNULL(pd_inqty,0)-IFNULL(pd_outqty,0))
+    from prodiodetail
+    where ((pd_piclass='采购验退单'  and pd_status=99 ) or pd_piclass='采购验收单') and IFNULL(pd_orderid,0)=purchasedetail.pd_id),0)
+    where pd_puid=#{pu_id}
   </update>
 
 
+  <update id="calcPurchase" parameterType="long" >
+    update purchasedetail set pd_netprice = PD_PRICE/(1+pd_taxrate/100) where pd_puid = #{pu_id,jdbcType=INTEGER};
+    update purchasedetail set pd_total = PD_PRICE*pd_qty,pd_nettotal = pd_netprice*pd_inqty where pd_puid = #{pu_id,jdbcType=INTEGER};
+    update purchase set pu_total = (select sum(pd_total) from prodiodetail where pd_puid = #{pi_id,jdbcType=INTEGER} ) where pu_id = #{pu_id,jdbcType=INTEGER};
+    update purchase set p_nettotal = (select sum(pd_nettotal) from prodiodetail where pd_puid = #{pi_id,jdbcType=INTEGER} ) where pu_id = #{pu_id,jdbcType=INTEGER};
+  </update>
+
+
+
+
+
+
+
 </mapper>

+ 24 - 28
frontend/saas-web/app/view/stock/otherIn/FormPanelController.js

@@ -6,40 +6,35 @@ Ext.define('saas.view.stock.otherIn.FormPanelController', {
         var me = this;
         this.control({
             //放大镜赋值关系 以及 tpl模板
-            'dbfindtrigger[name=pu_vendcode]': {
-                beforerender: function (f) {
-                    Ext.apply(f, {
-                        dataUrl: '/api/document/vendor/list',
+            'dbfindtrigger[name=pi_vendname]':{
+                beforerender:function(f){
+                    Ext.apply(f,{
+                        dataUrl:'/api/document/vendor/list',
                         // dataUrl:'http://localhost:9480/vendor/list',
                         addXtype: 'document-vendor-formpanel',
                         addTitle: '供应商资料',
-                        dbfinds: [{
-                            from: 've_id',
-                            to: 'pi_vendid'
-                        }, {
-                            from: 've_code',
-                            to: 'pu_vendcode'
-                        }, {
-                            from: 've_name',
-                            to: 'pu_vendname'
+                        dbfinds:[{
+                            from:'id',to:'pi_vendid'
+                        },{
+                            from:'ve_code',to:'pi_vendcode'
+                        },{
+                            from:'ve_name',to:'pi_vendname'
                         }],
-                        dbtpls: [{
-                            field: 've_code',
-                            width: 100
-                        }, {
-                            field: 've_name',
-                            width: 100
+                        dbtpls:[{
+                            field:'ve_code',width:100
+                        },{
+                            field:'ve_name',width:100
                         }],
-                        dbColumns: [{
-                            conditionCode: 've_id',
+                        dbColumns:[{
+                            conditionCode:'id',
                             "text": "供应商ID",
                             "flex": 0,
-                            "dataIndex": "ve_id",
+                            "dataIndex": "id",
                             "width": 0,
                             "xtype": "",
                             "items": null
-                        }, {
-                            conditionCode: 've_code',
+                        },{
+                            conditionCode:'ve_code',
                             "text": "供应商编号",
                             "flex": 1,
                             "dataIndex": "ve_code",
@@ -47,14 +42,14 @@ Ext.define('saas.view.stock.otherIn.FormPanelController', {
                             "xtype": "",
                             "items": null
                         }, {
-                            conditionCode: 've_name',
+                            conditionCode:'ve_name',
                             "text": "供应商名称",
                             "flex": 1,
                             "dataIndex": "ve_name",
                             "xtype": "",
                             "items": null
                         }, {
-                            conditionCode: 've_type',
+                            conditionCode:'ve_type',
                             "text": "供应商类型",
                             "flex": 0,
                             "dataIndex": "ve_type",
@@ -62,8 +57,9 @@ Ext.define('saas.view.stock.otherIn.FormPanelController', {
                             "xtype": "",
                             "items": null
                         }]
-                    });
-                },
+                    }) ;   
+
+                }
             },
             //放大镜赋值关系 以及 tpl模板
             'dbfindtrigger[name=pi_custname]': {

+ 0 - 62
frontend/saas-web/app/view/stock/otherOut/FormPanelController.js

@@ -5,72 +5,10 @@ Ext.define('saas.view.stock.otherOut.FormPanelController', {
     init: function (form) {
         var me = this;
         this.control({
-            //放大镜赋值关系 以及 tpl模板
-            'dbfindtrigger[name=pu_vendcode]': {
-                beforerender: function (f) {
-                    Ext.apply(f, {
-                        dataUrl: '/api/document/vendor/list',
-                        // dataUrl:'http://localhost:9480/vendor/list',
-                        addXtype: 'document-vendor-formpanel',
-                        addTitle: '供应商资料',
-                        dbfinds: [{
-                            from: 've_id',
-                            to: 'pi_vendid'
-                        }, {
-                            from: 've_code',
-                            to: 'pu_vendcode'
-                        }, {
-                            from: 've_name',
-                            to: 'pu_vendname'
-                        }],
-                        dbtpls: [{
-                            field: 've_code',
-                            width: 100
-                        }, {
-                            field: 've_name',
-                            width: 100
-                        }],
-                        dbColumns: [{
-                            conditionCode: 've_id',
-                            "text": "供应商ID",
-                            "flex": 0,
-                            "dataIndex": "ve_id",
-                            "width": 0,
-                            "xtype": "",
-                            "items": null
-                        }, {
-                            conditionCode: 've_code',
-                            "text": "供应商编号",
-                            "flex": 1,
-                            "dataIndex": "ve_code",
-                            "width": 100,
-                            "xtype": "",
-                            "items": null
-                        }, {
-                            conditionCode: 've_name',
-                            "text": "供应商名称",
-                            "flex": 1,
-                            "dataIndex": "ve_name",
-                            "xtype": "",
-                            "items": null
-                        }, {
-                            conditionCode: 've_type',
-                            "text": "供应商类型",
-                            "flex": 0,
-                            "dataIndex": "ve_type",
-                            "width": 200,
-                            "xtype": "",
-                            "items": null
-                        }]
-                    });
-
-                }
-            },
             //放大镜赋值关系 以及 tpl模板
             'dbfindtrigger[name=pi_vendname]':{
                 beforerender:function(f){
                     Ext.apply(f,{
-
                         dataUrl:'/api/document/vendor/list',
                         // dataUrl:'http://localhost:9480/vendor/list',
                         addXtype: 'document-vendor-formpanel',