Conflicts:
	pom.xml
This commit is contained in:
lvleigang 2024-09-20 15:53:13 +08:00
commit af75461f14
55 changed files with 2507 additions and 911 deletions

1
.gitignore vendored
View File

@ -63,3 +63,4 @@ $RECYCLE.BIN/
/base-buildpackage/target/
/base-common/target/
/base-core/target/
/base-webapp/target/classes/com/hzya/frame/

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

@ -45,7 +45,7 @@ savefile:
tomcatpath: /Users/apple/Desktop/log/local
pluginpath: /Users/apple/Desktop/log/local
zt:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
cbs8:
appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a
@ -60,3 +60,5 @@ cbs8:
elec_path: /Users/xiangerlin/Downloads/
OA:
data_source_code: yc_oa
server:
port: 10086

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

@ -1,5 +1,5 @@
server:
port: 9999
port: 10086
servlet:
context-path: /kangarooDataCenterV3
localIP: 127.0.0.1
@ -93,7 +93,7 @@ mybatis-plus:
db-config:
id-type: auto # 主键策略
zt:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
#JimuReport[minidao配置]
minidao :
base-package: org.jeecg.modules.jmreport.desreport.dao*

View File

@ -0,0 +1,48 @@
package com.hzya.frame.dingtalk.enums;
/**
* @Description 通讯录事件类型
* @Author xiangerlin
* @Date 2024/8/27 15:58
**/
public enum OrgEventEnum {
USER_ADD_ORG("user_add_org","通讯录用户新增"),
USER_MODIFY_ORG("user_modify_org","通讯录用户更改"),
USER_LEAVE_ORG("user_leave_org","通讯录用户离职"),
USER_ACTIVE_ORG("user_active_org","加入企业后用户激活"),
ORG_DEPT_CREATE("org_dept_create","通讯录企业部门创建"),
ORG_DEPT_MODIFY("org_dept_modify","通讯录企业部门更改"),
ORG_DEPT_REMOVE("org_dept_remove","通讯录企业部门删除"),
;
private String code;
private String explain;
OrgEventEnum(String code, String explain) {
this.code = code;
this.explain = explain;
}
public String getCode() {
return code;
}
public String getExplain() {
return explain;
}
/**
* 根据code获取事件类型
* @param code
* @return
*/
public static OrgEventEnum getByCode(String code){
for (OrgEventEnum org : OrgEventEnum.values()) {
if (org.getCode().equals(code)){
return org;
}
}
return null;
}
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.dingtalk.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
/**
* @Description 钉钉集成扩展类
* @Author xiangerlin
* @Date 2024/8/28 14:25
**/
public interface IDingTalkExtService {
/**
* 调用这个方法初始化钉钉参数
* @param entity
* @return
*/
SysExtensionApiEntity init(SysExtensionApiEntity entity);
/**
* 查询配置在应用上的钉钉参数
* @param sysApplication
* @return
*/
JSONObject getDingTalkConfig(SysApplicationEntity sysApplication);
/**
* 清空配置缓存
*/
void clearDingTalkConfigCatch();
}

View File

@ -0,0 +1,66 @@
package com.hzya.frame.dingtalk.service;
import com.dingtalk.api.request.OapiV2UserListRequest;
import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserListResponse;
import java.util.List;
/**
* @Description 钉钉service
* @Author xiangerlin
* @Date 2024/8/27 16:17
**/
public interface IDingTalkService {
/**
* 根据userid获取用户详情
* @param userId 钉钉userid
* @param appKey
* @param appSecret
* @return
*/
OapiV2UserGetResponse.UserGetResponse getUserById(String userId, String appKey, String appSecret);
/**
* 根据userid获取用户详情
* @param userId
* @return
*/
OapiV2UserGetResponse.UserGetResponse getUserById(String userId);
/**
* 获取部门用户列表
* @param req 请求参数
* @param appKey
* @param appSecret
* @return
*/
OapiV2UserListResponse.PageResult getUserListByDeptId(OapiV2UserListRequest req, String appKey, String appSecret);
/**
* 根据部门id获取部门详情
* @param deptId 钉钉部门id
* @param appKey
* @param appSecret
* @return
*/
OapiV2DepartmentGetResponse.DeptGetResponse getDeptById(Long deptId, String appKey, String appSecret);
/**
* 根据部门id获取部门详情
* @param deptId
* @return
*/
OapiV2DepartmentGetResponse.DeptGetResponse getDeptById(Long deptId);
/**
* 获取部门列表此接口只会返回下一级部门信息
* @param deptId 部门id如果不传则查询一级部门
* @param appKey
* @param appSecret
* @return
*/
List<OapiV2DepartmentListsubResponse.DeptBaseResponse> getDeptList(Long deptId, String appKey, String appSecret);
}

View File

@ -0,0 +1,100 @@
package com.hzya.frame.dingtalk.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.dingtalk.service.IDingTalkExtService;
import com.hzya.frame.dingtalk.util.DingTalkAccessToken;
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.apiPara.service.ISysApplicationApiParaService;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description 钉钉集成扩展类
* @Author xiangerlin
* @Date 2024/8/28 14:25
**/
@Service(value = "dingTalkExtService")
public class DingTalkExtServiceImpl implements IDingTalkExtService {
@Resource
private ISysApplicationApiParaDao sysApplicationApiParaDao;
private final ConcurrentHashMap<String, JSONObject> dingTalkMap = new ConcurrentHashMap<>();
/**
* 调用这个方法初始化钉钉参数
*
* @param entity
* @return
*/
@Override
public SysExtensionApiEntity init(SysExtensionApiEntity entity) {
Map<String, String> headers = entity.getHeaders();
if (null == headers){
headers = new HashMap<>();
}
SysApplicationEntity receiveApp = entity.getReceiveApp();
//查询应用上配置的参数
JSONObject dingTalkConfig = getDingTalkConfig(receiveApp);
//给token赋值
entity.setQuerys("access_token="+DingTalkAccessToken.getAccessToken(dingTalkConfig.getString("appKey"),dingTalkConfig.getString("appSecret")));
return entity;
}
/**
* 查询配置在应用上的钉钉参数
*
* @param sysApplication
* @return
*/
@Override
public JSONObject getDingTalkConfig(SysApplicationEntity sysApplication) {
if (null != sysApplication && StrUtil.isNotEmpty(sysApplication.getId()) && null != sysApplication.getAppId()){
JSONObject jsonObject = new JSONObject();
String key = sysApplication.getAppId()+"dingTalk";
if (null != dingTalkMap.get(key)){
return dingTalkMap.get(key);
}else {
//查询应用上配置的参数
SysApplicationApiParaEntity paraEntity = new SysApplicationApiParaEntity();
paraEntity.setAppId(sysApplication.getId());
List<SysApplicationApiParaEntity> paraList = sysApplicationApiParaDao.query(paraEntity);
if (CollectionUtils.isNotEmpty(paraList)) {
List<SysApplicationApiParaEntity> appKeyList = paraList.stream().filter(p -> p.getInterfaceKey().equals("appKey")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(appKeyList)) {
jsonObject.put("appKey", appKeyList.get(0).getInterfaceValue());
}
List<SysApplicationApiParaEntity> appSecretList = paraList.stream().filter(p -> p.getInterfaceKey().equals("appSecret")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(appSecretList)) {
jsonObject.put("appSecret", appSecretList.get(0).getInterfaceValue());
}
dingTalkMap.put(key,jsonObject);
return dingTalkMap.get(key);
}
}
}
return null;
}
/**
* 清空配置缓存
*/
@Override
public void clearDingTalkConfigCatch() {
dingTalkMap.clear();
}
}

View File

@ -0,0 +1,164 @@
package com.hzya.frame.dingtalk.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
import com.dingtalk.api.request.OapiV2UserGetRequest;
import com.dingtalk.api.request.OapiV2UserListRequest;
import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserListResponse;
import com.hzya.frame.dingtalk.service.IDingTalkService;
import com.hzya.frame.dingtalk.util.DingTalkAccessToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description 钉钉service
* @Author xiangerlin
* @Date 2024/8/27 16:17
**/
@Service(value = "dingTalkService")
public class DingTalkServiceImpl implements IDingTalkService {
Logger logger = LoggerFactory.getLogger(getClass());
@Value("${dingtalk.appKey:}")
private String dAppKey;
@Value("${dingtalk.appSecret:}")
private String dAppSecret;
/**
* 根据userid获取用户详情
*
* @param userId 钉钉userid
* @param appKey
* @param appSecret
* @return
*/
@Override
public OapiV2UserGetResponse.UserGetResponse getUserById(String userId, String appKey, String appSecret) {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
req.setLanguage("zh_CN");
try {
OapiV2UserGetResponse rsp = client.execute(req, DingTalkAccessToken.getAccessToken(appKey,appSecret));
if (rsp.isSuccess()){
OapiV2UserGetResponse.UserGetResponse result = rsp.getResult();
String s = JSONObject.toJSONString(result);
logger.info("人员详情信息:{}",s);
return result;
}
}catch (Exception e){
logger.error("根据部门id获取钉钉用户详情出错{}",e);
}
return null;
}
/**
* 根据userid获取用户详情
*
* @param userId
* @return
*/
@Override
public OapiV2UserGetResponse.UserGetResponse getUserById(String userId) {
return getUserById(userId,dAppKey,dAppSecret);
}
/**
* 获取部门用户列表
*
* @param req 请求参数
* @param appKey
* @param appSecret
* @return
*/
@Override
public OapiV2UserListResponse.PageResult getUserListByDeptId(OapiV2UserListRequest req, String appKey, String appSecret) {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/list");
req.setSize(100L);//每页最大只能查100条
req.setOrderField("modify_desc");
req.setContainAccessLimit(false);
req.setLanguage("zh_CN");
OapiV2UserListResponse rsp = client.execute(req, DingTalkAccessToken.getAccessToken(appKey,appSecret));
OapiV2UserListResponse.PageResult result = rsp.getResult();
return result;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
/**
* 根据部门id获取部门详情
*
* @param deptId 钉钉部门id
* @param appKey
* @param appSecret
* @return
*/
@Override
public OapiV2DepartmentGetResponse.DeptGetResponse getDeptById(Long deptId, String appKey, String appSecret) {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
req.setDeptId(deptId);
req.setLanguage("zh_CN");
try {
OapiV2DepartmentGetResponse rsp = client.execute(req, DingTalkAccessToken.getAccessToken(appKey,appSecret));
if (rsp.isSuccess()){
OapiV2DepartmentGetResponse.DeptGetResponse result = rsp.getResult();
String s = JSONObject.toJSONString(result);
logger.info("部门详情信息:{}",s);
return result;
}
}catch(Exception e){
logger.error("根据部门id获取钉钉部门出错{}",e);
}
return null;
}
/**
* 根据部门id获取部门详情
*
* @param deptId
* @return
*/
@Override
public OapiV2DepartmentGetResponse.DeptGetResponse getDeptById(Long deptId) {
return getDeptById(deptId,dAppKey,dAppSecret);
}
/**
* 获取部门列表此接口只会返回下一级部门信息
* @param deptId 部门id如果不传则查询一级部门
* @param appKey
* @param appSecret
* @return
*/
@Override
public List<OapiV2DepartmentListsubResponse.DeptBaseResponse> getDeptList(Long deptId,String appKey,String appSecret) {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
req.setDeptId(deptId);
req.setLanguage("zh_CN");
OapiV2DepartmentListsubResponse rsp = client.execute(req, DingTalkAccessToken.getAccessToken(appKey,appSecret));
if (rsp.isSuccess()){
List<OapiV2DepartmentListsubResponse.DeptBaseResponse> result = rsp.getResult();
return result;
}
}catch (Exception e){
logger.error("获取部门列表接口出错:{}",e);
}
return null;
}
}

View File

@ -0,0 +1,103 @@
package com.hzya.frame.dingtalk.util;
import cn.hutool.core.util.StrUtil;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
import com.aliyun.tea.TeaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import java.time.Instant;
/**
* @Description 钉钉获取accessToken
* @Author xiangerlin
* @Date 2024/8/27 14:05
**/
public class DingTalkAccessToken {
static Logger logger = LoggerFactory.getLogger(DingTalkAccessToken.class);
//token
private static String accessToken;
//过期时间
private static Instant expireTime;
private static final Long CACHE_EXPIRY_TIME = 7000L; // 缓存有效时间
//应用key
private static String appKey;
//应用密钥
private static String appSecret;
@Value("${dingtalk.appKey:}")
public static void setAppKey(String appKey) {
DingTalkAccessToken.appKey = appKey;
}
@Value("${dingtalk.appSecret:}")
public static void setAppSecret(String appSecret) {
DingTalkAccessToken.appSecret = appSecret;
}
/**
* 获取token
* @return
*/
public static String getAccessToken(){
return getAccessToken(appKey,appSecret);
}
/**
* 获取accessToken
*
* @param appKey
* @param appSecret
* @return
*/
public static String getAccessToken(String appKey,String appSecret) {
//判断是否过期 如果没过期直接返回
if (null != accessToken && expireTime != null && Instant.now().isBefore(expireTime)) {
return accessToken;
}
//获取新的accessToken
accessToken = fetchNewAccessToken(appKey,appSecret);
//过期时间设置成当前事件+7000s预留200s的时间
expireTime = Instant.now().plusSeconds(CACHE_EXPIRY_TIME);
return accessToken;
}
/**
* 获取新的accessToken
*
* @return
*/
private static String fetchNewAccessToken(String appKey,String appSecret) {
try {
//查询应用上配置的钉钉信息
if (StrUtil.isNotEmpty(appKey) && StrUtil.isNotEmpty(appSecret)) {
//查询应用上的信息
com.aliyun.dingtalkoauth2_1_0.Client client = DingTalkAccessToken.createClient();
com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
.setAppKey(appKey)
.setAppSecret(appSecret);
GetAccessTokenResponse accessToken = client.getAccessToken(getAccessTokenRequest);
String accessToken1 = accessToken.getBody().getAccessToken();
return accessToken1;
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code message 属性可帮助开发定位问题
}
logger.error("获取钉钉token出错:{}", _err);
}
return null;
}
/**
* 使用 Token 初始化账号Client
*
* @return Client
* @throws Exception
*/
private static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
}
}

