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

出入库单模块(审核反审核返利暂时没做)

hu 2 лет назад
Родитель
Сommit
6372a4d8b9

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

@@ -5004,6 +5004,30 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230719153803 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230719153903 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230719154003 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230719154103 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230719154203 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230719154303 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 17 - 2
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -24,7 +24,7 @@ public class stockbill extends Controller {
     public stockbill(JSONObject content) throws YosException {
         super(content);
     }
-    ArrayList<String> sqlList =new ArrayList<>();
+
     /**
      * 更新YOS销售出库单
      * @return
@@ -34,7 +34,7 @@ public class stockbill extends Controller {
     public String updateIcstockbill() throws YosException{
         String msg = "";
         int code = 1;
-
+        ArrayList<String> sqlList =new ArrayList<>();
         // 单据编号
         String fbillnum = content.getString("fbillnum");
         try {
@@ -127,11 +127,21 @@ public class stockbill extends Controller {
                 }
                //销售出库单审核逻辑待添加
 
+                SQLFactory sqlFactoryupdate = new SQLFactory(new stockbill(new JSONObject()), "出入库单审核");
+                sqlFactoryupdate.addParameter("siteid", "lsa");
+                sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
+                sqlFactoryupdate.addParameter("checkby", checkby);
+                sqlList.add(sqlFactoryupdate.getSQL());
             }else if (!stockbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(fstatus)) {
                 /**
                  * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
                  */
                 //销售出库单反审核逻辑待添加
+                SQLFactory sqlFactoryupdate = new SQLFactory(new stockbill(new JSONObject()), "出入库单反审核");
+                sqlFactoryupdate.addParameter("siteid", "lsa");
+                sqlFactoryupdate.addParameter("st_stockbillid", stockbillRows.get(0).getLong("st_stockbillid"));
+                sqlFactoryupdate.addParameter("checkby", "");
+                sqlList.add(sqlFactoryupdate.getSQL());
 
                 msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
                 code = 0;
@@ -140,6 +150,11 @@ public class stockbill extends Controller {
                  * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入销售出库单先反审核
                  */
                 //销售出库单反审核逻辑待添加
+                SQLFactory sqlFactoryupdate = new SQLFactory(new stockbill(new JSONObject()), "出入库单反审核");
+                sqlFactoryupdate.addParameter("siteid", "lsa");
+                sqlFactoryupdate.addParameter("st_stockbillid", stockbillRows.get(0).getLong("st_stockbillid"));
+                sqlFactoryupdate.addParameter("checkby", "");
+                sqlList.add(sqlFactoryupdate.getSQL());
 
             }
         } catch (Exception e) {

+ 8 - 0
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单列表查询.sql

@@ -0,0 +1,8 @@
+SELECT t1.*,
+       t2.enterprisename,
+       t2.abbreviation,
+       t2.phonenumber enterprisephonenumber
+FROM st_stockbill t1
+         LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
+    AND t1.siteid = t2.siteid
+      where siteid=$siteid$

+ 1 - 0
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单反审核.sql

@@ -0,0 +1 @@
+update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = $st_stockbillid$ and siteid=$siteid$

+ 1 - 0
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单审核.sql

@@ -0,0 +1 @@
+update st_stockbill set status='审核',checkby=$checkby$,checkdate=CURRENT_TIMESTAMP where st_stockbillid = $st_stockbillid$ and siteid=$siteid$

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

@@ -0,0 +1,16 @@
+SELECT t1.*,
+       t2.itemno item_itemno,
+       t2.itemname item_itemname,
+       t2.model item_model,
+       t2.spec item_spec,
+       t3.unitname,
+       t6.sonum
+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 t5 on t1.sa_orderitemsid=t5.sa_orderitemsid and t1.siteid=t5.siteid
+         left join sa_order t6 on t5.sa_orderid=t6.sa_orderid and t5.siteid=t6.siteid
+where $where$
+  and t1.siteid = $siteid$
+  and t1.st_stockbillid = $st_stockbillid$

+ 8 - 0
src/custom/restcontroller/webmanage/sale/stockbill/SQL/出入库单详情.sql

@@ -0,0 +1,8 @@
+SELECT t1.*,
+       t2.enterprisename,
+       t2.abbreviation,
+       t2.phonenumber enterprisephonenumber
+FROM st_stockbill t1
+         LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
+    AND t1.siteid = t2.siteid
+      where t1.siteid=$siteid$ and t1.st_stockbillid=$st_stockbillid$

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

@@ -0,0 +1,232 @@
+package restcontroller.webmanage.sale.stockbill;
+
+import beans.data.BatchDeleteErr;
+import beans.datacontrllog.DataContrlLog;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.annotation.CACHEING_CLEAN;
+import common.data.*;
+import restcontroller.R;
+
+import javax.swing.text.StyledEditorKit;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * 出入库单
+ */
+@API(title = "出入库单")
+public class stockbill extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public stockbill(JSONObject content) throws YosException {
+        super(content);
+    }
+    
+    @API(title = "出入库单详情", apiversion = R.ID20230719153803.v1.class)
+    @CACHEING
+    public String queryStockbillMain() throws YosException {
+        Long st_stockbillid = content.getLong("st_stockbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "出入库单详情");
+        sqlFactory.addParameter("st_stockbillid", st_stockbillid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
+
+        return getSucReturnObject().setData(row).toString();
+    }
+
+    @API(title = "查询出入库单列表", apiversion = R.ID20230719153903.v1.class)
+    @CACHEING
+    public String queryStockbillList() throws YosException {
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
+                where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
+            }
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+                where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
+            }
+            if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
+                where.append("and t1.remarks like'%").append(whereObject.getString("remarks")).append("%' ");
+            }
+
+            if (whereObject.containsKey("param") && !"".equals(whereObject.getString("param"))) {
+                Rows rowsStockbillid = dbConnect.runSqlQuery("select t1.st_stockbillid from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
+                        " where t1.siteid='" + siteid + "' and (t2.itemname like '%" + whereObject.getString("param") + "%' or t2.itemno like '%" + whereObject.getString("param") + "%')");
+
+                if (rowsStockbillid.toJsonArray("st_stockbillid").isEmpty()) {
+                    where.append(" and t1.st_stockbillid in (0)");
+                } else {
+                    String str = rowsStockbillid.toJsonArray("st_stockbillid").toJSONString();
+                    str = str.replace("[", "(").replace("]", ")");
+                    where.append(" and t1.st_stockbillid  in").append(str);
+                }
+
+
+            }
+        }
+//        SQLFactory sqlFactory = new SQLFactory(this, "出入库单列表查询", pageSize, pageNumber, pageSorting);
+//        sqlFactory.addParameter("siteid", siteid);
+//        sqlFactory.addParameter_SQL("where", where);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        QuerySQL querySQL = queryStockbillList(where.toString());
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    //查询出入库单列表
+    public QuerySQL queryStockbillList(String where) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
+                "enterprisename", "abbreviation");
+        querySQL.addQueryFields("enterprisephonenumber", "t2.phonenumber");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where);
+        return querySQL;
+    }
+
+ 
+
+    @API(title = "删除", apiversion = R.ID20230719154003.v1.class)
+    @CACHEING_CLEAN(apiClass = {stockbill.class})
+    public String delete() throws YosException {
+
+        JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
+        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbillids.size());
+        for (Object o : st_stockbillids) {
+            long st_stockbillid = Long.parseLong(o.toString());
+            Rows RowsStatus = dbConnect.runSqlQuery("select st_stockbillid,status from st_stockbill where siteid='"
+                    + siteid + "' and st_stockbillid='" + st_stockbillid + "'");
+
+            if (RowsStatus.isNotEmpty()) {
+                if (!RowsStatus.get(0).getString("status").equals("新建")) {
+                    batchDeleteErr.addErr(st_stockbillid, "非新建状态的出入库单无法删除");
+                    continue;
+                }
+            }
+
+            dbConnect.runSqlUpdate(
+                    "delete from st_stockbill where siteid='" + siteid + "' and st_stockbillid=" + st_stockbillid);
+        }
+        return batchDeleteErr.getReturnObject().toString();
+
+    }
+
+    @API(title = "审核", apiversion = R.ID20230719154103.v1.class)
+    @CACHEING_CLEAN(apiClass = {stockbill.class})
+    public String check() throws YosException {
+
+        Long st_stockbillid = content.getLong("st_stockbillid");
+        Rows rows = dbConnect.runSqlQuery("select st_stockbillid,status,billno from st_stockbill where st_stockbillid ='"
+                + st_stockbillid + "' and  siteid='" + siteid + "'");
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该出入库单不存在")
+                    .toString();
+        } else {
+            if (!rows.get(0).getString("status").equals("新建")) {
+                return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非新建状态,无法审核")
+                        .toString();
+            }
+        }
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单审核");
+        sqlFactoryupdate.addParameter("siteid", siteid);
+        sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
+        sqlFactoryupdate.addParameter("checkby", username);
+        sqlList.add(sqlFactoryupdate.getSQL());
+        sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "审核", "出入库单审核成功").getSQL());
+        dbConnect.runSqlUpdate(sqlList);
+
+        return getSucReturnObject().toString();
+
+    }
+
+
+    @API(title = "反审核", apiversion = R.ID20230719154203.v1.class)
+    @CACHEING_CLEAN(apiClass = {stockbill.class})
+    public String uncheck() throws YosException {
+        Long st_stockbillid = content.getLong("st_stockbillid");
+        Rows rows = dbConnect.runSqlQuery("select st_stockbillid,status,billno from st_stockbill where st_stockbillid ='"
+                + st_stockbillid + "' and  siteid='" + siteid + "'");
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该出入库单不存在")
+                    .toString();
+        } else {
+            if (!rows.get(0).getString("status").equals("审核")) {
+                return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非审核状态,无法反审核")
+                        .toString();
+            }
+        }
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+
+        SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单反审核");
+        sqlFactoryupdate.addParameter("siteid", siteid);
+        sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
+        sqlFactoryupdate.addParameter("checkby", username);
+        sqlList.add(sqlFactoryupdate.getSQL());
+        sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "反审核", "出入库单反审核成功").getSQL());
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+
+    @API(title = "出入库单明细列表", apiversion = R.ID20230719154303.v1.class)
+    @CACHEING
+    public String querStcokbillItemsList() throws YosException {
+        /*
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.spec like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        Long st_stockbillid = content.getLong("st_stockbillid");
+        SQLFactory sqlFactory = new SQLFactory(this, "出入库单明细列表查询", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("st_stockbillid", st_stockbillid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+
+    
+
+  
+}