forked from wuweidong/hzims-back-huoshan
20 changed files with 702 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||||
|
package com.hnac.hzims.message.entity.log; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@ApiModel(value = "app推送日志对象",description = "app推送日志对象") |
||||||
|
@TableName("hzims_app_log") |
||||||
|
@Data |
||||||
|
public class AppLogEntity extends MessageLogEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("是否推送全平台") |
||||||
|
private Boolean isAll; |
||||||
|
|
||||||
|
@ApiModelProperty("推送类型") |
||||||
|
private String platformType; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.hnac.hzims.message.entity.log; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "邮箱推送日志",description = "邮箱推送日志") |
||||||
|
@TableName("hzims_mail_log") |
||||||
|
public class MailLogEntity extends MessageLogEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("推送邮箱") |
||||||
|
private String email; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package com.hnac.hzims.message.entity.log; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import org.springblade.core.mp.support.QueryField; |
||||||
|
import org.springblade.core.mp.support.SqlCondition; |
||||||
|
import org.springblade.core.tenant.mp.TenantEntity; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "消息日志") |
||||||
|
@TableName("hzims_mail_log") |
||||||
|
public class MessageLogEntity extends TenantEntity { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "业务关键字",required = true) |
||||||
|
@NotNull(message = "业务关键字不能为空") |
||||||
|
@QueryField(condition = SqlCondition.LIKE) |
||||||
|
private String businessKey; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true) |
||||||
|
@NotNull(message = "业务分类不能为空") |
||||||
|
@QueryField(condition = SqlCondition.EQUAL) |
||||||
|
private String businessClassify; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "主题",required = true) |
||||||
|
@NotNull(message = "主题不能为空") |
||||||
|
@QueryField(condition = SqlCondition.LIKE) |
||||||
|
private String subject; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "内容",required = true) |
||||||
|
@NotNull(message = "内容不能为空") |
||||||
|
private String content; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "推送人") |
||||||
|
@QueryField(condition = SqlCondition.EQUAL) |
||||||
|
private String pusher; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "消息推送请求参数") |
||||||
|
@QueryField(condition = SqlCondition.EQUAL) |
||||||
|
private String params; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "错误日志") |
||||||
|
private String errorLog; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "推送结果") |
||||||
|
private String result; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否推送成功") |
||||||
|
@QueryField(condition = SqlCondition.EQUAL) |
||||||
|
private Boolean isSuccess; |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.hnac.hzims.message.entity.log; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "短信日志对象",description = "短信日志对象") |
||||||
|
@TableName("hzims_sms_log") |
||||||
|
public class SmsLogEntity extends MessageLogEntity implements Serializable { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "接受短信的手机号",required = true) |
||||||
|
private String phones; |
||||||
|
|
||||||
|
@ApiModelProperty("短信模板参数") |
||||||
|
private String paramsJson; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package com.hnac.hzims.message.entity.log; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@ApiModel(value = "web推送日志对象",description = "web推送日志对象") |
||||||
|
@Data |
||||||
|
public class WsLogEntity extends MessageLogEntity { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,216 @@ |
|||||||
|
package com.hnac.hzims.message.log.aspect; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hnac.hzims.message.MessageConstants; |
||||||
|
import com.hnac.hzims.message.dto.AppPushDto; |
||||||
|
import com.hnac.hzims.message.dto.MailPushDto; |
||||||
|
import com.hnac.hzims.message.dto.SmsPushDto; |
||||||
|
import com.hnac.hzims.message.dto.WsPushDto; |
||||||
|
import com.hnac.hzims.message.entity.MsgWsRecordEntity; |
||||||
|
import com.hnac.hzims.message.entity.log.AppLogEntity; |
||||||
|
import com.hnac.hzims.message.entity.log.MailLogEntity; |
||||||
|
import com.hnac.hzims.message.entity.log.SmsLogEntity; |
||||||
|
import com.hnac.hzims.message.log.service.IAppLogService; |
||||||
|
import com.hnac.hzims.message.log.service.IMailLogService; |
||||||
|
import com.hnac.hzims.message.log.service.ISmsLogService; |
||||||
|
import com.hnac.hzims.message.service.IMsgWsRecordService; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.aspectj.lang.ProceedingJoinPoint; |
||||||
|
import org.aspectj.lang.annotation.Around; |
||||||
|
import org.aspectj.lang.annotation.Aspect; |
||||||
|
import org.aspectj.lang.annotation.Pointcut; |
||||||
|
import org.aspectj.lang.reflect.MethodSignature; |
||||||
|
import org.springblade.core.log.logger.BladeLogger; |
||||||
|
import org.springblade.core.secure.utils.AuthUtil; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.DateUtil; |
||||||
|
import org.springblade.core.tool.utils.ObjectUtil; |
||||||
|
import org.springblade.core.tool.utils.SpringUtil; |
||||||
|
import org.springblade.core.tool.utils.StringUtil; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.lang.reflect.Method; |
||||||
|
import java.util.concurrent.ExecutorService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Aspect |
||||||
|
@Component |
||||||
|
@Slf4j |
||||||
|
public class LogAspect { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IMailLogService mailLogService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IAppLogService appLogService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private ISmsLogService smsLogService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private ExecutorService logExecutorService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private BladeLogger bladeLogger; |
||||||
|
|
||||||
|
@Pointcut("@annotation(com.hnac.hzims.message.log.aspect.SaveLog)") |
||||||
|
public void logPointCut() { |
||||||
|
} |
||||||
|
|
||||||
|
@Around("logPointCut()") |
||||||
|
public Object around(ProceedingJoinPoint point) { |
||||||
|
Object result = this.saveMessageLog(point); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/*** |
||||||
|
* 保存消息推送日志 |
||||||
|
* @param joinPoint 连接点 |
||||||
|
*/ |
||||||
|
private Object saveMessageLog(ProceedingJoinPoint joinPoint) { |
||||||
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
||||||
|
Method method = signature.getMethod(); |
||||||
|
SaveLog saveLog = method.getAnnotation(SaveLog.class); |
||||||
|
Object[] args = joinPoint.getArgs(); |
||||||
|
String errorLog = ""; |
||||||
|
Object result = null; |
||||||
|
try { |
||||||
|
//执行方法
|
||||||
|
result = joinPoint.proceed(); |
||||||
|
} catch (Throwable throwable) { |
||||||
|
bladeLogger.error("message-log",throwable.getMessage()); |
||||||
|
throwable.printStackTrace(); |
||||||
|
errorLog = throwable.getMessage(); |
||||||
|
} |
||||||
|
switch(saveLog.type()) { |
||||||
|
case MessageConstants.APP_PUSH: |
||||||
|
//app推送
|
||||||
|
this.savePushMessage(args[0],result,errorLog); |
||||||
|
break; |
||||||
|
case MessageConstants.SMS_PUSH: |
||||||
|
//短信推送
|
||||||
|
this.saveSmsMessage(args[0],result,errorLog); |
||||||
|
break; |
||||||
|
case MessageConstants.WS_PUSH: |
||||||
|
//websocket推送
|
||||||
|
this.saveWebsocketMessage(args[0],result,errorLog); |
||||||
|
break; |
||||||
|
case MessageConstants.MAIL_PUSH: |
||||||
|
//邮件推送
|
||||||
|
this.saveMailMessage(args[0],result,errorLog); |
||||||
|
break; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/*** |
||||||
|
* 保存websocket推送日志 |
||||||
|
* @param arg 参数 |
||||||
|
* @param result 结果 |
||||||
|
* @param errorLog 错误日志 |
||||||
|
*/ |
||||||
|
private void saveWebsocketMessage(Object arg, Object result, String errorLog) { |
||||||
|
IMsgWsRecordService recordService = SpringUtil.getBean(IMsgWsRecordService.class); |
||||||
|
WsPushDto wsPushDto = JSONObject.parseObject(JSON.toJSONString(arg),WsPushDto.class); |
||||||
|
MsgWsRecordEntity recordEntity = MsgWsRecordEntity.builder() |
||||||
|
.businessKey(wsPushDto.getBusinessKey()) |
||||||
|
.businessClassify(wsPushDto.getBusinessClassify()) |
||||||
|
.subject(wsPushDto.getSubject()) |
||||||
|
.content(wsPushDto.getContent()) |
||||||
|
.userIds(String.join(",",wsPushDto.getUserIdList())) |
||||||
|
.isAll(wsPushDto.isAll()) |
||||||
|
.parameters(JSON.toJSONString(arg)) |
||||||
|
.response(ObjectUtil.isNotEmpty(result) ? JSON.toJSONString(result) : null) |
||||||
|
.errorLog(errorLog) |
||||||
|
.success(StringUtil.isBlank(errorLog)) |
||||||
|
.build(); |
||||||
|
//处理未登陆情况
|
||||||
|
if(ObjectUtil.isEmpty(AuthUtil.getUser())){ |
||||||
|
recordEntity.setTenantId(wsPushDto.getTenantId()); |
||||||
|
recordEntity.setCreateUser(wsPushDto.getCreateUser()); |
||||||
|
recordEntity.setCreateTime(DateUtil.now()); |
||||||
|
} |
||||||
|
recordService.save(recordEntity); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存app推送日志 |
||||||
|
* @param arg 参数 |
||||||
|
* @param result 结果 |
||||||
|
* @param errorLog 错误信息 |
||||||
|
*/ |
||||||
|
private void savePushMessage(Object arg, Object result, String errorLog) { |
||||||
|
logExecutorService.execute(()->{ |
||||||
|
AppPushDto appPushDto = JSONObject.parseObject(JSON.toJSONString(arg),AppPushDto.class); |
||||||
|
AppLogEntity appLogEntity = appLogService.pushConvertLog(appPushDto); |
||||||
|
//补充日志中推送推送结果以及错误日志
|
||||||
|
appLogEntity.setErrorLog(errorLog); |
||||||
|
R r = JSONObject.parseObject(JSON.toJSONString(result),R.class); |
||||||
|
appLogEntity.setParams(JSON.toJSONString(arg)); |
||||||
|
appLogEntity.setResult(JSON.toJSONString(r)); |
||||||
|
appLogEntity.setIsSuccess(r.isSuccess()); |
||||||
|
//处理未登陆情况
|
||||||
|
if(ObjectUtil.isEmpty(AuthUtil.getUser())){ |
||||||
|
appLogEntity.setTenantId(appPushDto.getTenantId()); |
||||||
|
appLogEntity.setCreateUser(appPushDto.getCreateUser()); |
||||||
|
appLogEntity.setCreateTime(DateUtil.now()); |
||||||
|
} |
||||||
|
appLogService.save(appLogEntity); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/*** |
||||||
|
* 保存短信推送日志 |
||||||
|
* @param arg 参数 |
||||||
|
* @param result 结果 |
||||||
|
* @param errorLog 错误信息 |
||||||
|
*/ |
||||||
|
private void saveSmsMessage(Object arg, Object result,String errorLog) { |
||||||
|
SmsPushDto smsPushDto = JSONObject.parseObject(JSON.toJSONString(arg),SmsPushDto.class); |
||||||
|
SmsLogEntity smsLogEntity = smsLogService.pushConvertLog(smsPushDto); |
||||||
|
R r = JSONObject.parseObject(JSON.toJSONString(result),R.class); |
||||||
|
smsLogEntity.setErrorLog(errorLog); |
||||||
|
smsLogEntity.setResult(JSON.toJSONString(r)); |
||||||
|
smsLogEntity.setParams(JSON.toJSONString(arg)); |
||||||
|
smsLogEntity.setIsSuccess(r.isSuccess()); |
||||||
|
//处理未登陆情况
|
||||||
|
if(ObjectUtil.isEmpty(AuthUtil.getUser())){ |
||||||
|
smsLogEntity.setTenantId(smsPushDto.getTenantId()); |
||||||
|
smsLogEntity.setCreateUser(smsPushDto.getCreateUser()); |
||||||
|
smsLogEntity.setCreateTime(DateUtil.now()); |
||||||
|
} |
||||||
|
smsLogService.save(smsLogEntity); |
||||||
|
} |
||||||
|
|
||||||
|
/*** |
||||||
|
* 保存邮件发送日志 |
||||||
|
* @param arg 参数 |
||||||
|
* @param result 结果 |
||||||
|
* @param errorLog 错误信息 |
||||||
|
*/ |
||||||
|
private void saveMailMessage(Object arg, Object result,String errorLog) { |
||||||
|
logExecutorService.execute(()->{ |
||||||
|
MailPushDto mailPushDto = JSONObject.parseObject(JSON.toJSONString(arg),MailPushDto.class); |
||||||
|
MailLogEntity mailLogEntity = mailLogService.pushConvertLog(mailPushDto); |
||||||
|
//补充日志中推送推送结果以及错误日志
|
||||||
|
mailLogEntity.setErrorLog(errorLog); |
||||||
|
R r = JSONObject.parseObject(JSON.toJSONString(result),R.class); |
||||||
|
mailLogEntity.setResult(JSON.toJSONString(r)); |
||||||
|
mailLogEntity.setParams(JSON.toJSONString(arg)); |
||||||
|
mailLogEntity.setIsSuccess(r.isSuccess()); |
||||||
|
//处理未登陆情况
|
||||||
|
if(ObjectUtil.isEmpty(AuthUtil.getUser())){ |
||||||
|
mailLogEntity.setTenantId(mailPushDto.getTenantId()); |
||||||
|
mailLogEntity.setCreateUser(mailPushDto.getCreateUser()); |
||||||
|
mailLogEntity.setCreateTime(DateUtil.now()); |
||||||
|
} |
||||||
|
mailLogService.save(mailLogEntity); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.hnac.hzims.message.log.aspect; |
||||||
|
|
||||||
|
import java.lang.annotation.ElementType; |
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.RetentionPolicy; |
||||||
|
import java.lang.annotation.Target; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||||
|
@Target(value = {ElementType.METHOD}) |
||||||
|
public @interface SaveLog { |
||||||
|
/** |
||||||
|
* 日志保存类型 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String type() default ""; |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.hnac.hzims.message.log.mapper; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; |
||||||
|
import com.hnac.hzims.message.entity.log.AppLogEntity; |
||||||
|
import com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface AppLogMapper extends UserDataScopeBaseMapper<AppLogEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取app推送统计 |
||||||
|
* @param statisticDto |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
MsgPushStatisticVO getAppPushStatistic(@Param("statisticDto") MsgPushStatisticDto statisticDto); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.message.log.mapper.AppLogMapper"> |
||||||
|
|
||||||
|
<select id="getAppPushStatistic" resultType="com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO"> |
||||||
|
select sum(LENGTH(PUSHER)-LENGTH(REPLACE(PUSHER,',',''))+1) `count` |
||||||
|
from hzims_app_log |
||||||
|
<where> |
||||||
|
is_deleted = 0 |
||||||
|
<if test="statisticDto.startDate != null and statisticDto.startDate != ''"> |
||||||
|
and create_time >= #{statisticDto.startDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.endDate != null and statisticDto.endDate != ''"> |
||||||
|
and create_time <= #{statisticDto.endDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.deptId != null and statisticDto.deptId != ''"> |
||||||
|
and find_in_set(create_dept,#{statisticDto.deptId}) |
||||||
|
</if> |
||||||
|
<if test="statisticDto.businessClassify != null and statisticDto.businessClassify != ''"> |
||||||
|
and find_in_set(business_classify,#{statisticDto.businessClassify}) |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,20 @@ |
|||||||
|
package com.hnac.hzims.message.log.mapper; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; |
||||||
|
import com.hnac.hzims.message.entity.log.MailLogEntity; |
||||||
|
import com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface MailLogMapper extends UserDataScopeBaseMapper<MailLogEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取邮箱推送统计 |
||||||
|
* @param statisticDto |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
MsgPushStatisticVO getMailPushStatistic(@Param("statisticDto") MsgPushStatisticDto statisticDto); |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.message.log.mapper.MailLogMapper"> |
||||||
|
|
||||||
|
<select id="getMailPushStatistic" resultType="com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO"> |
||||||
|
select sum(LENGTH(PUSHER)-LENGTH(REPLACE(PUSHER,',',''))+1) `count` |
||||||
|
from hzims_mail_log |
||||||
|
<where> |
||||||
|
is_deleted = 0 |
||||||
|
<if test="statisticDto.startDate != null and statisticDto.startDate != ''"> |
||||||
|
and create_time >= #{statisticDto.startDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.endDate != null and statisticDto.endDate != ''"> |
||||||
|
and create_time <= #{statisticDto.endDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.deptId != null and statisticDto.deptId != ''"> |
||||||
|
and find_in_set(create_dept,#{statisticDto.deptId}) |
||||||
|
</if> |
||||||
|
<if test="statisticDto.businessClassify != null and statisticDto.businessClassify != ''"> |
||||||
|
and find_in_set(business_classify,#{statisticDto.businessClassify}) |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,21 @@ |
|||||||
|
package com.hnac.hzims.message.log.mapper; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; |
||||||
|
import com.hnac.hzims.message.entity.log.SmsLogEntity; |
||||||
|
import com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface SmsLogMapper extends UserDataScopeBaseMapper<SmsLogEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取短信推送统计 |
||||||
|
* @param statisticDto |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
MsgPushStatisticVO getSmsPushStatistic(@Param("statisticDto") MsgPushStatisticDto statisticDto); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.message.log.mapper.SmsLogMapper"> |
||||||
|
<select id="getSmsPushStatistic" resultType="com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO"> |
||||||
|
select sum(LENGTH(PUSHER)-LENGTH(REPLACE(PUSHER,',',''))+1) `count` |
||||||
|
from hzims_sms_log |
||||||
|
<where> |
||||||
|
is_deleted = 0 |
||||||
|
<if test="statisticDto.startDate != null and statisticDto.startDate != ''"> |
||||||
|
and create_time >= #{statisticDto.startDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.endDate != null and statisticDto.endDate != ''"> |
||||||
|
and create_time <= #{statisticDto.endDate} |
||||||
|
</if> |
||||||
|
<if test="statisticDto.deptId != null and statisticDto.deptId != ''"> |
||||||
|
and find_in_set(create_dept,#{statisticDto.deptId}) |
||||||
|
</if> |
||||||
|
<if test="statisticDto.businessClassify != null and statisticDto.businessClassify != ''"> |
||||||
|
and find_in_set(business_classify,#{statisticDto.businessClassify}) |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,56 @@ |
|||||||
|
package com.hnac.hzims.message.log.service; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.AppPushDto; |
||||||
|
import com.hnac.hzims.message.entity.log.AppLogEntity; |
||||||
|
import com.hnac.hzinfo.core.push.enums.PlatformType; |
||||||
|
import org.springblade.core.log.exception.ServiceException; |
||||||
|
import org.springblade.core.log.logger.BladeLogger; |
||||||
|
import org.springblade.core.tool.utils.BeanUtil; |
||||||
|
import org.springblade.core.tool.utils.CollectionUtil; |
||||||
|
import org.springblade.core.tool.utils.ObjectUtil; |
||||||
|
import org.springframework.util.Assert; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface IAppLogService extends IMessageLogService<AppLogEntity,AppPushDto> { |
||||||
|
|
||||||
|
BladeLogger bladeLogger = new BladeLogger(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 将app推送对象 转换为日志对象 |
||||||
|
* @param pushDto app推送对象 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
default AppLogEntity pushConvertLog(AppPushDto pushDto) { |
||||||
|
Assert.isTrue(ObjectUtil.isNotEmpty(pushDto),()->{ |
||||||
|
throw new ServiceException("app推送对象 转换为日志对象时,app推送对象不能为空"); |
||||||
|
}); |
||||||
|
AppLogEntity appLogEntity = BeanUtil.copy(pushDto,AppLogEntity.class); |
||||||
|
//排除对数据权限的影响
|
||||||
|
appLogEntity.setCreateDept(null); |
||||||
|
appLogEntity.setCreateTime(null); |
||||||
|
appLogEntity.setCreateUser(null); |
||||||
|
appLogEntity.setUpdateUser(null); |
||||||
|
appLogEntity.setUpdateTime(null); |
||||||
|
Assert.isTrue(CollectionUtil.isNotEmpty(pushDto.getTags()),()-> { |
||||||
|
bladeLogger.error("message-pushConvertLog","app推送 推送人不能为空"); |
||||||
|
throw new ServiceException("app推送 推送人不能为空"); |
||||||
|
}); |
||||||
|
appLogEntity.setPusher(pushDto.getTags().stream().collect(Collectors.joining(","))); |
||||||
|
String platformTypes = ""; |
||||||
|
if(pushDto.getIsAll()){ |
||||||
|
platformTypes = Arrays.stream(PlatformType.values()).map(PlatformType::getValue).collect(Collectors.joining(",")); |
||||||
|
} |
||||||
|
else { |
||||||
|
platformTypes = Arrays.stream(pushDto.getPlatformTypes()).map(PlatformType::getValue).collect(Collectors.joining(",")); |
||||||
|
} |
||||||
|
appLogEntity.setPlatformType(platformTypes); |
||||||
|
return appLogEntity; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.hnac.hzims.message.log.service; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.MailPushDto; |
||||||
|
import com.hnac.hzims.message.entity.log.MailLogEntity; |
||||||
|
import org.springblade.core.log.exception.ServiceException; |
||||||
|
import org.springblade.core.tool.utils.BeanUtil; |
||||||
|
import org.springblade.core.tool.utils.ObjectUtil; |
||||||
|
import org.springframework.util.Assert; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface IMailLogService extends IMessageLogService<MailLogEntity,MailPushDto> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 邮件推送对象转换为邮箱日志对象 |
||||||
|
* @param mailPushDto 邮件推送对象 |
||||||
|
* @return 邮箱日志对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
default MailLogEntity pushConvertLog(MailPushDto mailPushDto){ |
||||||
|
Assert.isTrue(ObjectUtil.isNotEmpty(mailPushDto),()->{ |
||||||
|
throw new ServiceException("邮件推送对象转换为邮箱日志对象时,邮件推送对象不能为空"); |
||||||
|
}); |
||||||
|
MailLogEntity mailLogEntity = BeanUtil.copy(mailPushDto,MailLogEntity.class); |
||||||
|
mailLogEntity.setEmail(Arrays.stream(mailPushDto.getToAccount()).collect(Collectors.joining(","))); |
||||||
|
mailLogEntity.setCreateDept(null); |
||||||
|
mailLogEntity.setCreateTime(null); |
||||||
|
mailLogEntity.setCreateUser(null); |
||||||
|
mailLogEntity.setUpdateUser(null); |
||||||
|
mailLogEntity.setUpdateTime(null); |
||||||
|
return mailLogEntity; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.hnac.hzims.message.log.service; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.dto.PushDto; |
||||||
|
import com.hnac.hzims.message.entity.log.MessageLogEntity; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface IMessageLogService<T extends MessageLogEntity,E extends PushDto> extends BaseService<T> { |
||||||
|
/** |
||||||
|
* 推送对象转换为日志 |
||||||
|
* @param pushDto |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
T pushConvertLog(E pushDto); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.hnac.hzims.message.log.service; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.hnac.hzims.message.dto.SmsPushDto; |
||||||
|
import com.hnac.hzims.message.entity.log.SmsLogEntity; |
||||||
|
import org.springblade.core.tool.utils.BeanUtil; |
||||||
|
import org.springblade.core.tool.utils.CollectionUtil; |
||||||
|
|
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
public interface ISmsLogService extends IMessageLogService<SmsLogEntity, SmsPushDto> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 短信推送对象转换为日志对象 |
||||||
|
* @param pushDto 短信推送对象 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
default SmsLogEntity pushConvertLog(SmsPushDto pushDto) { |
||||||
|
SmsLogEntity smsLogEntity = BeanUtil.copy(pushDto,SmsLogEntity.class); |
||||||
|
smsLogEntity.setCreateDept(null); |
||||||
|
smsLogEntity.setCreateTime(null); |
||||||
|
smsLogEntity.setCreateUser(null); |
||||||
|
smsLogEntity.setUpdateUser(null); |
||||||
|
smsLogEntity.setUpdateTime(null); |
||||||
|
smsLogEntity.setPusher(pushDto.getPhones().stream().collect(Collectors.joining(","))); |
||||||
|
smsLogEntity.setPhones(pushDto.getPhones().stream().collect(Collectors.joining(","))); |
||||||
|
if(CollectionUtil.isNotEmpty(pushDto.getParams())){ |
||||||
|
smsLogEntity.setParamsJson(JSON.toJSONString(pushDto.getParams())); |
||||||
|
} |
||||||
|
return smsLogEntity; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.hnac.hzims.message.log.service.impl; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.entity.log.AppLogEntity; |
||||||
|
import com.hnac.hzims.message.log.mapper.AppLogMapper; |
||||||
|
import com.hnac.hzims.message.log.service.IAppLogService; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Service("appLogService") |
||||||
|
public class AppLogServiceImpl extends BaseServiceImpl<AppLogMapper, AppLogEntity> implements IAppLogService { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.hnac.hzims.message.log.service.impl; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.entity.log.MailLogEntity; |
||||||
|
import com.hnac.hzims.message.log.mapper.MailLogMapper; |
||||||
|
import com.hnac.hzims.message.log.service.IMailLogService; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Service("mailLogService") |
||||||
|
@Slf4j |
||||||
|
@AllArgsConstructor |
||||||
|
public class MailLogServiceImpl extends BaseServiceImpl<MailLogMapper, MailLogEntity> |
||||||
|
implements IMailLogService { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.hnac.hzims.message.log.service.impl; |
||||||
|
|
||||||
|
import com.hnac.hzims.message.entity.log.SmsLogEntity; |
||||||
|
import com.hnac.hzims.message.log.mapper.SmsLogMapper; |
||||||
|
import com.hnac.hzims.message.log.service.ISmsLogService; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hx |
||||||
|
*/ |
||||||
|
@Service("smsLogService") |
||||||
|
public class SmsLogServiceImpl extends BaseServiceImpl<SmsLogMapper, SmsLogEntity> implements ISmsLogService { |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue