浏览代码

物料账户选择物料商品,发货单新增逻辑调整

eganwu 1 年之前
父节点
当前提交
945167dad2

+ 16 - 3
src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

@@ -63,6 +63,19 @@ public class dispatch extends Controller {
         SQLFactory sqlFactory = new SQLFactory(this, "发货单新增");
 
         if (sa_dispatchid <= 0) {
+
+            Rows rows = dbConnect.runSqlQuery("SELECT * from sa_dispatch WHERE sys_enterpriseid=" + content.getLong("sys_enterpriseid") + " and status='新建' and sa_orderid='" + sa_orderid + "' and siteid='" + siteid + "'");
+
+            if (rows.isNotEmpty()) {
+                sa_dispatchid = rows.get(0).getLong("sa_dispatchid");
+//                content.put("sa_dispatchid", sa_dispatchid);
+                Row row = new Row();
+                row.put("sa_dispatchid", sa_dispatchid);
+                row.put("error", "该订单号已存在新建的发货单");
+                return getErrReturnObject().setErrMsg(row.toString()).toString();
+            }
+
+
             sa_dispatchid = createTableID(tableName);
             Rows rowsinfo = dbConnect
                     .runSqlQuery("select contactsid from sys_enterprise_contacts where workaddress=1 and sys_enterpriseid="
@@ -513,7 +526,7 @@ public class dispatch extends Controller {
             }
         }
         //对接erp生成erp发货单
-        if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") ) {
+        if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
             ERPDocking erpDocking = new ERPDocking(siteid);
             String result = erpDocking.closeErpSainvoice(rows.get(0).getString("billno"), true, this, sa_dispatchid);
             if (!result.equals("true")) {
@@ -617,7 +630,7 @@ public class dispatch extends Controller {
         Rows sumcountRows = dbConnect.runSqlQuery("select count(1) sumcount from sa_dispatch_items where sa_dispatchid=" + rows.get(0).getLong("sa_dispatchid") + " and siteid='" + siteid + "'");
         Rows closecountRows = dbConnect.runSqlQuery("select  count(1) closecount from sa_dispatch_items where sa_dispatchid=" + rows.get(0).getLong("sa_dispatchid") + " and siteid='" + siteid + "' and isclose=1");
         if (sumcountRows.get(0).getLong("sumcount") == closecountRows.get(0).getLong("closecount")) {
-            if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") ) {
+            if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
                 ERPDocking erpDocking = new ERPDocking(siteid);
                 String result = erpDocking.closeErpSainvoice(rows.get(0).getString("billno"), true, this, rows.get(0).getLong("sa_dispatchid"));
                 if (!result.equals("true")) {
@@ -748,7 +761,7 @@ public class dispatch extends Controller {
             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") ) {
+        if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
             ERPDocking erpDocking = new ERPDocking(siteid);
             String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
             if (!result.equals("true")) {

+ 21 - 7
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -95,8 +95,8 @@ public class OrderItems extends Controller {
             if (sa_orderitemsid <= 0) {
                 //获取定制属性
                 customproperties = orderItemsHelper.getCustomProperties(itemRowsMap, item);
-                if(itemRow.getString("iscustomsize").equals("1")&&customproperties.isEmpty()){
-                    return getErrReturnObject().setErrMsg(itemRow.getString("itemno")+"的定制信息为空,无法添加").toString();
+                if (itemRow.getString("iscustomsize").equals("1") && customproperties.isEmpty()) {
+                    return getErrReturnObject().setErrMsg(itemRow.getString("itemno") + "的定制信息为空,无法添加").toString();
                 }
 
                 spec = orderItemsHelper.getCustomSpec(itemRowsMap, item);
@@ -546,7 +546,7 @@ public class OrderItems extends Controller {
         if (orderRows.isNotEmpty()) {
             sys_enterpriseid = orderRows.get(0).getLong("sys_enterpriseid");
         }
-        Long sa_promotionid=orderRows.get(0).getLong("sa_promotionid");
+        Long sa_promotionid = orderRows.get(0).getLong("sa_promotionid");
 //        boolean isExport = content.getBooleanValue("isExport");
 //        SQLFactory sqlFactory = new SQLFactory(this, "订单商品明细_列表", pageSize, pageNumber, pageSorting);
 //        if (isExport) {
@@ -560,11 +560,11 @@ public class OrderItems extends Controller {
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems");
         querySQL.addJoinTable(JOINTYPE.left, "st_invbal_sale", "t2", "t2.siteid = t1.siteid AND t2.itemid = t1.itemid");
         querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t3.itemid = t1.itemid and t3.siteid = t1.siteid",
-                "orderminqty_auxunit",  "orderaddqty_auxunit",  "spec", "iscustomsize", "widthschemeid", "lengthschemeid", "standards", "k3outcode");
+                "orderminqty_auxunit", "orderaddqty_auxunit", "spec", "iscustomsize", "widthschemeid", "lengthschemeid", "standards", "k3outcode");
 //        querySQL.addJoinTable(JOINTYPE.left, "plm_itemextend", "t4", "t4.itemid = t1.itemid and t4.siteid = t1.siteid",
 //                "erpitemno", "erpitemname", "material", "prodline", "device", "specalnote");
-        querySQL.addJoinTable(JOINTYPE.left,"sa_promotion_items","t4",
-                "t4.itemid = t1.itemid and t4.siteid = t1.siteid and t4.sa_promotionid="+sa_promotionid);
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_items", "t4",
+                "t4.itemid = t1.itemid and t4.siteid = t1.siteid and t4.sa_promotionid=" + sa_promotionid);
 
         querySQL.addQueryFields("candispatchqty", "ifnull(t2.candispatchqty, 0)");
         querySQL.addQueryFields("cansaleqty", "ifnull(t2.cansaleqty, 0)");
@@ -643,7 +643,7 @@ public class OrderItems extends Controller {
                 if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
                     if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
                         for (Row row : rowsMap.get(jsonObject.getString("fitemno"))
-                             ) {
+                        ) {
                             row.put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
                         }
                     }
@@ -1062,13 +1062,24 @@ public class OrderItems extends Controller {
         String type = "";
         String typemx = "";
         Long sys_enterpriseid = 0L;
+        JSONArray sa_accountclassinfos = new JSONArray();
         if (orderRows.isNotEmpty()) {
             sa_brandid = orderRows.get(0).getLong("sa_brandid");
             tradefield = orderRows.get(0).getString("tradefield");
             type = orderRows.get(0).getString("type");
             typemx = orderRows.get(0).getString("typemx");
             sys_enterpriseid = orderRows.get(0).getLong("sys_enterpriseid");
+            sa_accountclassinfos = orderRows.get(0).getJSONArray("sa_accountclassinfos");
+        }
+        boolean iswuliao = false;
+        for (Object sa_accountclassinfo : sa_accountclassinfos) {
+            JSONObject jsonObject = (JSONObject) sa_accountclassinfo;
+            if (jsonObject.getString("accountname").equals("物料账户")) {
+                iswuliao = true;
+            }
         }
+
+
         SQLFactory sqlFactory = new SQLFactory(this, "查询可添加商品列表", pageSize, pageNumber, pageSorting);
         switch (type) {
 //            case "总部订单":
@@ -1098,6 +1109,9 @@ public class OrderItems extends Controller {
                 sqlFactory.addParameter_SQL("where2", where2);
                 break;
         }
+        if(iswuliao){
+            where.append(" and t1.iswuliao ='1' ");
+        }
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter_SQL("where", where);
         String sql = sqlFactory.getSQL(false);