|
@@ -0,0 +1,218 @@
|
|
|
+package restcontroller.webmanage.saletool.sharematerial;
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 装备资源库
|
|
|
+ */
|
|
|
+public class EquipmentResourceLibrary extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public EquipmentResourceLibrary(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sat_sharematerial = "sat_sharematerial";
|
|
|
+
|
|
|
+ @API(title = "装备资源库新增或编辑", apiversion = R.ID20240407094502.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+
|
|
|
+ JSONArray sat_sharematerial_classids = new JSONArray();
|
|
|
+ if (content.containsKey("sat_sharematerial_classids")) {
|
|
|
+ sat_sharematerial_classids = content.getJSONArray("sat_sharematerial_classids");
|
|
|
+ for (Object obj : sat_sharematerial_classids) {
|
|
|
+ if (!(obj instanceof JSONArray)) {
|
|
|
+ return getErrReturnObject().setErrMsg("格式不正确,正确的为[[1,2,3]]").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sat_sharematerialid <= 0) {
|
|
|
+ sat_sharematerialid = createTableID(sat_sharematerial);
|
|
|
+ InsertSQL sqlFactory = SQLFactory.createInsertSQL(this, sat_sharematerial);
|
|
|
+ sqlFactory.setUniqueid(sat_sharematerialid);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("classid", 3);
|
|
|
+ sqlFactory.setValue("title", content.getStringValue("title"));
|
|
|
+ sqlFactory.setValue("sat_sharematerial_classids", sat_sharematerial_classids);
|
|
|
+ sqlFactory.setValue("type", content.getIntValue("type"));
|
|
|
+ sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ sqlFactory.setValue("isqrcode", content.getBooleanValue("isqrcode"));
|
|
|
+ sqlFactory.setValue("qrcodecontent", content.getStringValue("qrcodecontent", true));
|
|
|
+ sqlFactory.setValue("canshared_c", content.getBooleanValue("canshared_c"));
|
|
|
+ sqlFactory.setValue("candownload", content.getBooleanValue("candownload"));
|
|
|
+ sqlFactory.setValue("candownload_c", content.getBooleanValue("candownload_c"));
|
|
|
+
|
|
|
+ sqlFactory.insert();
|
|
|
+ content.put("sat_sharematerialid", sat_sharematerialid);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sat_sharematerialid > 0) {
|
|
|
+ UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(this, sat_sharematerial);
|
|
|
+ sqlFactory.setUniqueid(sat_sharematerialid);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("title", content.getStringValue("title"));
|
|
|
+ sqlFactory.setValue("sat_sharematerial_classids", sat_sharematerial_classids);
|
|
|
+ sqlFactory.setValue("type", content.getIntValue("type"));
|
|
|
+ sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ sqlFactory.setValue("isqrcode", content.getBooleanValue("isqrcode"));
|
|
|
+ sqlFactory.setValue("qrcodecontent", content.getStringValue("qrcodecontent", true));
|
|
|
+ sqlFactory.setValue("canshared_c", content.getBooleanValue("canshared_c"));
|
|
|
+ sqlFactory.setValue("candownload", content.getBooleanValue("candownload"));
|
|
|
+ sqlFactory.setValue("candownload_c", content.getBooleanValue("candownload_c"));
|
|
|
+
|
|
|
+ sqlFactory.update();
|
|
|
+ }
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "装备资源库详情", apiversion = R.ID20240407094602.v1.class)
|
|
|
+ public String detail() throws YosException {
|
|
|
+
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+
|
|
|
+ QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial
|
|
|
+ , "sat_sharematerialid", "type", "status", "sequence", "title", "canshared_c", "candownload_c", "candownload"
|
|
|
+ , "sat_sharematerial_classids", "mailcount", "canshared", "downloadcount", "isqrcode", "qrcodecontent", "sharecount", "readcount"
|
|
|
+ , "createby", "createdate", "checkby", "checkdate", "changeby", "changedate")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ sqlFactory.setUniqueid(sat_sharematerialid);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ Rows rows = sqlFactory.query();
|
|
|
+
|
|
|
+ Row detailRow = new Row();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ detailRow = rows.get(0);
|
|
|
+ Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
|
|
|
+ detailRow.put("attinfos", attRows);
|
|
|
+ detailRow.putIfAbsent("checkdate", "");
|
|
|
+ if (detailRow.getInteger("type") == 1) {
|
|
|
+ detailRow.put("typestr", "图片");
|
|
|
+ }
|
|
|
+ if (detailRow.getInteger("type") == 2) {
|
|
|
+ detailRow.put("typestr", "视频");
|
|
|
+ }
|
|
|
+ if (detailRow.getInteger("type") == 3) {
|
|
|
+ detailRow.put("typestr", "图文");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(detailRow).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "装备资源库列表", apiversion = R.ID20240407094702.v1.class)
|
|
|
+ public String list() 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.title like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("begindate_create") && !"".equals(whereObject.getString("begindate_create"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.createdate >='").append(whereObject.getString("begindate_create")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate_create") && !"".equals(whereObject.getString("enddate_create"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.createdate <='").append(whereObject.getString("enddate_create")).append(" 23:59:59' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("sat_sharematerial_classids") && !"".equals(whereObject.getString("sat_sharematerial_classids"))) {
|
|
|
+ JSONArray sat_courseware_classids = whereObject.getJSONArray("sat_sharematerial_classids");
|
|
|
+ if (sat_courseware_classids.size() > 0) {
|
|
|
+ where.append(" and (1=2");
|
|
|
+ for (Object obj : sat_courseware_classids) {
|
|
|
+ JSONArray array = (JSONArray) obj;
|
|
|
+ for (Object obj2 : array) {
|
|
|
+ where.append(" or (");
|
|
|
+ where.append("JSON_CONTAINS(t1.sat_sharematerial_classids,'" + obj2 + "')");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
|
|
|
+ "sat_sharematerialid", "title", "type", "status", "mailcount", "readcount", "downloadcount", "createdate", "checkdate")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setWhere("classid", 3);
|
|
|
+ sqlFactory.setWhere(where.toString());
|
|
|
+ sqlFactory.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
|
|
|
+ System.err.println(sqlFactory.getSQL());
|
|
|
+ Rows rows = sqlFactory.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sat_sharematerialid", new ArrayList<>());
|
|
|
+ // 附件
|
|
|
+ RowsMap RowsMap = getAttachmentUrl(sat_sharematerial, ids);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Rows Rows = RowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
|
|
|
+ row.put("attinfos", Rows);
|
|
|
+ row.putIfAbsent("checkdate", "");
|
|
|
+ if (row.getInteger("type") == 1) {
|
|
|
+ row.put("typestr", "图片");
|
|
|
+ }
|
|
|
+ if (row.getInteger("type") == 2) {
|
|
|
+ row.put("typestr", "视频");
|
|
|
+ }
|
|
|
+ if (row.getInteger("type") == 3) {
|
|
|
+ row.put("typestr", "图文");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|