Bläddra i källkod

Merge remote-tracking branch 'origin/develop' into develop

shenjingwei 3 dagar sedan
förälder
incheckning
874a2bac52

+ 1 - 1
src/custom/beans/stockbill/bills/BasicBill.java

@@ -289,7 +289,7 @@ public abstract class BasicBill {
                     saItemsku.setValue("sys_enterpriseid", null);
                 }
             } else {
-                saItemsku.setValue("stockid", "");
+                saItemsku.setValue("stockid", 0);
                 if (issale) {
                     saItemsku.setValue("status", "售出");
                     saItemsku.setValue("sys_enterpriseid", billRow.getLong("sys_enterpriseid"));

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

@@ -6791,6 +6791,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025102215584903 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 3 - 1
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单明细列表查询(红).sql

@@ -7,7 +7,8 @@ SELECT t1.*,
        t2.icminqty,
        t2.topclassnum,
        t3.unitname,
-       t7.sonum
+       t7.sonum,
+       t8.stockname
 FROM st_stockbill_items t1
          left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
          LEFT JOIN plm_unit t3 ON t3.unitid = t2.unitid AND t3.siteid = t2.siteid
@@ -15,6 +16,7 @@ FROM st_stockbill_items t1
          left join sa_aftersalesmag_items t5 on t1.sa_dispatch_itemsid=t5.sa_aftersalesmag_itemsid and t1.siteid=t5.siteid
          left join sa_orderitems t6 on t6.sa_orderitemsid=t5.sa_orderitemsid and t6.siteid=t5.siteid
          left join sa_order t7 on t6.sa_orderid=t7.sa_orderid and t6.siteid=t7.siteid
+         left join st_stock t8 on t8.stockid=t1.stockid and t8.siteid=t1.siteid
 where $where$
   and t1.siteid = $siteid$
   and t1.st_stockbillid = $st_stockbillid$

+ 4 - 2
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单明细列表查询.sql

@@ -2,18 +2,20 @@ SELECT t1.*,
        t2.itemno item_itemno,
        t2.itemname item_itemname,
        t2.model item_model,
-       t2.spec item_spec,
+       t2.spec,
        t2.icaddqty,
        t2.icminqty,
        t2.topclassnum,
        t3.unitname,
-       t7.sonum
+       t7.sonum,
+       t8.stockname
 FROM st_stockbill_items t1
          left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
          LEFT JOIN plm_unit t3 ON t3.unitid = t2.unitid AND t3.siteid = t2.siteid
          LEFT JOIN st_stockbill t4 ON t4.st_stockbillid = t1.st_stockbillid AND t4.siteid = t1.siteid
          left join sa_orderitems t6 on t6.sa_orderitemsid=t1.sa_orderitemsid and t6.siteid=t1.siteid
          left join sa_order t7 on t6.sa_orderid=t7.sa_orderid and t6.siteid=t7.siteid
+         left join st_stock t8 on t8.stockid=t1.stockid and t8.siteid=t1.siteid
 where $where$
   and t1.siteid = $siteid$
   and t1.st_stockbillid = $st_stockbillid$

+ 49 - 4
src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

@@ -16,7 +16,6 @@ import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.*;
 import org.apache.commons.lang.StringUtils;
-import org.apache.poi.hssf.record.DVALRecord;
 import restcontroller.R;
 import restcontroller.webmanage.sale.order.Order;
 import restcontroller.webmanage.sale.order.OrderItems;
@@ -309,6 +308,10 @@ public class stockbill extends Controller {
             querySQL.addJoinTable(JOINTYPE.left, "st_dbstockbill", "t9", "t1.sourceid=t9.st_dbstockbillid and t1.siteid = t9.siteid and t1.sourceobject='st_dbstockbill'");
             querySQL.addQueryFields("dbbillno", "t9.billno");
         }
+        if (billtypes.contains("返修出库")) {
+            querySQL.addJoinTable(JOINTYPE.left, "sa_sendrepair", "t10", "t10.sourceid=t1.st_stockbillid and t10.siteid = t1.siteid and t10.sourcetable='st_stockbill'","instockdate");
+        }
+
 
 
         querySQL.setWhere("t1.siteid", siteid);
@@ -318,6 +321,8 @@ public class stockbill extends Controller {
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 
+
+
         ArrayList<Long> ids = rows.toArrayList("st_stockbillid", new ArrayList<>());
         HashMap<Long, Integer> reportMap =Report.getViewCount(this,"st_stockbill",ids);
         for(Row row :rows){
@@ -325,6 +330,19 @@ public class stockbill extends Controller {
                 row.put("printcount",reportMap.get(row.getLong("st_stockbillid")));
             }
         }
+        if(billtypes.contains("返修出库")){
+            QuerySQL querySQLDatail = SQLFactory.createQuerySQL(this, "st_stockbill_items", "st_stockbillid").setTableAlias("t1");
+            querySQLDatail.addJoinTable(JOINTYPE.left, "st_stockbill_items_sku", "t2", "t1.st_stockbill_itemsid=t2.st_stockbill_itemsid and t1.siteid = t2.siteid ","sku");
+            querySQLDatail.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t3.itemid=t1.itemid and t3.siteid = t1.siteid ","itemno","itemname","spec","model");
+            querySQLDatail.setWhere("t1.st_stockbillid",ids);
+            Rows rowsdatail = querySQLDatail.query();
+            RowsMap rowsdatailMap = rowsdatail.toRowsMap("st_stockbillid");
+            for(Row row :rows){
+                if(rowsdatailMap.containsKey(row.getString("st_stockbillid"))){
+                    row.put("itemskus",rowsdatailMap.get(row.getString("st_stockbillid")));
+                }
+            }
+        }
 
         return getSucReturnObject().setData(rows).toString();
     }
@@ -884,8 +902,7 @@ public class stockbill extends Controller {
                 if (skustockid == 0 && stockid == 0) {
                     return getErrReturnObject().setErrMsg("请指定仓库").toString();
                 }
-                if (st_stockbill.getString("status").equals("审核")
-                        && !stockbillitemsrows.toRowsMap("skucontrol").get("1").toRowsMap("itemid").containsKey(
+                if (!stockbillitemsrows.toRowsMap("skucontrol").get("1").toRowsMap("itemid").containsKey(
                         skuRowsMap.get(FMACHINECODE).get(0).getString("itemid"))) {
                     return getErrReturnObject().setErrMsg("序列号所属的商品编号没有包含在单据表体中").toString();
                 }
@@ -913,6 +930,11 @@ public class stockbill extends Controller {
                         : skuRowsMap.get(FMACHINECODE).get(0).getString("stockno");
                 Rows stockrows = dbConnect.runSqlQuery("select *from st_stock where stockno='" + stockno + "'");
 
+
+                if(st_stockbill_itemsid>0 && dbConnect.runSqlQuery("select 1 from where st_stockbill_items_sku where st_stockbillid=st_stockbill_itemsid and st_stockbillid="+st_stockbillid).size()>0){
+                    scanqtyrefresh();
+                }
+
                 InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
                 long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
                 insertSQL.setUniqueid(st_stockbill_items_skuid);
@@ -923,11 +945,13 @@ public class stockbill extends Controller {
                 if (stockid == 0) {
                     skustockid = st_stockbill.getLong("stockid");
                 }
+
+
                 insertSQL.setValue("stockid", skustockid);
                 insertSQL.setValue("itemid", skuitemid);
                 insertSQL.setValue("sku", FMACHINECODE);
                 insertSQL.setValue("st_stockbillid", st_stockbillid);
-                insertSQL.setValue("st_stockbill_itemsid", st_stockbill_itemsid);
+                insertSQL.setValue("st_stockbill_itemsid", st_stockbill_itemsid==0?st_stockbillid:st_stockbill_itemsid);
                 sqllist.add(insertSQL.getSQL());
                 if (st_stockbill.getString("status").equals("审核")) {
                     if (isinstock(st_stockbill.getString("type"), st_stockbill.getString("rb"), true)) {
@@ -952,6 +976,27 @@ public class stockbill extends Controller {
         return getSucReturnObject().toString();
     }
 
+    @API(title = "扫描数量刷新", apiversion = R.ID2025102215584903.v1.class)
+    @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, stockbillitemssku.class})
+    public String scanqtyrefresh() throws YosException {
+        long st_stockbillid = content.getLong("st_stockbillid");
+        ArrayList<String> sqllist = new ArrayList<>();
+        Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t2.itemid,t1.st_stockbill_items_skuid from  st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku  where t1.st_stockbillid=t1.st_stockbill_itemsid and t1.st_stockbillid="+st_stockbillid);
+        Rows stockbilldetailRows = dbConnect.runSqlQuery("select t1.itemid,t1.st_stockbill_itemsid from st_stockbill_items t1 where t1.st_stockbillid="+st_stockbillid);
+        RowsMap stockbilldetailRowsMap = stockbilldetailRows.toRowsMap("itemid");
+        for(Row row :stockbillskuRows){
+            String itemid = row.getString("itemid");
+            long st_stockbill_items_skuid =row.getLong("st_stockbill_items_skuid");
+            if(stockbilldetailRowsMap.containsKey(itemid)){
+                sqllist.add("update st_stockbill_items_sku set st_stockbill_itemsid="+stockbilldetailRowsMap.get(itemid).get(0).getLong("st_stockbill_itemsid")+" where st_stockbill_items_skuid="+st_stockbill_items_skuid);
+            }
+        }
+
+        dbConnect.runSqlUpdate(sqllist);
+
+        return getSucReturnObject().toString();
+    }
+
 
     @API(title = "更新站点信息详情详情", apiversion = R.ID20230720143503.v1.class)
     public String updateParameterSiteInfo() throws YosException {

+ 10 - 0
src/custom/restcontroller/webmanage/sale/stockbill/stockbillitems.java

@@ -275,6 +275,16 @@ public class stockbillitems extends Controller {
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 
+        Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t1.st_stockbill_itemsid from  st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku  where t1.st_stockbillid!=t1.st_stockbill_itemsid and t1.st_stockbillid="+st_stockbillid);
+        RowsMap stockbillskuRowsMap = stockbillskuRows.toRowsMap("st_stockbill_itemsid");
+        for(Row row :rows){
+            if(stockbillskuRowsMap.containsKey(row.getString("st_stockbill_itemsid"))){
+                row.put("scanqty",stockbillskuRowsMap.get(row.getString("st_stockbill_itemsid")).size());
+            }else{
+                row.put("scanqty",0);
+            }
+        }
+
         return getSucReturnObject().setData(rows).toString();
     }