Browse Source

销售退货单保存报错

rainco 7 years ago
parent
commit
e98be95a66

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

@@ -129,7 +129,7 @@ public class ProdInOutController {
      * @param id
      * @return
      */
-    @PostMapping("/deleteItem/{id}")
+    @PostMapping("/deleteDetail/{id}")
     public Result deleteItem(@PathVariable("id") Long id) {
         prodInOutService.deleteItem(id);
         return Result.success();

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

@@ -401,9 +401,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入销售退货单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno =
-                //BillCodeSeq.SALEIN.getCaller() + Math.abs(Math.random()*100);
-                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
+        String piInoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
         //设置公司id
         targetPi.setCompanyId(sourcePi.getCompanyId());
         targetPi.setCreateTime(new Date());
@@ -564,7 +562,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         }else {//销售退货单
             caller = BillCodeSeq.SALEIN.getCaller();
         }
-        return maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        return  maxnumberService.pushMaxnubmer(count, code, caller).getData();
         //return  caller+Math.abs(Math.random()*100);
     }
 
@@ -596,16 +594,19 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             prodIODetailMapper.updatePDSaleOut(id);
             //更新主表
             prodInOutMapper.updatePiTotal(id);
-
             //更新销售已转数
-            prodIODetailMapper.updateSaleYqty(prodInOut.getPi_said());
-        }else{//销售退货单
+            if(prodInOut.getPi_said()!=null) {
+                prodIODetailMapper.updateSaleYqty(prodInOut.getPi_said());
+            }
+        }else{//销售退货单z
             //更新明细
             prodIODetailMapper.updatePDSaleIN(id);
             //更新主表
             prodInOutMapper.updatePiTotal(id);
             //出货单已转数
-            prodIODetailMapper.updateSaleOutYqty(prodInOut.getPi_said());
+            if(prodInOut.getPi_said()!=null){
+                prodIODetailMapper.updateSaleOutYqty(prodInOut.getPi_said());
+            }
         }
     }
 

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

@@ -739,14 +739,10 @@
 
   <update id="updateSaleOutYqty" parameterType="long">
 update prodiodetail a
-  set a.pd_yqty =IFNULL(
-    (
-      select  b.pd_inqty  from
-        (select pd_ioid,sum(pd_inqty) pd_inqty from  prodiodetail  where pd_piclass='销售退货单'
-          and pd_piid=#{id}  GROUP BY pd_ioid ) b
-          where IFNULL(b.pd_ioid ,0)= a.pd_id
-     ),0)
-where a.pd_id in (select pd_ioid from prodiodetail where pd_piid=#{id} and pd_piclass='出货单')
+  set a.pd_yqty =ifnull((select  b.pd_inqty  from  (
+	select pd_ioid,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">