Browse Source

发货单同步

hu 1 year ago
parent
commit
8e31884df4
1 changed files with 28 additions and 28 deletions
  1. 28 28
      src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

+ 28 - 28
src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

@@ -812,39 +812,39 @@ public class dispatch extends Controller {
 //
         Rows rows = dbConnect.runSqlQuery("select t1.*,t3.agentnum,t2.enterprisename,t4.sonum,t5.name,t5.phonenumber,t5.address from sa_dispatch t1 left join sys_enterprise t2  on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid left join sa_order t4 on t1.sa_orderid=t4.sa_orderid and t1.siteid=t4.siteid left join sys_enterprise_contacts t5 on t1.rec_contactsid=t5.contactsid and t1.siteid=t5.siteid where t1.sa_dispatchid ='"
                 + sa_dispatchid + "' and  t1.siteid='" + siteid + "'");
-//        Rows rowsdetail = dbConnect.runSqlQuery("select t3.sonum,t2.rowno sorowno,t4.itemno,t1.batchno,t1.rowno,t1.qty,t2.price,t1.remarks from sa_dispatch_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid  where t1.sa_dispatchid ='"
-//                + sa_dispatchid + "' and  t1.siteid='" + siteid + "'");
+        Rows rowsdetail = dbConnect.runSqlQuery("select t3.sonum,t2.rowno sorowno,t4.itemno,t1.batchno,t1.rowno,t1.qty,t2.price,t1.remarks from sa_dispatch_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid  where t1.sa_dispatchid ='"
+                + sa_dispatchid + "' and  t1.siteid='" + siteid + "'");
         SQLFactory sqlFactoryupdate = new SQLFactory(this, "发货单复核");
-//        Rows orderRows = dbConnect.runSqlQuery("select distinct t1.sa_orderid from sa_orderitems t1 inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='" + siteid + "' and t2.sa_dispatchid=" + sa_dispatchid);
-//        if (orderRows.size() == 1) {
-//            sqlList.add("update sa_dispatch set sa_orderid=" + orderRows.get(0).getLong("sa_orderid") + " where siteid='" + siteid + "' and sa_dispatchid=" + sa_dispatchid);
-//        }
+        Rows orderRows = dbConnect.runSqlQuery("select distinct t1.sa_orderid from sa_orderitems t1 inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='" + siteid + "' and t2.sa_dispatchid=" + sa_dispatchid);
+        if (orderRows.size() == 1) {
+            sqlList.add("update sa_dispatch set sa_orderid=" + orderRows.get(0).getLong("sa_orderid") + " where siteid='" + siteid + "' and sa_dispatchid=" + sa_dispatchid);
+        }
 
 
         //对接erp生成erp发货单
-//        if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
-//            ERPDocking erpDocking = new ERPDocking();
-//            String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
-//            if (!result.equals("true")) {
-//                System.out.println(result);
-//                return getErrReturnObject().setErrMsg(result).toString();
-//            }
-//        }
+        if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
+            ERPDocking erpDocking = new ERPDocking();
+             result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
+            if (!result.equals("true")) {
+                System.out.println(result);
+                return getErrReturnObject().setErrMsg(result).toString();
+            }
+        }
 
-//            //判断当前订单是否已发完货,如果发完,则生把订单变为关闭状态
-//            //总数量
-//            Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
-//            RowsMap totalRowsMap=totalRows.toRowsMap("sa_orderid");
-//            //已发完数量
-//            Rows deliRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where undeliqty=0 and siteid='" + siteid + "' group by sa_orderid");
-//            RowsMap deliRowsMap=deliRows.toRowsMap("sa_orderid");
-//            for (Row row:orderRows) {
-//                if(totalRowsMap.containsKey(row.getString("sa_orderid")) && deliRowsMap.containsKey(row.getString("sa_orderid"))){
-//                    if (totalRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count") ==deliRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count")) {
-//                        dbConnect.runSqlUpdate("update sa_order set status='关闭' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
-//                    }
-//                }
-//            }
+            //判断当前订单是否已发完货,如果发完,则生把订单变为关闭状态
+            //总数量
+            Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
+            RowsMap totalRowsMap=totalRows.toRowsMap("sa_orderid");
+            //已发完数量
+            Rows deliRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where undeliqty=0 and siteid='" + siteid + "' group by sa_orderid");
+            RowsMap deliRowsMap=deliRows.toRowsMap("sa_orderid");
+            for (Row row:orderRows) {
+                if(totalRowsMap.containsKey(row.getString("sa_orderid")) && deliRowsMap.containsKey(row.getString("sa_orderid"))){
+                    if (totalRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count") ==deliRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count")) {
+                        dbConnect.runSqlUpdate("update sa_order set status='关闭' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
+                    }
+                }
+            }
         Executor.sendEml(this, "dispatchreccheck", sa_dispatchid, siteid);
         sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "复核", "发货单复核成功").getSQL());