View File

@ -50,6 +50,7 @@ public class HomeServiceImpl extends BaseService<HomeEntity, String> implements
for (int a = 0; a < sysApplicationEntities.size(); a++) {
if(homeEntities.get(i).getAppId()!= null && sysApplicationEntities.get(a).getId().equals(homeEntities.get(i).getAppId())){
homeEntities.get(i).setPath(sysApplicationEntities.get(a).getAppLogo());
homeEntities.get(i).setName(sysApplicationEntities.get(a).getName());
continue;
}
}

View File

@ -0,0 +1,77 @@
package com.hzya.frame.mdm.entity;
public class MdmFiledsRuleDto {
/** 主数据模版ID */
private String mdmId;
/** 模版数据库id */
private String dbId;
/** 模版数据库字段id */
private String filedId;
/** 字段类型 1、select 2、treeselect */
private String filedType;
/** 字段服务 */
private String typeFiled;
/** 字段服务 */
private String id;
/** 字段服务 */
private String dataId;
public String getMdmId() {
return mdmId;
}
public void setMdmId(String mdmId) {
this.mdmId = mdmId;
}
public String getDbId() {
return dbId;
}
public void setDbId(String dbId) {
this.dbId = dbId;
}
public String getFiledId() {
return filedId;
}
public void setFiledId(String filedId) {
this.filedId = filedId;
}
public String getFiledType() {
return filedType;
}
public void setFiledType(String filedType) {
this.filedType = filedType;
}
public String getTypeFiled() {
return typeFiled;
}
public void setTypeFiled(String typeFiled) {
this.typeFiled = typeFiled;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
}

View File

@ -3,6 +3,7 @@ package com.hzya.frame.mdm.mdmModule.dao;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.mdm.entity.MdmDataDto;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.mdm.entity.MdmFiledsRuleDto;
import com.hzya.frame.mdm.entity.MdmQuery;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.basedao.dao.IBaseDao;
@ -68,5 +69,7 @@ public interface IMdmModuleDao extends IBaseDao<MdmModuleEntity, String> {
void updataTreeUpData(Map<String, String> updateMaps);
void updataTreeUpDataDetail(Map<String, String> updateMaps);
MdmFiledsRuleDto queryDataId(MdmFiledsRuleDto mdmFiledsRuleDto);
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.mdm.entity.MdmDataDto;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.mdm.entity.MdmFiledsRuleDto;
import com.hzya.frame.mdm.entity.MdmQuery;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
@ -181,6 +182,12 @@ public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String>
super.update(getSqlIdPrifx() + "updataTreeUpDataDetail", maps);
}
@Override
public MdmFiledsRuleDto queryDataId(MdmFiledsRuleDto mdmFiledsRuleDto) {
MdmFiledsRuleDto o = (MdmFiledsRuleDto) super.selectOne(getSqlIdPrifx() + "queryDataId", mdmFiledsRuleDto);
return o;
}
@Override
public List<String> queryMdMFields(Map<String, Object> maps) {
List<String> o = (List<String>) super.selectList(getSqlIdPrifx() + "queryMdMFields", maps);

View File

@ -1086,5 +1086,14 @@ where id = #{id}
AND b.sts = 'Y'
AND b.data_status != 'N'
</update>
<!-- 分页查询列表 采用like格式 -->
<select id="queryDataId" resultType="com.hzya.frame.mdm.entity.MdmFiledsRuleDto"
parameterType="com.hzya.frame.mdm.entity.MdmFiledsRuleDto">
select
data_id as dataId
from ${typeFiled} where sts='Y' and id = #{id}
</select>
</mapper>

View File

@ -2340,7 +2340,20 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
xf.setCreate();
sysButtonConfigDao.save(xf);
}
if ("viewData".equals(mdmModuleViewButtonEntities.get(i).getButtonValue())) {
SysButtonConfigEntity xf = new SysButtonConfigEntity();
xf.setCode("viewData");
xf.setNameCh("查看数据格式");
xf.setNameEn("viewData");
xf.setMenuId(module.getId());
xf.setIconName("");
xf.setStyles("");
xf.setBtnFunction("viewData");
xf.setRemark("查看数据格式");
xf.setSorts(i + 1L);
xf.setCreate();
sysButtonConfigDao.save(xf);
}
}
}

