Commit a884e6a6 authored by huyuchen's avatar huyuchen

消息提醒修改

parent 921bb4ea
......@@ -141,4 +141,15 @@ public interface SecurityConstants {
**/
String WX_SEND_MESSAGE = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s";
/**
* @Author: huyc
* @Date: 2023/7/28
* @Description: 企业微信发送消息授权路径
* @return:
* 下面链接中的state参数是和前端进行交互区分的重要参数,如果新增,请不要和以前的前缀相同
* 1,2,3,4 前缀为合同审批待处理、抄送和垫付审批中的待处理、抄送。 5 前缀为突发事件待处理页面的标识
* 1=垫付审批待处理,2=垫付审批抄送,3=合同审批待处理,4=合同审批抄送,5=事件审批待处理
**/
String WX_GET_MESSAGE_AUTH_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect";
}
......@@ -80,6 +80,11 @@ public class TMessageInfo {
@ExcelProperty("处理人-当前提醒人")
@Schema(description = "处理人-当前提醒人")
private String alertUser;
/**
* 处理人-当前提醒人
*/
@Schema(description = "处理人-当前提醒人id")
private String alertUserId;
/**
* 是否通知企业微信用户 0 是 1 否
*/
......
......@@ -41,6 +41,8 @@ public class WxConfig {
private String corpsecret;
@Value("${wx.agentid}")
private String agentid;
@Value("${wx.authUrl}")
private String authUrl;
@Autowired
private RedisTemplate redisTemplate;
......
......@@ -27,7 +27,6 @@ import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -64,7 +63,6 @@ public class TMessageInfoController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tmessageinfo_get')" )
public R<TMessageInfo> getById(@PathVariable("id" ) String id) {
return R.ok(tMessageInfoService.getById(id));
}
......@@ -76,10 +74,9 @@ public class TMessageInfoController {
*/
@Operation(summary = "新增消息提醒", description = "新增消息提醒")
@SysLog("新增消息提醒" )
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_tmessageinfo_add')" )
@PostMapping("/saveMessageInfo")
public R<Boolean> save(@RequestBody TMessageInfo tMessageInfo) {
return R.ok(tMessageInfoService.saveMessage(tMessageInfo));
return tMessageInfoService.saveMessage(tMessageInfo);
}
/**
......@@ -90,7 +87,6 @@ public class TMessageInfoController {
@Operation(summary = "修改消息提醒", description = "修改消息提醒")
@SysLog("修改消息提醒" )
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_tmessageinfo_edit')" )
public R<Boolean> updateById(@RequestBody TMessageInfo tMessageInfo) {
return R.ok(tMessageInfoService.updateById(tMessageInfo));
}
......@@ -104,7 +100,20 @@ public class TMessageInfoController {
**/
@Operation(summary = "更新消息信息", description = "更新消息信息")
@Inner
@PostMapping("/inner/updateMessageInfo")
@PostMapping("/inner/updateInnerMessageInfo")
public void updateInnerMessageInfo(@RequestBody TMessageInfo tMessageInfo) {
tMessageInfoService.updateMessageInfo(tMessageInfo);
}
/**
* @Author huyc
* @Description 更新消息信息
* @Date 14:30 2023/7/26
* @Param
* @return
**/
@Operation(summary = "更新消息信息", description = "更新消息信息")
@PostMapping("/updateMessageInfo")
public void updateMessageInfo(@RequestBody TMessageInfo tMessageInfo) {
tMessageInfoService.updateMessageInfo(tMessageInfo);
}
......@@ -118,7 +127,7 @@ public class TMessageInfoController {
**/
@Operation(summary = "查询消息数量", description = "查询消息数量")
@PostMapping("/selectMessageCount")
public long selectMessageCount(@RequestBody TMessageInfo tMessageInfo) {
public R<Long> selectMessageCount(@RequestBody TMessageInfo tMessageInfo) {
return tMessageInfoService.selectMessageCount(tMessageInfo);
}
......@@ -130,7 +139,6 @@ public class TMessageInfoController {
@Operation(summary = "通过id删除消息提醒", description = "通过id删除消息提醒")
@SysLog("通过id删除消息提醒" )
@DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tmessageinfo_del')" )
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tMessageInfoService.removeById(id));
}
......
......@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.msg.entity.TMessageInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
/**
* 消息提醒
......@@ -36,9 +37,9 @@ public interface TMessageInfoService extends IService<TMessageInfo> {
*/
IPage<TMessageInfo> getTMessageInfoPage(Page<TMessageInfo> page, TMessageInfo tMessageInfo);
boolean saveMessage(TMessageInfo tMessageInfo);
R<Boolean> saveMessage(TMessageInfo tMessageInfo);
void updateMessageInfo(TMessageInfo tMessageInfo);
long selectMessageCount(TMessageInfo tMessageInfo);
R<Long> selectMessageCount(TMessageInfo tMessageInfo);
}
......@@ -20,13 +20,26 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.msg.config.WxConfig;
import com.yifu.cloud.plus.v1.msg.entity.TMessageInfo;
import com.yifu.cloud.plus.v1.msg.mapper.TMessageInfoMapper;
import com.yifu.cloud.plus.v1.msg.service.TMessageInfoService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
/**
* 消息提醒
......@@ -36,7 +49,15 @@ import org.springframework.stereotype.Service;
*/
@Log4j2
@Service
@AllArgsConstructor
public class TMessageInfoServiceImpl extends ServiceImpl<TMessageInfoMapper, TMessageInfo> implements TMessageInfoService {
@Autowired
private final UpmsDaprUtils upmsDaprUtils;
@Autowired
private WxConfig wxConfig;
/**
* 消息提醒简单分页查询
* @param tMessageInfo 消息提醒
......@@ -48,9 +69,40 @@ public class TMessageInfoServiceImpl extends ServiceImpl<TMessageInfoMapper, TMe
}
@Override
public boolean saveMessage(TMessageInfo tMessageInfo) {
return false;
public R<Boolean> saveMessage(TMessageInfo tMessageInfo) {
//企业微信通知
if (CommonConstants.ZERO_STRING.equals(tMessageInfo.getWxFlag())) {
//获取人员的账号
R<SysUser> simpleUser = upmsDaprUtils.getSimpleUser(tMessageInfo.getAlertUserId());
if(null != simpleUser && null != simpleUser.getData()) {
SysUser user = simpleUser.getData();
if (Common.isEmpty(user) || Common.isEmpty(user.getWxMessage())) {
return R.failed("未找到对应的人员信息");
} else {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> textcard = new HashMap<>();
Map<String, Object> requestMap = new HashMap<>();
String authUrl = String.format(SecurityConstants.WX_GET_MESSAGE_AUTH_URL, wxConfig.getCorpid(), wxConfig.getAuthUrl(), CommonConstants.ONE_STRING + tMessageInfo.getModelId());
textcard.put("title", "审批待处理");
textcard.put("url", authUrl);
StringBuilder description = new StringBuilder();
description.append("申请人:").append(tMessageInfo.getSubmitUser()).append("<br>");
description.append("待处理人:").append(tMessageInfo.getAlertUser()).append("<br>");
description.append("模块:").append(tMessageInfo.getModelType());
textcard.put("description", description.toString());
requestMap.put("touser", user.getWxMessage());
requestMap.put("agentid", wxConfig.getAgentid());
requestMap.put("msgtype", "textcard");
requestMap.put("textcard", textcard);
// 必须加上header说明
if (!wxConfig.sendTextCard(restTemplate, requestMap)) {
wxConfig.sendTextCard(restTemplate, requestMap);
}
}
}
}
baseMapper.insert(tMessageInfo);
return R.ok();
}
@Override
......@@ -75,10 +127,10 @@ public class TMessageInfoServiceImpl extends ServiceImpl<TMessageInfoMapper, TMe
}
@Override
public long selectMessageCount(TMessageInfo tMessageInfo) {
return baseMapper.selectCount(Wrappers.<TMessageInfo>query().lambda()
.eq(TMessageInfo::getAlertUser,tMessageInfo.getAlertUser())
.eq(TMessageInfo::getModelId,tMessageInfo.getModelId())
.eq(TMessageInfo::getHandlerStatus,CommonConstants.ONE_STRING));
public R<Long> selectMessageCount(TMessageInfo tMessageInfo) {
YifuUser user = SecurityUtils.getUser();
return R.ok(baseMapper.selectCount(Wrappers.<TMessageInfo>query().lambda()
.eq(TMessageInfo::getAlertUserId,user.getId())
.eq(TMessageInfo::getHandlerStatus,CommonConstants.ONE_STRING)));
}
}
......@@ -64,3 +64,9 @@ springdoc:
- group: mail
#按包路径匹配
packagesToScan: com.yifu.cloud.plus.v1.msg.controller
wx:
corpid: ww59249a765dd499ad
corpsecret: o3fLn0u9SFHh5_htpIRBSp2bOibTa8pZGcOJIJqvidQ
agentid: 1000003
authUrl: https://wx.worfu.com/auth/oauth/wxLogin
......@@ -29,6 +29,7 @@
<result property="alertType" column="ALERT_TYPE"/>
<result property="handlerStatus" column="HANDLER_STATUS"/>
<result property="alertUser" column="ALERT_USER"/>
<result property="alertUserId" column="ALERT_USER_ID"/>
<result property="wxFlag" column="WX_FLAG"/>
<result property="listUrl" column="LIST_URL"/>
<result property="infoUrl" column="INFO_URL"/>
......@@ -46,6 +47,7 @@
a.INFO_URL,
a.MODEL_TYPE,
a.MODEL_ID,
a.ALERT_USER_ID,
a.CREATE_TIME
</sql>
<sql id="tMessageInfo_where">
......@@ -62,6 +64,9 @@
<if test="tMessageInfo.alertUser != null and tMessageInfo.alertUser.trim() != ''">
AND a.ALERT_USER = #{tMessageInfo.alertUser}
</if>
<if test="tMessageInfo.alertUserId != null and tMessageInfo.alertUserId.trim() != ''">
AND a.ALERT_USER_ID = #{tMessageInfo.alertUserId}
</if>
<if test="tMessageInfo.infoUrl != null and tMessageInfo.infoUrl.trim() != ''">
AND a.INFO_URL = #{tMessageInfo.infoUrl}
</if>
......
......@@ -138,6 +138,11 @@ public class SysUser extends BaseEntity {
*/
private String wxOpenid;
/**
* 微信公众号的openid(工资条使用)
*/
private String wxMessage;
/**
* LDAP_DN
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment