Explorar o código

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

WuYi hai 15 horas
pai
achega
f6fd2f4d1f

+ 22 - 2
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/common/system/service/impl/NewsService.java

@@ -2,6 +2,7 @@ package com.lc.ibps.common.system.service.impl;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import javax.annotation.Resource;
 
@@ -104,10 +105,12 @@ public class NewsService implements INewsService {
 
 			} else {
 				// --- 情况 B:前端传了具体的用户ID列表 ---
+				boolean insertFlag = false;
 				// 遍历列表,为每个用户插入一条记录
 				for (String targetUserId : scopeUserIds) {
 					String insertSql= "";
-					if(targetUserId.length()>0){
+					if((!Objects.equals(targetUserId, "ALL"))&&(targetUserId.length()>0)){
+						insertFlag = true;
 						 insertSql = "INSERT INTO t_ggfwb (id_, create_by_, create_time_, gong_gao_id_, gong_gao_lei_xing, gong_gao_mu_biao_) " +
 								"VALUES ('%s', '%s', NOW(), '%s', '%s', '%s')";
 					} else {
@@ -120,7 +123,24 @@ public class NewsService implements INewsService {
 						insertSql = String.format(insertSql, id, currentUserId, newsId, newsType, targetUserId);
 						commonDao.execute(insertSql);
 					}
-
+				}
+				// 传具体范围增加当前用户
+				if(insertFlag){
+					// 如果当前用户不在列表中,则手动插入一条记录
+					boolean currentUserExists = false;
+					for (String uid : scopeUserIds) {
+						if (currentUserId.equals(uid)) {
+							currentUserExists = true;
+							break;
+						}
+					}
+					if (!currentUserExists) {
+						String creatorInsertSql = "INSERT INTO t_ggfwb (id_, create_by_, create_time_, gong_gao_id_, gong_gao_lei_xing, gong_gao_mu_biao_) " +
+								"VALUES ('%s', '%s', NOW(), '%s', '%s', '%s')";
+						String creatorId = UniqueIdUtil.getId();
+						creatorInsertSql = String.format(creatorInsertSql, creatorId, currentUserId, newsId, newsType, currentUserId);
+						commonDao.execute(creatorInsertSql);
+					}
 				}
 			}
 		} catch (Exception e){

+ 1 - 1
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/common/provider/NewsProvider.java

@@ -170,7 +170,7 @@ public class NewsProvider extends GenericProvider implements INewsService, INews
 			//使用 scopeUserIds 做业务逻辑
 			if (scopeUserIds != null && isTableExists) {
 				//暂定newsType为user,后期可扩展(user=用户, dept=部门, role=角色')
-				scopeUserIds.add(ContextUtil.getCurrentUserId()); //华创启德自己发的公告需要能自己也能看到
+				//scopeUserIds.add(ContextUtil.getCurrentUserId()); //华创启德自己发的公告需要能自己也能看到
 				newsService.saveNewsScope("user", scopeUserIds,newsId);
 			}
 

+ 22 - 2
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/EquipmentMaintenancePlanJob.java

@@ -14,6 +14,7 @@ import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
 import com.lc.ibps.org.party.persistence.dao.PartyUserCalendarDao;
 import com.lc.ibps.org.party.persistence.entity.PartyUserCalendarPo;
 import org.apache.commons.lang3.StringUtils;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.jetbrains.annotations.NotNull;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
@@ -35,6 +36,7 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
     private final PartyUserCalendarDao calendarDao = AppUtil.getBean(PartyUserCalendarDao.class);
     public static final String HS_DAY1 = "日保养";
     public static final String HS_DAY2 = "每天";
+    private static final int DEFAULT_ADVANCE_DAYS = 30;
 
     @Override
     public void executeJob(JobExecutionContext context) throws Exception {
@@ -404,13 +406,14 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
                 "WHERE b.shi_fou_guo_shen_ = '已完成' and a.ji_hua_ri_qi_<>'' and a.ji_hua_ri_qi_ is not null " +
                 "AND a.ji_hua_ri_qi_ <= DATE_ADD(CURDATE(), INTERVAL 30 DAY) AND a.ji_hua_ri_qi_>= CURRENT_DATE AND a.shi_fou_guo_shen_='待处理' " +
                 "AND (a.dsrw_ is null or a.dsrw_ ='') ";*/
+        int advanceDays = getAdvanceDays();//华创启德提前90天推送
         String sql = "UPDATE t_mjsbjdxzjhzb a " +
                 "JOIN t_mjsbjdxzjh b ON a.parent_id_ = b.id_ " +
                 "JOIN t_sbdj d ON a.she_bei_bian_hao_ = d.id_ " +
                 "SET a.marks_ = 'record' " +
                 "WHERE b.shi_fou_guo_shen_ = '已完成' " +
                 "  AND a.ji_hua_ri_qi_ <> '' AND a.ji_hua_ri_qi_ IS NOT NULL " +
-                "  AND a.ji_hua_ri_qi_ <= DATE_ADD(CURDATE(), INTERVAL 30 DAY) " +
+                "  AND a.ji_hua_ri_qi_ <= DATE_ADD(CURDATE(), INTERVAL "+advanceDays+" DAY) " +
                 "  AND a.ji_hua_ri_qi_ >= CURRENT_DATE " +
                 "  AND a.shi_fou_guo_shen_ = '待处理' " +
                 "  AND (a.dsrw_ IS NULL OR a.dsrw_ = '') " +
@@ -597,6 +600,7 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
                 "where b.shi_fou_guo_shen_='已完成' and a.marks_ = 'record' and a.ji_hua_ri_qi_<>'' and a.ji_hua_ri_qi_ is not null " +
                 " and a.ji_hua_ri_qi_<=DATE_ADD(CURDATE(),INTERVAL 30 DAY) and a.ji_hua_ri_qi_>=CURRENT_DATE and a.shi_fou_guo_shen_='待处理' " +
                 " AND (a.dsrw_ is null or a.dsrw_ ='') ";*/
+        int advanceDays = getAdvanceDays();
         String fetchSql = "SELECT a.id_ id_ " +
                 "FROM t_mjsbjdxzjhzb a " +
                 "INNER JOIN t_mjsbjdxzjh b ON a.parent_id_ = b.id_ " +
@@ -604,7 +608,7 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
                 "WHERE b.shi_fou_guo_shen_ = '已完成' " +
                 "  AND a.marks_ = 'record' " +
                 "  AND a.ji_hua_ri_qi_ <> '' AND a.ji_hua_ri_qi_ IS NOT NULL " +
-                "  AND a.ji_hua_ri_qi_ <= DATE_ADD(CURDATE(), INTERVAL 30 DAY) " +
+                "  AND a.ji_hua_ri_qi_ <= DATE_ADD(CURDATE(), INTERVAL "+advanceDays+" DAY) " +
                 "  AND a.ji_hua_ri_qi_ >= CURRENT_DATE " +
                 "  AND a.shi_fou_guo_shen_ = '待处理' " +
                 "  AND (a.dsrw_ IS NULL OR a.dsrw_ = '') " +
@@ -638,6 +642,22 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
         }
         return danWeiMingChen;
     }
+    private int getAdvanceDays() {
+        try {
+            String setting = ContextUtil.getSetting();
+            if (StringUtils.isNotEmpty(setting)) {
+                ObjectMapper objectMapper = new ObjectMapper();
+                Map<String, Object> map = objectMapper.readValue(setting, Map.class);
+                if (map != null && map.containsKey(ADVANCE_DAYS)) {
+                    return Integer.parseInt(map.get(ADVANCE_DAYS).toString());
+                }
+            }
+        } catch (Exception e) {
+            logger.warn("从setting中读取advance_days失败,使用默认值{}天", DEFAULT_ADVANCE_DAYS, e);
+        }
+        return DEFAULT_ADVANCE_DAYS;
+    }
+
     public String convertToSqlInFormat(String input) {
         String[] parts = input.split(",");
         String quoted = String.join("','", parts); // 用 ',' 连接