From 733ab25766c994654699b83cd739e6b5670dd3b3 Mon Sep 17 00:00:00 2001
From: 354798ggg <1074825718@qq.com>
Date: 星期五, 30 六月 2023 16:49:18 +0800
Subject: [PATCH] 更改公告所属包
---
src/main/java/com/product/administration/service/AnnouncementService.java | 238 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 238 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/product/administration/service/AnnouncementService.java b/src/main/java/com/product/administration/service/AnnouncementService.java
new file mode 100644
index 0000000..1990dfa
--- /dev/null
+++ b/src/main/java/com/product/administration/service/AnnouncementService.java
@@ -0,0 +1,238 @@
+package com.product.administration.service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.alibaba.druid.util.StringUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.product.administration.config.CmnConst;
+import com.product.core.config.CoreConst;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldMetaEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.core.service.support.QueryFilterService;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.core.websocket.service.WebsocketMesssageServiceThread;
+import com.product.util.BaseUtil;
+
+@Component
+public class AnnouncementService extends AbstractBaseService {
+ @Autowired
+ public QueryFilterService queryFilterService;
+ @Autowired
+ public BaseDao baseDao;
+ private final String COOPERATE_URL = "16209107146651641w21286";
+
+ public String addAnnouncement(FieldSetEntity fse) throws BaseException {
+ fse.setValue("publish_status", 0);
+ fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ return baseDao.add(fse);
+ }
+
+ public boolean releaseAnnouncement(FieldSetEntity fse) throws BaseException {
+ fse.setValue("publish_status", 1);
+ int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+ String user_name = SpringMVCContextHolder.getCurrentUser().getUser_name();
+ fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ String[] extentArr = fse.getString("extent").split(",");
+ DataTableEntity dt = new DataTableEntity();
+ for (int i = 0; i < extentArr.length; i++) {
+ FieldSetEntity fs = new FieldSetEntity();
+ FieldMetaEntity metaEntity = new FieldMetaEntity();
+ metaEntity.setTableName(new Object[]{CmnConst.product_oa_ANNOUNCEMENT_ROLE});
+ fs.setMeta(metaEntity);
+ fs.setValue("user_id", extentArr[i]);
+ fs.setValue("status", 0);
+ fs.setValue("announcement_uuid", fse.getString("uuid"));
+ dt.addFieldSetEntity(fs);
+ }
+ fse.addSubDataTable(dt);
+ String uuid = "";
+ if (StringUtils.isEmpty(fse.getUUID())) {
+ uuid = baseDao.add(fse);
+ } else {
+ boolean update = baseDao.update(fse);
+ if (update) {
+ uuid = fse.getUUID();
+ }
+ }
+ WebsocketMesssageServiceThread.getInstance().appendMessage(fse.getString("extent"), "[鍏憡]" + user_name + "鍙戝竷浜嗐��" + fse.getString("title") + "銆嬪叕鍛�", "[鍏憡]" + user_name + "鍙戝竷浜嗐��" + fse.getString("title") + "銆嬪叕鍛�",
+ user_id, "1", COOPERATE_URL + "?" + CoreConst.UUID + "=" + uuid + "&news=1", CmnConst.product_oa_ANNOUNCEMENT, fse.getUUID(), user_id, 0, 0);
+
+ return !StringUtils.isEmpty(uuid);
+ }
+
+ public boolean remindAnnouncement(FieldSetEntity fs) throws BaseException {
+ FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.product_oa_ANNOUNCEMENT, fs.getUUID(), false);
+ String user_name = SpringMVCContextHolder.getCurrentUser().getUser_name();
+ int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+ WebsocketMesssageServiceThread.getInstance().appendMessage(fs.getString("extent"), "[鍏憡]" + user_name + "鎻愰啋浣犳煡鐪嬪叕鍛娿��" + fse.getString("title") + "銆�", "[鍏憡]" + user_name + "鎻愰啋浣犳煡鐪嬪叕鍛娿��" + fse.getString("title") + "銆�",
+ user_id, "1", COOPERATE_URL + "?" + CoreConst.UUID + "=" + fs.getUUID() + "&news=1", CmnConst.product_oa_ANNOUNCEMENT, fse.getUUID(), user_id, 0, 0);
+
+ return !StringUtils.isEmpty(fs.getUUID());
+ }
+
+ public boolean updateAnnouncement(FieldSetEntity fse) throws BaseException {
+ fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
+ return baseDao.update(fse);
+ }
+
+ public FieldSetEntity getAnnouncement(FieldSetEntity fse) throws BaseException {
+ return baseDao.getFieldSetEntity(CmnConst.product_oa_ANNOUNCEMENT, fse.getString("uuid"), false);
+ }
+
+ public DataTableEntity listAnnouncement(FieldSetEntity fse) throws BaseException {
+ String queryFilter = "";
+ if (!BaseUtil.dataTableIsEmpty(fse.getSubDataTable("systemSeniorQueryString"))) {
+ queryFilter = " and " + queryFilterService.getQueryFilter(fse);
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT, "publish_status=0 " + queryFilter, new Object[]{},
+ new Object[]{}, " created_utc_datetime desc ", fse.getInteger("pagesize"), fse.getInteger("cpage"));
+ baseDao.loadPromptData(dt);
+ return dt;
+ }
+
+ public DataTableEntity listAnnouncementRelease(FieldSetEntity fse) throws BaseException {
+ String queryFilter = "";
+ if (!BaseUtil.dataTableIsEmpty(fse.getSubDataTable("systemSeniorQueryString"))) {
+ queryFilter = " and " + queryFilterService.getQueryFilter(fse);
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT, "publish_status=1" + queryFilter, new Object[]{},
+ new Object[]{}, " created_utc_datetime desc ", fse.getInteger("pagesize"), fse.getInteger("cpage"));
+ baseDao.loadPromptData(dt);
+ return dt;
+ }
+
+ public DataTableEntity listAnnouncementReceive(FieldSetEntity fse) throws BaseException {
+ String queryFilter = "";
+ if (!BaseUtil.dataTableIsEmpty(fse.getSubDataTable("systemSeniorQueryString"))) {
+ queryFilter = " and " + queryFilterService.getQueryFilter(fse);
+ }
+ int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+ String id = "," + user_id + ",";
+ String type = "";
+ if (!StringUtils.isEmpty(fse.getString("type"))) {
+ type = " and type='" + fse.getString("type") + "'";
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT,
+ "publish_status=1 and concat(',',extent,',') like '%" + id + "%'" + type + queryFilter, new Object[]{},
+ new Object[]{}, CmnConst.CREATED_UTC_DATETIME + " desc", fse.getInteger("pagesize"), fse.getInteger("cpage"));
+ baseDao.loadPromptData(dt);
+
+ return dt;
+ }
+
+ public JSONArray treeAnnouncementType(FieldSetEntity fse) throws BaseException {
+
+ //灏佽鍏憡绫诲埆鏍戠粨鏋�
+ DataTableEntity dictDt = baseDao.listTable(CmnConst.PRODUCT_SYS_DICT, "dict_name='" + CmnConst.ANNOUNCEMENT_TYPE + "'");
+ JSONArray menus = new JSONArray();
+ JSONObject parent_menu = new JSONObject();
+ parent_menu.put("dict_label", "鍏憡绫诲埆");
+ parent_menu.put("dict_value", "0");
+ JSONArray sub = new JSONArray();
+ for (int i = 0; i < dictDt.getRows(); i++) {
+ FieldSetEntity fs = dictDt.getFieldSetEntity(i);
+ JSONObject submen = BaseUtil.fieldSetEntityToJson(fs);
+ sub.add(submen);
+ }
+ parent_menu.put("children", sub);
+ menus.add(parent_menu);
+ return menus;
+ }
+// public DataTableEntity announcementRoleList(FieldSetEntity fse) throws BaseException {
+// int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+// String id = "," + user_id + ",";
+// DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT,
+// "WHERE concat(',',extent,',') like '%" + id + "%'");
+// baseDao.loadPromptData(dt);
+// return dt;
+// }
+
+ public boolean delAnnouncement(FieldSetEntity fse) throws BaseException {
+ String[] uuid = fse.getString("uuid").split(",");
+ return baseDao.delete(CmnConst.product_oa_ANNOUNCEMENT, uuid);
+ }
+
+ public FieldSetEntity findAnnouncement(FieldSetEntity fse) throws BaseException {
+// FieldSetEntity fs = baseDao.getFieldSetEntity(CmnConst.product_oa_ANNOUNCEMENT, fse.getString("uuid"), false);
+ String sqlfs = "SELECT *,(SELECT user_name FROM " + CmnConst.PRODUCT_SYS_USERS + " WHERE user_id=a.created_by)created_by_save,(SELECT user_name FROM " + CmnConst.PRODUCT_SYS_USERS + " WHERE user_id=a.updated_by)updated_by_save from " + CmnConst.product_oa_ANNOUNCEMENT + " a WHERE uuid=?";
+ FieldSetEntity fs = baseDao.getFieldSetEntityBySQL(sqlfs, new String[]{fse.getString("uuid")}, false);
+ String sql = "SELECT b.user_id user_id,b.show_name show_name,c.org_level_name,a.status FROM " + CmnConst.product_oa_ANNOUNCEMENT_ROLE + " a LEFT JOIN product_sys_staffs b on a.user_id=b.user_id LEFT JOIN product_sys_org_levels c on b.dept_uuid=c.uuid WHERE a.announcement_uuid=?";
+ DataTableEntity dt = baseDao.listTable(sql, new String[]{fs.getUUID()});
+ fs.addSubDataTable(dt);
+ fs.setValue("number", dt.getRows());
+ int a = 0;
+ for (int i = 0; i < dt.getRows(); i++) {
+ if (dt.getInt(i, "status") == 1) {
+ a++;
+ }
+ }
+ fs.setValue("readNum", a);
+ return fs;
+ }
+
+ public boolean readAnnouncementRemind(FieldSetEntity fs) throws BaseException {
+ FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.product_oa_ANNOUNCEMENT, fs.getUUID(), false);
+ String expiration_date = fse.getString("expiration_date");
+
+ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
+ String current_time = tempDate.format(new Date());
+ int compareTo = 0;
+ if (expiration_date != null) {
+ compareTo = current_time.compareTo(expiration_date);
+ }
+ String user_name = SpringMVCContextHolder.getCurrentUser().getUser_name();
+ int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+ if (compareTo <= 0 && fse.getInteger("status") == 1) {
+ WebsocketMesssageServiceThread.getInstance().appendMessage(fse.getString("created_by"), "[鎻愰啋]" + user_name + "宸茶浜嗐��" + fse.getString("title") + "銆嬪叕鍛�", "[鎻愰啋]" + user_name + "宸茶浜嗐��" + fse.getString("title") + "銆嬪叕鍛�",
+ user_id, "1", null, null, null, user_id, 0, 0);
+ }
+ return baseDao.executeUpdate("update product_oa_announcement_role set status=1 where user_id=? and announcement_uuid=?",
+ new String[]{"" + user_id, fse.getString("uuid")});
+
+ }
+
+ public DataTableEntity listAnnouncementGateway(FieldSetEntity fs) throws BaseException {
+ //褰撳墠浜簎uid
+ int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
+ String id = "," + user_id + ",";
+ DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT,
+ "publish_status=1 and concat(',',extent,',') like '%" + id + "%'", new Object[]{},
+ new Object[]{}, CmnConst.CREATED_UTC_DATETIME + " desc", 5, 1);
+ baseDao.loadPromptData(dt);
+// DataTableEntity dt = baseDao.listTable(CmnConst.product_oa_ANNOUNCEMENT, "publish_status=1 and created_by=?", new Object[]{user_id}, new Object[]{}, CmnConst.CREATED_UTC_DATETIME + " desc", 5, 1);
+// baseDao.loadPromptData(dt);
+ return dt;
+ }
+// public static String emojiConvert1(String str)
+// throws UnsupportedEncodingException {
+// String patternString = "([\\x{10000}-\\x{10ffff}\ud800-\udfff])";
+// Pattern pattern = Pattern.compile(patternString);
+// Matcher matcher = pattern.matcher(str);
+// StringBuffer sb = new StringBuffer();
+// while(matcher.find()) {
+// try {
+// matcher.appendReplacement(
+// sb,
+// "[["
+// + URLEncoder.encode(matcher.group(1),
+// "UTF-8") + "]]");
+// } catch(UnsupportedEncodingException e) {
+// throw e;
+// }
+// }
+// matcher.appendTail(sb);
+// return sb.toString();
+// }
+}
--
Gitblit v1.9.2