Преглед изворни кода

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

hu пре 2 година
родитељ
комит
41d7e064a3

BIN
out/artifacts/yos/yos.war


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

@@ -5354,6 +5354,22 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20231201144302 {
+        public static class v1 {
+        }
+    }
+    public static class ID20231201145402 {
+        public static class v1 {
+        }
+    }
+    public static class ID20231201145502 {
+        public static class v1 {
+        }
+    }
+    public static class ID20231201153702 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 141 - 0
src/custom/restcontroller/webmanage/role/RoleOptionLimit.java

@@ -0,0 +1,141 @@
+package restcontroller.webmanage.role;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+
+import java.util.ArrayList;
+
+/**
+ * 用户角色选项权限-sys_role_optionlimit
+ */
+public class RoleOptionLimit extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public RoleOptionLimit(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "角色选项权限-新增或更新", apiversion = R.ID20231201144302.v1.class)
+    public String insertOrUpdate() throws YosException {
+
+        Long optiontypeid = content.getLongValue("optiontypeid");
+        Long roleid = content.getLongValue("roleid");
+        JSONArray values = content.getJSONArray("values");
+
+        if (optiontypeid <= 0) {
+            return getErrReturnObject().setErrMsg("请选择分类项").toString();
+        }
+        if (roleid <= 0) {
+            return getErrReturnObject().setErrMsg("请选择角色").toString();
+        }
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        for (Object obj : values) {
+            String value = obj.toString();
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_role_optionlimit");
+            insertSQL.setUniqueid(createTableID("sys_role_optionlimit"));
+            insertSQL.setValue("roleid", roleid);
+            insertSQL.setValue("optiontypeid", optiontypeid);
+            insertSQL.setValue("value", value);
+            insertSQL.setWhere("not exists(select 1 from  sys_role_optionlimit where roleid=" + roleid + " and optiontypeid=" + optiontypeid + " and value='" + value + "' )");
+            sqlList.add(insertSQL.getSQL());
+        }
+        String deleteSql = "DELETE from sys_role_optionlimit WHERE roleid=" + roleid + " and optiontypeid=" + optiontypeid;
+        if (values.size() > 0) {
+            deleteSql = deleteSql + " and value not in " + values;
+        }
+        sqlList.add(deleteSql.replace("[", "(").replace("]", ")"));
+
+        dbConnect.runSqlUpdate(sqlList);
+
+
+        return detail();
+    }
+
+    @API(title = "角色选项权限-删除", apiversion = R.ID20231201145402.v1.class)
+    public String delete() throws YosException {
+
+        Long optiontypeid = content.getLongValue("optiontypeid");
+        Long roleid = content.getLongValue("roleid");
+        String deleteSql = "DELETE from sys_role_optionlimit WHERE optiontypeid = " + optiontypeid + " and roleid=" + roleid + "";
+        dbConnect.runSqlUpdate(deleteSql);
+
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "角色选项权限-列表", apiversion = R.ID20231201145502.v1.class)
+    public String list() throws YosException {
+        Long roleid = content.getLongValue("roleid");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "角色选项限制查询列表", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("roleid", roleid);
+        Rows rows = sqlFactory.runSqlQuery(dbConnect);
+
+        RowsMap optiontypemxMap = new RowsMap();
+
+        if (rows.isNotEmpty()) {
+            String sql = "SELECT distinct optiontypeid,value from sys_optiontypemx WHERE optiontypeid in " + rows.toArrayList("optiontypeid");
+            optiontypemxMap = dbConnect.runSqlQuery(sql.replace("[", "(").replace("]", ")")).toRowsMap("optiontypeid");
+        }
+
+        for (Row row : rows) {
+            Rows optiontypemxRows = optiontypemxMap.getOrDefault(row.getString("optiontypeid"), new Rows());
+//            for (Row optiontypemxRow : optiontypemxRows) {
+//                optiontypemxRow.putIfAbsent("subvalues", new JSONArray());
+//            }
+
+//            row.put("optiontypemxall", optiontypemxRows);
+            row.put("optiontypemx", optiontypemxRows.toArray("value"));
+            Long optiontypeid = row.getLong("optiontypeid");
+            Rows valuerows = dbConnect.runSqlQuery("SELECT `value` from sys_role_optionlimit WHERE roleid=" + roleid + " and optiontypeid=" + optiontypeid);
+            row.put("values", valuerows.toArray("value"));
+        }
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "详细", apiversion = R.ID20231201153702.v1.class)
+    public String detail() throws YosException {
+        Long optiontypeid = content.getLongValue("optiontypeid");
+        Long roleid = content.getLongValue("roleid");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "角色选项限制查询详情");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("optiontypeid", optiontypeid);
+        sqlFactory.addParameter("roleid", roleid);
+        Rows rows = sqlFactory.runSqlQuery(dbConnect);
+        if (rows.isEmpty()) {
+            return getSucReturnObject().setData(new Row()).toString();
+        }
+
+        String sql = "SELECT distinct optiontypeid,value from sys_optiontypemx WHERE optiontypeid in " + rows.toArrayList("optiontypeid");
+        RowsMap optiontypemxMap = dbConnect.runSqlQuery(sql.replace("[", "(").replace("]", ")")).toRowsMap("optiontypeid");
+
+        for (Row row : rows) {
+            Rows optiontypemxRows = optiontypemxMap.getOrDefault(row.getString("optiontypeid"), new Rows());
+//            for (Row optiontypemxRow : optiontypemxRows) {
+//                optiontypemxRow.putIfAbsent("subvalues", new JSONArray());
+//            }
+//            row.put("optiontypemxall", optiontypemxRows);
+            row.put("optiontypemx", optiontypemxRows.toArray("value"));
+
+            Rows valuerows = dbConnect.runSqlQuery("SELECT `value` from sys_role_optionlimit WHERE roleid=" + roleid + " and optiontypeid=" + optiontypeid);
+            row.put("values", valuerows.toArray("value"));
+        }
+
+
+        return getSucReturnObject().setData(rows.get(0)).toString();
+    }
+}

