消息推送模块代码更新

This commit is contained in:
username 2024-09-18 16:51:20 +08:00
parent 2874005465
commit 165e548056
28 changed files with 1419 additions and 885 deletions

View File

@ -38,6 +38,12 @@
<profile.active>llg</profile.active>
</properties>
</profile>
<profile>
<id>zqtlocal</id> <!--曾庆拓-->
<properties>
<profile.active>zqtlocal</profile.active>
</properties>
</profile>
</profiles>
<build>

View File

@ -62,6 +62,7 @@ public class PushMessagePluginInitializer extends PluginBaseEntity {
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行定时消息推送========");
//目前只查询一周内的异常日志进行消息推送
List<SysPushMessageEntity> list = sysPushMessageDao.getAll();
for(SysPushMessageEntity entity : list){

View File

@ -36,4 +36,4 @@ cbs8:
OA:
data_source_code: yc_oa
zt:
url: http://127.0.0.1:9082/kangarooDataCenterV3/entranceController/externalCallInterface
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface

View File

@ -42,6 +42,7 @@
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="appName" column="app_name" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id="SysApplicationApiEntity_Base_Column_List">
@ -156,52 +157,87 @@ WHERE
<select id="entity_list_base" resultMap="get-SysApplicationApiEntity-result"
parameterType="com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity">
select
<include refid="SysApplicationApiEntity_Base_Column_List"/>
from sys_application_api
api.id
,api.api_status
,api.api_code
,api.api_path
,api.app_id
,api.catalogue_id
,api.api_name
,api.api_remark
,api.need_Login
,api.authentication_port
,api.parameter_passing_mode
,api.destination_address
,api.request_coding
,api.request_method
,api.timeout_period
,api.current_limiting
,api.header_in
,api.query_in
,api.body_in_type
,api.body_in
,api.body_out
,api.bean_name
,api.return_msg
,api.return_success_field
,api.return_success_value
,api.fun_name
,api.extension_api
,api.sorts
,api.create_user_id
,api.create_time
,api.modify_user_id
,api.modify_time
,api.sts
,api.org_id
,app.name as app_name
from sys_application_api api
left join sys_application app on api.app_id = app.id
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="apiStatus != null and apiStatus != ''">and api_status = #{apiStatus}</if>
<if test="apiCode != null ">and api_code = #{apiCode}</if>
<if test="apiPath != null and apiPath != ''">and api_path = #{apiPath}</if>
<if test="appId != null and appId != ''">and app_id = #{appId}</if>
<if test="catalogueId != null and catalogueId != ''">and catalogue_id = #{catalogueId}</if>
<if test="apiName != null and apiName != ''">and api_name = #{apiName}</if>
<if test="apiRemark != null and apiRemark != ''">and api_remark = #{apiRemark}</if>
<if test="needLogin != null and needLogin != ''">and need_Login = #{needLogin}</if>
<if test="authenticationPort != null and authenticationPort != ''">and authentication_port =
<if test="id != null and id != ''">and api.id = #{id}</if>
<if test="apiStatus != null and apiStatus != ''">and api.api_status = #{apiStatus}</if>
<if test="apiCode != null ">and api.api_code = #{apiCode}</if>
<if test="apiPath != null and apiPath != ''">and api.api_path = #{apiPath}</if>
<if test="appId != null and appId != ''">and api.app_id = #{appId}</if>
<if test="catalogueId != null and catalogueId != ''">and api.catalogue_id = #{catalogueId}</if>
<if test="apiName != null and apiName != ''">and api.api_name = #{apiName}</if>
<if test="apiRemark != null and apiRemark != ''">and api.api_remark = #{apiRemark}</if>
<if test="needLogin != null and needLogin != ''">and api.need_Login = #{needLogin}</if>
<if test="authenticationPort != null and authenticationPort != ''">and api.authentication_port =
#{authenticationPort}
</if>
<if test="parameterPassingMode != null and parameterPassingMode != ''">and parameter_passing_mode =
<if test="parameterPassingMode != null and parameterPassingMode != ''">and api.parameter_passing_mode =
#{parameterPassingMode}
</if>
<if test="destinationAddress != null and destinationAddress != ''">and destination_address =
<if test="destinationAddress != null and destinationAddress != ''">and api.destination_address =
#{destinationAddress}
</if>
<if test="requestCoding != null and requestCoding != ''">and request_coding = #{requestCoding}</if>
<if test="requestMethod != null and requestMethod != ''">and request_method = #{requestMethod}</if>
<if test="timeoutPeriod != null and timeoutPeriod != ''">and timeout_period = #{timeoutPeriod}</if>
<if test="currentLimiting != null and currentLimiting != ''">and current_limiting = #{currentLimiting}</if>
<if test="headerIn != null and headerIn != ''">and header_in = #{headerIn}</if>
<if test="queryIn != null and queryIn != ''">and query_in = #{queryIn}</if>
<if test="bodyInType != null and bodyInType != ''">and body_in_type = #{bodyInType}</if>
<if test="bodyIn != null and bodyIn != ''">and body_in = #{bodyIn}</if>
<if test="bodyOut != null and bodyOut != ''">and body_out = #{bodyOut}</if>
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
<if test="returnMsg != null and returnMsg != ''">and return_msg = #{returnMsg}</if>
<if test="returnSuccessField != null and returnSuccessField != ''">and return_success_field = #{returnSuccessField}</if>
<if test="returnSuccessValue != null and returnSuccessValue != ''">and return_success_value = #{returnSuccessValue}</if>
<if test="funName != null and funName != ''">and fun_name = #{funName}</if>
<if test="extensionApi != null and extensionApi != ''">and extension_api = #{extensionApi}</if>
<if test="sorts != null">and sorts = #{sorts}</if>
<if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
<if test="create_time != null">and create_time = #{create_time}</if>
<if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
<if test="modify_time != null">and modify_time = #{modify_time}</if>
<if test="sts != null and sts != ''">and sts = #{sts}</if>
<if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
and sts='Y'
<if test="requestCoding != null and requestCoding != ''">and api.request_coding = #{requestCoding}</if>
<if test="requestMethod != null and requestMethod != ''">and api.request_method = #{requestMethod}</if>
<if test="timeoutPeriod != null and timeoutPeriod != ''">and api.timeout_period = #{timeoutPeriod}</if>
<if test="currentLimiting != null and currentLimiting != ''">and api.current_limiting = #{currentLimiting}</if>
<if test="headerIn != null and headerIn != ''">and api.header_in = #{headerIn}</if>
<if test="queryIn != null and queryIn != ''">and api.query_in = #{queryIn}</if>
<if test="bodyInType != null and bodyInType != ''">and api.body_in_type = #{bodyInType}</if>
<if test="bodyIn != null and bodyIn != ''">and api.body_in = #{bodyIn}</if>
<if test="bodyOut != null and bodyOut != ''">and api.body_out = #{bodyOut}</if>
<if test="beanName != null and beanName != ''">and api.bean_name = #{beanName}</if>
<if test="returnMsg != null and returnMsg != ''">and api.return_msg = #{returnMsg}</if>
<if test="returnSuccessField != null and returnSuccessField != ''">and api.return_success_field = #{returnSuccessField}</if>
<if test="returnSuccessValue != null and returnSuccessValue != ''">and api.return_success_value = #{returnSuccessValue}</if>
<if test="funName != null and funName != ''">and api.fun_name = #{funName}</if>
<if test="extensionApi != null and extensionApi != ''">and api.extension_api = #{extensionApi}</if>
<if test="sorts != null">and api.sorts = #{sorts}</if>
<if test="create_user_id != null and create_user_id != ''">and api.create_user_id = #{create_user_id}</if>
<if test="create_time != null">and api.create_time = #{create_time}</if>
<if test="modify_user_id != null and modify_user_id != ''">and api.modify_user_id = #{modify_user_id}</if>
<if test="modify_time != null">and api.modify_time = #{modify_time}</if>
<if test="sts != null and sts != ''">and api.sts = #{sts}</if>
<if test="org_id != null and org_id != ''">and api.org_id = #{org_id}</if>
and api.sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
<if test=" sort == null or sort == ''.toString() ">order by api.sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

View File

@ -24,6 +24,8 @@ public interface ISysApplicationApiService extends IBaseService<SysApplicationAp
**/
JsonResultEntity queryEntity(JSONObject jsonObject);
JsonResultEntity queryMultiAppPage(JSONObject jsonObject);
/**
* 模糊查询联查sys_app
* @param entity

View File

@ -1,10 +1,13 @@
package com.hzya.frame.sysnew.application.api.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
import com.hzya.frame.sysnew.application.api.service.ISysApplicationApiService;
import com.hzya.frame.sysnew.application.plugin.entity.SysApplicationPluginEntity;
import com.hzya.frame.sysnew.messageTemplate.entity.SysMessageTemplateEntity;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.stereotype.Service;
@ -12,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.ArrayList;
import java.util.List;
/**
@ -49,6 +53,42 @@ public class SysApplicationApiServiceImpl extends BaseService<SysApplicationApiE
return BaseResult.getSuccessMessageEntity("查询数据成功", list);
}
@Override
public JsonResultEntity queryMultiAppPage(JSONObject jsonObject){
SysApplicationApiEntity entity = getData("jsonStr", jsonObject, SysApplicationApiEntity.class);
//判断分页
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
}
int pageNum = entity.getPageNum();
int pageSize = entity.getPageSize();
//查询时不分页
entity.setPageNum(null);
entity.setPageSize(null);
String appIds = entity.getAppId();
if(appIds == null || "".equals(appIds.trim())){
return BaseResult.getFailureMessageEntity("应用ID不能为空");
}
String[] appIdList = appIds.split(",");
List<SysApplicationApiEntity> resultList = new ArrayList<>();
for (int i = 0; i < appIdList.length; i++) {
entity.setAppId(appIdList[i]);
List<SysApplicationApiEntity> list = sysApplicationApiDao.queryBase(entity);
resultList.addAll(list);
}
//手动分页
int total = resultList.size();
int fromIndex = (pageNum - 1) * pageSize;
int toIndex = Math.min(fromIndex + pageSize, total);
List<SysApplicationApiEntity> pageList = resultList.subList(fromIndex, toIndex);
PageInfo<SysApplicationApiEntity> pageInfo = new PageInfo<>(pageList);
pageInfo.setTotal(total);
pageInfo.setPages((total + pageSize - 1) / pageSize);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
/**
* 模糊查询联查sys_app
*

View File

@ -42,6 +42,16 @@ public class SysApplicationEntity extends BaseEntity {
private String interfaceStatus;
/** 数据源是否启用1、开启 2、关闭 */
private String dbStatus;
/** 新消息数 */
private int newMessageCount;
public int getNewMessageCount() {
return newMessageCount;
}
public void setNewMessageCount(int newMessageCount) {
this.newMessageCount = newMessageCount;
}
/** 系统类型 1、致远OA 2、用友U8C 3、用友BIP */
private String appType;

View File

@ -2649,7 +2649,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
sysPushMessageEntity.setReceiveApiCode(receiveApi.getApiCode());
sysPushMessageEntity.setReturnData(sysMessageManageLogEntity.getReturnData());
sysPushMessageEntity.setStatus(sysMessageManageLogEntity.getStatus());
//taskExecutor.execute(() -> sendMssage(sysPushMessageEntity));
taskExecutor.execute(() -> sendMssage(sysPushMessageEntity));
return sysMessageManageLogEntity;
}

View File

@ -566,7 +566,8 @@ where id = #{id}
a.status AS status,
a.remark AS remark,
a.create_time AS createTime,
a.modify_time AS modifyTime
a.modify_time AS modifyTime,
receiveApi.api_name AS receiveApiName
FROM
<choose>
<when test=" status != null and status.trim() != '' and status == 3">
@ -577,6 +578,7 @@ where id = #{id}
</otherwise>
</choose>
LEFT JOIN sys_application sendApp ON a.send_app = sendApp.id AND sendApp.sts = 'Y'
LEFT JOIN sys_application_api receiveApi ON a.receive_code = receiveApi.api_code AND receiveApi.sts = 'Y'
<trim prefix="where" prefixOverrides="and">
<if test="ids != null and ids.size>0">
AND a.id in

View File

@ -12,8 +12,6 @@ public class SysMessageTemplateEntity extends BaseEntity {
/** 公司id */
private String companyId;
/** 调用单据类型 */
private String billKindId;
/** 模版类型 */
private String templateType;
/** 模版名称 */
@ -26,14 +24,8 @@ public class SysMessageTemplateEntity extends BaseEntity {
private String btns;
/** 数据源 */
private String dataSource;
/** 创建时间 */
private Date createDate;
/** 创建人 */
private String createPersonId;
/** 状态 */
/** 状态 0停用 1启用 */
private String state;
/** 删除标志 */
private Integer isdelete;
public String getCompanyId() {
@ -44,14 +36,6 @@ public class SysMessageTemplateEntity extends BaseEntity {
this.companyId = companyId;
}
public String getBillKindId() {
return billKindId;
}
public void setBillKindId(String billKindId) {
this.billKindId = billKindId;
}
public String getTemplateType() {
return templateType;
}
@ -99,23 +83,6 @@ public class SysMessageTemplateEntity extends BaseEntity {
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreatePersonId() {
return createPersonId;
}
public void setCreatePersonId(String createPersonId) {
this.createPersonId = createPersonId;
}
public String getState() {
return state;
}
@ -123,14 +90,5 @@ public class SysMessageTemplateEntity extends BaseEntity {
public void setState(String state) {
this.state = state;
}
public Integer getIsdelete() {
return isdelete;
}
public void setIsdelete(Integer isdelete) {
this.isdelete = isdelete;
}
}

View File

@ -12,17 +12,13 @@
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
<result property="billKindId" column="bill_kind_id" jdbcType="VARCHAR"/>
<result property="templateType" column="template_type" jdbcType="VARCHAR"/>
<result property="templateName" column="template_name" jdbcType="VARCHAR"/>
<result property="messageTitle" column="message_title" jdbcType="VARCHAR"/>
<result property="messageContents" column="message_contents" jdbcType="VARCHAR"/>
<result property="btns" column="btns" jdbcType="VARCHAR"/>
<result property="dataSource" column="data_source" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
<result property="createPersonId" column="create_person_id" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="VARCHAR"/>
<result property="isdelete" column="isdelete" jdbcType="INTEGER"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "SysMessageTemplateEntity_Base_Column_List">
@ -34,18 +30,14 @@
,modify_time
,sts
,org_id
,company_id
,bill_kind_id
,company_id
,template_type
,template_name
,message_title
,message_contents
,btns
,data_source
,create_date
,create_person_id
,state
,isdelete
,data_source
,state
</sql>
<!--通过ID获取数据 -->
@ -70,17 +62,13 @@
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="billKindId != null and billKindId != ''"> and bill_kind_id = #{billKindId} </if>
<if test="templateType != null and templateType != ''"> and template_type = #{templateType} </if>
<if test="templateName != null and templateName != ''"> and template_name = #{templateName} </if>
<if test="messageTitle != null and messageTitle != ''"> and message_title = #{messageTitle} </if>
<if test="messageContents != null and messageContents != ''"> and message_contents = #{messageContents} </if>
<if test="btns != null and btns != ''"> and btns = #{btns} </if>
<if test="dataSource != null and dataSource != ''"> and data_source = #{dataSource} </if>
<if test="createDate != null"> and create_date = #{createDate} </if>
<if test="createPersonId != null and createPersonId != ''"> and create_person_id = #{createPersonId} </if>
<if test="state != null and state != ''"> and state = #{state} </if>
<if test="isdelete != null"> and isdelete = #{isdelete} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -100,15 +88,12 @@
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="billKindId != null and billKindId != ''"> and bill_kind_id = #{billKindId} </if>
<if test="templateType != null and templateType != ''"> and template_type = #{templateType} </if>
<if test="templateName != null and templateName != ''"> and template_name = #{templateName} </if>
<if test="messageTitle != null and messageTitle != ''"> and message_title = #{messageTitle} </if>
<if test="messageContents != null and messageContents != ''"> and message_contents = #{messageContents} </if>
<if test="btns != null and btns != ''"> and btns = #{btns} </if>
<if test="dataSource != null and dataSource != ''"> and data_source = #{dataSource} </if>
<if test="createDate != null"> and create_date = #{createDate} </if>
<if test="createPersonId != null and createPersonId != ''"> and create_person_id = #{createPersonId} </if>
<if test="state != null and state != ''"> and state = #{state} </if>
<if test="isdelete != null"> and isdelete = #{isdelete} </if>
and sts='Y'
@ -132,17 +117,13 @@
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
<if test="billKindId != null and billKindId != ''"> and bill_kind_id like concat('%',#{billKindId},'%') </if>
<if test="templateType != null and templateType != ''"> and template_type like concat('%',#{templateType},'%') </if>
<if test="templateName != null and templateName != ''"> and template_name like concat('%',#{templateName},'%') </if>
<if test="messageTitle != null and messageTitle != ''"> and message_title like concat('%',#{messageTitle},'%') </if>
<if test="messageContents != null and messageContents != ''"> and message_contents like concat('%',#{messageContents},'%') </if>
<if test="btns != null and btns != ''"> and btns like concat('%',#{btns},'%') </if>
<if test="dataSource != null and dataSource != ''"> and data_source like concat('%',#{dataSource},'%') </if>
<if test="createDate != null"> and create_date like concat('%',#{createDate},'%') </if>
<if test="createPersonId != null and createPersonId != ''"> and create_person_id like concat('%',#{createPersonId},'%') </if>
<if test="state != null and state != ''"> and state like concat('%',#{state},'%') </if>
<if test="isdelete != null"> and isdelete like concat('%',#{isdelete},'%') </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -164,15 +145,12 @@
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> or company_id = #{companyId} </if>
<if test="billKindId != null and billKindId != ''"> or bill_kind_id = #{billKindId} </if>
<if test="templateType != null and templateType != ''"> or template_type = #{templateType} </if>
<if test="templateName != null and templateName != ''"> or template_name = #{templateName} </if>
<if test="messageTitle != null and messageTitle != ''"> or message_title = #{messageTitle} </if>
<if test="messageContents != null and messageContents != ''"> or message_contents = #{messageContents} </if>
<if test="btns != null and btns != ''"> or btns = #{btns} </if>
<if test="dataSource != null and dataSource != ''"> or data_source = #{dataSource} </if>
<if test="createDate != null"> or create_date = #{createDate} </if>
<if test="createPersonId != null and createPersonId != ''"> or create_person_id = #{createPersonId} </if>
<if test="state != null and state != ''"> or state = #{state} </if>
<if test="isdelete != null"> or isdelete = #{isdelete} </if>
and sts='Y'
@ -194,17 +172,13 @@
<if test="sts != null and sts != ''"> sts , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<if test="billKindId != null and billKindId != ''"> bill_kind_id , </if>
<if test="templateType != null and templateType != ''"> template_type , </if>
<if test="templateName != null and templateName != ''"> template_name , </if>
<if test="messageTitle != null and messageTitle != ''"> message_title , </if>
<if test="messageContents != null and messageContents != ''"> message_contents , </if>
<if test="btns != null and btns != ''"> btns , </if>
<if test="dataSource != null and dataSource != ''"> data_source , </if>
<if test="createDate != null"> create_date , </if>
<if test="createPersonId != null and createPersonId != ''"> create_person_id , </if>
<if test="state != null and state != ''"> state , </if>
<if test="isdelete != null"> isdelete , </if>
<if test="sts == null ">sts,</if>
</trim>
)values(
@ -218,17 +192,13 @@
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>
<if test="companyId != null and companyId != ''"> #{companyId} ,</if>
<if test="billKindId != null and billKindId != ''"> #{billKindId} ,</if>
<if test="templateType != null and templateType != ''"> #{templateType} ,</if>
<if test="templateName != null and templateName != ''"> #{templateName} ,</if>
<if test="messageTitle != null and messageTitle != ''"> #{messageTitle} ,</if>
<if test="messageContents != null and messageContents != ''"> #{messageContents} ,</if>
<if test="btns != null and btns != ''"> #{btns} ,</if>
<if test="dataSource != null and dataSource != ''"> #{dataSource} ,</if>
<if test="createDate != null"> #{createDate} ,</if>
<if test="createPersonId != null and createPersonId != ''"> #{createPersonId} ,</if>
<if test="state != null and state !=''"> #{state} ,</if>
<if test="isdelete != null"> #{isdelete} ,</if>
<if test="sts == null ">'Y',</if>
</trim>
)
@ -278,17 +248,13 @@ update sys_message_template set
<if test="sts != null and sts != ''"> sts = #{sts},</if>
<if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''"> company_id = #{companyId},</if>
<if test="billKindId != null and billKindId != ''"> bill_kind_id = #{billKindId},</if>
<if test="templateType != null and templateType != ''"> template_type = #{templateType},</if>
<if test="templateName != null and templateName != ''"> template_name = #{templateName},</if>
<if test="messageTitle != null and messageTitle != ''"> message_title = #{messageTitle},</if>
<if test="messageContents != null and messageContents != ''"> message_contents = #{messageContents},</if>
<if test="btns != null and btns != ''"> btns = #{btns},</if>
<if test="dataSource != null and dataSource != ''"> data_source = #{dataSource},</if>
<if test="createDate != null"> create_date = #{createDate},</if>
<if test="createPersonId != null and createPersonId != ''"> create_person_id = #{createPersonId},</if>
<if test="state != null and state !=''"> state = #{state},</if>
<if test="isdelete != null"> isdelete = #{isdelete},</if>
</trim>
where id = #{id}
</update>

View File

@ -9,11 +9,15 @@ import com.hzya.frame.sysnew.messageTemplate.dao.ISysMessageTemplateDao;
import com.hzya.frame.sysnew.messageTemplate.service.ISysMessageTemplateService;
import com.hzya.frame.sysnew.person.dao.ISysPersonDao;
import com.hzya.frame.sysnew.user.entity.SysUserEntity;
import com.hzya.frame.sysnew.warningConfig.dao.ISysWarningConfigDao;
import com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.sql.*;
@ -28,178 +32,178 @@ import java.util.List;
*/
@Service(value = "sysMessageTemplateService")
public class SysMessageTemplateServiceImpl extends BaseService<SysMessageTemplateEntity, String> implements ISysMessageTemplateService {
private ISysMessageTemplateDao sysMessageTemplateDao;
@Resource
public IExecSqlService execSqlService;
@Resource
private ISysWarningConfigDao sysWarningConfigDao;
@Resource
public IExecSqlService execSqlService;
@Autowired
public void setSysMessageTemplateDao(ISysMessageTemplateDao dao) {
this.sysMessageTemplateDao = dao;
this.dao = dao;
}
public void setSysMessageTemplateDao(ISysMessageTemplateDao dao) {
this.sysMessageTemplateDao = dao;
this.dao = dao;
}
@Override
public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
//判断分页
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<SysMessageTemplateEntity> list = sysMessageTemplateDao.queryByLike(entity);
PageInfo<SysMessageTemplateEntity> pageInfo = new PageInfo(list);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
@Override
public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
//判断分页
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<SysMessageTemplateEntity> list = sysMessageTemplateDao.queryByLike(entity);
PageInfo<SysMessageTemplateEntity> pageInfo = new PageInfo(list);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
@Override
public JsonResultEntity queryEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if(entity == null){
entity = new SysMessageTemplateEntity();
}
List<SysMessageTemplateEntity> list = sysMessageTemplateDao.queryByLike(entity);
return BaseResult.getSuccessMessageEntity("查询数据成功", list);
}
@Override
public JsonResultEntity queryEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
entity = new SysMessageTemplateEntity();
}
List<SysMessageTemplateEntity> list = sysMessageTemplateDao.queryByLike(entity);
return BaseResult.getSuccessMessageEntity("查询数据成功", list);
}
@Override
public JsonResultEntity getEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if(entity.getId() == null || "".equals(entity.getId())){
return BaseResult.getFailureMessageEntity("系统错误");
}
entity = sysMessageTemplateDao.get(entity.getId());
if(entity == null){
return BaseResult.getFailureMessageEntity("获取消息模版失败");
}
return BaseResult.getSuccessMessageEntity("获取消息模版成功", entity);
}
@Override
public JsonResultEntity getEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity = sysMessageTemplateDao.get(entity.getId());
if (entity == null) {
return BaseResult.getFailureMessageEntity("获取消息模版失败");
}
return BaseResult.getSuccessMessageEntity("获取消息模版成功", entity);
}
@Override
public JsonResultEntity saveEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if(entity.getBillKindId() == null || "".equals(entity.getBillKindId())){
return BaseResult.getFailureMessageEntity("调用单据类型不允许为空");
}
if(entity.getTemplateType() == null || "".equals(entity.getTemplateType())){
return BaseResult.getFailureMessageEntity("模版类型不允许为空");
}
if(entity.getTemplateName() == null || "".equals(entity.getTemplateName())){
return BaseResult.getFailureMessageEntity("模版名称不允许为空");
}
if(entity.getMessageContents() == null || "".equals(entity.getMessageContents())){
return BaseResult.getFailureMessageEntity("消息内容不允许为空");
}
if(entity.getDataSource() == null || "".equals(entity.getDataSource())){
return BaseResult.getFailureMessageEntity("数据源不允许为空");
}
if(entity.getCreateDate() == null){
return BaseResult.getFailureMessageEntity("创建时间不允许为空");
}
if(entity.getCreatePersonId() == null || "".equals(entity.getCreatePersonId())){
return BaseResult.getFailureMessageEntity("创建人不允许为空");
}
entity.setCreate();
sysMessageTemplateDao.save(entity);
return BaseResult.getSuccessMessageEntity("保存消息模版成功",entity);
}
@Override
public JsonResultEntity saveEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getTemplateType() == null || "".equals(entity.getTemplateType())) {
return BaseResult.getFailureMessageEntity("模版类型不允许为空");
}
if (entity.getTemplateName() == null || "".equals(entity.getTemplateName())) {
return BaseResult.getFailureMessageEntity("模版名称不允许为空");
}
if (entity.getMessageContents() == null || "".equals(entity.getMessageContents())) {
return BaseResult.getFailureMessageEntity("消息内容不允许为空");
}
if (entity.getDataSource() == null || "".equals(entity.getDataSource())) {
return BaseResult.getFailureMessageEntity("数据源不允许为空");
}
entity.setCreate();
sysMessageTemplateDao.save(entity);
return BaseResult.getSuccessMessageEntity("保存消息模版成功", entity);
}
@Override
public JsonResultEntity updateEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if(entity.getBillKindId() == null || "".equals(entity.getBillKindId())){
return BaseResult.getFailureMessageEntity("调用单据类型不允许为空");
}
if(entity.getTemplateType() == null || "".equals(entity.getTemplateType())){
return BaseResult.getFailureMessageEntity("模版类型不允许为空");
}
if(entity.getTemplateName() == null || "".equals(entity.getTemplateName())){
return BaseResult.getFailureMessageEntity("模版名称不允许为空");
}
if(entity.getMessageContents() == null || "".equals(entity.getMessageContents())){
return BaseResult.getFailureMessageEntity("消息内容不允许为空");
}
if(entity.getDataSource() == null || "".equals(entity.getDataSource())){
return BaseResult.getFailureMessageEntity("数据源不允许为空");
}
if(entity.getCreateDate() == null){
return BaseResult.getFailureMessageEntity("创建时间不允许为空");
}
if(entity.getCreatePersonId() == null || "".equals(entity.getCreatePersonId())){
return BaseResult.getFailureMessageEntity("创建人不允许为空");
}
entity.setUpdate();
sysMessageTemplateDao.update(entity);
return BaseResult.getSuccessMessageEntity("修改消息模版成功",entity);
}
@Override
public JsonResultEntity updateEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if (entity.getTemplateType() == null || "".equals(entity.getTemplateType())) {
return BaseResult.getFailureMessageEntity("模版类型不允许为空");
}
if (entity.getTemplateName() == null || "".equals(entity.getTemplateName())) {
return BaseResult.getFailureMessageEntity("模版名称不允许为空");
}
if (entity.getMessageContents() == null || "".equals(entity.getMessageContents())) {
return BaseResult.getFailureMessageEntity("消息内容不允许为空");
}
if (entity.getDataSource() == null || "".equals(entity.getDataSource())) {
return BaseResult.getFailureMessageEntity("数据源不允许为空");
}
entity.setUpdate();
sysMessageTemplateDao.update(entity);
return BaseResult.getSuccessMessageEntity("修改消息模版成功", entity);
}
@Override
public JsonResultEntity deleteEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity.setUpdate();
//1判断这个模版有没有被使用过使用过就不能删除待完成
//将模版id去预警配置表里查一下如果有匹配的数据代表有人正在使用不能删除
sysMessageTemplateDao.logicRemove(entity);
return BaseResult.getSuccessMessageEntity("删除消息模版成功");
}
@Override
public JsonResultEntity deleteEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//判断这个模版有没有被使用过使用过就不能删除
//将模版id去预警配置表里查一下如果有匹配的数据代表有人正在使用不能删除
SysWarningConfigEntity warningConfigEntity = new SysWarningConfigEntity();
warningConfigEntity.setMessageTemplateId(entity.getId());
int count = sysWarningConfigDao.getCount(warningConfigEntity);
if (count > 0) {
return BaseResult.getFailureMessageEntity("该模版已被使用,不能删除");
}
entity.setUpdate();
sysMessageTemplateDao.logicRemove(entity);
return BaseResult.getSuccessMessageEntity("删除消息模版成功");
}
@Override
public JsonResultEntity enableDisableEntity(JSONObject jsonObject){
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if (entity.getState() == null || "".equals(entity.getState())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//0启用1禁用
if("0".equals(entity.getState())){
entity.setUpdate();
sysMessageTemplateDao.update(entity);
return BaseResult.getSuccessMessageEntity("启用模版成功");
}else{
//停用消息模版
entity.setUpdate();
sysMessageTemplateDao.update(entity);
return BaseResult.getSuccessMessageEntity("停用模版成功");
}
}
@Override
public JsonResultEntity enableDisableEntity(JSONObject jsonObject) {
SysMessageTemplateEntity entity = getData("jsonStr", jsonObject, SysMessageTemplateEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if (entity.getState() == null || "".equals(entity.getState())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//0停用1启用
if ("0".equals(entity.getState())) {
entity.setUpdate();
sysMessageTemplateDao.update(entity);
//同步停用到预警配置表
SysWarningConfigEntity warningConfigEntity = new SysWarningConfigEntity();
warningConfigEntity.setMessageTemplateId(entity.getId());
warningConfigEntity.setStatus("1");
List<SysWarningConfigEntity> warningConfigList = sysWarningConfigDao.queryByLike(warningConfigEntity);
for (SysWarningConfigEntity warningConfig : warningConfigList) {
warningConfig.setStatus("0");
warningConfig.setUpdate();
sysWarningConfigDao.update(warningConfig);
}
return BaseResult.getSuccessMessageEntity("停用模版成功");
} else {
entity.setUpdate();
sysMessageTemplateDao.update(entity);
return BaseResult.getSuccessMessageEntity("启用模版成功");
}
}
@Override
public JsonResultEntity checkSql(JSONObject jsonObject) throws Exception {
try {
String sql = JSONObject.parseObject(jsonObject.getString("jsonStr")).getString("sql");
List<HashMap<String, Object>> result = execSqlService.execSelectSql(sql, "master");
return BaseResult.getSuccessMessageEntity("SQL检查成功", result);
} catch (Exception e) {
return BaseResult.getFailureMessageEntity("SQL检查失败原因" + e.getMessage());
}
}
@Override
public JsonResultEntity checkSql(JSONObject jsonObject) throws Exception {
try {
String sql = JSONObject.parseObject(jsonObject.getString("jsonStr")).getString("sql");
List<HashMap<String, Object>> result = execSqlService.execSelectSql(sql, "master");
return BaseResult.getSuccessMessageEntity("SQL检查成功", result);
} catch (Exception e) {
return BaseResult.getFailureMessageEntity("SQL检查失败原因" + e.getMessage());
}
}
@Override
public JsonResultEntity spliceMessage(JSONObject jsonObject){
return BaseResult.getSuccessMessageEntity("消息拼接成功");
}
@Override
public JsonResultEntity spliceMessage(JSONObject jsonObject) {
return BaseResult.getSuccessMessageEntity("消息拼接成功");
}
}

View File

@ -9,8 +9,6 @@ public class SysPushMessageEntity extends BaseEntity {
private Long warningAppCode;
/** 预警接口编码 */
private Long warningApiCode;
/** 接收者ID列表*/
private String recipientIdList;
/** 预警应用类型 */
private String warningAppType;
/** 发送应用名称 */
@ -59,14 +57,6 @@ public class SysPushMessageEntity extends BaseEntity {
this.receiveApiCode = receiveApiCode;
}
public String getRecipientIdList() {
return recipientIdList;
}
public void setRecipientIdList(String recipientIdList) {
this.recipientIdList = recipientIdList;
}
public String getWarningAppType() {
return warningAppType;
}

View File

@ -7,7 +7,6 @@
<result property="warningAppCode" column="warning_app_code" jdbcType="INTEGER"/>
<result property="warningApiCode" column="warning_api_code" jdbcType="INTEGER"/>
<result property="warningAppType" column="warning_app_type" jdbcType="VARCHAR"/>
<result property="recipientIdList" column="recipient_id_list" jdbcType="VARCHAR"/>
<result property="sendAppName" column="send_app_name" jdbcType="VARCHAR"/>
<result property="receiveAppName" column="receive_app_name" jdbcType="VARCHAR"/>
<result property="receiveApiName" column="receive_api_name" jdbcType="VARCHAR"/>
@ -23,19 +22,20 @@
warning_config.sendAppid AS warning_app_code,
warning_config.endApiCode AS warning_api_code,
warning_config.app_type AS warning_app_type,
warning_config.recipient_id AS recipient_id_list,
log.send_app_name,
log.receive_app_name,
receive_api_name,
log.receive_api_code,
log.return_data,
log.STATUS
log.STATUS,
log.create_time
FROM
v_hzya_sys_warning warning_config
LEFT JOIN v_hzya_sys_send_message_log log ON warning_config.api_code = log.receive_api_code
LEFT JOIN v_hzya_sys_send_message_log log ON warning_config.api_code = log.receive_api_code
WHERE
log.STATUS = '4'
AND warning_config.push_method = '定时'
AND warning_config.push_method = '定时'
AND log.create_time > DATE_SUB( CURDATE( ), INTERVAL 1 WEEK )
</select>
</mapper>

View File

@ -30,4 +30,5 @@ public class SysPushMessageServiceImpl extends BaseService<SysPushMessageEntity,
List<SysPushMessageEntity> list = sysPushMessageDao.getAll();
return BaseResult.getSuccessMessageEntity("success");
}
}

View File

@ -9,17 +9,20 @@ import com.hzya.frame.web.entity.BaseEntity;
* @since 2024-08-30 14:19:30
*/
public class SysSendMessageLogEntity extends BaseEntity {
//接收人姓名
private String recipientsPersonName;
//发送人姓名
private String sendPersonName;
/** 公司id */
private String companyId;
/** 来源业务单据 */
private String billId;
/** 消息类型1、系统消息、2、单据消息、3、钉钉、4微信、5短信、6、邮件 */
private String type;
/** 发送给谁三方系统userID 钉钉微信、邮箱、手机号) */
private String sendToUserId;
private String recipientsPersonId;
/** 发送给系统内部人员ID */
private String sendToPersonId;
private String recipientsInteriorId;
/** 消息内容 */
private String sendCount;
/** 发送时间 */
@ -32,7 +35,72 @@ public class SysSendMessageLogEntity extends BaseEntity {
private Integer state;
/** 三方系统消息结果 */
private String resultMessage;
/** 预警接口表id */
private String warningInterfaceId;
/** 应用id */
private String appId;
/** 应用名称 */
private String appName;
/** 消息标题 */
private String messageTitle;
/** 按钮 */
private String btns;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getMessageTitle() {
return messageTitle;
}
public void setMessageTitle(String messageTitle) {
this.messageTitle = messageTitle;
}
public String getBtns() {
return btns;
}
public void setBtns(String btns) {
this.btns = btns;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getWarningInterfaceId() {
return warningInterfaceId;
}
public void setWarningInterfaceId(String warningInterfaceId) {
this.warningInterfaceId = warningInterfaceId;
}
public String getRecipientsPersonName() {
return recipientsPersonName;
}
public void setRecipientsPersonName(String recipientsPersonName) {
this.recipientsPersonName = recipientsPersonName;
}
public String getSendPersonName() {
return sendPersonName;
}
public void setSendPersonName(String sendPersonName) {
this.sendPersonName = sendPersonName;
}
public String getCompanyId() {
return companyId;
@ -42,14 +110,6 @@ public class SysSendMessageLogEntity extends BaseEntity {
this.companyId = companyId;
}
public String getBillId() {
return billId;
}
public void setBillId(String billId) {
this.billId = billId;
}
public String getType() {
return type;
}
@ -58,20 +118,20 @@ public class SysSendMessageLogEntity extends BaseEntity {
this.type = type;
}
public String getSendToUserId() {
return sendToUserId;
public String getRecipientsPersonId() {
return recipientsPersonId;
}
public void setSendToUserId(String sendToUserId) {
this.sendToUserId = sendToUserId;
public void setRecipientsPersonId(String recipientsPersonId) {
this.recipientsPersonId = recipientsPersonId;
}
public String getSendToPersonId() {
return sendToPersonId;
public String getRecipientsInteriorId() {
return recipientsInteriorId;
}
public void setSendToPersonId(String sendToPersonId) {
this.sendToPersonId = sendToPersonId;
public void setRecipientsInteriorId(String recipientsInteriorId) {
this.recipientsInteriorId = recipientsInteriorId;
}
public String getSendCount() {

View File

@ -12,31 +12,24 @@
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
<result property="billId" column="bill_id" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="sendToUserId" column="send_to_user_id" jdbcType="VARCHAR"/>
<result property="sendToPersonId" column="send_to_person_id" jdbcType="VARCHAR"/>
<result property="recipientsPersonId" column="recipients_person_id" jdbcType="VARCHAR"/>
<result property="recipientsInteriorId" column="recipients_interior_id" jdbcType="VARCHAR"/>
<result property="sendCount" column="send_count" jdbcType="VARCHAR"/>
<result property="sendDatetime" column="send_datetime" jdbcType="TIMESTAMP"/>
<result property="sendPersonId" column="send_person_id" jdbcType="VARCHAR"/>
<result property="sourceModelName" column="source_model_name" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="resultMessage" column="result_message" jdbcType="VARCHAR"/>
<result property="recipientsPersonName" column="recipients_person_name" jdbcType="VARCHAR"/>
<result property="sendPersonName" column="send_person_name" jdbcType="VARCHAR"/>
<result property="warningInterfaceId" column="warning_interface_id" jdbcType="VARCHAR"/>
<result property="appId" column="app_id" jdbcType="VARCHAR"/>
<result property="messageTitle" column="message_title" jdbcType="VARCHAR"/>
<result property="appName" column="app_name" jdbcType="VARCHAR"/>
<result property="btns" column="btns" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="get-PushMessageEntity-result" type="com.hzya.frame.plugin.pushMessage.entity.PushMessageEntity" >
<result property="pushMessage" column="push_message" jdbcType="VARCHAR"/>
<result property="warningAppCode" column="warning_app_code" jdbcType="VARCHAR"/>
<result property="warningApiCode" column="warning_api_code" jdbcType="VARCHAR"/>
<result property="appType" column="app_type" jdbcType="VARCHAR"/>
<result property="recipientIdList" column="recipient_id_list" jdbcType="VARCHAR"/>
<result property="sendAppName" column="send_app_name" jdbcType="VARCHAR"/>
<result property="receiveAppName" column="receive_app_name" jdbcType="VARCHAR"/>
<result property="receiveApiName" column="receive_api_name" jdbcType="VARCHAR"/>
<result property="receiveApiCode" column="receive_api_code" jdbcType="VARCHAR"/>
<result property="returnData" column="return_data" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "SysSendMessageLogEntity_Base_Column_List">
id
@ -47,53 +40,67 @@
,modify_time
,sts
,org_id
,company_id
,bill_id
,company_id
,type
,send_to_user_id
,send_to_person_id
,recipients_person_id
,recipients_interior_id
,send_count
,send_datetime
,send_person_id
,source_model_name
,state
,result_message
,result_message
,warning_interface_id
</sql>
<!--通过ID获取数据 -->
<select id="entity_get" resultMap="get-SysSendMessageLogEntity-result">
select
<include refid="SysSendMessageLogEntity_Base_Column_List" />
from sys_send_message_log where id = #{ id } and sts='Y'
log.*
,p1.person_name as recipients_person_name
,p2.person_Name as send_person_name
from sys_send_message_log log
LEFT JOIN sys_person p1 ON p1.id = log.recipients_person_id
LEFT JOIN sys_person p2 ON p2.id = log.send_person_id
where log.id = #{ id } and log.sts='Y' and p1.sts='Y' and p2.sts='Y'
</select>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-SysSendMessageLogEntity-result" parameterType = "com.hzya.frame.sysnew.sendMessageLog.entity.SysSendMessageLogEntity">
select
<include refid="SysSendMessageLogEntity_Base_Column_List" />
from sys_send_message_log
log.*
,p1.person_name as recipients_person_name
,p2.person_Name as send_person_name
,i.app_id AS app_id
from sys_send_message_log log
LEFT JOIN sys_person p1 ON p1.id = log.recipients_person_id
LEFT JOIN sys_person p2 ON p2.id = log.send_person_id
LEFT JOIN sys_warning_interface i ON i.id = log.warning_interface_id
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
<if test="create_time != null"> and create_time = #{create_time} </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="billId != null and billId != ''"> and bill_id = #{billId} </if>
<if test="type != null and type != ''"> and type = #{type} </if>
<if test="sendToUserId != null and sendToUserId != ''"> and send_to_user_id = #{sendToUserId} </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> and send_to_person_id = #{sendToPersonId} </if>
<if test="sendCount != null and sendCount != ''"> and send_count = #{sendCount} </if>
<if test="sendDatetime != null"> and send_datetime = #{sendDatetime} </if>
<if test="sendPersonId != null and sendPersonId != ''"> and send_person_id = #{sendPersonId} </if>
<if test="sourceModelName != null and sourceModelName != ''"> and source_model_name = #{sourceModelName} </if>
<if test="state != null"> and state = #{state} </if>
<if test="resultMessage != null and resultMessage != ''"> and result_message = #{resultMessage} </if>
and sts='Y'
<if test="id != null and id != ''"> and log.id = #{id} </if>
<if test="sorts != null"> and log.sorts = #{sorts} </if>
<if test="create_user_id != null and create_user_id != ''"> and log.create_user_id = #{create_user_id} </if>
<if test="create_time != null"> and log.create_time = #{create_time} </if>
<if test="modify_user_id != null and modify_user_id != ''"> and log.modify_user_id = #{modify_user_id} </if>
<if test="modify_time != null"> and log.modify_time = #{modify_time} </if>
<if test="sts != null and sts != ''"> and log.sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and log.org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and log.company_id = #{companyId} </if>
<if test="type != null and type != ''"> and log.type = #{type} </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> and log.recipients_person_id = #{recipientsPersonId} </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> and log.recipients_interior_id = #{recipientsInteriorId} </if>
<if test="sendCount != null and sendCount != ''"> and log.send_count = #{sendCount} </if>
<if test="sendDatetime != null"> and log.send_datetime = #{sendDatetime} </if>
<if test="sendPersonId != null and sendPersonId != ''"> and log.send_person_id = #{sendPersonId} </if>
<if test="sourceModelName != null and sourceModelName != ''"> and log.source_model_name = #{sourceModelName} </if>
<if test="state != null"> and log.state = #{state} </if>
<if test="resultMessage != null and resultMessage != ''"> and log.result_message = #{resultMessage} </if>
<if test="appId != null and appId != ''" > and app_id = #{appId} </if>
and log.sts='Y'
and p1.sts='Y'
and p2.sts='Y'
and i.sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort == null or sort == ''.toString() "> order by log.sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
@ -110,10 +117,9 @@
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="billId != null and billId != ''"> and bill_id = #{billId} </if>
<if test="type != null and type != ''"> and type = #{type} </if>
<if test="sendToUserId != null and sendToUserId != ''"> and send_to_user_id = #{sendToUserId} </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> and send_to_person_id = #{sendToPersonId} </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> and recipients_person_id = #{recipientsPersonId} </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> and recipients_interior_id = #{recipientsInteriorId} </if>
<if test="sendCount != null and sendCount != ''"> and send_count = #{sendCount} </if>
<if test="sendDatetime != null"> and send_datetime = #{sendDatetime} </if>
<if test="sendPersonId != null and sendPersonId != ''"> and send_person_id = #{sendPersonId} </if>
@ -128,32 +134,51 @@
<!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-SysSendMessageLogEntity-result" parameterType = "com.hzya.frame.sysnew.sendMessageLog.entity.SysSendMessageLogEntity">
select
<include refid="SysSendMessageLogEntity_Base_Column_List" />
from sys_send_message_log
SELECT
log.*,
p1.person_name AS recipients_person_name,
p2.person_Name AS send_person_name,
i.app_id AS app_id,
app.NAME AS app_name,
template.btns,
template.message_title
FROM
sys_send_message_log log
LEFT JOIN sys_person p1 ON p1.id = log.recipients_person_id
LEFT JOIN sys_person p2 ON p2.id = log.send_person_id
LEFT JOIN sys_warning_interface i ON i.id = log.warning_interface_id
LEFT JOIN sys_application app ON app.id = i.app_id
LEFT JOIN sys_warning_config config ON i.warning_config_id = config.id
LEFT JOIN sys_message_template template ON template.id = config.message_template_id
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
<if test="billId != null and billId != ''"> and bill_id like concat('%',#{billId},'%') </if>
<if test="type != null and type != ''"> and type like concat('%',#{type},'%') </if>
<if test="sendToUserId != null and sendToUserId != ''"> and send_to_user_id like concat('%',#{sendToUserId},'%') </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> and send_to_person_id like concat('%',#{sendToPersonId},'%') </if>
<if test="sendCount != null and sendCount != ''"> and send_count like concat('%',#{sendCount},'%') </if>
<if test="sendDatetime != null"> and send_datetime like concat('%',#{sendDatetime},'%') </if>
<if test="sendPersonId != null and sendPersonId != ''"> and send_person_id like concat('%',#{sendPersonId},'%') </if>
<if test="sourceModelName != null and sourceModelName != ''"> and source_model_name like concat('%',#{sourceModelName},'%') </if>
<if test="state != null"> and state like concat('%',#{state},'%') </if>
<if test="resultMessage != null and resultMessage != ''"> and result_message like concat('%',#{resultMessage},'%') </if>
and sts='Y'
<if test="id != null and id != ''"> and log.id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and log.sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and log.create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and log.create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and log.modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and log.modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and log.sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and log.org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and log.company_id like concat('%',#{companyId},'%') </if>
<if test="type != null and type != ''"> and log.type like concat('%',#{type},'%') </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> and log.recipients_person_id like concat('%',#{recipientsPersonId},'%') </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> and log.recipients_interior_id like concat('%',#{recipientsInteriorId},'%') </if>
<if test="sendCount != null and sendCount != ''"> and log.send_count like concat('%',#{sendCount},'%') </if>
<if test="sendDatetime != null"> and log.send_datetime like concat('%',DATE (#{sendDatetime}),'%') </if>
<if test="sendPersonId != null and sendPersonId != ''"> and log.send_person_id like concat('%',#{sendPersonId},'%') </if>
<if test="sourceModelName != null and sourceModelName != ''"> and log.source_model_name like concat('%',#{sourceModelName},'%') </if>
<if test="state != null"> and log.state like concat('%',#{state},'%') </if>
<if test="resultMessage != null and resultMessage != ''"> and log.result_message like concat('%',#{resultMessage},'%') </if>
<if test="appId != null and appId != ''">and i.app_id like concat('%',#{appId},'%') </if>
and log.sts='Y'
and i.sts='Y'
and config.sts='Y'
and template.sts='Y'
and p1.sts='Y'
and p2.sts='Y'
and app.sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort == null or sort == ''.toString() "> order by log.sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
@ -172,10 +197,9 @@
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> or company_id = #{companyId} </if>
<if test="billId != null and billId != ''"> or bill_id = #{billId} </if>
<if test="type != null and type != ''"> or type = #{type} </if>
<if test="sendToUserId != null and sendToUserId != ''"> or send_to_user_id = #{sendToUserId} </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> or send_to_person_id = #{sendToPersonId} </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> or recipients_person_id = #{recipientsPersonId} </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> or recipients_interior_id = #{recipientsInteriorId} </if>
<if test="sendCount != null and sendCount != ''"> or send_count = #{sendCount} </if>
<if test="sendDatetime != null"> or send_datetime = #{sendDatetime} </if>
<if test="sendPersonId != null and sendPersonId != ''"> or send_person_id = #{sendPersonId} </if>
@ -201,16 +225,16 @@
<if test="sts != null and sts != ''"> sts , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<if test="billId != null and billId != ''"> bill_id , </if>
<if test="type != null and type != ''"> type , </if>
<if test="sendToUserId != null and sendToUserId != ''"> send_to_user_id , </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> send_to_person_id , </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> recipients_person_id , </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> recipients_interior_id , </if>
<if test="sendCount != null and sendCount != ''"> send_count , </if>
<if test="sendDatetime != null"> send_datetime , </if>
<if test="sendPersonId != null and sendPersonId != ''"> send_person_id , </if>
<if test="sourceModelName != null and sourceModelName != ''"> source_model_name , </if>
<if test="state != null"> state , </if>
<if test="resultMessage != null and resultMessage != ''"> result_message , </if>
<if test="warningInterfaceId != null and warningInterfaceId != ''"> warning_interface_id , </if>
<if test="sts == null ">sts,</if>
</trim>
)values(
@ -224,34 +248,34 @@
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>
<if test="companyId != null and companyId != ''"> #{companyId} ,</if>
<if test="billId != null and billId != ''"> #{billId} ,</if>
<if test="type != null and type != ''"> #{type} ,</if>
<if test="sendToUserId != null and sendToUserId != ''"> #{sendToUserId} ,</if>
<if test="sendToPersonId != null and sendToPersonId != ''"> #{sendToPersonId} ,</if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> #{recipientsPersonId} ,</if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> #{recipientsInteriorId} ,</if>
<if test="sendCount != null and sendCount != ''"> #{sendCount} ,</if>
<if test="sendDatetime != null"> #{sendDatetime} ,</if>
<if test="sendPersonId != null and sendPersonId != ''"> #{sendPersonId} ,</if>
<if test="sourceModelName != null and sourceModelName != ''"> #{sourceModelName} ,</if>
<if test="state != null"> #{state} ,</if>
<if test="resultMessage != null and resultMessage != ''"> #{resultMessage} ,</if>
<if test="warningInterfaceId != null and warningInterfaceId != ''"> #{warningInterfaceId} ,</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
insert into sys_send_message_log(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, bill_id, type, send_to_user_id, send_to_person_id, send_count, send_datetime, send_person_id, source_model_name, state, result_message, sts)
insert into sys_send_message_log(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, bill_id, type, recipients_person_id, recipients_interior_id, send_count, send_datetime, send_person_id, source_model_name, state, result_message, sts)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.billId},#{entity.type},#{entity.sendToUserId},#{entity.sendToPersonId},#{entity.sendCount},#{entity.sendDatetime},#{entity.sendPersonId},#{entity.sourceModelName},#{entity.state},#{entity.resultMessage}, 'Y')
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.billId},#{entity.type},#{entity.recipientsPersonId},#{entity.recipientsInteriorId},#{entity.sendCount},#{entity.sendDatetime},#{entity.sendPersonId},#{entity.sourceModelName},#{entity.state},#{entity.resultMessage}, 'Y')
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into sys_send_message_log(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, bill_id, type, send_to_user_id, send_to_person_id, send_count, send_datetime, send_person_id, source_model_name, state, result_message)
insert into sys_send_message_log(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, bill_id, type, recipients_person_id, recipients_interior_id, send_count, send_datetime, send_person_id, source_model_name, state, result_message)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.billId},#{entity.type},#{entity.sendToUserId},#{entity.sendToPersonId},#{entity.sendCount},#{entity.sendDatetime},#{entity.sendPersonId},#{entity.sourceModelName},#{entity.state},#{entity.resultMessage})
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.billId},#{entity.type},#{entity.recipientsPersonId},#{entity.recipientsInteriorId},#{entity.sendCount},#{entity.sendDatetime},#{entity.sendPersonId},#{entity.sourceModelName},#{entity.state},#{entity.resultMessage})
</foreach>
on duplicate key update
create_user_id = values(create_user_id),
@ -263,8 +287,8 @@
company_id = values(company_id),
bill_id = values(bill_id),
type = values(type),
send_to_user_id = values(send_to_user_id),
send_to_person_id = values(send_to_person_id),
recipients_person_id = values(recipients_person_id),
recipients_interior_id = values(recipients_interior_id),
send_count = values(send_count),
send_datetime = values(send_datetime),
send_person_id = values(send_person_id),
@ -282,10 +306,9 @@ update sys_send_message_log set
<if test="sts != null and sts != ''"> sts = #{sts},</if>
<if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''"> company_id = #{companyId},</if>
<if test="billId != null and billId != ''"> bill_id = #{billId},</if>
<if test="type != null and type != ''"> type = #{type},</if>
<if test="sendToUserId != null and sendToUserId != ''"> send_to_user_id = #{sendToUserId},</if>
<if test="sendToPersonId != null and sendToPersonId != ''"> send_to_person_id = #{sendToPersonId},</if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> recipients_person_id = #{recipientsPersonId},</if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> recipients_interior_id = #{recipientsInteriorId},</if>
<if test="sendCount != null and sendCount != ''"> send_count = #{sendCount},</if>
<if test="sendDatetime != null"> send_datetime = #{sendDatetime},</if>
<if test="sendPersonId != null and sendPersonId != ''"> send_person_id = #{sendPersonId},</if>
@ -308,10 +331,9 @@ update sys_send_message_log set sts= 'N' ,modify_time = #{modify_time},modify_u
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="billId != null and billId != ''"> and bill_id = #{billId} </if>
<if test="type != null and type != ''"> and type = #{type} </if>
<if test="sendToUserId != null and sendToUserId != ''"> and send_to_user_id = #{sendToUserId} </if>
<if test="sendToPersonId != null and sendToPersonId != ''"> and send_to_person_id = #{sendToPersonId} </if>
<if test="recipientsPersonId != null and recipientsPersonId != ''"> and recipients_person_id = #{recipientsPersonId} </if>
<if test="recipientsInteriorId != null and recipientsInteriorId != ''"> and recipients_interior_id = #{recipientsInteriorId} </if>
<if test="sendCount != null and sendCount != ''"> and send_count = #{sendCount} </if>
<if test="sendDatetime != null"> and send_datetime = #{sendDatetime} </if>
<if test="sendPersonId != null and sendPersonId != ''"> and send_person_id = #{sendPersonId} </if>
@ -326,28 +348,5 @@ update sys_send_message_log set sts= 'N' ,modify_time = #{modify_time},modify_u
delete from sys_send_message_log where id = #{id}
</delete>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-PushMessageEntity-result" parameterType = "com.hzya.frame.plugin.pushMessage.entity.PushMessageEntity">
SELECT
warning_config.push_method,
warning_config.sendAppid AS warning_app_code,
warning_config.endApiCode AS warning_api_code,
warning_config.app_type,
warning_config.recipient_id AS recipient_id_list,
log.send_app_name,
log.receive_app_name,
receive_api_name,
log.receive_api_code,
log.return_data,
log.STATUS
FROM
v_hzya_sys_warning warning_config
LEFT JOIN v_hzya_sys_send_message_log log ON warning_config.api_code = log.receive_api_code
WHERE
log.STATUS = '4'
AND warning_config.push_method = '定时'
</select>
</mapper>

View File

@ -23,6 +23,8 @@ public interface ISysSendMessageLogService extends IBaseService<SysSendMessageLo
JsonResultEntity saveEntity(JSONObject jsonObject);
JsonResultEntity markRead(JSONObject jsonObject);
JsonResultEntity updateEntity(JSONObject jsonObject);
JsonResultEntity deleteEntity(JSONObject jsonObject);

View File

@ -10,8 +10,12 @@ import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
import com.hzya.frame.sysnew.application.apiPara.dao.ISysApplicationApiParaDao;
import com.hzya.frame.sysnew.application.apiPara.entity.SysApplicationApiParaEntity;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.service.impl.ApplicationCache;
import com.hzya.frame.sysnew.messageTemplate.dao.ISysMessageTemplateDao;
import com.hzya.frame.sysnew.messageTemplate.entity.SysMessageTemplateEntity;
import com.hzya.frame.sysnew.person.dao.ISysPersonDao;
import com.hzya.frame.sysnew.pushMessage.entity.SysPushMessageEntity;
import com.hzya.frame.sysnew.sendMessageLog.entity.SysSendMessageLogEntity;
import com.hzya.frame.sysnew.sendMessageLog.dao.ISysSendMessageLogDao;
@ -28,7 +32,9 @@ import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.ArrayList;
@ -44,369 +50,442 @@ import java.util.List;
@Service(value = "sysSendMessageLogService")
public class SysSendMessageLogServiceImpl extends BaseService<SysSendMessageLogEntity, String> implements ISysSendMessageLogService {
@Resource
private ISysWarningInterfaceDao sysWarningInterfaceDao;
@Resource
private ISysWarningConfigDao sysWarningConfigDao;
@Resource
private ISysMessageTemplateDao sysMessageTemplateDao;
@Resource
private ISysUserDao sysUserDao;
@Resource
private ISysApplicationApiDao sysApplicationApiDao;
@Resource
private ISysApplicationApiParaDao sysApplicationApiParaDao;
@Value("${zt.url}")
private String url ;
private ISysSendMessageLogDao sysSendMessageLogDao;
@Resource
private ApplicationCache applicationCache;
@Resource
private ISysWarningInterfaceDao sysWarningInterfaceDao;
@Resource
private ISysWarningConfigDao sysWarningConfigDao;
@Resource
private ISysMessageTemplateDao sysMessageTemplateDao;
@Resource
private ISysUserDao sysUserDao;
@Resource
private ISysPersonDao sysPersonsDao;
@Autowired
public void setSysSendMessageLogDao(ISysSendMessageLogDao dao) {
this.sysSendMessageLogDao = dao;
this.dao = dao;
}
@Resource
private ISysApplicationApiDao sysApplicationApiDao;
@Resource
private ISysApplicationApiParaDao sysApplicationApiParaDao;
@Override
public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryByLike(entity);
PageInfo pageInfo = new PageInfo(list);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
@Value("${zt.url}")
private String url ;
@Override
public JsonResultEntity queryEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
entity = new SysSendMessageLogEntity();
}
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryByLike(entity);
return BaseResult.getSuccessMessageEntity("查询数据成功", list);
}
private ISysSendMessageLogDao sysSendMessageLogDao;
@Override
public JsonResultEntity getEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity = sysSendMessageLogDao.get(entity.getId());
if (entity == null) {
return BaseResult.getFailureMessageEntity("获取发送消息日志失败");
}
return BaseResult.getSuccessMessageEntity("获取发送消息日志成功", entity);
}
@Autowired
public void setSysSendMessageLogDao(ISysSendMessageLogDao dao) {
this.sysSendMessageLogDao = dao;
this.dao = dao;
}
@Override
public JsonResultEntity saveEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getBillId() == null || "".equals(entity.getBillId())) {
return BaseResult.getFailureMessageEntity("来源业务单据不能为空");
}
entity.setCreate();
sysSendMessageLogDao.save(entity);
return BaseResult.getSuccessMessageEntity("保存发送消息日志成功", entity);
}
@Override
public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryByLike(entity);
PageInfo pageInfo = new PageInfo(list);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
@Override
public JsonResultEntity updateEntity(JSONObject jsonObject){
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if (entity.getBillId() == null || "".equals(entity.getBillId())) {
return BaseResult.getFailureMessageEntity("来源业务单据不能为空");
}
entity.setUpdate();
sysSendMessageLogDao.update(entity);
return BaseResult.getSuccessMessageEntity("修改发送消息日志成功", entity);
}
@Override
public JsonResultEntity queryEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
entity = new SysSendMessageLogEntity();
}
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryByLike(entity);
return BaseResult.getSuccessMessageEntity("查询数据成功", list);
}
@Override
public JsonResultEntity deleteEntity(JSONObject jsonObject){
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity.setUpdate();;
sysSendMessageLogDao.logicRemove(entity);
return BaseResult.getSuccessMessageEntity("删除发送消息日志成功", entity);
}
@Override
public JsonResultEntity getEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity = sysSendMessageLogDao.get(entity.getId());
if (entity == null) {
return BaseResult.getFailureMessageEntity("获取发送消息日志失败");
}
return BaseResult.getSuccessMessageEntity("获取发送消息日志成功", entity);
}
@Override
public JsonResultEntity markRead(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity.getAppId() == null || "".equals(entity.getAppId())) {
return BaseResult.getFailureMessageEntity("传入appId不能为空");
}
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryBase(entity);
if (list == null || list.size() == 0) {
return BaseResult.getSuccessMessageEntity("未找到需要标记已读的消息日志", list);
}
for (SysSendMessageLogEntity log : list) {
log.setState(1);
log.setUpdate();
sysSendMessageLogDao.update(log);
}
return BaseResult.getSuccessMessageEntity("标记已读成功", list);
}
@Override
public JsonResultEntity saveEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
entity.setCreate();
sysSendMessageLogDao.save(entity);
return BaseResult.getSuccessMessageEntity("保存发送消息日志成功", entity);
}
@Override
public JsonResultEntity updateEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity.setUpdate();
sysSendMessageLogDao.update(entity);
return BaseResult.getSuccessMessageEntity("修改发送消息日志成功", entity);
}
@Override
public JsonResultEntity deleteEntity(JSONObject jsonObject) {
SysSendMessageLogEntity entity = getData("jsonStr", jsonObject, SysSendMessageLogEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不能为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
entity.setUpdate();
;
sysSendMessageLogDao.logicRemove(entity);
return BaseResult.getSuccessMessageEntity("删除发送消息日志成功", entity);
}
/**
* sendMessage方法根据请求错误消息组装成消息模版推送到三方业务系统
* 1先获取接口调用的日志数据
* 2如果日志状态为失败且该接口预警状态为启用则进行消息推送
* 3根据预警配置找到消息模版并生成消息内容
* 4根据预警配置找到预警应用并推送消息
* 5保存消息推送日志
* */
@Override
public boolean sendMessage(SysPushMessageEntity entity){
String status = entity.getStatus();
Long receiveApiCode = entity.getReceiveApiCode();
String sendAppName = entity.getSendAppName();
String receiveApiName = entity.getReceiveApiName();
String recieveAppName = entity.getReceiveAppName();
String returnData = entity.getReturnData();
String warningAppType = entity.getWarningAppType();
Long warningAppCode = entity.getWarningAppCode();
Long warningApiCode = entity.getWarningApiCode();
String sendMsgContent = "";
/**
* sendMessage方法根据请求错误消息组装成消息模版推送到三方业务系统
* 1先获取接口调用的日志数据
* 2如果日志状态为失败且该接口预警状态为启用则进行消息推送
* 3根据预警配置找到消息模版并生成消息内容
* 4根据预警配置找到预警应用并推送消息
* 5保存消息推送日志
*/
@Override
public boolean sendMessage(SysPushMessageEntity entity) {
String status = entity.getStatus();
Long receiveApiCode = entity.getReceiveApiCode();
String sendAppName = entity.getSendAppName();
String receiveApiName = entity.getReceiveApiName();
String recieveAppName = entity.getReceiveAppName();
String returnData = entity.getReturnData();
String sendMsgContent = "";
SysWarningInterfaceEntity interfaceEntity = new SysWarningInterfaceEntity();
SysWarningConfigEntity configEntity = new SysWarningConfigEntity();
SysMessageTemplateEntity templateEntity = new SysMessageTemplateEntity();
SysApplicationApiParaEntity sysApplicationApiParaEntity = new SysApplicationApiParaEntity();
//SysWarningInterfaceEntity interfaceEntityApi = new SysWarningInterfaceEntity();
SysWarningInterfaceEntity interfaceEntity = new SysWarningInterfaceEntity();
SysWarningConfigEntity configEntity = new SysWarningConfigEntity();
SysMessageTemplateEntity templateEntity = new SysMessageTemplateEntity();
SysApplicationApiParaEntity sysApplicationApiParaEntity = new SysApplicationApiParaEntity();
interfaceEntity.setApiCode(receiveApiCode);
//interfaceEntityApi.setApiCode(receiveApiCode);
interfaceEntity.setApiCode(receiveApiCode);
if (status == null) {
logger.error("日志状态为空");
return false;
}
//只有发送失败的日志才会推送消息成功的日志不推送消息
if ("4".equals(status)) {
try {
interfaceEntity = sysWarningInterfaceDao.queryOne(interfaceEntity);
} catch (Exception e) {
logger.error("API接口预警信息可能配置了多个");
return false;
}
//List<SysWarningInterfaceEntity> interfaceEntityList =sysWarningInterfaceDao.queryByLike(interfaceEntityApi);
//for(SysWarningInterfaceEntity interfaceEntity : interfaceEntityList){
if (interfaceEntity == null) {
logger.error("未找到API接口预警信息");
return false;
}
//只有预警接口状态为启用才会进行消息推送
if (interfaceEntity.getStatus() == null || interfaceEntity.getStatus().equals("1") == false) {
logger.error("API接口未启用推送");
return false;
}
//根据主表id找到主表记录中的消息模版id
String warningConfigId = interfaceEntity.getWarningConfigId();
SysWarningConfigEntity statusEntity = new SysWarningConfigEntity();
statusEntity.setStatus("1");
statusEntity.setId(warningConfigId);
if (warningConfigId == null || "".equals(warningConfigId)) {
logger.error("未找到该接口预警配置信息的主表id");
return false;
}
configEntity = sysWarningConfigDao.queryOne(statusEntity);
if (configEntity == null) {
logger.error("未找到该接口预警配置信息");
return false;
}
String messageTemplateId = configEntity.getMessageTemplateId();
if (messageTemplateId == null || "".equals(messageTemplateId)) {
logger.error("未找到该接口预警配置信息的消息模版id");
return false;
}
templateEntity = sysMessageTemplateDao.get(messageTemplateId);
if (templateEntity == null) {
logger.error("未找到该接口预警配置信息的消息模版信息");
return false;
}
if(templateEntity.getState() == null || !"1".equals(templateEntity.getState())){
logger.error("当前预警配置中消息模版状态为禁用");
return false;
}
if(status == null){
logger.error("日志状态为空");
return false;
}
//只有发送失败的日志才会推送消息成功的日志不推送消息
if ("4".equals(status)) {
interfaceEntity = sysWarningInterfaceDao.queryOne(interfaceEntity);
if(interfaceEntity == null){
logger.error("未找到API接口预警信息");
return false;
}
//只有预警接口状态为启用才会进行消息推送
if(interfaceEntity.getStatus() == null || interfaceEntity.getStatus().equals("1") == false){
logger.error("API接口未启用推送");
return false;
}
//根据主表id找到主表记录中的消息模版id
String warningConfigId = interfaceEntity.getWarningConfigId();
if(warningConfigId == null || "".equals(warningConfigId)){
logger.error("未找到该接口预警配置信息的主表id");
return false;
}
configEntity = sysWarningConfigDao.get(warningConfigId);
if(configEntity == null){
logger.error("未找到该接口预警配置信息");
return false;
}
String messageTemplateId = configEntity.getMessageTemplateId();
if(messageTemplateId == null || "".equals(messageTemplateId)){
logger.error("未找到该接口预警配置信息的消息模版id");
return false;
}
templateEntity = sysMessageTemplateDao.get(messageTemplateId);
if(templateEntity == null){
logger.error("未找到该接口预警配置信息的消息模版信息");
return false;
}
String messageContent = templateEntity.getMessageContents();
if (messageContent == null || "".equals(messageContent)) {
logger.error("未找到该接口预警配置信息的消息模版内容");
return false;
}
//推送消息内容拼接
sendMsgContent = messageContent.replace("${receive_app_name}", recieveAppName);
sendMsgContent = sendMsgContent.replace("${send_app_name}", sendAppName);
sendMsgContent = sendMsgContent.replace("${receive_api_name}", receiveApiName);
sendMsgContent = sendMsgContent.replace("${return_data}", returnData);
//消息模版名称
String templateName = templateEntity.getTemplateName();
String type = "";
String bodyParams = "";
String warningAppId = configEntity.getWarningAppId();
String messageContent = templateEntity.getMessageContents();
if(messageContent == null || "".equals(messageContent)){
logger.error("未找到该接口预警配置信息的消息模版内容");
return false;
}
//推送消息内容拼接
sendMsgContent = messageContent.replace("${reciecveAppName}",recieveAppName);
sendMsgContent = sendMsgContent.replace("${sendAppName}",sendAppName);
sendMsgContent = sendMsgContent.replace("${receiveApiName}",receiveApiName);
sendMsgContent = sendMsgContent.replace("${returnData}",returnData);
//消息模版名称
String templateName = templateEntity.getTemplateName();
String type = "";
String bodyParams = "";
String warningAppId = configEntity.getWarningAppId();
Long warningApiCode = configEntity.getAcceptMessageApiCode();
String appCode = String.valueOf(warningApiCode).substring(0, 6);
SysApplicationEntity warningApp = getAppByAppId(appCode);
String warningAppType = warningApp.getAppType();
Integer warningAppCode = warningApp.getAppId();
//查询预警人员id列表
String recipientIdList = configEntity.getRecipientId();
//根据预警人员id列表获取预警应用人员id列表
String warningAppReceiverIdList = getWarningAppReceiverIdList(warningAppType,recipientIdList);
//查询预警人员id列表
String recipientIdList = configEntity.getRecipientIdList();
//根据预警人员id列表获取预警应用人员id列表
String warningAppReceiverIdList = getWarningAppReceiverIdList(warningAppType, recipientIdList);
switch (warningAppType){
case "6WX":
//调用微信推送消息
break;
case "5DD":
//消息类型3表示钉钉
type = "3";
//获取钉钉发送消息时使用的微应用的AgentID
sysApplicationApiParaEntity.setAppId(warningAppId);
sysApplicationApiParaEntity.setInterfaceKey("agentId");
String agentId = sysApplicationApiParaDao.queryOne(sysApplicationApiParaEntity).getInterfaceValue();
//拼接调用钉钉接口的body参数
bodyParams = splicingDDBody(sendMsgContent,agentId,warningAppReceiverIdList).toString();
break;
default:
logger.error("未找到该应用类型");
break;
}
String result = HttpRequest.post(url).
header("appId",warningAppCode.toString()).
header("apiCode",warningApiCode.toString()).
header("publicKey","ZJYA7v6DubGMm8EdBPGo+Jj9wCpUeCGJEpfBRLiInq4dvDlCe7eDIk+3zDUT+v578prj").
header("secretKey","bsAMm6tvJs/BV1SO/9ZzjlW+OQaK0mwyv6rLvktyNy/OdltLuG2zze9bT7ttfAA9j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(bodyParams).
execute().
body();
JSONObject resultJson = JSONObject.parseObject(result);
String body = resultJson.getString("attribute");
switch (warningAppType) {
case "6WX":
//调用微信推送消息
break;
case "5DD":
//消息类型3表示钉钉
type = "3";
//获取钉钉发送消息时使用的微应用的AgentID
sysApplicationApiParaEntity.setAppId(warningAppId);
sysApplicationApiParaEntity.setInterfaceKey("agentId");
String agentId = sysApplicationApiParaDao.queryOne(sysApplicationApiParaEntity).getInterfaceValue();
//拼接调用钉钉接口的body参数
bodyParams = splicingDDBody(sendMsgContent, agentId, warningAppReceiverIdList).toString();
break;
default:
logger.error("未找到该应用类型");
break;
}
String result = HttpRequest.post(url).
header("appId", warningAppCode.toString()).
header("apiCode", warningApiCode.toString()).
header("publicKey", "ZJYA7v6DubGMm8EdBPGo+Jj9wCpUeCGJEpfBRLiInq4dvDlCe7eDIk+3zDUT+v578prj").
header("secretKey", "bsAMm6tvJs/BV1SO/9ZzjlW+OQaK0mwyv6rLvktyNy/OdltLuG2zze9bT7ttfAA9j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(bodyParams).
execute().
body();
JSONObject resultJson = JSONObject.parseObject(result);
String body = resultJson.getString("attribute");
SysApplicationApiEntity warningApiEntity = getApiByAppIdApiCode(warningAppId, warningApiCode.toString());
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setApiCode(warningApiCode);
SysApplicationApiEntity warningApiEntity = sysApplicationApiDao.queryOne(sysApplicationApiEntity);
//根据预警接口编码以及返回数据判断消息推送是否成功
if (warningApiEntity.getReturnSuccessField() != null && !"".equals(warningApiEntity.getReturnSuccessField())
&& warningApiEntity.getReturnSuccessValue() != null && !"".equals(warningApiEntity.getReturnSuccessValue())) {
//先判断返回值是否为JSON格式
if (JSONUtil.isTypeJSON(body)) {
JSONObject cheackdatas = JSONObject.parseObject(body);
JSONObject datas = JSONObject.parseObject(body);
String checkdata = cheackdatas.getString(warningApiEntity.getReturnSuccessField());
//判断返回值是否为预警接口预期的返回值(1返回值匹配2返回值配置的就是not null3返回值带.)
if (checkdata != null && warningApiEntity.getReturnSuccessValue().equals(checkdata)) {
logger.info("推送消息成功,开始保存日志");
} else if (warningApiEntity.getReturnSuccessValue().equals("not null") && checkdata != null) {
logger.info("推送消息成功,开始保存日志");
} else {
String fieldname = warningApiEntity.getReturnSuccessField();
if (fieldname.contains(".")) {
String[] fileds = fieldname.split("\\.");
boolean flags = false;
for (int i = 0; i < fileds.length; i++) {
if (JSONUtil.isTypeJSON(datas.getString(fileds[i]))) {
datas = datas.getJSONObject(fileds[i]);
if (fileds.length - 2 == i) {
String a = datas.getString(fileds[i + 1]);
if (a != null && warningApiEntity.getReturnSuccessValue().equals(a)) {
flags = true;
break;
} else if (warningApiEntity.getReturnSuccessValue().equals("not null") && a != null) {
flags = true;
break;
} else {
break;
}
}
}
}
if (flags) {
logger.info("推送消息成功,开始保存日志");
} else {
logger.error("推送消息失败,返回值错误");
}
//根据预警接口编码以及返回数据判断消息推送是否成功
if(warningApiEntity.getReturnSuccessField() != null && !"".equals(warningApiEntity.getReturnSuccessField())
&& warningApiEntity.getReturnSuccessValue() != null && !"".equals(warningApiEntity.getReturnSuccessValue())){
//先判断返回值是否为JSON格式
if (JSONUtil.isTypeJSON(body)){
JSONObject cheackdatas = JSONObject.parseObject(body);
JSONObject datas = JSONObject.parseObject(body);
String checkdata = cheackdatas.getString(warningApiEntity.getReturnSuccessField());
//判断返回值是否为预警接口预期的返回值(1返回值匹配2返回值配置的就是not null3返回值带.)
if (checkdata != null && warningApiEntity.getReturnSuccessValue().equals(checkdata)) {
logger.info("推送消息成功,开始保存日志");
}else if(warningApiEntity.getReturnSuccessValue().equals("not null") && checkdata != null){
logger.info("推送消息成功,开始保存日志");
}else {
String fieldname = warningApiEntity.getReturnSuccessField();
if(fieldname.contains(".")){
String[] fileds = fieldname.split("\\.");
boolean flags = false;
for (int i = 0; i < fileds.length; i++) {
if (JSONUtil.isTypeJSON(datas.getString(fileds[i]))) {
datas = datas.getJSONObject(fileds[i]);
if(fileds.length-2 == i ){
String a = datas.getString(fileds[i+1]);
if (a != null && warningApiEntity.getReturnSuccessValue().equals(a)) {
flags = true;
break;
}else if(warningApiEntity.getReturnSuccessValue().equals("not null") && a != null){
flags = true;
break;
}else {
break;
}
}
}
}
if(flags){
logger.info("推送消息成功,开始保存日志");
}else {
logger.error("推送消息失败,返回值错误");
}
} else {
logger.error("推送消息失败,返回值错误");
}
}
} else {
logger.error("接口调用失败,返回格式错误不是JSON");
}
} else {
logger.error("api返回信息字段未配置开始保存日志");
}
saveLog(sendMsgContent, type, resultJson.toString(), templateName, recipientIdList, warningAppReceiverIdList, interfaceEntity.getId());
logger.info("保存日志成功");
//}
}else {
logger.error("推送消息失败,返回值错误");
}
}
}else{
logger.error("接口调用失败,返回格式错误不是JSON");
}
}else{
logger.error("api返回信息字段未配置开始保存日志");
}
saveLog(sendMsgContent,type,resultJson.toString(),templateName,recipientIdList,warningAppReceiverIdList);
logger.info("保存日志成功");
}else{
logger.error("日志状态为成功,不需要推送消息");
return false;
}
return true;
}
} else {
logger.error("日志状态为成功,不需要推送消息");
return false;
}
return true;
}
/**
* 根据appCode查询缓存中的应用信息
*/
private SysApplicationEntity getAppByAppId(String appId) {
String str = "appId" + appId;
Object o = applicationCache.get("1", str);
if (o != null) {
return (SysApplicationEntity) o;
}
return null;
}
/**保存推送消息日志时需要循环预警应用人员id列表*/
public void saveLog(String sendMsgContent,String type,String resultMessage,String templateName,String recipientIdList,String warningAppReceiverIdList){
SysSendMessageLogEntity logEntity = new SysSendMessageLogEntity();
logEntity.setSendCount(sendMsgContent);
logEntity.setType(type);
logEntity.setBillId("test1411");
logEntity.setSendDatetime(new Date());
/**
* 根据appId和apiCode查询缓存中的api信息
*/
private SysApplicationApiEntity getApiByAppIdApiCode(String appId, String apiCode) {
logEntity.setSts("Y");
logEntity.setCreate_user_id("1");
logEntity.setModify_user_id("1");
logEntity.setCreate_time(new Date());
logEntity.setModify_time(new Date());
logEntity.setOrg_id("0");
logEntity.setCompanyId("0");
String str = "appId" + appId + "apiCode" + apiCode;
Object o = applicationCache.get("2", str);
if (o != null) {
return (SysApplicationApiEntity) o;
}
return null;
}
/**
* 保存推送消息日志时需要循环预警应用人员id列表
*/
public void saveLog(String sendMsgContent, String type, String resultMessage, String templateName, String recipientIdList, String warningAppReceiverIdList,String warningInterfaceId) {
SysSendMessageLogEntity logEntity = new SysSendMessageLogEntity();
logEntity.setSendCount(sendMsgContent);
logEntity.setType(type);
logEntity.setSendDatetime(new Date());
logEntity.setSts("Y");
logEntity.setCreate_user_id("1");
logEntity.setModify_user_id("1");
logEntity.setCreate_time(new Date());
logEntity.setModify_time(new Date());
logEntity.setOrg_id("0");
logEntity.setCompanyId("0");
logEntity.setSendPersonId("1");
logEntity.setResultMessage(resultMessage);
logEntity.setSourceModelName(templateName);
logEntity.setResultMessage(resultMessage);
logEntity.setSourceModelName(templateName);
logEntity.setState(0);
logEntity.setWarningInterfaceId(warningInterfaceId);
String[] recipientsInteriorIdList = warningAppReceiverIdList.split(",");
String[] recipientsPersonIdList = recipientIdList.split(",");
String[] personIdList = warningAppReceiverIdList.split(",");
String[] userIdList = recipientIdList.split(",");
for (int i = 0; i < recipientsInteriorIdList.length; i++) {
logEntity.setRecipientsInteriorId(recipientsInteriorIdList[i]);
logEntity.setRecipientsPersonId(recipientsPersonIdList[i]);
logEntity.setId(UUIDUtils.getUUID());
sysSendMessageLogDao.save(logEntity);
}
}
for(int i=0;i<personIdList.length;i++){
logEntity.setSendToPersonId(personIdList[i]);
logEntity.setSendToUserId(userIdList[i]);
logEntity.setId(UUIDUtils.getUUID());
sysSendMessageLogDao.save(logEntity);
}
}
/**拼接调用钉钉接口的body参数*/
public JSONObject splicingDDBody(String sendMsgContent,String agentId,String userid_list){
JSONObject bodyJson = new JSONObject();
JSONObject msg = new JSONObject();
JSONObject text = new JSONObject();
/**
* 拼接调用钉钉接口的body参数
*/
public JSONObject splicingDDBody(String sendMsgContent, String agentId, String userid_list) {
JSONObject bodyJson = new JSONObject();
JSONObject msg = new JSONObject();
JSONObject text = new JSONObject();
text.put("content",sendMsgContent);
msg.put("msgtype","text");
msg.put("text",text);
bodyJson.put("msg",msg);
bodyJson.put("to_all_user","false");
bodyJson.put("agent_id",agentId);
bodyJson.put("userid_list",userid_list);
text.put("content", sendMsgContent);
msg.put("msgtype", "text");
msg.put("text", text);
bodyJson.put("msg", msg);
bodyJson.put("to_all_user", "false");
bodyJson.put("agent_id", agentId);
bodyJson.put("userid_list", userid_list);
return bodyJson;
}
return bodyJson;
}
/**根据预警应用类型和预警人员id列表,获取预警应用人员id列表*/
public String getWarningAppReceiverIdList(String warningAppType,String userIdList){
/**
* 根据预警应用类型和预警人员id列表,获取预警应用人员id列表
*/
public String getWarningAppReceiverIdList(String warningAppType, String personIdList) {
String[] userIdArray = userIdList.split(",");
String warningAppReceiverIdList = "";
//根据预警人员id列表查表sys_user中匹配的数据记录
List<SysUserEntity> sysUserList = new ArrayList<>();
for(String userId : userIdArray){
sysUserList.add(sysUserDao.get(userId));
}
switch (warningAppType){
case "6WX":
//获取微信预警人员id列表
break;
case "5DD":
//获取钉钉预警人员id列表
for(SysUserEntity sysUser : sysUserList){
if(sysUser.getDdUserId()!= null && !"".equals(sysUser.getDdUserId())){
if(!warningAppReceiverIdList.isEmpty()){
warningAppReceiverIdList += ",";
}
warningAppReceiverIdList += sysUser.getDdUserId();
}
}
break;
default:
logger.error("未找到该应用类型");
break;
}
String[] personIdArray = personIdList.split(",");
List<SysUserEntity> sysUserList = new ArrayList<>();
SysUserEntity sysUserEntity = new SysUserEntity();
for (String personId : personIdArray) {
sysUserEntity.setPersonId(personId);
sysUserList.add(sysUserDao.queryOne(sysUserEntity));
}
String warningAppReceiverIdList = "";
switch (warningAppType) {
case "6WX":
//获取微信预警人员id列表
break;
case "5DD":
//获取钉钉预警人员id列表
for (SysUserEntity sysUser : sysUserList) {
if (sysUser.getDdUserId() == null || "".equals(sysUser.getDdUserId())) {
String personName = sysPersonsDao.get(sysUser.getPersonId()).getPersonName();
logger.error("接收人:" +personName + "未配置钉钉用户id");
}
if (sysUser.getDdUserId() != null && !"".equals(sysUser.getDdUserId())) {
if (!warningAppReceiverIdList.isEmpty()) {
warningAppReceiverIdList += ",";
}
warningAppReceiverIdList += sysUser.getDdUserId();
}
}
break;
default:
logger.error("未找到该应用类型");
break;
}
return warningAppReceiverIdList;
}
}
}

View File

@ -14,8 +14,8 @@ public class SysWarningConfigEntity extends BaseEntity {
private String companyId;
/** 消息模版id */
private String messageTemplateId;
/** 应用id */
private String appId;
/** 应用id列表 */
private String appIdList;
/** 预警应用id */
private String warningAppId;
/** 接收推送消息的api编码 */
@ -25,8 +25,63 @@ public class SysWarningConfigEntity extends BaseEntity {
/** 是否启用0停用、1启用 */
private String status;
/** 接收人id存表sys_user的id */
private String recipientId;
private String recipientIdList;
/** 模版名称 */
private String templateName;
/** 应用名称 */
private String appNameList;
/** 预警应用名称 */
private String warningAppNameList;
/** 接收人名称列表 */
private String recipientNameList;
public String getWarningAppNameList() {
return warningAppNameList;
}
public void setWarningAppNameList(String warningAppNameList) {
this.warningAppNameList = warningAppNameList;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getAppNameList() {
return appNameList;
}
public void setAppNameList(String appNameList) {
this.appNameList = appNameList;
}
public String getRecipientNameList() {
return recipientNameList;
}
public void setRecipientNameList(String recipientNameList) {
this.recipientNameList = recipientNameList;
}
public String getAppIdList() {
return appIdList;
}
public void setAppIdList(String appIdList) {
this.appIdList = appIdList;
}
public String getRecipientIdList() {
return recipientIdList;
}
public void setRecipientIdList(String recipientIdList) {
this.recipientIdList = recipientIdList;
}
public String getCompanyId() {
return companyId;
@ -44,13 +99,6 @@ public class SysWarningConfigEntity extends BaseEntity {
this.messageTemplateId = messageTemplateId;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getWarningAppId() {
return warningAppId;
@ -84,13 +132,5 @@ public class SysWarningConfigEntity extends BaseEntity {
this.status = status;
}
public String getRecipientId() {
return recipientId;
}
public void setRecipientId(String recipientId) {
this.recipientId = recipientId;
}
}

View File

@ -13,12 +13,13 @@
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
<result property="messageTemplateId" column="message_template_id" jdbcType="VARCHAR"/>
<result property="appId" column="app_id" jdbcType="VARCHAR"/>
<result property="appIdList" column="app_id_list" jdbcType="VARCHAR"/>
<result property="warningAppId" column="warning_app_id" jdbcType="VARCHAR"/>
<result property="acceptMessageApiCode" column="accept_message_api_code" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="recipientId" column="recipient_id" jdbcType="VARCHAR"/>
<result property="recipientIdList" column="recipient_id_list" jdbcType="VARCHAR"/>
<result property="templateName" column="template_name" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "SysWarningConfigEntity_Base_Column_List">
@ -32,19 +33,22 @@
,org_id
,company_id
,message_template_id
,app_id
,app_id_list
,warning_app_id
,accept_message_api_code
,remark
,status
,recipient_id
,recipient_id_list
</sql>
<!--通过ID获取数据 -->
<select id="entity_get" resultMap="get-SysWarningConfigEntity-result">
select
<include refid="SysWarningConfigEntity_Base_Column_List" />
from sys_warning_config where id = #{ id } and sts='Y'
config.*
,template.template_name
from sys_warning_config config
LEFT JOIN sys_message_template template ON template.id = config.message_template_id
where config.id = #{ id } AND config.sts='Y' AND template.sts='Y'
</select>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-SysWarningConfigEntity-result" parameterType = "com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity">
@ -62,12 +66,12 @@
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> and message_template_id = #{messageTemplateId} </if>
<if test="appId != null and appId != ''"> and app_id = #{appId} </if>
<if test="appIdList != null and appIdList != ''"> and app_id_list = #{appIdList} </if>
<if test="warningAppId != null and warningAppId != ''"> and warning_app_id = #{warningAppId} </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> and accept_message_api_code = #{acceptMessageApiCode} </if>
<if test="remark != null and remark != ''"> and remark = #{remark} </if>
<if test="status != null and status != ''"> and status = #{status} </if>
<if test="recipientId != null and recipientId != ''"> and recipient_id = #{recipientId} </if>
<if test="recipientIdList != null and recipientIdList != ''"> and recipient_id_list = #{recipientIdList} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -88,12 +92,12 @@
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> and message_template_id = #{messageTemplateId} </if>
<if test="appId != null and appId != ''"> and app_id = #{appId} </if>
<if test="appIdList != null and appIdList != ''"> and app_id_list = #{appIdList} </if>
<if test="warningAppId != null and warningAppId != ''"> and warning_app_id = #{warningAppId} </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> and accept_message_api_code = #{acceptMessageApiCode} </if>
<if test="remark != null and remark != ''"> and remark = #{remark} </if>
<if test="status != null and status != ''"> and status = #{status} </if>
<if test="recipientId != null and recipientId != ''"> and recipient_id = #{recipientId} </if>
<if test="recipientIdList != null and recipientIdList != ''"> and recipient_id_list = #{recipientIdList} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -103,28 +107,31 @@
<!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-SysWarningConfigEntity-result" parameterType = "com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity">
select
<include refid="SysWarningConfigEntity_Base_Column_List" />
from sys_warning_config
config.*
,template.template_name
from sys_warning_config config
LEFT JOIN sys_message_template template ON template.id = config.message_template_id
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> and message_template_id like concat('%',#{messageTemplateId},'%') </if>
<if test="appId != null and appId != ''"> and app_id like concat('%',#{appId},'%') </if>
<if test="warningAppId != null and warningAppId != ''"> and warning_app_id like concat('%',#{warningAppId},'%') </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> and accept_message_api_code like concat('%',#{acceptMessageApiCode},'%') </if>
<if test="remark != null and remark != ''"> and remark like concat('%',#{remark},'%') </if>
<if test="status != null and status != ''"> and status like concat('%',#{status},'%') </if>
<if test="recipientId != null and recipientId != ''"> and recipient_id like concat('%',#{recipientId},'%') </if>
and sts='Y'
<if test="id != null and id != ''"> and config.id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and config.sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and config.create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and config.create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and config.modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and config.modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and config.sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and config.org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and config.company_id like concat('%',#{companyId},'%') </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> and config.message_template_id like concat('%',#{messageTemplateId},'%') </if>
<if test="appIdList != null and appIdList != ''"> and config.app_id_list like concat('%',#{appIdList},'%') </if>
<if test="warningAppId != null and warningAppId != ''"> and config.warning_app_id like concat('%',#{warningAppId},'%') </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> and config.accept_message_api_code like concat('%',#{acceptMessageApiCode},'%') </if>
<if test="remark != null and remark != ''"> and config.remark like concat('%',#{remark},'%') </if>
<if test="status != null and status != ''"> and config.status like concat('%',#{status},'%') </if>
<if test="recipientIdList != null and recipientIdList != ''"> and config.recipient_id_list like concat('%',#{recipientIdList},'%') </if>
and config.sts='Y'
and template.sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort == null or sort == ''.toString() "> order by config.sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
@ -144,12 +151,12 @@
<if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> or company_id = #{companyId} </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> or message_template_id = #{messageTemplateId} </if>
<if test="appId != null and appId != ''"> or app_id = #{appId} </if>
<if test="appIdList != null and appIdList != ''"> or app_id_list = #{appIdList} </if>
<if test="warningAppId != null and warningAppId != ''"> or warning_app_id = #{warningAppId} </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> or accept_message_api_code = #{acceptMessageApiCode} </if>
<if test="remark != null and remark != ''"> or remark = #{remark} </if>
<if test="status != null and status != ''"> or status = #{status} </if>
<if test="recipientId != null and recipientId != ''"> or recipient_id = #{recipientId} </if>
<if test="recipientIdList != null and recipientIdList != ''"> or recipient_id_list = #{recipientIdList} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -170,12 +177,12 @@
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> message_template_id , </if>
<if test="appId != null and appId != ''"> app_id , </if>
<if test="appIdList != null and appIdList != ''"> app_id_list , </if>
<if test="warningAppId != null and warningAppId != ''"> warning_app_id , </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> accept_message_api_code , </if>
<if test="remark != null and remark != ''"> remark , </if>
<if test="status != null and status != ''"> status , </if>
<if test="recipientId != null and recipientId != ''"> recipient_id , </if>
<if test="recipientIdList != null and recipientIdList != ''"> recipient_id_list , </if>
<if test="sts == null ">sts,</if>
</trim>
)values(
@ -190,30 +197,30 @@
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>
<if test="companyId != null and companyId != ''"> #{companyId} ,</if>
<if test="messageTemplateId != null and messageTemplateId != ''"> #{messageTemplateId} ,</if>
<if test="appId != null and appId != ''"> #{appId} ,</if>
<if test="appIdList != null and appIdList != ''"> #{appIdList} ,</if>
<if test="warningAppId != null and warningAppId != ''"> #{warningAppId} ,</if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> #{acceptMessageApiCode} ,</if>
<if test="remark != null and remark != ''"> #{remark} ,</if>
<if test="status != null and status != ''"> #{status} ,</if>
<if test="recipientId != null and recipientId != ''"> #{recipientId} ,</if>
<if test="recipientIdList != null and recipientIdList != ''"> #{recipientIdList} ,</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
insert into sys_warning_config(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, message_template_id, app_id, warning_app_id, accept_message_api_code, remark, status, recipient_id, sts)
insert into sys_warning_config(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, message_template_id, app_id_list, warning_app_id, accept_message_api_code, remark, status, recipient_id_list, sts)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.messageTemplateId},#{entity.appId},#{entity.warningAppId},#{entity.acceptMessageApiCode},#{entity.remark},#{entity.status},#{entity.recipientId}, 'Y')
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.messageTemplateId},#{entity.appIdList},#{entity.warningAppId},#{entity.acceptMessageApiCode},#{entity.remark},#{entity.status},#{entity.recipientIdList}, 'Y')
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into sys_warning_config(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, message_template_id, app_id, warning_app_id, accept_message_api_code, remark, status, recipient_id)
insert into sys_warning_config(create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, message_template_id, app_id_list, warning_app_id, accept_message_api_code, remark, status, recipient_id_list)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.messageTemplateId},#{entity.appId},#{entity.warningAppId},#{entity.acceptMessageApiCode},#{entity.remark},#{entity.status},#{entity.recipientId})
(#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.messageTemplateId},#{entity.appIdList},#{entity.warningAppId},#{entity.acceptMessageApiCode},#{entity.remark},#{entity.status},#{entity.recipientIdList})
</foreach>
on duplicate key update
create_user_id = values(create_user_id),
@ -224,12 +231,12 @@
org_id = values(org_id),
company_id = values(company_id),
message_template_id = values(message_template_id),
app_id = values(app_id),
app_id_list = values(app_id_list),
warning_app_id = values(warning_app_id),
accept_message_api_code = values(accept_message_api_code),
remark = values(remark),
status = values(status),
recipient_id = values(recipient_id)</insert>
recipient_id_list = values(recipient_id_list)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity" >
update sys_warning_config set
@ -242,12 +249,12 @@ update sys_warning_config set
<if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''"> company_id = #{companyId},</if>
<if test="messageTemplateId != null and messageTemplateId != ''"> message_template_id = #{messageTemplateId},</if>
<if test="appId != null and appId != ''"> app_id = #{appId},</if>
<if test="appIdList != null and appIdList != ''"> app_id_list = #{appIdList},</if>
<if test="warningAppId != null and warningAppId != ''"> warning_app_id = #{warningAppId},</if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> accept_message_api_code = #{acceptMessageApiCode},</if>
<if test="remark != null and remark != ''"> remark = #{remark},</if>
<if test="status != null and status != ''"> status = #{status},</if>
<if test="recipientId != null and recipientId != ''"> recipient_id = #{recipientId},</if>
<if test="recipientIdList != null and recipientIdList != ''"> recipient_id_list = #{recipientIdList},</if>
</trim>
where id = #{id}
</update>
@ -265,12 +272,12 @@ update sys_warning_config set sts= 'N' ,modify_time = #{modify_time},modify_use
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="messageTemplateId != null and messageTemplateId != ''"> and message_template_id = #{messageTemplateId} </if>
<if test="appId != null and appId != ''"> and app_id = #{appId} </if>
<if test="appIdList != null and appIdList != ''"> and app_id_list = #{appIdList} </if>
<if test="warningAppId != null and warningAppId != ''"> and warning_app_id = #{warningAppId} </if>
<if test="acceptMessageApiCode != null and acceptMessageApiCode != ''"> and accept_message_api_code = #{acceptMessageApiCode} </if>
<if test="remark != null and remark != ''"> and remark = #{remark} </if>
<if test="status != null and status != ''"> and status = #{status} </if>
<if test="recipientId != null and recipientId != ''"> and recipient_id = #{recipientId} </if>
<if test="recipientIdList != null and recipientIdList != ''"> and recipient_id_list = #{recipientIdList} </if>
and sts='Y'
</trim>
</update>

View File

@ -1,11 +1,22 @@
package com.hzya.frame.sysnew.warningConfig.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.messageTemplate.dao.ISysMessageTemplateDao;
import com.hzya.frame.sysnew.messageTemplate.entity.SysMessageTemplateEntity;
import com.hzya.frame.sysnew.person.dao.ISysPersonDao;
import com.hzya.frame.sysnew.person.entity.SysPersonEntity;
import com.hzya.frame.sysnew.user.dao.ISysUserDao;
import com.hzya.frame.sysnew.user.entity.SysUserEntity;
import com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity;
import com.hzya.frame.sysnew.warningConfig.dao.ISysWarningConfigDao;
import com.hzya.frame.sysnew.warningConfig.service.ISysWarningConfigService;
import com.hzya.frame.sysnew.warningInterface.dao.ISysWarningInterfaceDao;
import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.stereotype.Service;
@ -13,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.ArrayList;
import java.util.List;
/**
@ -23,7 +35,20 @@ import java.util.List;
*/
@Service(value = "sysWarningConfigService")
public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEntity, String> implements ISysWarningConfigService {
@Resource
private ISysWarningInterfaceDao sysWarningInterfaceDao;
@Resource
private ISysUserDao sysUserDao;
@Resource
private ISysPersonDao sysPersonDao;
@Resource
private ISysApplicationDao sysApplicationDao;
@Resource
private ISysMessageTemplateDao sysMessageTemplateDao;
private ISysWarningConfigDao sysWarningConfigDao;
@Autowired
@ -40,7 +65,9 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<SysWarningConfigEntity> list = sysWarningConfigDao.queryByLike(entity);
PageInfo pageInfo = new PageInfo(list);
//查询并记录应用名称预警应用名称接收者名称列表
List<SysWarningConfigEntity> resultList = queryNameList(list);
PageInfo pageInfo = new PageInfo(resultList);
return BaseResult.getSuccessMessageEntity("查询数据成功",pageInfo);
}
@ -51,8 +78,11 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
entity = new SysWarningConfigEntity();
}
List<SysWarningConfigEntity> list = sysWarningConfigDao.queryByLike(entity);
return BaseResult.getSuccessMessageEntity("查询数据成功",list);
//查询并记录应用名称预警应用名称接收者名称列表
List<SysWarningConfigEntity> resultList = queryNameList(list);
return BaseResult.getSuccessMessageEntity("查询数据成功",resultList);
}
/**查询应用名称、预警应用名称、接收者名称列表*/
@Override
public JsonResultEntity getEntity(JSONObject jsonObject){
@ -63,23 +93,51 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
if(entity.getId() == null || "".equals(entity.getId())){
return BaseResult.getFailureMessageEntity("系统错误");
}
//查询主表信息
entity = sysWarningConfigDao.get(entity.getId());
if(entity == null){
return BaseResult.getFailureMessageEntity("获取预警配置失败");
}
return BaseResult.getSuccessMessageEntity("获取预警配置成功",entity);
List<SysWarningConfigEntity> list = new ArrayList<>();
list.add(entity);
//查询并记录应用名称预警应用名称接收者名称列表
List<SysWarningConfigEntity> resultList = queryNameList(list);
String warningConfigId = resultList.get(0).getId();
//查询子表信息
SysWarningInterfaceEntity interfaceEntity = new SysWarningInterfaceEntity();
interfaceEntity.setWarningConfigId(warningConfigId);
List<SysWarningInterfaceEntity> interfaceList = sysWarningInterfaceDao.queryByLike(interfaceEntity);
//拼接主子表信息并返回
JSONObject father = (JSONObject) JSONObject.toJSON(resultList.get(0));
JSONArray sonArray = new JSONArray();
for(SysWarningInterfaceEntity interfaceOne : interfaceList){
JSONObject interfaceJson = (JSONObject) JSONObject.toJSON(interfaceOne);
sonArray.add(interfaceJson);
}
JSONObject resultJson = new JSONObject();
resultJson.put("father", father);
resultJson.put("son", sonArray);
return BaseResult.getSuccessMessageEntity("获取预警配置成功",resultJson);
}
@Override
public JsonResultEntity saveEntity(JSONObject jsonObject){
SysWarningConfigEntity entity = getData("jsonStr", jsonObject, SysWarningConfigEntity.class);
JSONObject jsonStr = jsonObject.getJSONObject("jsonStr");
JSONArray sonArray = jsonStr.getJSONArray("son");
List<SysWarningInterfaceEntity> interfaceEntities = new ArrayList<>();
for(int i=0;i<sonArray.size();i++){
String sonString = sonArray.getJSONObject(i).toString();
SysWarningInterfaceEntity interfaceEntity = getData(sonString,SysWarningInterfaceEntity.class);
interfaceEntities.add(interfaceEntity);
}
SysWarningConfigEntity entity = getData("father", jsonStr, SysWarningConfigEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if(entity.getMessageTemplateId() == null || "".equals(entity.getMessageTemplateId())){
return BaseResult.getFailureMessageEntity("消息模版不允许为空");
return BaseResult.getFailureMessageEntity("消息模版id不允许为空");
}
if(entity.getAppId() == null || "".equals(entity.getAppId())){
if(entity.getAppIdList() == null || "".equals(entity.getAppIdList())){
return BaseResult.getFailureMessageEntity("应用ID不允许为空");
}
if(entity.getWarningAppId() == null || "".equals(entity.getWarningAppId())){
@ -88,27 +146,59 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
if(entity.getStatus() == null || "".equals(entity.getStatus())){
return BaseResult.getFailureMessageEntity("状态不允许为空");
}
if(entity.getRecipientId() == null || "".equals(entity.getRecipientId())){
if(entity.getRecipientIdList() == null || "".equals(entity.getRecipientIdList())){
return BaseResult.getFailureMessageEntity("接收者ID不允许为空");
}
//检查接收者是否合规
String checkResult = checkRecipients(entity);
if(!"success".equals(checkResult)){
return BaseResult.getFailureMessageEntity(checkResult);
}
entity.setCreate();
String warningConfigId = entity.getId();
sysWarningConfigDao.save(entity);
for(SysWarningInterfaceEntity interfaceEntity : interfaceEntities){
interfaceEntity.setWarningConfigId(warningConfigId);
if(interfaceEntity.getApiCode() == null || "".equals(interfaceEntity.getApiCode())){
return BaseResult.getFailureMessageEntity("接口编码不能为空");
}
if(interfaceEntity.getPushMethod() == null || "".equals(interfaceEntity.getPushMethod())){
return BaseResult.getFailureMessageEntity("推送方式不能为空");
}
if(interfaceEntity.getStatus() == null || "".equals(interfaceEntity.getStatus())){
return BaseResult.getFailureMessageEntity("状态不能为空");
}
if(interfaceEntity.getWarningConfigId() == null || "".equals(interfaceEntity.getWarningConfigId())){
return BaseResult.getFailureMessageEntity("预警配置id不能为空");
}
interfaceEntity.setCreate();
sysWarningInterfaceDao.save(interfaceEntity);
}
return BaseResult.getSuccessMessageEntity("保存预警配置成功",entity);
}
@Override
public JsonResultEntity updateEntity(JSONObject jsonObject){
SysWarningConfigEntity entity = getData("jsonStr", jsonObject, SysWarningConfigEntity.class);
if (entity == null) {
JSONObject jsonStr = jsonObject.getJSONObject("jsonStr");
JSONArray sonArray = jsonStr.getJSONArray("son");
List<SysWarningInterfaceEntity> interfaceEntities = new ArrayList<>();
for(int i=0;i<sonArray.size();i++){
String sonString = sonArray.getJSONObject(i).toString();
SysWarningInterfaceEntity interfaceEntity = getData(sonString,SysWarningInterfaceEntity.class);
interfaceEntities.add(interfaceEntity);
}
SysWarningConfigEntity entity = getData("father", jsonStr, SysWarningConfigEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
if(entity.getId() == null || "".equals(entity.getId())){
return BaseResult.getFailureMessageEntity("系统错误");
}
if(entity.getMessageTemplateId() == null || "".equals(entity.getMessageTemplateId())){
return BaseResult.getFailureMessageEntity("消息模版不允许为空");
return BaseResult.getFailureMessageEntity("消息模版id不允许为空");
}
if(entity.getAppId() == null || "".equals(entity.getAppId())){
if(entity.getAppIdList() == null || "".equals(entity.getAppIdList())){
return BaseResult.getFailureMessageEntity("应用ID不允许为空");
}
if(entity.getWarningAppId() == null || "".equals(entity.getWarningAppId())){
@ -117,14 +207,68 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
if(entity.getStatus() == null || "".equals(entity.getStatus())){
return BaseResult.getFailureMessageEntity("状态不允许为空");
}
if(entity.getRecipientId() == null || "".equals(entity.getRecipientId())){
if(entity.getRecipientIdList() == null || "".equals(entity.getRecipientIdList())){
return BaseResult.getFailureMessageEntity("接收者ID不允许为空");
}
//检查接收者是否合规
String checkResult = checkRecipients(entity);
if(!"success".equals(checkResult)){
return BaseResult.getFailureMessageEntity(checkResult);
}
entity.setUpdate();
String warningConfigId = entity.getId();
sysWarningConfigDao.update(entity);
//先查询现有的子表数据并记录
SysWarningInterfaceEntity oldInterfaceEntity = new SysWarningInterfaceEntity();
oldInterfaceEntity.setWarningConfigId(warningConfigId);
List<SysWarningInterfaceEntity> oldInterfaceList = sysWarningInterfaceDao.queryBase(oldInterfaceEntity);
//更新子表数据
for(SysWarningInterfaceEntity interfaceEntity : interfaceEntities){
interfaceEntity.setWarningConfigId(warningConfigId);
if(interfaceEntity.getApiCode() == null || "".equals(interfaceEntity.getApiCode())){
return BaseResult.getFailureMessageEntity("接口编码不能为空");
}
if(interfaceEntity.getPushMethod() == null || "".equals(interfaceEntity.getPushMethod())){
return BaseResult.getFailureMessageEntity("推送方式不能为空");
}
if(interfaceEntity.getStatus() == null || "".equals(interfaceEntity.getStatus())){
return BaseResult.getFailureMessageEntity("状态不能为空");
}
if(interfaceEntity.getWarningConfigId() == null || "".equals(interfaceEntity.getWarningConfigId())){
return BaseResult.getFailureMessageEntity("预警配置id不能为空");
}
if(interfaceEntity.getId() == null || "".equals(interfaceEntity.getId())){
//新增
interfaceEntity.setCreate();
sysWarningInterfaceDao.save(interfaceEntity);
}else{
//修改
interfaceEntity.setUpdate();
interfaceEntity.setSts("Y");
sysWarningInterfaceDao.update(interfaceEntity);
}
}
//删除多余的子表数据
boolean isDelete = true;
for(SysWarningInterfaceEntity oldInterface : oldInterfaceList){
isDelete = true;
for(SysWarningInterfaceEntity interfaceEntity : interfaceEntities){
if(oldInterface.getId().equals(interfaceEntity.getId())){
isDelete = false;
break;
}
}
if(isDelete){
sysWarningInterfaceDao.logicRemove(oldInterface);
}
}
return BaseResult.getSuccessMessageEntity("修改预警配置成功",entity);
}
/**
* 删除主表时同时删除子表数据*/
@Override
public JsonResultEntity deleteEntity(JSONObject jsonObject) {
SysWarningConfigEntity entity = getData("jsonStr", jsonObject, SysWarningConfigEntity.class);
@ -134,8 +278,14 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//先删除子表中对应数据在删除主表数据
SysWarningInterfaceEntity interfaceEntity = new SysWarningInterfaceEntity();
interfaceEntity.setWarningConfigId(entity.getId());
sysWarningInterfaceDao.logicRemoveMultiCondition(interfaceEntity);
entity.setUpdate();
sysWarningConfigDao.logicRemove(entity);
return BaseResult.getSuccessMessageEntity("删除预警配置成功");
}
@ -146,22 +296,108 @@ public class SysWarningConfigServiceImpl extends BaseService<SysWarningConfigEnt
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
return BaseResult.getFailureMessageEntity("id不能为空");
}
if (entity.getStatus() == null || "".equals(entity.getStatus())) {
return BaseResult.getFailureMessageEntity("系统错误");
return BaseResult.getFailureMessageEntity("状态不能为空");
}
//0启用1禁用
if(entity.getMessageTemplateId() == null || "".equals(entity.getMessageTemplateId())){
return BaseResult.getFailureMessageEntity("消息模版id不允许为空");
}
//0停用1启用
if("0".equals(entity.getStatus())){
entity.setUpdate();
sysWarningConfigDao.update(entity);
return BaseResult.getSuccessMessageEntity("用模版成功");
return BaseResult.getSuccessMessageEntity("用模版成功");
}else{
//停用消息模版
//校验该预警设置的消息模版是否为启用状态
SysMessageTemplateEntity templateEntity = sysMessageTemplateDao.get(entity.getMessageTemplateId());
if(templateEntity == null){
return BaseResult.getFailureMessageEntity("消息模版不存在");
}
if(!"1".equals(templateEntity.getState())){
return BaseResult.getFailureMessageEntity("该预警设置的消息模版未启用,请先启用");
}
entity.setUpdate();
sysWarningConfigDao.update(entity);
return BaseResult.getSuccessMessageEntity("停用模版成功");
return BaseResult.getSuccessMessageEntity("用模版成功");
}
}
public String checkRecipients(SysWarningConfigEntity entity){
String recipientIds = entity.getRecipientIdList();
String[] recipientIdList = recipientIds.split(",");
SysUserEntity userEntity = new SysUserEntity();
for(String recipientId : recipientIdList){
String personName = sysPersonDao.get(recipientId).getPersonName();
userEntity.setPersonId(recipientId);
SysUserEntity usefulEntity = sysUserDao.queryOne(userEntity);
if(usefulEntity == null){
return "接收人"+personName+"不存在账号";
}
//预警应用只有一个的情况下
switch (entity.getWarningAppId()){
case "7ebc1702511f463d9cf50162973bf935":
String ddUserId = usefulEntity.getDdUserId();
if(ddUserId == null || "".equals(ddUserId)){
return "接收人"+personName+"未配置钉钉用户id";
}
break;
default:
return "预警应用类型错误";
}
}
return "success";
}
public List<SysWarningConfigEntity> queryNameList(List<SysWarningConfigEntity> list){
for(SysWarningConfigEntity configEntity : list){
//拼接应用名称列表
String appIds = configEntity.getAppIdList();
String[] appIdList = appIds.split(",");
String appNameList = "";
for(String appId : appIdList){
SysApplicationEntity appEntity = sysApplicationDao.get(appId);
String appName = appEntity.getName();
if(!"".equals(appNameList)){
appNameList += ",";
}
appNameList += appName;
}
configEntity.setAppNameList(appNameList);
//拼接预警应用名称列表
String warningAppIds = configEntity.getWarningAppId();
String[] warningAppIdList = warningAppIds.split(",");
String warningAppNameList = "";
for(String warningAppId : warningAppIdList){
SysApplicationEntity warningAppEntity = sysApplicationDao.get(warningAppId);
String warningAppName = warningAppEntity.getName();
if(!"".equals(warningAppNameList)){
warningAppNameList += ",";
}
warningAppNameList += warningAppName;
}
configEntity.setWarningAppNameList(warningAppNameList);
//拼接接收者名称列表
String recipientIds = configEntity.getRecipientIdList();
String[] recipientIdList = recipientIds.split(",");
String recipientNameList = "";
for(String recipientId : recipientIdList){
// SysUserEntity userEntity = sysUserDao.get(recipientId);
// String personId = userEntity.getPersonId();
SysPersonEntity personEntity = sysPersonDao.get(recipientId);
String recipientName = personEntity.getPersonName();
if(!"".equals(recipientNameList)){
recipientNameList += ",";
}
recipientNameList += recipientName;
}
configEntity.setRecipientNameList(recipientNameList);
}
return list;
}
}

View File

@ -1,7 +1,9 @@
package com.hzya.frame.sysnew.warningInterface.dao;
import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.basedao.dao.IBaseDao;
import java.util.List;
/**
* 预警接口表(sys_warning_interface: table)表数据库访问层
@ -11,5 +13,6 @@ import com.hzya.frame.basedao.dao.IBaseDao;
*/
public interface ISysWarningInterfaceDao extends IBaseDao<SysWarningInterfaceEntity, String> {
List<SysWarningInterfaceEntity> getWarningAppList();
}

View File

@ -4,6 +4,9 @@ import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
import com.hzya.frame.sysnew.warningInterface.dao.ISysWarningInterfaceDao;
import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import java.util.List;
/**
* 预警接口表(SysWarningInterface)表数据库访问层
*
@ -12,6 +15,10 @@ import com.hzya.frame.basedao.dao.MybatisGenericDao;
*/
@Repository(value = "SysWarningInterfaceDaoImpl")
public class SysWarningInterfaceDaoImpl extends MybatisGenericDao<SysWarningInterfaceEntity, String> implements ISysWarningInterfaceDao{
@Override
public List<SysWarningInterfaceEntity> getWarningAppList(){
List tempList = (List<SysWarningInterfaceEntity>)super.selectList(getSqlIdPrifx() + "warning_app_list", null);
return tempList;
}
}

View File

@ -9,7 +9,11 @@ import com.hzya.frame.web.entity.BaseEntity;
* @since 2024-09-03 10:06:19
*/
public class SysWarningInterfaceEntity extends BaseEntity {
/** 应用id */
private String appId;
/** 应用名称 */
private String appName;
/** 公司id */
private String companyId;
/** api名称 */
@ -23,6 +27,21 @@ public class SysWarningInterfaceEntity extends BaseEntity {
/** 主表id预警配置表id */
private String warningConfigId;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getCompanyId() {
return companyId;

View File

@ -17,7 +17,10 @@
<result property="pushMethod" column="push_method" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="warningConfigId" column="warning_config_id" jdbcType="VARCHAR"/>
<result property="appId" column="app_id" jdbcType="VARCHAR"/>
<result property="appName" column="app_name" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "SysWarningInterfaceEntity_Base_Column_List">
id
@ -33,7 +36,8 @@
,api_code
,push_method
,status
,warning_config_id
,warning_config_id
,app_id
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-SysWarningInterfaceEntity-result" parameterType = "com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity">
@ -85,29 +89,50 @@
<if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
</select>
<select id = "warning_app_list" resultMap="get-SysWarningInterfaceEntity-result" >
select distinct app_id from sys_warning_interface where sts='Y'
</select>
<!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-SysWarningInterfaceEntity-result" parameterType = "com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity">
select
<include refid="SysWarningInterfaceEntity_Base_Column_List" />
from sys_warning_interface
i.id
,i.sorts
,i.create_user_id
,i.create_time
,i.modify_user_id
,i.modify_time
,i.sts
,i.org_id
,i.company_id
,i.api_name
,i.api_code
,i.push_method
,i.status
,i.warning_config_id
,i.app_id
,app.name as app_name
from sys_warning_interface i
left join sys_application app on app.id = i.app_id
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
<if test="apiName != null and apiName != ''"> and api_name like concat('%',#{apiName},'%') </if>
<if test="apiCode != null and apiCode != ''"> and api_code like concat('%',#{apiCode},'%') </if>
<if test="pushMethod != null and pushMethod != ''"> and push_method like concat('%',#{pushMethod},'%') </if>
<if test="status != null and status != ''"> and status like concat('%',#{status},'%') </if>
<if test="warningConfigId != null and warningConfigId != ''"> and warning_config_id like concat('%',#{warningConfigId},'%') </if>
and sts='Y'
<if test="id != null and id != ''"> and i.id like concat('%',#{id},'%') </if>
<if test="sorts != null"> and i.sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and i.create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and i.create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and i.modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and i.modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and i.sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and i.org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and i.company_id like concat('%',#{companyId},'%') </if>
<if test="apiName != null and apiName != ''"> and i.api_name like concat('%',#{apiName},'%') </if>
<if test="apiCode != null and apiCode != ''"> and i.api_code like concat('%',#{apiCode},'%') </if>
<if test="pushMethod != null and pushMethod != ''"> and i.push_method like concat('%',#{pushMethod},'%') </if>
<if test="status != null and status != ''"> and i.status like concat('%',#{status},'%') </if>
<if test="warningConfigId != null and warningConfigId != ''"> and i.warning_config_id like concat('%',#{warningConfigId},'%') </if>
and i.sts='Y'
and app.sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort == null or sort == ''.toString() "> order by i.sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
@ -155,6 +180,7 @@
<if test="pushMethod != null and pushMethod != ''"> push_method , </if>
<if test="status != null and status != ''"> status , </if>
<if test="warningConfigId != null and warningConfigId != ''"> warning_config_id , </if>
<if test="appId != null and appId != ''" > app_id ,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
@ -173,6 +199,7 @@
<if test="pushMethod != null and pushMethod != ''"> #{pushMethod} ,</if>
<if test="status != null and status != ''"> #{status} ,</if>
<if test="warningConfigId != null and warningConfigId != ''"> #{warningConfigId} ,</if>
<if test="appId != null and appId != ''" > #{appId} ,</if>
<if test="sts == null ">'Y',</if>
</trim>
)

View File

@ -17,6 +17,8 @@ public interface ISysWarningInterfaceService extends IBaseService<SysWarningInte
JsonResultEntity queryEntity(JSONObject jsonObject);
JsonResultEntity queryWarningAppList(JSONObject jsonObject);
JsonResultEntity saveEntity(JSONObject jsonObject);
JsonResultEntity getEntity(JSONObject jsonObject);

View File

@ -3,6 +3,12 @@ package com.hzya.frame.sysnew.warningInterface.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationDto;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.service.impl.ApplicationCache;
import com.hzya.frame.sysnew.sendMessageLog.dao.ISysSendMessageLogDao;
import com.hzya.frame.sysnew.sendMessageLog.entity.SysSendMessageLogEntity;
import com.hzya.frame.sysnew.warningConfig.entity.SysWarningConfigEntity;
import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
import com.hzya.frame.sysnew.warningInterface.dao.ISysWarningInterfaceDao;
@ -14,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.ArrayList;
import java.util.List;
/**
@ -26,7 +33,14 @@ import java.util.List;
public class SysWarningInterfaceServiceImpl extends BaseService<SysWarningInterfaceEntity, String> implements ISysWarningInterfaceService {
private ISysWarningInterfaceDao sysWarningInterfaceDao;
@Resource
private ISysApplicationDao sysApplicationDao;
@Resource
private ISysSendMessageLogDao sysSendMessageLogDao;
@Autowired
public void setSysWarningInterfaceDao(ISysWarningInterfaceDao dao) {
this.sysWarningInterfaceDao = dao;
@ -75,10 +89,7 @@ public class SysWarningInterfaceServiceImpl extends BaseService<SysWarningInterf
public JsonResultEntity saveEntity(JSONObject jsonObject){
SysWarningInterfaceEntity entity = getData("jsonStr", jsonObject, SysWarningInterfaceEntity.class);
if(entity == null){
return BaseResult.getFailureMessageEntity("查询参数不存在");
}
if(entity.getId() == null || "".equals(entity.getId())){
return BaseResult.getFailureMessageEntity("系统错误");
return BaseResult.getFailureMessageEntity("未传入保存参数");
}
if(entity.getApiCode() == null || "".equals(entity.getApiCode())){
return BaseResult.getFailureMessageEntity("接口编码不能为空");
@ -150,18 +161,44 @@ public class SysWarningInterfaceServiceImpl extends BaseService<SysWarningInterf
if (entity.getStatus() == null || "".equals(entity.getStatus())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//0启用1禁
//0停用1启
if("0".equals(entity.getStatus())){
entity.setUpdate();
sysWarningInterfaceDao.update(entity);
return BaseResult.getSuccessMessageEntity("启用模版成功");
return BaseResult.getSuccessMessageEntity("停用预警接口成功");
}else{
//停用消息模版
entity.setUpdate();
sysWarningInterfaceDao.update(entity);
return BaseResult.getSuccessMessageEntity("停用模版成功");
return BaseResult.getSuccessMessageEntity("启用预警接口成功");
}
}
/**查询已经配置了预警的应用列表,并返回应用列表及其未读消息数*/
@Override
public JsonResultEntity queryWarningAppList(JSONObject jsonObject){
List<SysWarningInterfaceEntity> appIdList = sysWarningInterfaceDao.getWarningAppList();
List<SysApplicationEntity> appList = new ArrayList<>();
for (SysWarningInterfaceEntity entity : appIdList) {
if (entity == null) {
continue;
}
String appId = entity.getAppId();
SysApplicationEntity app = sysApplicationDao.get(appId);
if (app == null) {
continue;
}
SysSendMessageLogEntity logEntity = new SysSendMessageLogEntity();
logEntity.setAppId(appId);
logEntity.setState(0);
List<SysSendMessageLogEntity> list = sysSendMessageLogDao.queryByLike(logEntity);
app.setNewMessageCount(list.size());
if (app != null) {
appList.add(app);
}
}
return BaseResult.getSuccessMessageEntity("查询预警应用列表成功",appList);
}
}