yonge há 5 anos atrás
pai
commit
3e1225f475

+ 2 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/AuthServerApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages="com.ym.mec")
 @ComponentScan(basePackages="com.ym.mec")
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class AuthServerApplication {
 public class AuthServerApplication {
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMessageConfig.java

@@ -49,6 +49,8 @@ public class SysMessageConfig {
 
 
 	/** 跳转url */
 	/** 跳转url */
 	private String url;
 	private String url;
+	
+	private String group;
 
 
 	public void setId(Integer id) {
 	public void setId(Integer id) {
 		this.id = id;
 		this.id = id;
@@ -98,6 +100,14 @@ public class SysMessageConfig {
 		return this.url;
 		return this.url;
 	}
 	}
 
 
+	public String getGroup() {
+		return group;
+	}
+
+	public void setGroup(String group) {
+		this.group = group;
+	}
+
 	@Override
 	@Override
 	public String toString() {
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 		return ToStringBuilder.reflectionToString(this);

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/SysMessageService.java

@@ -23,10 +23,11 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param errorMsg 错误消息
 	 * @param errorMsg 错误消息
 	 * @param readStatus 阅读状态
 	 * @param readStatus 阅读状态
 	 * @param memo 备注
 	 * @param memo 备注
+	 * @param group 消息组
 	 * @return
 	 * @return
 	 */
 	 */
 	public int addMessage(Integer userId, String subject, String content, String receivers, Date triggerTime, MessageSendMode mode, SendStatusEnum status,
 	public int addMessage(Integer userId, String subject, String content, String receivers, Date triggerTime, MessageSendMode mode, SendStatusEnum status,
-			String errorMsg, Integer readStatus, String memo);
+			String errorMsg, Integer readStatus, String memo, String group);
 
 
 	/**
 	/**
 	 * 修改消息对象
 	 * 修改消息对象
@@ -54,14 +55,14 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param userId 用户编号
 	 * @param userId 用户编号
 	 * @param mode 消息模式
 	 * @param mode 消息模式
 	 * @param messageType 消息类型
 	 * @param messageType 消息类型
-	 * @param receiver 消息接受者
+	 * @param receivers 消息接受者(多个用户用逗号分隔)
 	 * @param triggerTime 触发时间
 	 * @param triggerTime 触发时间
 	 * @param readStatus 阅读状态(0-未读  1-已读)
 	 * @param readStatus 阅读状态(0-未读  1-已读)
 	 * @param url 超链接地址
 	 * @param url 超链接地址
 	 * @param args 参数
 	 * @param args 参数
 	 * @return
 	 * @return
 	 */
 	 */
-	public void sendMessage(MessageSender messageSender, Integer userId, MessageSendMode mode, MessageType messageType, String receiver, Date triggerTime,
+	public void sendMessage(MessageSender messageSender, Integer userId, MessageSendMode mode, MessageType messageType, String receivers, Date triggerTime,
 			Integer readStatus, String url, Object... args);
 			Integer readStatus, String url, Object... args);
 
 
 	/**
 	/**

+ 14 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -47,9 +47,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 
 	@Autowired
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
 	private SysUserFeignService sysUserFeignService;
-	
+
 	@Autowired
 	@Autowired
-	private RedisCache<String,Object> redisCache;
+	private RedisCache<String, Object> redisCache;
 
 
 	// 验证码有效期
 	// 验证码有效期
 	public static final int CODE_EXPIRE = 60 * 5;
 	public static final int CODE_EXPIRE = 60 * 5;
@@ -69,7 +69,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 
 	@Override
 	@Override
 	public int addMessage(Integer userId, String subject, String content, String receivers, Date triggerTime, MessageSendMode mode, SendStatusEnum status,
 	public int addMessage(Integer userId, String subject, String content, String receivers, Date triggerTime, MessageSendMode mode, SendStatusEnum status,
-			String errorMsg, Integer readStatus, String memo) {
+			String errorMsg, Integer readStatus, String memo, String group) {
 		SysMessage message = null;
 		SysMessage message = null;
 		Date date = new Date();
 		Date date = new Date();
 
 
@@ -99,6 +99,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				message.setErrorMsg(errorMsg);
 				message.setErrorMsg(errorMsg);
 				message.setReadStatus(readStatus);
 				message.setReadStatus(readStatus);
 				message.setMemo(memo);
 				message.setMemo(memo);
+				message.setGroup(group);
 
 
 				messages.add(message);
 				messages.add(message);
 			}
 			}
@@ -143,7 +144,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				errorMsg = e.getMessage();
 				errorMsg = e.getMessage();
 				LOGGER.warn("消息发送失败", e);
 				LOGGER.warn("消息发送失败", e);
 			}
 			}
-			return addMessage(null, subject, content, receivers, triggerTime, mode, status, errorMsg, readStatus, memo) > 0;
+			return addMessage(null, subject, content, receivers, triggerTime, mode, status, errorMsg, readStatus, memo, null) > 0;
 		}
 		}
 
 
 		return false;
 		return false;
@@ -151,12 +152,13 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 
 	@Override
 	@Override
 	@Async
 	@Async
-	public void sendMessage(MessageSender messageSender, Integer userId, MessageSendMode mode, MessageType type, String receiver, Date triggerTime,
+	public void sendMessage(MessageSender messageSender, Integer userId, MessageSendMode mode, MessageType type, String receivers, Date triggerTime,
 			Integer readStatus, String url, Object... args) {
 			Integer readStatus, String url, Object... args) {
 
 
-		if (StringUtils.isBlank(receiver)) {
+		if (StringUtils.isBlank(receivers)) {
 			throw new BizException("接收地址不能为空");
 			throw new BizException("接收地址不能为空");
 		}
 		}
+		String[] tos = StringUtils.split(receivers, ',');
 		SysMessageConfig messageConfig = sysMessageConfigService.queryByType(type);
 		SysMessageConfig messageConfig = sysMessageConfigService.queryByType(type);
 		if (messageConfig == null) {
 		if (messageConfig == null) {
 			throw new BizException("消息类型错误");
 			throw new BizException("消息类型错误");
@@ -168,8 +170,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		if (triggerTime == null || date.after(triggerTime)) {
 		if (triggerTime == null || date.after(triggerTime)) {
 			status = SendStatusEnum.SENDING;
 			status = SendStatusEnum.SENDING;
 			try {
 			try {
-				if (debugMode == true || messageSenderPluginContext.send(messageSender, messageConfig.getDescription(),
-								MessageFormatter.arrayFormat(messageConfig.getContent(), args), receiver, url)) {
+				if (debugMode == true
+						|| messageSenderPluginContext.batchSend(messageSender, messageConfig.getDescription(),
+								MessageFormatter.arrayFormat(messageConfig.getContent(), args), tos, url)) {
 					status = SendStatusEnum.SUCCESSED;
 					status = SendStatusEnum.SUCCESSED;
 				} else {
 				} else {
 					status = SendStatusEnum.FAILED;
 					status = SendStatusEnum.FAILED;
@@ -180,8 +183,8 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				LOGGER.warn("消息发送失败", e);
 				LOGGER.warn("消息发送失败", e);
 			}
 			}
 		}
 		}
-		addMessage(userId, type.getCode(), MessageFormatter.arrayFormat(messageConfig.getContent(), args), receiver, triggerTime, mode, status, errorMsg,
-				readStatus, url);
+		addMessage(userId, type.getCode(), MessageFormatter.arrayFormat(messageConfig.getContent(), args), receivers, triggerTime, mode, status, errorMsg,
+				readStatus, url, messageConfig.getGroup());
 	}
 	}
 
 
 	@Override
 	@Override
@@ -209,7 +212,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				LOGGER.warn("消息发送失败", e);
 				LOGGER.warn("消息发送失败", e);
 			}
 			}
 		}
 		}
-		addMessage(userId, title, content, receiver, triggerTime, mode, status, errorMsg, readStatus, url);
+		addMessage(userId, title, content, receiver, triggerTime, mode, status, errorMsg, readStatus, url, null);
 	}
 	}
 
 
 	@Override
 	@Override

+ 10 - 3
mec-biz/src/main/resources/config/mybatis/SysMessageConfigMapper.xml

@@ -12,6 +12,7 @@
 		<result column="description_" property="description" />
 		<result column="description_" property="description" />
 		<result column="modify_on_" property="modifyOn" />
 		<result column="modify_on_" property="modifyOn" />
 		<result column="url_" property="url" />
 		<result column="url_" property="url" />
+		<result column="group_" property="group" />
 	</resultMap>
 	</resultMap>
 
 
 	<sql id="queryCondition">
 	<sql id="queryCondition">
@@ -24,7 +25,10 @@
 				and content_ = #{content,jdbcType=VARCHAR},
 				and content_ = #{content,jdbcType=VARCHAR},
 			</if>
 			</if>
 			<if test="description != null">
 			<if test="description != null">
-				and description_ = #{description,jdbcType=TIMESTAMP}
+				and description_ = #{description,jdbcType=VARCHAR}
+			</if>
+			<if test="group != null">
+				and group_ = #{group,jdbcType=VARCHAR}
 			</if>
 			</if>
 		</where>
 		</where>
 	</sql>
 	</sql>
@@ -47,8 +51,8 @@
 		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
 		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
 			AS ID FROM DUAL </selectKey> -->
 			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO sys_message_config
 		INSERT INTO sys_message_config
-		(id_,message_type_,content_,description_,modify_on_,url_)
-		VALUES(#{id},#{messageType},#{content},#{description},#{modifyOn},#{url})
+		(id_,message_type_,content_,description_,modify_on_,url_,group_)
+		VALUES(#{id},#{messageType},#{content},#{description},#{modifyOn},#{url},#{group})
 	</insert>
 	</insert>
 
 
 	<!-- 根据主键查询一条记录 -->
 	<!-- 根据主键查询一条记录 -->
@@ -67,6 +71,9 @@
 			<if test="url != null">
 			<if test="url != null">
 				url_ = #{url},
 				url_ = #{url},
 			</if>
 			</if>
+			<if test="group != null">
+				group_ = #{group},
+			</if>
 			<if test="content != null">
 			<if test="content != null">
 				content_ = #{content},
 				content_ = #{content},
 			</if>
 			</if>

+ 2 - 0
mec-education/src/main/java/com/ym/mec/education/EducationApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages = {"com.ym.mec", "org.snaker"})
 @ComponentScan(basePackages = {"com.ym.mec", "org.snaker"})
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class EducationApplication {
 public class EducationApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {

+ 3 - 0
mec-im/src/main/java/com/ym/SealClassApplication.java

@@ -1,6 +1,7 @@
 package com.ym;
 package com.ym;
 
 
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -9,6 +10,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
@@ -19,6 +21,7 @@ import org.springframework.web.client.RestTemplate;
 @EnableScheduling
 @EnableScheduling
 @EnableDiscoveryClient
 @EnableDiscoveryClient
 @Configuration
 @Configuration
+@EnableAsync
 public class SealClassApplication {
 public class SealClassApplication {
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {

+ 2 - 0
mec-student/src/main/java/com/ym/mec/student/StudentApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages = "com.ym.mec")
 @ComponentScan(basePackages = "com.ym.mec")
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class StudentApplication {
 public class StudentApplication {
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {

+ 2 - 0
mec-task/src/main/java/com/ym/mec/task/TaskApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages="com.ym.mec")
 @ComponentScan(basePackages="com.ym.mec")
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class TaskApplication {
 public class TaskApplication {
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {

+ 2 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/TeacherApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages = { "com.ym.mec", "org.snaker.engine" })
 @ComponentScan(basePackages = { "com.ym.mec", "org.snaker.engine" })
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class TeacherApplication {
 public class TeacherApplication {
 	
 	
 	public static void main(String[] args) {
 	public static void main(String[] args) {

+ 2 - 0
mec-web/src/main/java/com/ym/mec/web/WebApplication.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import com.spring4all.swagger.EnableSwagger2Doc;
 import com.spring4all.swagger.EnableSwagger2Doc;
@@ -20,6 +21,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @ComponentScan(basePackages = "com.ym.mec")
 @ComponentScan(basePackages = "com.ym.mec")
 @Configuration
 @Configuration
 @EnableSwagger2Doc
 @EnableSwagger2Doc
+@EnableAsync
 public class WebApplication {
 public class WebApplication {
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {