|
|
@@ -1,6 +1,8 @@
|
|
|
package restcontroller.webmanage.saletool.sharematerial;
|
|
|
|
|
|
import beans.attachment.Attachment;
|
|
|
+import beans.parameter.Parameter;
|
|
|
+import beans.remind.Remind;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
|
@@ -8,6 +10,7 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
+import utility.email.EmailContent;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
@@ -84,7 +87,7 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
|
|
|
@API(title = "装备资源库详情", apiversion = R.ID20240407094602.v1.class)
|
|
|
public String detail() throws YosException {
|
|
|
-
|
|
|
+ String ownertable = "sat_sharematerial";
|
|
|
Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
|
|
|
QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial
|
|
|
@@ -132,6 +135,33 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
detailRow.put("dataauth", dataauthRows);
|
|
|
}
|
|
|
|
|
|
+ QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
|
|
|
+ attachmentQuery.setSiteid(siteid);
|
|
|
+ attachmentQuery.setWhere("ownertable", ownertable);
|
|
|
+ attachmentQuery.setWhere("ownerid", sat_sharematerialid);
|
|
|
+ attachmentQuery.setWhere("usetype", ownertable);
|
|
|
+ attachmentQuery.setOrderBy("t1.sequence");
|
|
|
+ System.err.println(attachmentQuery.getSQL());
|
|
|
+ Rows attachmentRows = attachmentQuery.query();
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<Long> ids = attachmentRows.toArrayList("attachmentid", new ArrayList<>());
|
|
|
+
|
|
|
+ RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
|
|
|
+
|
|
|
+ for (Row row : attachmentRows) {
|
|
|
+ Rows attPicRows = new Rows();
|
|
|
+ Rows tempAttRows = attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows());
|
|
|
+ for (Row tempAttRow : tempAttRows) {
|
|
|
+ if (tempAttRow.getString("usetype").equals(ownertable)) {
|
|
|
+ attPicRows.add(tempAttRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ row.put("attinfos", attPicRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ detailRow.put("attinfos_pic", attachmentRows);
|
|
|
+
|
|
|
|
|
|
return getSucReturnObject().setData(detailRow).toString();
|
|
|
}
|
|
|
@@ -202,6 +232,8 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ boolean isDataAuth = content.getBooleanValue("isDataAuth");
|
|
|
+
|
|
|
QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
|
|
|
"sat_sharematerialid", "title", "type", "status", "mailcount", "readcount", "downloadcount", "createdate", "checkdate", "sat_sharematerial_classids")
|
|
|
.setTableAlias("t1");
|
|
|
@@ -209,7 +241,9 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
sqlFactory.setWhere("classid", 3);
|
|
|
sqlFactory.setWhere(where.toString());
|
|
|
sqlFactory.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
|
|
|
- System.err.println(sqlFactory.getSQL());
|
|
|
+ if (isDataAuth) {
|
|
|
+ sqlFactory.setDataAuth(true);
|
|
|
+ }
|
|
|
Rows rows = sqlFactory.query();
|
|
|
|
|
|
ArrayList<Long> ids = rows.toArrayList("sat_sharematerialid", new ArrayList<>());
|
|
|
@@ -333,4 +367,35 @@ public class EquipmentResourceLibrary extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @API(title = "发送邮件", apiversion = R.ID20240408154702.v1.class)
|
|
|
+ public String sendMail() throws Exception {
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+ String email = content.getStringValue("email");
|
|
|
+
|
|
|
+ if (!Parameter.get(siteid, "remind_mail").equalsIgnoreCase("1")) {
|
|
|
+ return getErrReturnObject().setErrMsg("邮件功能未开启").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial where sat_sharematerialid=" + sat_sharematerialid);
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows rowsAtt = Attachment.get(this, "sat_sharematerial", sat_sharematerialid, "sat_sharematerial");
|
|
|
+
|
|
|
+ EmailContent emailContent = new EmailContent();
|
|
|
+ emailContent.addText(rows.get(0).getString("content"));
|
|
|
+ for (Row rowAtt : rowsAtt) {
|
|
|
+ emailContent.addFile(rowAtt.getString("url"));
|
|
|
+ }
|
|
|
+ Remind remind = new Remind(siteid);
|
|
|
+ remind.setTitle(rows.get(0).getString("title"));
|
|
|
+ remind.setToemail(email);
|
|
|
+ remind.setContent(emailContent);
|
|
|
+ remind.sendByMail();
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
}
|