异常处理优化

yun-zuoyi
wei.peng 7 years ago
commit 3d159a9bfb

@ -3,6 +3,7 @@ package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.SysConfig;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -19,29 +20,34 @@ public interface ISysConfigService {
*
* @param sysConfig
*/
@ApiOperation(value = "添加系统参数")
void insertSysConfig(SysConfig sysConfig);
/**
*
* @param id
*/
@ApiOperation(value = "删除系统参数")
void deleteSysConfigById(Long id);
/**
*
* @param sysConfig
*/
@ApiOperation(value = "修改系统参数")
void updateSysConfig(SysConfig sysConfig);
/**
*
*/
@ApiOperation(value = "查询全部系统参数")
List<SysConfig> ListSysConfig();
/**
* id
* @param id
*/
@ApiOperation(value = "根据id查询系统参数")
SysConfig getSysConfigById(Long id);
/**
@ -50,6 +56,7 @@ public interface ISysConfigService {
* @param pager
* @return
*/
@ApiOperation(value = "系统配置复杂查询分页排序")
ListPager querySysConfigByPager(SysConfig sysConfig, Pager pager);
/**
@ -57,11 +64,21 @@ public interface ISysConfigService {
* @param code
* @return
*/
@ApiOperation(value = "根据code查询系统配置")
SysConfig getSysConfigByCode(String code);
/**
*
*
* @return
*/
@ApiOperation(value = "查询系统邮件配置项")
List findMailConfig();
/**
*
* @param code
* @param value
*/
@ApiOperation(value = "根据系统配置代码修改配置项")
void updateSysConfigByCode(String code,String value);
}

