Selaa lähdekoodia

发货单相关接口支持version

eganwu 2 vuotta sitten
vanhempi
commit
feb3b77f48

+ 24 - 2
src/custom/beans/dispatch/Dispatch.java

@@ -8,11 +8,12 @@ import common.YosException;
 import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
+import common.data.UpdateSQL;
 
 public class Dispatch {
 
-	
-	 /**
+
+    /**
      * 查询合同的签约价格
      *
      * @param controller
@@ -28,4 +29,25 @@ public class Dispatch {
         return rows.toRowsMap("sa_dispatchid");
     }
 
+    /**
+     * 通过版本更新发货单表头数据
+     *
+     * @param controller
+     * @throws YosException
+     */
+    public static void updateDispatchWithVersion(Controller controller) throws YosException {
+        if (controller.content.containsKey("sa_dispatch_v")) {
+            int sa_dispatch_v = controller.content.getIntValue("sa_dispatch_v");
+            Long sa_dispatchid = controller.content.getLong("sa_dispatchid");
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, "sa_dispatch");
+            updateSQL.setDataVersion(sa_dispatch_v);
+            updateSQL.setValue("changeby", controller.username);
+            updateSQL.setWhere("sa_dispatchid", sa_dispatchid);
+            updateSQL.setWhere("siteid", controller.siteid);
+            updateSQL.update();
+        }
+
+
+    }
+
 }

+ 1 - 1
src/custom/beans/order/Order.java