View File

@ -87,6 +87,15 @@ public interface IMdmService {
* @Date 9:40 上午 2023/10/18
**/
JsonResultEntity queryMdmShowDetailsData(JSONObject jsonObject);
/**
* @param jsonObject
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 主数据详情数据字典
* @Date 9:40 上午 2023/10/18
**/
JsonResultEntity queryMdmShowDetailsDictionary(JSONObject jsonObject);
//
/**
* @param jsonObject

View File

@ -101,12 +101,6 @@ public class MdmServiceImpl implements IMdmService {
@Resource
private IMdmServiceCache mdmServiceCache;
@Resource
private ISysMenuConfigDao sysMenuConfigDao;
@Resource
private ISysButtonConfigDao sysButtonConfigDao;
@Resource
private ISysPopedomOperateDao sysPopedomOperateDao;
@Resource
private IMdmModuleDbDao mdmModuleDbDao;
@Resource
private ISysUserDao sysUserDao;
@ -1381,15 +1375,188 @@ public class MdmServiceImpl implements IMdmService {
}
}
//if (tablename != null && !"".equals(tablename)) {
// Map<String, Object> queryData = new HashMap<>();
// queryData.put("tableName", tablename);//表名
// queryData.put("id", entity.getId());//字段
// List<HashMap<String, Object>> datas = mdmModuleDbDao.getServiceByDistributeId(queryData);
// jsonObject.put(tablename, datas);
//}
return BaseResult.getSuccessMessageEntity("获取数据成功", jsonObject);
}
/**
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 主数据详情数据字典
* @Date 9:40 上午 2023/10/18
**/
@Override
public JsonResultEntity queryMdmShowDetailsDictionary(JSONObject object) {
MdmDto entity = getData("jsonStr", object, MdmDto.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if (entity.getMdmCode() == null || "".equals(entity.getMdmCode())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if (entity.getId() == null || "".equals(entity.getId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//查询模版
MdmModuleEntity mdmModuleEntity = mdmServiceCache.getMdmModuleEntity(entity.getMdmCode());
if (mdmModuleEntity == null) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//查询数据源主表
MdmModuleDbEntity mdmModuleDbEntity = new MdmModuleDbEntity();
mdmModuleDbEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleDbEntity.setSts("Y");
List<MdmModuleDbEntity> mdmModuleDbEntityList = mdmServiceCache.queryMdmModuleDb(mdmModuleDbEntity);
if (mdmModuleDbEntityList == null || mdmModuleDbEntityList.size() == 0) {
return BaseResult.getFailureMessageEntity("系统错误");
}
MdmModuleDbFiledsEntity queryFild = new MdmModuleDbFiledsEntity();
queryFild.setMdmId(mdmModuleEntity.getId());
queryFild.setSts("Y");
List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(queryFild);
MdmModuleDbFiledsRuleEntity mdmModuleDbFiledsRuleEntity = new MdmModuleDbFiledsRuleEntity();
mdmModuleDbFiledsRuleEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleDbFiledsRuleEntity.setSts("Y");
List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(mdmModuleDbFiledsRuleEntity);
List<MdmFiledsRuleDto> mdmFiledsRuleDtos = new ArrayList<>();
if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){
for (int i = 0; i < mdmModuleDbFiledsRuleEntities.size(); i++) {
if("treeselect".equals(mdmModuleDbFiledsRuleEntities.get(i).getRuleValue()) || "select".equals(mdmModuleDbFiledsRuleEntities.get(i).getRuleValue())){
MdmFiledsRuleDto mdmFiledsRuleDto = new MdmFiledsRuleDto();
mdmFiledsRuleDto.setDbId(mdmModuleDbFiledsRuleEntities.get(i).getDbId());
mdmFiledsRuleDto.setFiledId(mdmModuleDbFiledsRuleEntities.get(i).getFiledId());
mdmFiledsRuleDto.setMdmId(mdmModuleDbFiledsRuleEntities.get(i).getMdmId());
mdmFiledsRuleDto.setFiledType(mdmModuleDbFiledsRuleEntities.get(i).getRuleValue());
mdmFiledsRuleDtos.add(mdmFiledsRuleDto);
}
}
}
if(mdmFiledsRuleDtos != null && mdmFiledsRuleDtos.size() > 0){
for (int i = 0; i < mdmFiledsRuleDtos.size(); i++) {
for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) {
if(mdmFiledsRuleDtos.get(i).getFiledId().equals(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId())
&& "service".equals(mdmModuleDbFiledsRuleEntities.get(i1).getRuleCode())){
mdmFiledsRuleDtos.get(i).setTypeFiled(mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue());
}
}
}
}
//String tablename = null;
JSONObject jsonObject = new JSONObject();
jsonObject.put("appName","数智中台");
jsonObject.put("appCode","800004");
jsonObject.put("mdmCode",entity.getMdmCode());
jsonObject.put("optionName","admin");
for (int i = 0; i < mdmModuleDbEntityList.size(); i++) {
if ("1".equals(mdmModuleDbEntityList.get(i).getDbType()) || "2".equals(mdmModuleDbEntityList.get(i).getDbType())) {
//查询数据
Map<String, Object> queryData = new HashMap<>();
queryData.put("tableName", mdmModuleDbEntityList.get(i).getDbName());//表名
if ("1".equals(mdmModuleDbEntityList.get(i).getDbType())) {
queryData.put("detailFlag", false);//是否明细
queryData.put("id", entity.getId());//字段
HashMap<String, Object> datas = mdmModuleDbDao.getServiceDataById(queryData);
convertKeysToLowerCase(datas);
JSONObject zbdata = new JSONObject();
if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){
for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) {
if(mdmModuleDbFiledsEntities.get(i2).getDbId().equals(mdmModuleDbEntityList.get(i).getId())){
if("1".equals(mdmModuleDbFiledsEntities.get(i2).getViewType())){
//判断是否是下拉类型
Object data = datas.get(mdmModuleDbFiledsEntities.get(i2).getEnName());
if(mdmFiledsRuleDtos != null && mdmFiledsRuleDtos.size() > 0){
for (int i1 = 0; i1 < mdmFiledsRuleDtos.size(); i1++) {
if(mdmModuleDbFiledsEntities.get(i2).getId().equals(mdmFiledsRuleDtos.get(i1).getFiledId())){
//查询对应的data_id
String strData = String.valueOf(data);
int index = strData.lastIndexOf(',');
if (index!= -1) {
strData = strData.substring(index + 1);
}
mdmFiledsRuleDtos.get(i1).setId(strData);
MdmFiledsRuleDto mdmFiledsRuleDto = mdmModuleDao.queryDataId(mdmFiledsRuleDtos.get(i1));
if(mdmFiledsRuleDto != null && mdmFiledsRuleDto.getDataId() != null && !"".equals(mdmFiledsRuleDto.getDataId())){
data = mdmFiledsRuleDto.getDataId();
}else {
data = null;
}
}
}
}
zbdata.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),data);
}
}
}
}
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), zbdata);
} else {
queryData.put("detailFlag", true);//是否明细
queryData.put("id", entity.getId());//字段
List<HashMap<String, Object>> datas = mdmModuleDbDao.getServiceByFormmainId(queryData);
convertKeysToLowerCase(datas);
List<JSONObject> mxDataList = new ArrayList<>();
if(datas != null && datas.size() > 0){
for (int i1 = 0; i1 < datas.size(); i1++) {
JSONObject mxData = new JSONObject();
if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){
for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) {
if(mdmModuleDbFiledsEntities.get(i2).getDbId().equals(mdmModuleDbEntityList.get(i).getId())){
if("1".equals(mdmModuleDbFiledsEntities.get(i2).getViewType())){
//判断是否是下拉类型
Object data = datas.get(i1).get(mdmModuleDbFiledsEntities.get(i2).getEnName());
if(mdmFiledsRuleDtos != null && mdmFiledsRuleDtos.size() > 0){
for (int b = 0; b < mdmFiledsRuleDtos.size(); b++) {
if(mdmModuleDbFiledsEntities.get(i2).getId().equals(mdmFiledsRuleDtos.get(b).getFiledId())){
//查询对应的data_id
String strData = String.valueOf(data);
int index = strData.lastIndexOf(',');
if (index!= -1) {
strData = strData.substring(index + 1);
}
mdmFiledsRuleDtos.get(b).setId(strData);
MdmFiledsRuleDto mdmFiledsRuleDto = mdmModuleDao.queryDataId(mdmFiledsRuleDtos.get(b));
if(mdmFiledsRuleDto != null && mdmFiledsRuleDto.getDataId() != null && !"".equals(mdmFiledsRuleDto.getDataId())){
data = mdmFiledsRuleDto.getDataId();
}else {
data = null;
}
}
}
}
mxData.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),data);
}
}
}
}
mxDataList.add(mxData);
}
}else {
JSONObject mxData = new JSONObject();
if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){
for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) {
if(mdmModuleDbFiledsEntities.get(i2).getDbId().equals(mdmModuleDbEntityList.get(i).getId())){
if("1".equals(mdmModuleDbFiledsEntities.get(i2).getViewType())){
mxData.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),null);
}
}
}
}
mxDataList.add(mxData);
}
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), mxDataList);
}
}
}
return BaseResult.getSuccessMessageEntity("获取数据成功", jsonObject);
}

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

