Преглед изворни кода

同步销售出库单bug修复(发货单没有更新出库数量无法关闭)

hu пре 2 година
родитељ
комит
240042805d
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

+ 5 - 5
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -183,7 +183,7 @@ public class stockbill extends Controller {
                         /**
                          * 更新发货单数量
                          */
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty+"+fqty+" where siteid='lsa' and sa_dispatch_itemsid="+sainvoicedetailid);
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)+"+fqty+" where siteid='lsa' and sa_dispatch_itemsid="+sainvoicedetailid);
                     }else{
                         if(aftersalesmagRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && aftersalesmagRowsMap.get(sainvoicedetailid).isNotEmpty()){
                             logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).toJsonObject().toString());
@@ -260,7 +260,7 @@ public class stockbill extends Controller {
                      */
                     Rows stockbilldetailrows =dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
                     for (Row row :stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
                         sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid="+row.getLong("sa_dispatchid"));
                     }
                 }
@@ -301,7 +301,7 @@ public class stockbill extends Controller {
                      */
                     Rows stockbilldetailrows =dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
                     for (Row row :stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
                         sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid="+row.getLong("sa_dispatchid"));
                     }
 
@@ -317,8 +317,8 @@ public class stockbill extends Controller {
             Rows stockbillrows =dbConnect.runSqlQuery("select st_stockbillid,status,rb from st_stockbill where billno='"+fbillnum+"' and siteid='lsa'");
             if(frb.equals("蓝")){
                 //查询可关闭的发货单
-                Rows dispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
-                Rows undispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
+                Rows dispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
+                Rows undispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
                 ArrayList<String>  sqldispatch =new ArrayList<>();
                 for (Row row:dispatchrows) {
                     sqldispatch.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='lsa'");