+ 9 - 0
src/custom/restcontroller/webmanage/role/SQL/角色选项限制查询列表.sql

@@ -0,0 +1,9 @@
+SELECT t1.*
+from (
+         SELECT DISTINCT t1.roleid, t1.optiontypeid, t2.remarks optionttypename, t3.rolename
+         from sys_role_optionlimit t1
+                  LEFT JOIN sys_optiontype t2 ON t2.optiontypeid = t1.optiontypeid
+                  LEFT JOIN sys_role t3 ON t3.roleid = t1.roleid
+         where t3.siteid = $siteid$
+           and t1.roleid = $roleid$
+     ) t1

+ 7 - 0
src/custom/restcontroller/webmanage/role/SQL/角色选项限制查询详情.sql

@@ -0,0 +1,7 @@
+SELECT DISTINCT t1.roleid, t1.optiontypeid, t2.remarks optionttypename, t3.rolename
+from sys_role_optionlimit t1
+         LEFT JOIN sys_optiontype t2 ON t2.optiontypeid = t1.optiontypeid
+         LEFT JOIN sys_role t3 ON t3.roleid = t1.roleid
+where t3.siteid = $siteid$
+  and t1.roleid = $roleid$
+  and t1.optiontypeid = $optiontypeid$

+ 50 - 37
src/custom/restcontroller/webmanage/sale/dispatch/dispatchItems.java