@ -1,7 +1,12 @@
package cn.estsh.i3plus.core.apiservice.controller;
import cn.estsh.i3plus.icloud.core.sdk.ICoreDemoCloud;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.bean.BaseModelBean;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -10,6 +15,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/cloud")
@Api(description="分布式服务测试")
@ -36,12 +43,12 @@ public class DemoCloudController {
LOGGER.error("XXXX --> post调用出错" + e.getMessage(),e);
}
try {
iCoreDemoCloud.testPut("testPut = " + test);
iCoreDemoCloud.testPut("testPut = " + test,"name");
}catch (Exception e){
LOGGER.error("XXXX --> testPut调用出错" + e.getMessage(),e);
}
try {
iCoreDemoCloud.testDelete("delete = " + test);
iCoreDemoCloud.testDelete(new Pager(),"delete = " + test);
}catch (Exception e){
LOGGER.error("XXXX --> delete调用出错" + e.getMessage(),e);
}
@ -64,24 +71,54 @@ public class DemoCloudController {
return ResultBean.success("返回:" + test).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PostMapping(value="/test-put")
@PutMapping(value="/test-put")
@ApiOperation(value="put接受数据",notes = "put接受数据")
public ResultBean testPut(String test) {
LOGGER.info("【put接受数据】{}", test);
public ResultBean testPut(String test,String name) {
LOGGER.info("【put接受数据】param1:{},param2:{}", test,name);
return ResultBean.success("返回:" + test).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@DeleteMapping(value="/test-delete")
@ApiOperation(value="delete接受数据",notes = "delete接受数据")
public ResultBean testDelete(String test) {
LOGGER.info("【delete接受数据】{}",test);
public ResultBean testDelete(
@RequestBody Pager pager,
@RequestParam("test") String test) {
LOGGER.info("【delete接受数据】pager:{},test:{}",pager,test);
return ResultBean.success("返回:" + test).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PutMapping(value="/test-cloud-put")
@ApiOperation(value="测试cloudput",notes = "测试cloudput")
public ResultBean putTestCloud(String test) {
LOGGER.info("【put--->{}",test);
public ResultBean putTestCloud(String test,String name) {
LOGGER.info("【put接受数据】test:{},name:{}",test,name);
return ResultBean.success("返回:" + test).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PostMapping(value="/test-object")
@ApiOperation(value="测试单对象")
public ResultBean testObject(@RequestBody Pager pager) {
LOGGER.info("【object接受数据】{}" ,pager);
return ResultBean.success("返回:" + pager).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PostMapping(value="/test-map")
@ApiOperation(value="测试get",notes = "测试get")
public ResultBean testFeignMap(@RequestBody Map<String,String> map) {
LOGGER.info("【map接受数据】{}" ,map);
return ResultBean.success("返回:" + map).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PostMapping(value="/test-arr")
@ApiOperation(value="测试arr",notes = "测试arr")
public ResultBean testFeignArr(@RequestBody String[] arr) {
LOGGER.info("【arr接受数据】{}" ,arr);
return ResultBean.success("返回:" + arr).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
@PostMapping(value="/test-more-object")
@ApiOperation(value="测试多对象模型",notes = "测试多对象模型")
public ResultBean testFeignMoreObj(@RequestBody BaseModelBean<SysRole> roleBean) {
LOGGER.info("【more-obj接受多对象模型】objBean:{},pager:{}" ,roleBean.getObj(),roleBean.getPager());
return ResultBean.success("返回:" + roleBean).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
}

@ -10,7 +10,7 @@ import cn.estsh.i3plus.pojo.platform.bean.SysConfig;
import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api;
@ -58,11 +58,9 @@ public class SysConfigController extends CoreBaseController {
sysConfigService.insertSysConfig(sysConfig);
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ -73,11 +71,9 @@ public class SysConfigController extends CoreBaseController {
sysConfigService.deleteSysConfigById(Long.parseLong(id));
return ResultBean.success("删除成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ -101,11 +97,9 @@ public class SysConfigController extends CoreBaseController {
sysConfigService.updateSysConfig(sysConfig);
return ResultBean.success("删除成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ -118,11 +112,9 @@ public class SysConfigController extends CoreBaseController {
.setResultList(sysConfigList)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ -138,11 +130,9 @@ public class SysConfigController extends CoreBaseController {
return ResultBean.fail("数据不存在").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
}
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ -155,11 +145,55 @@ public class SysConfigController extends CoreBaseController {
.setListPager(sysConfigListPager)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping(value = "/get-code/{code}")
@ApiOperation(value = "根据代码获取系统配置")
public ResultBean getSysConfigByCode(@PathVariable("code") String code){
try {
SysConfig sysConfig = sysConfigService.getSysConfigByCode(code);
if(sysConfig == null){
return ResultBean.fail("数据不存在").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
} else{
return ResultBean.success("查询成功").setResultObject(sysConfig).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/find-mail")
@ApiOperation(value = "查询邮件配置")
public ResultBean findMailSysConfig(){
try {
List sysConfig = sysConfigService.findMailConfig();
if(sysConfig == null){
return ResultBean.fail("数据不存在").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
} else{
return ResultBean.success("查询成功").setResultList(sysConfig).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@PostMapping("/update-code/{code}/{value}")
public ResultBean updateSysConfigByCode(@PathVariable("code") String code,@PathVariable("value") String value){
try{
// sysConfigService.update
return null;
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}

@ -1,7 +1,6 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueueConfig;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.StringTool;
@ -10,7 +9,8 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
@ -20,10 +20,8 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -60,11 +58,19 @@ public class SysMessageController extends CoreBaseController {
.notNull("messageReceiversId",sysMessage.getMessageReceiversId());
// 设置发件人名称
// sysMessage.setMessageSendId(user.getUser().getId());
// sysMessage.setRedSendName(user.getUser().getName());
sysMessage.setMessageSenderId(getSessionUser().getUserId());
sysMessage.setMessageSenderNameRdd(getSessionUser().getUserName());
sysMessage.setMessageSendTime(sdf.format(new Date()));
sysMessage.setMessageContentType(ImppEnumUtil.MESSAGE_CONTENT_TYPE.HTML.getValue());
sysMessageService.insertSysMessage(sysMessage);
ConvertBean.modelInitialize(sysMessage,getSessionUser());
// 判断消息类型推送到对应的队列
if(ImppEnumUtil.USER_MESSAGE_TYPE.MAIL.getValue() == sysMessage.getMessageType().intValue()){
rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE,sysMessage);
}else{
rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE,sysMessage);
}
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);

@ -2,8 +2,12 @@ package cn.estsh.i3plus.core.apiservice.mq;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
import com.rabbitmq.client.Channel;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
@ -35,17 +39,42 @@ public class LetterQueueReceiver {
* @param message
* rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_QUEUE, new SysMessage(....));
*/
// @RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE)
public void processImppMessage(SysRefUserMessage msg, Channel channel, Message message) {
//@RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE)
public void processImppMessage(SysMessage msg, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_MESSAGE_QUEUE】数据接收成功{}",msg);
LOGGER.info("【MQ-IMPP_MESSAGE_LETTER_QUEUE】数据接收成功{}",msg);
sysMessageService.insertSysRefUserMessage(msg);
msg = sysMessageService.insertSysMessage(msg);
// 收件人信息
String[] messageReceiver = msg.getMessageReceiversId().split(",");
String[] receiverName = new String[messageReceiver.length];
SysRefUserMessage refUserMessage;
SysUser sysUser;
for (int i = 0; i < messageReceiver.length; i++) {
sysUser = sysUserService.getSysUserById(Long.parseLong(messageReceiver[i]));
receiverName[i] = sysUser.getUserName();
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(msg.getId());
refUserMessage.setMessageTitleRdd(msg.getMessageTitle());
refUserMessage.setMessageTypeRdd(msg.getMessageType());
refUserMessage.setReceiverId(sysUser.getId());
refUserMessage.setReceiverNameRdd(sysUser.getUserName());
refUserMessage.setReceiverTime(TimeTool.getNowTime(true));
sysMessageService.insertSysRefUserMessage(refUserMessage);
}
msg.setMessageSenderNameRdd(StringUtils.join(receiverName, ","));
sysMessageService.updateSysMessage(msg);
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
} catch (IOException e) {
LOGGER.error("【MQ-IMPP_MESSAGE_QUEUE】处理出错{}",e.getMessage(),e);
LOGGER.error("【MQ-IMPP_MESSAGE_LETTER_QUEUE】处理出错{}",e.getMessage(),e);
//丢弃这条消息
try {
// 未成功处理,重新发送

@ -2,10 +2,14 @@ package cn.estsh.i3plus.core.apiservice.mq;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
import cn.estsh.i3plus.core.apiservice.util.MailUtil;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
import com.rabbitmq.client.Channel;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
@ -13,8 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @Description :
@ -31,35 +33,57 @@ public class MailQueueReceiver {
ISysMessageService sysMessageService;
@Autowired
ISysUserService sysUserService;
@Autowired
MailUtil mailUtil;
/**
*
* @param msg
* @param channel
* @param message
*/
// @RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE)
public void processImppMail(SysRefUserMessage msg, Channel channel, Message message) {
//@RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE)
public void processImppMail(SysMessage msg, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_MESSAGE_QUEUE】数据接收成功{}",msg);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
msg.setReceiverTime(sdf.format(new Date()));
sysMessageService.insertSysRefUserMessage(msg);
LOGGER.info("【MQ-IMPP_MESSAGE_MAIL_QUEUE】数据接收成功{}",msg);
msg = sysMessageService.insertSysMessage(msg);
mailUtil.init();
// 收件人信息
String[] messageReceiver = msg.getMessageReceiversId().split(",");
String[] receiverName = new String[messageReceiver.length];
SysRefUserMessage refUserMessage;
SysUser sysUser;
SysMessage sysMessage = sysMessageService.getSysMessageById(msg.getMessageId());
SysUser sysUser = sysUserService.getSysUserById(msg.getReceiverId());
for (int i = 0; i < messageReceiver.length; i++) {
sysUser = sysUserService.getSysUserById(Long.parseLong(messageReceiver[i]));
receiverName[i] = sysUser.getUserName();
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(msg.getId());
refUserMessage.setMessageTitleRdd(msg.getMessageTitle());
refUserMessage.setMessageTypeRdd(msg.getMessageType());
refUserMessage.setReceiverId(sysUser.getId());
refUserMessage.setReceiverNameRdd(sysUser.getUserName());
refUserMessage.setReceiverTime(TimeTool.getNowTime(true));
sysMessageService.insertSysRefUserMessage(refUserMessage);
// 发送邮件
mailUtil.setSubject(msg.getMessageTitle());
mailUtil.setContentType(ImppEnumUtil.MESSAGE_CONTENT_TYPE.valueOfDescription(msg.getMessageContentType()));
mailUtil.setBody(msg.getMessageContent());
mailUtil.setTo(sysUser.getUserEmail());
mailUtil.send();
}
// MailUtil mailUtil = new MailUtil();
// mailUtil.setSubject(sysMessage.getMessageTitle());
// mailUtil.setContentType(ImppEnumUtil.MESSAGE_CONTENT_TYPE.valueOfDescription(sysMessage.getMessageContentType()));
// mailUtil.setBody(sysMessage.getMessageContent());
// mailUtil.setTo(sysUser.getUserEmail());
// mailUtil.send();
msg.setMessageSenderNameRdd(StringUtils.join(receiverName, ","));
sysMessageService.updateSysMessage(msg);
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
} catch (IOException e) {
LOGGER.error("【MQ-IMPP_MESSAGE_QUEUE】处理出错{}",e.getMessage(),e);
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}",e.getMessage(),e);
//丢弃这条消息
try {
// 未成功处理,重新发送

@ -1,12 +1,14 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.platform.bean.SysConfig;
import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,36 +32,42 @@ public class SysConfigService implements ISysConfigService {
private SysConfigRepository SysConfigRDao;
@Override
@ApiOperation(value = "添加系统参数")
public void insertSysConfig(SysConfig sysConfig) {
LOGGER.info("系统参数 SYS_CONFIG :{}",sysConfig);
SysConfigRDao.insert(sysConfig);
}
@Override
@ApiOperation(value = "删除系统参数")
public void deleteSysConfigById(Long id) {
LOGGER.info("系统参数 SYS_CONFIG :{}",id);
SysConfigRDao.deleteById(id);
}
@Override
@ApiOperation(value = "修改系统参数")
public void updateSysConfig(SysConfig sysConfig) {
LOGGER.info("系统参数 SYS_CONFIG :{}",sysConfig);
SysConfigRDao.update(sysConfig);
}
@Override
@ApiOperation(value = "查询全部系统参数")
public List<SysConfig> ListSysConfig() {
LOGGER.info("系统参数 SYS_CONFIG list");
return SysConfigRDao.findAll();
}
@Override
@ApiOperation(value = "根据id查询系统参数")
public SysConfig getSysConfigById(Long id) {
LOGGER.info("系统参数 SYS_CONFIG id:{}",id);
return SysConfigRDao.getById(id);
}
@Override
@ApiOperation(value = "系统配置复杂查询分页排序")
public ListPager querySysConfigByPager(SysConfig sysConfig, Pager pager) {
LOGGER.info("系统参数 SYS_CONFIG SysConfig:{}Pager:{}",sysConfig,pager);
if(sysConfig == null) {
@ -73,20 +81,27 @@ public class SysConfigService implements ISysConfigService {
}
@Override
@ApiOperation(value = "查询系统邮件配置项")
public SysConfig getSysConfigByCode(String code) {
return SysConfigRDao.getByProperty("configCode",code);
}
@Override
@ApiOperation(value = "查询系统邮件配置项")
public List findMailConfig() {
List mailConfig = new ArrayList();
// mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_HOST));
// mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_PORT));
// mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_USER));
// mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_PASSWORD));
// mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_NICK));
mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_HOST));
mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_PORT));
mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_USER));
mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_PASSWORD));
mailConfig.add(SysConfigRDao.getByProperty("configCode", PlatformConstWords.MAIL_NICK));
return mailConfig;
}
@Override
public void updateSysConfigByCode(String code, String value) {
SysConfigRDao.updateByProperties("configCode",value,"",value);
}
}

@ -1,19 +1,15 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueueConfig;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
import cn.estsh.i3plus.pojo.platform.repository.SysMessageRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysRefUserMessageRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysUserRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
@ -51,36 +47,7 @@ public class SysMessageService implements ISysMessageService {
@Override
public SysMessage insertSysMessage(SysMessage sysMessage) {
sysMessage = sysMessageRDao.insert(sysMessage);
String[] messageReceiver = sysMessage.getMessageReceiversId().split(",");
// 收件人名称集合
String[] receiverName = new String[messageReceiver.length];
SysRefUserMessage refUserMessage;
SysUser sysUser;
for (int i = 0; i < messageReceiver.length; i++) {
sysUser = sysUserRDao.getById(Long.parseLong(messageReceiver[i]));
receiverName[i] = sysUser.getUserName();
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(sysMessage.getId());
refUserMessage.setMessageTitleRdd(sysMessage.getMessageTitle());
refUserMessage.setMessageTypeRdd(sysMessage.getMessageType());
refUserMessage.setReceiverId(sysUser.getId());
refUserMessage.setReceiverNameRdd(sysUser.getUserName());
// 判断消息类型推送到对应的队列
if(ImppEnumUtil.USER_MESSAGE_TYPE.MAIL.getValue() == sysMessage.getMessageType().intValue()){
rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE,refUserMessage);
}else{
rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE,refUserMessage);
}
}
sysMessage.setMessageSenderNameRdd(StringUtils.join(receiverName, ","));
sysMessageRDao.update(sysMessage);
return sysMessage;
return sysMessageRDao.insert(sysMessage);
}
@Override

@ -159,8 +159,8 @@ public class MailUtil {
MimeMessage msg = new MimeMessage(conn);
if (nick != null && !"".equals(nick)) {
msg.setSubject( MimeUtility.encodeText(nick, MimeUtility.mimeCharset("gb2312"), null));
nick = MimeUtility.encodeText(nick, MimeUtility.mimeCharset("gb2312"), null);
msg.setSubject(nick);
msg.setFrom(new InternetAddress(nick + " <" + from + ">"));
} else {
msg.setFrom(new InternetAddress(this.from));

@ -0,0 +1,17 @@
package cn.estsh.i3plus.core.apiservice.websocket;
import org.apache.commons.lang3.RandomStringUtils;
/**
* @Description :
* @Reference :
* @Author : Adair Peng
* @CreateDate : 2018-11-22 15:02
* @Modify:
**/
public class TestMain {
public static void main(String[] args) {
System.out.println(RandomStringUtils.random(15, true, false));
}
}

@ -0,0 +1,207 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleResourceRepository;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-11-22 11:01
* @Modify:
**/
public class TestExcelSysConfig extends TestBase {
public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelPermission.class);
// 文件路径
public static final String PATH_NAME = "init/sys-config.xlsx";
// 权限Sheet 名称
public static final String SHEET_SYS_CONFIG = "sys-config";
public static final String SHEET_DICTIONARY = "dictionary";
public static final String SHEET_LANGUAGE = "language";
public static final String SHEET_RESOURCE = "resource";
@Autowired
private SysConfigRepository sysConfigRDao;
@Autowired
private SysDictionaryRepository sysDictionaryRDao;
@Autowired
private SysLocaleLanguageRepository sysLocaleLanguageRDao;
@Autowired
private SysLocaleResourceRepository sysLocaleResourceRDao;
@Test
public void testInit() throws Exception {
XSSFWorkbook workbook = getWorkbook(PATH_NAME);
if(workbook != null){
XSSFSheet sheetSysConfig = workbook.getSheet(SHEET_SYS_CONFIG);
XSSFSheet sheetDictionary = workbook.getSheet(SHEET_DICTIONARY);
XSSFSheet sheetLanguage = workbook.getSheet(SHEET_LANGUAGE);
XSSFSheet sheetResource = workbook.getSheet(SHEET_RESOURCE);
List<SysConfig> sysConfigList = getSysConfig(sheetSysConfig);
List<SysDictionary> sysDictionaryList = getSysDictionary(sheetDictionary);
List<SysLocaleLanguage> sysLocaleLanguageList = getSysLocaleLanguage(sheetLanguage);
List<SysLocaleResource> sysLocaleResourceList= getSysLocaleResource(sheetResource);
LOGGER.info("System Init SysConfig Size:{}",sysConfigList.size());
LOGGER.info("System Init SysDictionary Size:{}",sysDictionaryList.size());
LOGGER.info("System Init SysLocaleLanguage Size:{}",sysLocaleLanguageList.size());
LOGGER.info("System Init SysLocaleResource Size:{}",sysLocaleResourceList.size());
sysConfigRDao.saveAll(sysConfigList);
sysDictionaryRDao.saveAll(sysDictionaryList);
sysLocaleLanguageRDao.saveAll(sysLocaleLanguageList);
sysLocaleResourceRDao.saveAll(sysLocaleResourceList);
}
}
public List<SysConfig> getSysConfig(XSSFSheet sheet){
List<SysConfig> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysConfig obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysConfig();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setName(row.getCell(1).getStringCellValue());
obj.setConfigType(Integer.valueOf(row.getCell(2).getStringCellValue()));
obj.setConfigCode(row.getCell(3).getStringCellValue());
obj.setConfigValue(row.getCell(4).getStringCellValue());
obj.setConfigDescription(row.getCell(5).getStringCellValue());
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysDictionary> getSysDictionary(XSSFSheet sheet){
List<SysDictionary> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysDictionary obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysDictionary();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setName(row.getCell(1).getStringCellValue());
obj.setDictionaryCode(row.getCell(2).getStringCellValue());
obj.setParentId(Long.valueOf(row.getCell(3).getStringCellValue()));
obj.setParentNameRdd(row.getCell(4).getStringCellValue());
obj.setParentCodeRdd(row.getCell(5).getStringCellValue());
obj.setDictionaryValue(row.getCell(6).getStringCellValue());
obj.setDictionarySort(Integer.valueOf(row.getCell(7).getStringCellValue()));
obj.setDictionaryDescription(row.getCell(8).getStringCellValue());
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysLocaleLanguage> getSysLocaleLanguage(XSSFSheet sheet){
List<SysLocaleLanguage> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysLocaleLanguage obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysLocaleLanguage();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setLanguageName(row.getCell(1).getStringCellValue());
obj.setLanguageCode(row.getCell(2).getStringCellValue());
obj.setLanguageSort(Integer.valueOf(row.getCell(3).getStringCellValue()));
obj.setIsDefault(Integer.valueOf(row.getCell(4).getStringCellValue()));
obj.setLanguageStatus(Integer.valueOf(row.getCell(5).getStringCellValue()));
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysLocaleResource> getSysLocaleResource(XSSFSheet sheet){
List<SysLocaleResource> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysLocaleResource obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysLocaleResource();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setResourceType(Integer.valueOf(row.getCell(1).getStringCellValue()));
obj.setLanguageCode(row.getCell(2).getStringCellValue());
obj.setLanguageNameRdd(row.getCell(3).getStringCellValue());
obj.setResourceKey(row.getCell(4).getStringCellValue());
obj.setResourceValue(row.getCell(5).getStringCellValue());
obj.setIsSystem(Integer.valueOf(row.getCell(6).getStringCellValue()));
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public XSSFWorkbook getWorkbook(String pathName){
try {
InputStream in = TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName);
XSSFWorkbook workbook = new XSSFWorkbook(in);
return workbook;
}catch (Exception e){
LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage());
e.getMessage();
return null;
}
}
}
Loading…
Cancel
Save