Browse Source

解决销售出货单保存报错、明细出不来问题

rainco 7 years ago
parent
commit
8cb32f32d9

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

@@ -91,12 +91,16 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         prodInOut.setCompanyId(companyId);
         prodInOut.setCreatorId(userId);
         prodInOut.setCreateTime(new Date());
-        prodInOut.setPi_date(new Date());
+        prodInOut.setPi_recordmanid(userId);
+        prodInOut.setPi_recorddate(new Date());
+        prodInOut.setPi_recordman("TESTADMIN");
 
+        if(prodInOut.getPi_date() == null){
+            prodInOut.setPi_date(new Date());
+        }
         //编号获取
         pi_inoutno = pushMaxnubmer(prodInOut);
         prodInOut.setPi_inoutno(pi_inoutno);
-
         prodInOut.setPi_class(main.getPi_class());
         prodInOut.setPi_said(main.getPi_said());
         prodInOut.setPi_sacode(main.getPi_sacode());
@@ -112,6 +116,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                 detail.setPd_piid(pi_id);
                 detail.setPd_inoutno(pi_inoutno);
                 detail.setPd_piclass(pi_class);
+                detail.setCompanyId(companyId);
+                detail.setCreateTime(new Date());
                 detail.setPd_yqty(0.0);
                 insertDetails.add(detail);
             }
@@ -394,10 +400,17 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         String piInoutno =
                 //BillCodeSeq.SALEIN.getCaller() + Math.abs(Math.random()*100);
                 maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
+        //设置公司id
+        targetPi.setCompanyId(sourcePi.getCompanyId());
+        targetPi.setCreateTime(new Date());
+        targetPi.setCreatorId(BaseContextHolder.getUserId());
+        targetPi.setPi_recordmanid(BaseContextHolder.getUserId());
+        targetPi.setPi_recorddate(new Date());
+        targetPi.setPi_recordman("TESTADMIN");
+
         targetPi.setPi_inoutno(piInoutno);
         targetPi.setPi_class(BillCodeSeq.SALEIN.getName());
         targetPi.setPi_date(new Date());
-        targetPi.setPi_recorddate(new Date());
         targetPi.setPi_status(Status.UNAUDITED.getDisplay());
         targetPi.setPi_statuscode(Status.UNAUDITED.name());
         //客户信息
@@ -406,9 +419,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         targetPi.setPi_custname(sourcePi.getPi_custname());
         targetPi.setPi_said(sourcePi.getPi_said());
         targetPi.setPi_sacode(sourcePi.getPi_sacode());
-
-        //设置公司id
-        targetPi.setCompanyId(sourcePi.getCompanyId());
         //保存数据
         getMapper().insertSelective(targetPi);
         //插入销售退货单从表
@@ -419,6 +429,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             pdOutqty = sourcePid.getPd_outqty()==null?0.0:sourcePid.getPd_outqty();
             pdYqty = sourcePid.getPd_yqty()==null?0.0:sourcePid.getPd_yqty();
             if(pdOutqty-pdYqty>0){
+                //公司id
+                targetPid.setCompanyId(sourcePid.getCompanyId());
+                targetPid.setCreateTime(new Date());
                 targetPid.setPd_piid(pi_id);
                 targetPid.setPd_inoutno(piInoutno);
                 targetPid.setPd_piclass(BillCodeSeq.SALEIN.getName());
@@ -436,8 +449,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                 targetPid.setPd_unit(sourcePid.getPd_unit());
                 targetPid.setPd_ioid(sourcePid.getId());
                 targetPid.setPd_status(0);
-                //公司id
-                targetPid.setCompanyId(sourcePid.getCompanyId());
+
                 //本次转单数
                 targetPid.setPd_inqty(pdOutqty-pdYqty);
                 prodIODetailMapper.insertSelective(targetPid);

+ 11 - 11
applications/sale/sale-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -41,7 +41,7 @@
     <result column="pd_ym" jdbcType="INTEGER" property="pd_ym" />
     <result column="pd_yqty" jdbcType="INTEGER" property="pd_yqty" />
     <result column="pd_ioid" jdbcType="INTEGER" property="pd_ioid" />
-    <association property="productDTO" javaType="com.usoftchina.saas.document.entities.Product">
+    <association property="productDTO" javaType="com.usoftchina.saas.document.dto.ProductDTO">
       <id column="pr_id" property="id"/>
       <result column="pr_code" property="pr_code"/>
       <result column="pr_detail" property="pr_detail"/>
@@ -739,16 +739,16 @@
 
   <update id="updateSaleOutYqty" parameterType="long">
 update prodiodetail
-  set a.pd_yqty =ifnull((select  b.pd_inqty  from  (select pi_said,sum(pd_inqty) pd_inqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='销售退货单'
-and pi_said=#{id}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
+  set a.pd_yqty =IFNULL((select  b.pd_inqty  from  (select pi_said,sum(pd_inqty) pd_inqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='销售退货单'
+and pi_said=#{id}  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_said=#{id} and pi_class='销售出货单')
   </update>
   <update id="updateSaleYqty" parameterType="long">
     update saledtail
-    set a.sd_yqty =ifnull((
+    set a.sd_yqty =IFNULL((
     select  b.pd_ounqty  from  (select pi_said,sum(pd_outqty) pd_outqty
       from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='销售出货单'
-      and pi_said=#{id}  GROUP BY pi_said) b where ifnull(b.pd_ioid ,0)= a.pd_id
+      and pi_said=#{id}  GROUP BY pi_said) b where IFNULL(b.pd_ioid ,0)= a.pd_id
       ),0)
     where a.sd_said = #{id}
   </update>
@@ -760,16 +760,16 @@ where a.pd_piid = (select pi_id from prodinout where pi_said=#{id} and pi_class=
 
   <update id="updatePDSaleIN" parameterType="long">
    update prodiodetail set
-   pd_total=ifnull(pd_inqty,0)*ifnull(pd_orderprice,0),
-   pd_netprice = ifnull(pd_sendprice,0)/(1+ifnull(pd_taxrate,0)/100),
-   pd_nettotal = (ifnull(pd_sendprice,0)/(1+ifnull(pd_taxrate,0)/100))*ifnull(pd_inqty)
+   pd_total=IFNULL(pd_inqty,0)*IFNULL(pd_orderprice,0),
+   pd_netprice = IFNULL(pd_sendprice,0)/(1+IFNULL(pd_taxrate,0)/100),
+   pd_nettotal = (IFNULL(pd_sendprice,0)/(1+IFNULL(pd_taxrate,0)/100))*IFNULL(pd_inqty,0)
    where pd_piid=#{id}
   </update>
   <update id="updatePDSaleOut" parameterType="long">
     update prodiodetail set
-    pd_total=ifnull(pd_outqty,0)*ifnull(pd_orderprice,0),
-    pd_netprice = ifnull(pd_sendprice,0)/(1+ifnull(pd_taxrate,0)/100),
-    pd_nettotal = (ifnull(pd_sendprice,0)/(1+ifnull(pd_taxrate,0)/100))*ifnull(pd_outqty)
+    pd_total=IFNULL(pd_outqty,0)*IFNULL(pd_orderprice,0),
+    pd_netprice = IFNULL(pd_sendprice,0)/(1+IFNULL(pd_taxrate,0)/100),
+    pd_nettotal = (IFNULL(pd_sendprice,0)/(1+IFNULL(pd_taxrate,0)/100))*IFNULL(pd_outqty,0)
     where pd_piid=#{id}
   </update>
 </mapper>

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

@@ -34,6 +34,7 @@
     <result column="pi_text5" jdbcType="VARCHAR" property="pi_text5" />
     <result column="pi_auditdate" jdbcType="TIMESTAMP" property="pi_auditdate" />
     <result column="pi_auditman" jdbcType="VARCHAR" property="pi_auditman" />
+    <result column="pi_address" jdbcType="VARCHAR" property="pi_address" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.usoftchina.saas.storage.po.ProdInOut">
     <result column="pi_address" jdbcType="LONGVARCHAR" property="pi_address" />

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/dto/ProdInOutDTO.java

@@ -43,7 +43,7 @@ public class ProdInOutDTO extends CommonBaseDTO implements Serializable {
 
     private Double pi_total;
 
-    private Integer pi_recordmanid;
+    private Long pi_recordmanid;
 
     private String pi_recordman;
 

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/dto/ProdInOutListDTO.java

@@ -41,7 +41,7 @@ public class ProdInOutListDTO extends CommonBaseEntity implements Serializable {
 
     private Double pi_total;
 
-    private Integer pi_recordmanid;
+    private Long pi_recordmanid;
 
     private String pi_recordman;
 

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOut.java

@@ -37,7 +37,7 @@ public class ProdInOut extends CommonBaseEntity implements Serializable {
 
     private Double pi_total;
 
-    private Integer pi_recordmanid;
+    private Long pi_recordmanid;
 
     private String pi_recordman;
 

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOutList.java

@@ -40,7 +40,7 @@ public class ProdInOutList extends CommonBaseEntity{
 
     private Double pi_total;
 
-    private Integer pi_recordmanid;
+    private Long pi_recordmanid;
 
     private String pi_recordman;