|
@@ -0,0 +1,121 @@
|
|
|
+package restcontroller.webmanage.sale.reporttype;
|
|
|
+
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import beans.user.User;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.InsertSQL;
|
|
|
+import common.data.QuerySQL;
|
|
|
+import common.data.Rows;
|
|
|
+import common.data.SQLFactory;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+@API(title = "报表分类")
|
|
|
+public class ReportType extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public ReportType(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "授权报表中心应用的报表查询", apiversion = R.ID20240407094904.v1.class)
|
|
|
+ public String queryReport() throws YosException {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_report", "sys_reportid");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "jimu_report", "t2", "t1.jimu_report_id = t2.id");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_reporttype", "t3", "t1.sys_reportid = t3.sys_reportid and t3.siteid='" + siteid + "'");
|
|
|
+ querySQL.setWhere("t1.systemappid=" + 163 + " and (ifnull(t1.siteid,'')='' or t1.siteid = '" + siteid + "')");
|
|
|
+ querySQL.addQueryFields("name", "if(t1.reporttype = '积木报表', t2.name, t1.name)");
|
|
|
+ querySQL.addQueryFields("type", "group_concat(t3.type separator ',')");
|
|
|
+ querySQL.addGroupBy("t1.sys_reportid", "t1.name", "t2.name");
|
|
|
+ querySQL.setWhere("((t1.reporttype = '积木报表' and t2.id is not null) or (t1.reporttype != '积木报表'))");
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows query = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(query).toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "设置报表分类", apiversion = R.ID20240407095004.v1.class)
|
|
|
+ public String updateReportType() throws YosException {
|
|
|
+ Long sys_reportid = content.getLong("sys_reportid");
|
|
|
+ JSONArray types = content.getJSONArray("types");
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+
|
|
|
+ long[] sys_reporttypes = createTableID("sys_reporttype", types.size());
|
|
|
+ int i = 0;
|
|
|
+ if (dbConnect.runSqlQuery("select 1 from sys_reporttype where siteid='" + siteid + "' and sys_reportid=" + sys_reportid).isNotEmpty()) {
|
|
|
+ sqlList.add("delete from sys_reporttype where siteid='" + siteid + "' and sys_reportid=" + sys_reportid);
|
|
|
+ }
|
|
|
+ for (Object o : types) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_reporttype");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("type", o);
|
|
|
+ insertSQL.setValue("sys_reporttypeid", sys_reporttypes[i]);
|
|
|
+ insertSQL.setValue("sys_reportid", sys_reportid);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sys_report", sys_reportid, "编辑", "设置分类" + types).getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询报表已授权分类", apiversion = R.ID20240407095104.v1.class)
|
|
|
+ public String queryReportType() throws YosException {
|
|
|
+ Long sys_reportid = content.getLong("sys_reportid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_reporttype", "sys_reporttypeid", "type", "sys_reportid");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_reportid", sys_reportid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows query = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(query).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "报表已授权分类删除", apiversion = R.ID20240407095204.v1.class)
|
|
|
+ public String deleteReportType() throws YosException {
|
|
|
+ Long sys_reportid = content.getLong("sys_reportid");
|
|
|
+ JSONArray sys_reporttypeids = content.getJSONArray("sys_reporttypeids");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ if (!sys_reporttypeids.isEmpty()) {
|
|
|
+ String replace = sys_reporttypeids.toString().replace("[", "(").replace("]", ")");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select type from sys_reporttype where sys_reporttypeid in " + replace);
|
|
|
+ sqlList.add("delete from sys_reporttype where siteid='" + siteid + "' and sys_reporttypeid in " + replace);
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sys_report", sys_reportid, "删除", "删除分类" + rows.toArrayList("type")).getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "已授权报表分类查询", apiversion = R.ID20240407094804.v1.class)
|
|
|
+ public String queryType() throws YosException {
|
|
|
+ if (userInfo.isSiteAdministrator() || userInfo.isSysAdministrator()) {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select distinct type from sys_reporttype where siteid = '" + siteid + "'");
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+ Rows userroleRows = dbConnect.runSqlQuery("select roleid from sys_userrole where siteid='" + siteid + "' and userid=" + userid);
|
|
|
+ if (userroleRows.isNotEmpty()) {
|
|
|
+ String roleids = userroleRows.toArrayList("roleid").toString().replace("[", "(").replace("]", ")");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_reporttype", "type");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("exists(select 1 from sys_rolereportauth t2 where t1.siteid=t2.siteid and t1.sys_reportid=t2.sys_reportid and t2.roleid in" + roleids + ")");
|
|
|
+ querySQL.addGroupBy("type");
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows query = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(query).toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(new Rows()).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|