@ -3,6 +3,7 @@ package com.hzya.frame.sysnew.application.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
@ -432,4 +433,8 @@ public interface ISysApplicationService extends IBaseService<SysApplicationEntit
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity externalCallInterfaceToESB(ServletRequest servletRequest, ServletResponse servletResponse);
SysExtensionApiEntity setDDtoken(SysExtensionApiEntity sysExtensionApiEntity);
SysExtensionApiEntity setDDUserId(SysExtensionApiEntity sysExtensionApiEntity);
}

View File

@ -1986,6 +1986,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
boolean flag = true;
try {
response = closeableHttpClient.execute(get);
HttpEntity entity = response.getEntity();
synchronized (lock) {
@ -2649,7 +2650,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;
}
@ -3478,4 +3479,39 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
}
}
}
@Override
public SysExtensionApiEntity setDDtoken(SysExtensionApiEntity sysExtensionApiEntity) {
SysApplicationApiEntity sysApplicationApiEntity = sysExtensionApiEntity.getReceiveApi();
StringBuilder stringBuilder = new StringBuilder();
if (sysApplicationApiEntity.getQueryIn() != null && !"".equals(sysApplicationApiEntity.getQueryIn())) {
JSONArray jsonArray = JSONArray.parseArray(sysApplicationApiEntity.getQueryIn());
if (jsonArray != null && jsonArray.size() > 0) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject object1 = jsonArray.getJSONObject(i);
if(i > 0){
stringBuilder.append("&");
}
stringBuilder.append(object1.getString("parameterName")).append("=").append(object1.getString("example"));
}
}
}
sysExtensionApiEntity.setQuerys(stringBuilder.toString());
return sysExtensionApiEntity;
}
@Override
public SysExtensionApiEntity setDDUserId(SysExtensionApiEntity sysExtensionApiEntity) {
String bodys = sysExtensionApiEntity.getBodys();
StringBuilder stringBuilder = new StringBuilder();
JSONObject jsonObject = JSONObject.parseObject(bodys);
stringBuilder.append("userid=").append(jsonObject.getString("userid"));
stringBuilder.append("&");
stringBuilder.append("access_token=").append(jsonObject.getString("access_token"));
sysExtensionApiEntity.setQuerys(stringBuilder.toString());
return sysExtensionApiEntity;
}
}