@@ -133,8 +133,6 @@ 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<>();
@@ -158,41 +156,56 @@ public class dispatchItems extends Controller {
                     .runSqlQuery("select sa_dispatch_itemsid from sa_dispatch_items where sa_dispatch_itemsid="
                             + iteminfo.getLong("sa_dispatch_itemsid"))
                     .isEmpty()) {
-                Rows sa_dispatch_itemsrows = dbConnect.runSqlQuery("select sa_dispatch_itemsid,qty,remarks from sa_dispatch_items where sa_dispatchid="
-                        + sa_dispatchid + " and sa_orderitemsid=" + iteminfo.getLong("sa_orderitemsid"));
-                if (!sa_dispatch_itemsrows.isEmpty()) {
-                    SQLFactory saleFactory = new SQLFactory(this, "发货单明细更新");
-                    saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsrows.get(0).getLong("sa_dispatch_itemsid"));
-                    // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
-                    saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty").add(sa_dispatch_itemsrows.get(0).getBigDecimal("qty")));
-                    if (!StringUtils.isBlank(iteminfo.getString("remarks"))) {
-                        saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
-                    } else {
-                        saleFactory.addParameter("remarks", sa_dispatch_itemsrows.get(0).getString("remarks"));
-                    }
-
-                    saleFactory.addParameter("userid", userid);
-                    saleFactory.addParameter("username", username);
-                    saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
-                    saleFactory.addParameter("batchno", iteminfo.getStringValue("batchno"));
-                    sqlList.add(saleFactory.getSQL());
-                } else {
-                    SQLFactory saleFactory = new SQLFactory(this, "发货单明细新增");
-                    saleFactory.addParameter("siteid", siteid);
-                    saleFactory.addParameter("rowno", maxid + i + 1);
-                    saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsid[i]);
-                    saleFactory.addParameter("sa_dispatchid", sa_dispatchid);
-                    saleFactory.addParameter("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
-                    saleFactory.addParameter("itemid", iteminfo.getString("itemid"));
-                    saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
-                    saleFactory.addParameter("batchcontrol", iteminfo.getBooleanValue("batchcontrol"));
-                    saleFactory.addParameter("batchno", "");
-                    saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
-                    saleFactory.addParameter("userid", userid);
-                    saleFactory.addParameter("username", username);
-                    saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
-                    sqlList.add(saleFactory.getSQL());
-                }
+//                Rows sa_dispatch_itemsrows = dbConnect.runSqlQuery("select sa_dispatch_itemsid,qty,remarks from sa_dispatch_items where sa_dispatchid="
+//                        + sa_dispatchid + " and sa_orderitemsid=" + iteminfo.getLong("sa_orderitemsid"));
+//                if (!sa_dispatch_itemsrows.isEmpty()) {
+//                    SQLFactory saleFactory = new SQLFactory(this, "发货单明细更新");
+//                    saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsrows.get(0).getLong("sa_dispatch_itemsid"));
+//                    // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
+//                    saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty").add(sa_dispatch_itemsrows.get(0).getBigDecimal("qty")));
+//                    if (!StringUtils.isBlank(iteminfo.getString("remarks"))) {
+//                        saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
+//                    } else {
+//                        saleFactory.addParameter("remarks", sa_dispatch_itemsrows.get(0).getString("remarks"));
+//                    }
+//
+//                    saleFactory.addParameter("userid", userid);
+//                    saleFactory.addParameter("username", username);
+//                    saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
+//                    saleFactory.addParameter("batchno", iteminfo.getStringValue("batchno"));
+//                    sqlList.add(saleFactory.getSQL());
+//                } else {
+//                    SQLFactory saleFactory = new SQLFactory(this, "发货单明细新增");
+//                    saleFactory.addParameter("siteid", siteid);
+//                    saleFactory.addParameter("rowno", maxid + i + 1);
+//                    saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsid[i]);
+//                    saleFactory.addParameter("sa_dispatchid", sa_dispatchid);
+//                    saleFactory.addParameter("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
+//                    saleFactory.addParameter("itemid", iteminfo.getString("itemid"));
+//                    saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
+//                    saleFactory.addParameter("batchcontrol", iteminfo.getBooleanValue("batchcontrol"));
+//                    saleFactory.addParameter("batchno", "");
+//                    saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
+//                    saleFactory.addParameter("userid", userid);
+//                    saleFactory.addParameter("username", username);
+//                    saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
+//                    sqlList.add(saleFactory.getSQL());
+//                }
+                SQLFactory saleFactory = new SQLFactory(this, "发货单明细新增");
+                saleFactory.addParameter("siteid", siteid);
+                saleFactory.addParameter("rowno", maxid + i + 1);
+                saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsid[i]);
+                saleFactory.addParameter("sa_dispatchid", sa_dispatchid);
+                saleFactory.addParameter("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
+                saleFactory.addParameter("itemid", iteminfo.getString("itemid"));
+                saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
+                saleFactory.addParameter("batchcontrol", iteminfo.getBooleanValue("batchcontrol"));
+                saleFactory.addParameter("batchno", "");
+                saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
+                saleFactory.addParameter("userid", userid);
+                saleFactory.addParameter("username", username);
+                saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
+                sqlList.add(saleFactory.getSQL());
                 i++;
             } else {
                 SQLFactory saleFactory = new SQLFactory(this, "发货单明细更新");