@@ -349,7 +349,7 @@ public class Order extends BaseClass {
     public static void updateOrderWithVersion(Controller controller) throws YosException {
         if (controller.content.containsKey("sa_order_v")) {
             int sa_order_v = controller.content.getIntValue("sa_order_v");
-            Long sa_orderid = controller.content.getLongValue("sa_orderid");
+            Long sa_orderid = controller.content.getLong("sa_orderid");
             UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, "sa_order");
             updateSQL.setDataVersion(sa_order_v);
             updateSQL.setValue("changeby", controller.username);

+ 1 - 0
src/custom/restcontroller/webmanage/sale/dispatch/SQL/发货单详情查询.sql

@@ -26,6 +26,7 @@ SELECT t1.billno,
        t1.closeby,
        t1.closedate,
        t1.billdate,
+       t1.sa_dispatch_v,
        t7.agentnum,
        t8.erpbillno,
        case when t3.type='项目订单' then t9.projectname else t3.projectnote end projectname

+ 26 - 12
src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

@@ -90,6 +90,8 @@ public class dispatch extends Controller {
                             + sa_dispatchid);
             if (rows.isNotEmpty()) {
                 if (rows.get(0).getString("status").equals("新建")) {
+                    //通过版本更新发货单表头数据
+                    Dispatch.updateDispatchWithVersion(this);
                     sqlFactory = new SQLFactory(this, "发货单更新");
                     if (sa_orderid <= 0) {
                         sqlFactory.addParameter("sa_orderid", rows.get(0).getLong("sa_orderid"));
@@ -239,14 +241,14 @@ public class dispatch extends Controller {
 
             if (whereObject.containsKey("sa_orderitemsid") && !"".equals(whereObject.getString("sa_orderitemsid"))) {
                 Rows rowsDispatchid = dbConnect.runSqlQuery("select t1.sa_dispatchid from sa_dispatch_items t1 left join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid " +
-                        " where t2.status !='新建' and t1.siteid='"+siteid+"' and t1.sa_orderitemsid ="+whereObject.getLong("sa_orderitemsid")+"");
+                        " where t2.status !='新建' and t1.siteid='" + siteid + "' and t1.sa_orderitemsid =" + whereObject.getLong("sa_orderitemsid") + "");
 
-                if(rowsDispatchid.toJsonArray("sa_dispatchid").isEmpty()){
+                if (rowsDispatchid.toJsonArray("sa_dispatchid").isEmpty()) {
                     where.append(" and t1.sa_dispatchid in (0)");
-                }else {
+                } else {
                     String str = rowsDispatchid.toJsonArray("sa_dispatchid").toJSONString();
                     str = str.replace("[", "(").replace("]", ")");
-                    where.append(" and t1.sa_dispatchid  in" ).append(str);
+                    where.append(" and t1.sa_dispatchid  in").append(str);
                 }
 
 
@@ -430,6 +432,9 @@ public class dispatch extends Controller {
     @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
     public String uncheck() throws YosException {
         Long sa_dispatchid = content.getLong("sa_dispatchid");
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
+
         Long sa_orderid = 0L;
         Rows rows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");
@@ -477,6 +482,8 @@ public class dispatch extends Controller {
     @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
     public String unclose() throws YosException {
         Long sa_dispatchid = content.getLong("sa_dispatchid");
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
         Long sa_orderid = 0L;
         Rows rows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");
@@ -522,7 +529,7 @@ public class dispatch extends Controller {
         String canCloseSainvoiceByHand = request.doPost(object1.toString(),
                 "http://60.190.151.198:8092/BYESB/jaxrs/webclientrest");
 
-        if(!canCloseSainvoiceByHand.equals("true")){
+        if (!canCloseSainvoiceByHand.equals("true")) {
             return getErrReturnObject().setErrMsg("中间表状态不为1,无法手工关闭")
                     .toString();
         }
@@ -584,7 +591,7 @@ public class dispatch extends Controller {
         contentfeek.put("billno", rows.get(0).getString("billno"));
         objectfeek.put("content", contentfeek);
 
-         request.doPost(objectfeek.toString(),
+        request.doPost(objectfeek.toString(),
                 "http://60.190.151.198:8092/BYESB/jaxrs/webclientrest");
 
         return getSucReturnObject().toString();
@@ -594,6 +601,9 @@ public class dispatch extends Controller {
     @API(title = "行关闭", apiversion = R.ID20230522093703.v1.class)
     @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
     public String closeRows() throws YosException {
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
+
         JSONArray sa_dispatch_itemsids = content.getJSONArray("sa_dispatch_itemsids");
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_dispatch_itemsids.size());
         String sql = "";
@@ -703,6 +713,9 @@ public class dispatch extends Controller {
     @API(title = "复核", apiversion = R.ID20221114135803.v1.class)
     @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
     public String recheck() throws YosException {
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
+
         Long sa_dispatchid = content.getLong("sa_dispatchid");
         Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");
@@ -739,16 +752,16 @@ public class dispatch extends Controller {
             if (rowsMapDispatchDetail.containsKey(jsonObject.getString("fitemno"))) {
                 if (rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).isNotEmpty()) {
                     rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("FQty"));
-                }else{
-                    rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).get(0).put("invbalqty",0);
+                } else {
+                    rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", 0);
                 }
             }
         }
 
         if (!rowsDispatchDetail.isEmpty()) {
             for (Row row : rowsDispatchDetail) {
-                System.out.println(Parameter.get(siteid,"dispatchinstock"));
-                 System.out.println(Parameter.get(siteid,"dispatchinstock").equals("1"));
+                System.out.println(Parameter.get(siteid, "dispatchinstock"));
+                System.out.println(Parameter.get(siteid, "dispatchinstock").equals("1"));
                 if (rowsMap.get(row.getString("sa_orderitemsid")).isEmpty()) {
                     return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细不存在对应得订单行,无法复核")
                             .toString();
@@ -758,7 +771,7 @@ public class dispatch extends Controller {
                             .toString();
                 }
 
-                if(Parameter.get(siteid,"dispatchinstock").equals("1")){
+                if (Parameter.get(siteid, "dispatchinstock").equals("1")) {
                     if (row.getBigDecimal("qty").compareTo(row.getBigDecimal("invbalqty")) > 0) {
                         return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的数量大于erp的库存数量,无法复核")
                                 .toString();
@@ -766,7 +779,6 @@ public class dispatch extends Controller {
                 }
 
 
-
                 sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").subtract(row.getBigDecimal("qty")) + ",deliedqty=" + (row.getBigDecimal("qty").add(rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
             }
         } else {
@@ -827,6 +839,8 @@ public class dispatch extends Controller {
     @API(title = "反复核", apiversion = R.ID20230720152503.v1.class)
     @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
     public String unrecheck() throws YosException {
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
         Long sa_dispatchid = content.getLong("sa_dispatchid");
         Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid,sys_enterpriseid from sa_dispatch where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");

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

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.sale.dispatch;
 
 import beans.data.BatchDeleteErr;
+import beans.dispatch.Dispatch;
 import beans.parameter.Parameter;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -123,6 +124,8 @@ public class dispatchItems extends Controller {
     @API(title = "新建或修改发货单商品明细", apiversion = R.ID20221115104603.v1.class,intervaltime = 200)
     @CACHEING_CLEAN(apiClass = {dispatchItems.class, dispatch.class})
     public String insertormodify_dispatchItems() throws YosException {
+        //通过版本更新发货单表头数据
+        Dispatch.updateDispatchWithVersion(this);
         Long sa_dispatchid = content.getLong("sa_dispatchid");
         JSONArray iteminfos = content.getJSONArray("iteminfos");
         ArrayList<String> sqlList = new ArrayList<>();