View File

@ -15,4 +15,13 @@ public interface ILoginService {
* @throws Exception
*/
JsonResultEntity doLogin(JSONObject jsonObject)throws Exception;
/****
* 移动端登录
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2024-09-14 10:51
* @param
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity appDoLogin(JSONObject jsonObject) ;
}

View File

@ -2,7 +2,18 @@ package com.hzya.frame.sysnew.login.impl;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.request.OapiV2UserGetRequest;
import com.dingtalk.api.request.OapiV2UserGetuserinfoRequest;
import com.dingtalk.api.response.OapiGettokenResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.login.ILoginService;
@ -21,11 +32,16 @@ import com.hzya.frame.sysnew.userRoles.entity.SysUserRolesEntity;
import com.hzya.frame.util.AESUtil;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@ -35,6 +51,7 @@ import java.util.List;
**/
@Service(value = "loginService")
public class LoginServiceImpl implements ILoginService {
private final Logger logger = LoggerFactory.getLogger(LoginServiceImpl.class);
@Resource
private ISysUserDao sysUserDao;
@ -42,7 +59,8 @@ public class LoginServiceImpl implements ILoginService {
private ISysPersonDao sysPersonDao;
@Resource
private ISysOrganDao sysOrganDao;
@Value("${zt.url}")
private String url ;
@Resource
private ISysApplicationDao sysApplicationDao;
@Resource
@ -67,7 +85,10 @@ public class LoginServiceImpl implements ILoginService {
return BaseResult.getFailureMessageEntity("请输入用户名或密码");
}
entity.setPassword(AESUtil.encrypt(entity.getLoginCode() + "-" + entity.getPassword()));
SysUserEntity sysUserEntity = sysUserDao.queryOne(entity);
SysUserEntity sysUserEntity = new SysUserEntity();
sysUserEntity.setLoginCode(entity.getLoginCode());
sysUserEntity.setPassword(entity.getPassword());
sysUserEntity = sysUserDao.queryOne(sysUserEntity);
if (sysUserEntity == null || sysUserEntity.getId() == null || "".equals(sysUserEntity.getId())) {
return BaseResult.getFailureMessageEntity("用户名或密码错误");
}
@ -113,6 +134,14 @@ public class LoginServiceImpl implements ILoginService {
//}
//登录
StpUtil.login(sysUserEntity.getId());
//修改ddid或者修改微信id
if((entity.getDdUserId() != null && !"".equals(entity.getDdUserId()))
|| (entity.getWxUserId() != null && !"".equals(entity.getWxUserId())) ){
sysUserEntity.setDdUserId(entity.getDdUserId());
sysUserEntity.setWxUserId(entity.getWxUserId());
sysUserDao.update(sysUserEntity);
}
//获取token
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
String token = tokenInfo.getTokenValue();
@ -131,6 +160,131 @@ public class LoginServiceImpl implements ILoginService {
return BaseResult.getSuccessMessageEntity("登录成功", res);
}
/****
* 移动端登录地址
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2024-09-14 11:14
* @param
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public JsonResultEntity appDoLogin(JSONObject jsonObject) {
//移动端类型
JSONObject entity = getData("jsonStr", jsonObject, JSONObject.class);
logger.error(entity.toString());
//boolean f = true;
//if(f){
// return BaseResult.getFailureMessageEntity("cuowu",entity);
//}
//DD,weChat
String appType = entity.getString("appType");
String appId = entity.getString("appId");
String apiCode = entity.getString("apiCode");
String userApiCode = entity.getString("userApiCode");
SysUserEntity userEntity = new SysUserEntity();
switch (appType){
case "DD":
String code = entity.getString("code");//授权码
String requestType = entity.getString("UserAgent");// pc端还是移动端
JSONObject bodyParams = new JSONObject();
bodyParams.put("code",code);
String result = HttpRequest.post(url).
header("appId",appId).
header("apiCode",userApiCode).
header("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj").
header("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(bodyParams.toJSONString()).
execute().
body();
JSONObject resultJson = JSONObject.parseObject(result);
boolean flag = resultJson.getBoolean("flag");
if(!flag){
return BaseResult.getFailureMessageEntity("请求错误:"+resultJson.getString("msg"));
}
String userid = resultJson.getJSONObject("attribute").getJSONObject("result").getString("userid");
if(StrUtil.isEmpty(userid)){
return BaseResult.getFailureMessageEntity("认证失败获取钉钉userid错误","1006");
}
userEntity.setDdUserId( userid);
userEntity = sysUserDao.queryOne(userEntity);
if(null == userEntity ){
JSONObject object = new JSONObject();
object.put("userid",userid);
return BaseResult.getFailureMessageEntity("认证失败!当前用户未绑定钉钉","1005",object);
}
break;
case "weChat":
break;
default:
return BaseResult.getFailureMessageEntity("错误的App类型:"+appType+" 支持的app类型有DD,weChat");
}
//登录
StpUtil.login(userEntity.getId());
//获取token
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
String token = tokenInfo.getTokenValue();
//获取公司
SysOrganEntity sysOrganEntity = new SysOrganEntity();
sysOrganEntity.setUserId(userEntity.getId());
List<SysOrganEntity> sysOrganEntities = sysOrganDao.queryUserCompany(sysOrganEntity);
//返回值
JSONObject res = new JSONObject();
res.put("token", token);
res.put("userInfo", userEntity);
res.put("company", sysOrganEntities);
//切换数据源查询
return BaseResult.getSuccessMessageEntity("登录成功", res);
//校验当前登陆人是否有权限
//boolean flag = false;
//SysInterfaceEntity sysInterfaceEntity = (SysInterfaceEntity) interfaceCache.get("6","beanNameloginServiceinterfacNamedoLogin");
//if(sysInterfaceEntity == null || sysInterfaceEntity.getId() == null){
// return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
//}
////查询用户权限
//if(!flag){
// SysPopedomInterfaceEntity userPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("4","userId"+sysUserEntity.getId()+"interfaceId"+sysInterfaceEntity.getId());
// if(userPopedomInterfaceEntity != null && userPopedomInterfaceEntity.getId() != null ){
// flag = true;
// }
//}
////查询用户角色的权限
//if(!flag){
// List<SysUserRolesEntity> userRoleMap = (List<SysUserRolesEntity>) interfaceCache.get("3",null);
// if(userRoleMap != null && userRoleMap.size() > 0){
// for (SysUserRolesEntity sysUserRolesEntity : userRoleMap) {
// if(sysUserRolesEntity.getUserId().equals(sysUserEntity.getId())){
// SysPopedomInterfaceEntity sysPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("5","roleId"+sysUserRolesEntity.getRoleId()+"interfaceId"+sysInterfaceEntity.getId());
// if(sysPopedomInterfaceEntity != null && sysPopedomInterfaceEntity.getId() != null ){
// flag = true;
// break;
// }
// }
// }
// }
//}
//if(!flag){
// return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
//}
}
private JSONObject getAccess_token(String appId,String apiCode) {
String result = HttpRequest.post(url).
header("appId",appId).
header("apiCode",apiCode).
header("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj").
header("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
execute().
body();
JSONObject resultJson = JSONObject.parseObject(result);
return resultJson;
}
protected <T> T getData(String key, JSONObject jsonObject, Class<T> clz) {
if (checkStr(jsonObject.getString(key))) {
return jsonObject.getJSONObject(key).toJavaObject(clz);

View File

@ -21,7 +21,9 @@ public class SysMessageManageLogEntity extends BaseEntity {
private String messageCode;
/** 发送者应用 */
private String sendApp;
/** 发送者 */
private String sendAppName;
/** 发送者 */
private String sendApi;
/** 接收者编码 */
private String receiveCode;
@ -196,5 +198,13 @@ public class SysMessageManageLogEntity extends BaseEntity {
public void setCreateTimeEnd(Date createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public String getSendAppName() {
return sendAppName;
}
public void setSendAppName(String sendAppName) {
this.sendAppName = sendAppName;
}
}

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

@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.messageManageLogBack.detail.server.ISysMessageManageLogDetailBackService;
import com.hzya.frame.sysnew.messageManageLogBack.service.ISysMessageManageLogBackService;
import com.hzya.frame.sysnew.messageManageLogDetail.dao.ISysMessageManageLogDetailDao;
@ -41,7 +43,8 @@ public class SysMessageManageLogServiceImpl extends BaseService<SysMessageManage
private ISysMessageManageLogDao sysMessageManageLogDao;
@Resource
private IEsbService esbService;
@Resource
private ISysApplicationDao sysApplicationDao;
@Resource
private ISysMessageManageLogBackService sysMessageManageLogBackService;
@Resource
@ -222,6 +225,14 @@ public class SysMessageManageLogServiceImpl extends BaseService<SysMessageManage
}
entity = sysMessageManageLogDao.queryOne(entity);
if (entity != null && entity.getId() != null) {
if(entity.getSendApp()!= null){
SysApplicationEntity sysApplicationEntity = new SysApplicationEntity();
sysApplicationEntity.setId(entity.getSendApp());
sysApplicationEntity = sysApplicationDao.queryOne(sysApplicationEntity);
if(sysApplicationEntity!= null && sysApplicationEntity.getName() != null){
entity.setSendAppName(sysApplicationEntity.getName());
}
}
return BaseResult.getSuccessMessageEntity("查询数据成功", entity);
} else {
return BaseResult.getFailureMessageEntity("未查询到数据");

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">
@ -35,17 +31,13 @@
,sts
,org_id
,company_id
,bill_kind_id
,template_type
,template_name
,message_title
,message_contents
,btns
,data_source
,create_date
,create_person_id
,state
,isdelete
</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.*;
@ -31,175 +35,175 @@ public class SysMessageTemplateServiceImpl extends BaseService<SysMessageTemplat
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

@ -10,16 +10,19 @@ import com.hzya.frame.web.entity.BaseEntity;
*/
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
@ -48,52 +41,66 @@
,sts
,org_id
,company_id
,bill_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
,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;
@ -25,9 +29,12 @@ import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
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;
@ -43,368 +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;
@Resource
private ApplicationCache applicationCache;
@Resource
private ISysWarningInterfaceDao sysWarningInterfaceDao;
@Resource
private ISysWarningConfigDao sysWarningConfigDao;
@Resource
private ISysMessageTemplateDao sysMessageTemplateDao;
@Resource
private ISysUserDao sysUserDao;
@Resource
private ISysPersonDao sysPersonsDao;
private ISysSendMessageLogDao sysSendMessageLogDao;
@Resource
private ISysApplicationApiDao sysApplicationApiDao;
@Resource
private ISysApplicationApiParaDao sysApplicationApiParaDao;
@Autowired
public void setSysSendMessageLogDao(ISysSendMessageLogDao dao) {
this.sysSendMessageLogDao = dao;
this.dao = dao;
}
@Value("${zt.url}")
private String url ;
@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);
}
private ISysSendMessageLogDao sysSendMessageLogDao;
@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);
}
@Autowired
public void setSysSendMessageLogDao(ISysSendMessageLogDao dao) {
this.sysSendMessageLogDao = dao;
this.dao = dao;
}
@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 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 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 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 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 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 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 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("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").
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

@ -104,6 +104,8 @@
<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="ddUserId != null and ddUserId != ''">and dd_user_id = #{ddUserId}</if>
<if test="wxUserId != null and wxUserId != ''">and wx_user_id = #{wxUserId}</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
@ -373,6 +375,8 @@
<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="ddUserId != null and ddUserId != ''">dd_user_id = #{ddUserId},</if>
<if test="wxUserId != null and wxUserId != ''">wx_user_id = #{wxUserId},</if>
</trim>
where id = #{id}
</update>

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;
/**
@ -24,6 +36,19 @@ 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

@ -3,6 +3,8 @@ package com.hzya.frame.sysnew.warningInterface.dao;
import com.hzya.frame.sysnew.warningInterface.entity.SysWarningInterfaceEntity;
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

@ -10,6 +10,10 @@ import com.hzya.frame.web.entity.BaseEntity;
*/
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
@ -34,6 +37,7 @@
,push_method
,status
,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;
/**
@ -27,6 +34,13 @@ public class SysWarningInterfaceServiceImpl extends BaseService<SysWarningInterf
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);
}
}

View File

@ -21,11 +21,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;

View File

@ -78,7 +78,7 @@ public class EntranceServiceImpl implements IEntranceService {
if (m.getName().equals(serviceMethod.trim())) {
if (m.getName().startsWith("thirdInterface")) {//TODO 后续可能要加强校验规则
logger.info("第三方接口,不校验是否登陆");
}else if (!"doLogin".equals(m.getName())) {
}else if (!"doLogin".equals(m.getName())&& !"appDoLogin".equals(m.getName()) ) {
try {
StpUtil.checkLogin();
//校验当前登陆人是否有权限

View File

@ -0,0 +1,24 @@
package com.hzya.frame.webapp.web.corsconfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author 👻👻👻👻👻👻👻👻👻👻 gjh
* @version 1.0
* @content
* @date 2024-09-14 17:10
*/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowCredentials(false);
}
}

View File

@ -464,6 +464,15 @@
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../fw-bip/src/main/webapp/WEB-INF/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<filtering>false</filtering>
<includes>
<!-- 匹配所有jar包 -->
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>