Просмотр исходного кода

bug修复及发货计划明细订单信息刷新接口优化测试

hu 2 месяцев назад
Родитель
Сommit
2f6fbba2c7

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6891,6 +6891,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025120110193103 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 2 - 1
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmag.java

@@ -214,7 +214,8 @@ public class aftersalesmag extends Controller {
         querySQL.addQueryFields("cardphonenumber","t6.phonenumber");
         querySQL.addQueryFields("cardaddress","t6.address");
 
-        querySQL.setDistinct(true);
+        querySQL.addGroupBy("t4.agentnum,t5.contact,t5.phonenumber,t5.address,t6.cardno,t6.begdate" +
+                ",t6.enddate,t1.sku,t2.itemid,t2.itemno,t2.itemname,t2.model,t2.spec,t3.unitname,t6.name,t6.phonenumber,t6.address");
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 

+ 2 - 2
src/custom/restcontroller/webmanage/sale/sendplan/SQL/发货计划订单未发货量.sql

@@ -1,4 +1,4 @@
-select t1.sa_orderitemsid,t2.sa_orderid,t6.sa_agentsid,t5.enterprisename,t3.type,t3.billdate,t3.checkdate,t3.submitdate,t6.agentnum,t7.abbreviation,t4.marketingcategory,
+select t1.sa_orderitemsid,t2.itemid,t2.sa_orderid,t6.sa_agentsid,t5.enterprisename,t3.type,t3.billdate,t3.checkdate,t3.submitdate,t6.agentnum,t7.abbreviation,t4.marketingcategory,
        t3.sonum,t4.itemno,t4.itemname,t4.model,t4.spec,t1.undeliqty,t1.willoutqty,(t1.undeliqty-t1.willoutqty) sendqty,t4.outplace  from
     (select t.sa_orderitemsid,sum(t.undeliqty)undeliqty,sum(t.willoutqty)willoutqty from
         (select sa_orderitemsid,undeliqty,0 willoutqty  from sa_orderitems t1
@@ -16,4 +16,4 @@ select t1.sa_orderitemsid,t2.sa_orderid,t6.sa_agentsid,t5.enterprisename,t3.type
         inner join plm_item t4 on t2.itemid=t4.itemid
         left join sys_enterprise_finance t5 on t3.sys_enterprise_financeid=t5.sys_enterprise_financeid and t3.siteid=t5.siteid
         left join sa_agents t6 on t3.sys_enterpriseid=t6.sys_enterpriseid and t3.siteid=t6.siteid
-        left join sys_enterprise t7 on t3.sys_enterpriseid=t7.sys_enterpriseid and t3.siteid=t7.siteid where $where$;
+        left join sys_enterprise t7 on t3.sys_enterpriseid=t7.sys_enterpriseid and t3.siteid=t7.siteid where $where$ order by t2.itemid;

+ 100 - 1
src/custom/restcontroller/webmanage/sale/sendplan/sendplandetail.java

@@ -18,8 +18,107 @@ public class sendplandetail extends Controller {
     public sendplandetail(JSONObject content) throws YosException {
         super(content);
     }
+    //ID2025120110193103
+    @API(title = "订单信息刷新(新)", apiversion = R.ID2025032709331803.v1.class)
+    public String orderRefresh_new() throws YosException {
+        long sa_sendplanid = content.getLongValue("sa_sendplanid");
+        Rows sendplanRows = dbConnect.runSqlQuery("select * from sa_sendplan where sa_sendplanid='" + sa_sendplanid + "' and siteid='" + siteid + "'");
+        if (sendplanRows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("发货计划不存在,无法进行订单信息刷新").toString();
+        }
+        dbConnect.runSqlUpdate("delete from sa_sendplandetail where sa_sendplanid='" + sa_sendplanid + "' and siteid='" + siteid + "'");
+        /*
+          过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 and t1.undeliqty>0 and t3.type='" + sendplanRows.get(0).getString("type")
+                + "' and  DATE_FORMAT(t3.checkdate, '%Y-%m-%d') >='" + sendplanRows.get(0).getString("begindate")
+                + "' and  DATE_FORMAT(t3.checkdate, '%Y-%m-%d') <='" + sendplanRows.get(0).getString("enddate")
+                + "' and ( \n" +
+                "\t\t(t3.type in('标准订单','网销订单')) or\n" +
+                "\t\t(\n" +
+                "\t\t\tt3.type='配件订单'\n" +
+                "\t\t\tand t3.sys_enterpriseid in (\n" +
+                "\t\t\tselect distinct sys_enterpriseid from st_stockbill \n" +
+                "\t\t\twhere type='销售出库'  and status='审核' and \n" +
+                "\t\t\tbilldate= '" + sendplanRows.get(0).getString("senddate") + "'\n" +
+                "\t\t\t)\n" +
+                "\t\t))");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "发货计划订单未发货量");
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
 
-    @API(title = "订单信息刷新", apiversion = R.ID2025032709331803.v1.class)
+        Rows stockbillrows = dbConnect.runSqlQuery("select t2.itemid,sum(t2.undeliqty) qty from sa_order t1 " +
+                " inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid " +
+                " where t1.status='审核' and t2.isclose=0 and t2.undeliqty>0 and t1.siteid='" + siteid + "' " +
+                " group by t2.itemid ");
+        Rows invbalrows = dbConnect.runSqlQuery("select itemid,sum(qty) qty from st_invbal t1 group by itemid");
+
+        RowsMap stockbillrowsMap = stockbillrows.toRowsMap("itemid");
+        RowsMap invbalrowsMap = invbalrows.toRowsMap("itemid");
+
+        ArrayList<String> list = new ArrayList<>();
+        long olditemid=0;
+        BigDecimal oldcanuseqty=BigDecimal.ZERO;
+        BigDecimal oldsendqty=BigDecimal.ZERO;
+        for (Row row : rows) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_sendplandetail");
+            long sa_sendplandetailid=createTableID("sa_sendplandetailid");
+            insertSQL.setUniqueid(sa_sendplandetailid);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("sa_sendplanid", sa_sendplanid);
+            insertSQL.setValue("sa_orderid", row.getLong("sa_orderid"));
+            insertSQL.setValue("sa_orderitemsid", row.getLong("sa_orderitemsid"));
+            insertSQL.setValue("outplace", row.getString("outplace"));
+            insertSQL.setValue("sa_agentsid", row.getString("sa_agentsid"));
+
+            BigDecimal canuseqty = BigDecimal.ZERO;
+            BigDecimal willoutqty = BigDecimal.ZERO;
+            BigDecimal invbalqty = BigDecimal.ZERO;
+            BigDecimal sendqty = BigDecimal.ZERO;
+            if (stockbillrowsMap.containsKey(row.getString("itemid"))) {
+                willoutqty = stockbillrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
+            }
+            if (invbalrowsMap.containsKey(row.getString("itemid"))) {
+                invbalqty = invbalrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
+            }
+            canuseqty = invbalqty.subtract(willoutqty);
+
+            insertSQL.setValue("willoutqty", willoutqty);
+            insertSQL.setValue("willinqty", 0);
+            insertSQL.setValue("canuseqty", canuseqty);
+            if (canuseqty.compareTo(BigDecimal.ZERO) <= 0) {
+                insertSQL.setValue("sendqty", 0);
+                insertSQL.setValue("colorflag", 0);
+            } else {
+                sendqty=row.getBigDecimal("sendqty");
+                insertSQL.setValue("sendqty", sendqty);
+                if (canuseqty.compareTo(row.getBigDecimal("sendqty")) >= 0) {
+                    insertSQL.setValue("colorflag", 2);
+                } else {
+                    insertSQL.setValue("colorflag", 3);
+                }
+            }
+
+            if(row.getLong("itemid")==olditemid){
+                insertSQL.setValue("canuseqty", oldcanuseqty.subtract(oldsendqty));
+            }
+            olditemid=row.getLong("itemid");
+            oldcanuseqty=oldcanuseqty.subtract(oldsendqty);
+            oldsendqty=sendqty;
+            list.add(insertSQL.getSQL());
+        }
+        dbConnect.runSqlUpdate(list);
+        list = new ArrayList<>();
+        Rows rows1 = dbConnect.runSqlQuery("select t1.sa_orderid from (select sa_orderid,count(0)count from sa_sendplandetail where sa_sendplanid=" + sa_sendplanid + " group by sa_orderid) t1 inner join (select sa_orderid,count(0)count from sa_sendplandetail where colorflag='2' and  sa_sendplanid=" + sa_sendplanid + "  group by sa_orderid) t2 on  t1.sa_orderid=t2.sa_orderid and t1.count=t2.count");
+        for (Row row : rows1) {
+            list.add("update sa_sendplandetail set colorflag=1 where sa_sendplanid=" + sa_sendplanid + " and sa_orderid =" + row.getLong("sa_orderid"));
+        }
+        return getSucReturnObject().toString();
+    }
+    //ID2025032709331803
+    @API(title = "订单信息刷新", apiversion = R.ID2025120110193103.v1.class)
     @CACHEING_CLEAN(apiClass = {sendplandetail.class})
     public String orderRefresh() throws YosException {
         long sa_sendplanid = content.getLongValue("sa_sendplanid");

+ 2 - 0
src/custom/restcontroller/webmanage/sale/u8prodprice/u8prodprice.java

@@ -96,6 +96,8 @@ public class u8prodprice extends Controller {
         querySQL.setTableAlias("t1");
         querySQL.setSiteid(siteid);
         querySQL.setWhere("t1.sa_u8prodpriceid",sa_u8prodpriceid);
+        querySQL.addQueryFields("begindate","DATE(t1.begindate)");
+        querySQL.addQueryFields("enddate","DATE(t1.enddate)");
         Rows rows = querySQL.query();
         Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
         return getSucReturnObject().setData(row).toString();