Commit 053eddff authored by fangxinjiang's avatar fangxinjiang

科目预警提醒-fxj

parent 58260716
...@@ -71,23 +71,27 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E ...@@ -71,23 +71,27 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E
Map<String, BudgetWarningVo> pushMap = new HashMap<>(); Map<String, BudgetWarningVo> pushMap = new HashMap<>();
// 科目+二级成本中心 作为key 创建用户信息map // 科目+二级成本中心 作为key 创建用户信息map
Map<String, List<SysUser>> sysUserMap = new HashMap<>(); Map<String, List<SysUser>> sysUserMap = new HashMap<>();
Map<String, List<String>> sysUserEkpMap = new HashMap<>();
// 遍历预警信息列表,按科目+二级成本中心初始化Map // 遍历预警信息列表,按科目+二级成本中心初始化Map
for (BudgetWarningVo vo : vos) { for (BudgetWarningVo vo : vos) {
// 创建组合键 // 创建组合键
String key = vo.getKm() + "_" + vo.getCbzx(); String key = vo.getKm() + "_" + vo.getCbzx();
// 将预警信息放入Map中 // 将预警信息放入Map中
pushMap.put(key, vo); pushMap.put(key, vo);
sysUserMap = getMapInfo(vo); sysUserMap.putAll(getMapInfo(vo));
sysUserEkpMap.putAll(getMapInfoEkp(vo));
} }
//开始推送信息到企业微信 //开始推送信息到企业微信
if (Common.isNotKong(pushMap) && Common.isNotKong(sysUserMap)){ if (Common.isNotKong(pushMap) && Common.isNotNull(sysUserEkpMap)){
List<SysUser> users; List<SysUser> users;
List<String> userIds;
BudgetWarningVo config; BudgetWarningVo config;
String content; String content;
for (Map.Entry<String, BudgetWarningVo> entry : pushMap.entrySet()){ for (Map.Entry<String, BudgetWarningVo> entry : pushMap.entrySet()){
users = sysUserMap.get(entry.getKey()); users = sysUserMap.get(entry.getKey());
userIds = sysUserEkpMap.get(entry.getKey());
config = pushMap.get(entry.getKey()); config = pushMap.get(entry.getKey());
if (Common.isNotKong(users) && Common.isNotKong(config)){ if (Common.isNotKong(config)){
content = String.format("系统告警:%s 当前您所属的成本中心:%s下的%s预算余额当前剩余%s元,已不足%s%%,请关注预算使用情况,如有需要,可尽快追加预算。以免影响人员报销。", content = String.format("系统告警:%s 当前您所属的成本中心:%s下的%s预算余额当前剩余%s元,已不足%s%%,请关注预算使用情况,如有需要,可尽快追加预算。以免影响人员报销。",
config.getAt(), config.getAt(),
config.getCbzx(), config.getCbzx(),
...@@ -96,7 +100,7 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E ...@@ -96,7 +100,7 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E
config.getFz(), config.getFz(),
config.getFz()); config.getFz());
// 处理推送信息保存 // 处理推送信息保存
hanlderWarning(users, config, content); hanlderWarning(users, config, content,userIds);
} }
} }
} }
...@@ -106,29 +110,32 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E ...@@ -106,29 +110,32 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E
} }
} }
private void hanlderWarning(List<SysUser> users, BudgetWarningVo config, String content) { private void hanlderWarning(List<SysUser> users, BudgetWarningVo config, String content, List<String> userIds) {
EkpBudgetWarningInfo warningInfo; EkpBudgetWarningInfo warningInfo;
HashMap<String,SysUser> userWxMap = new HashMap<>();
if (Common.isNotKong(users)){
for (SysUser user : users){ for (SysUser user : users){
sendMessageToWx(user.getWxMessage(), content); userWxMap.put(user.getUsername(),user);
}
}
if (Common.isNotKong(userIds)){
SysUser userTemp;
for (String userId : userIds){
String[] temp = userId.split("_");
if (temp.length > 1){
userTemp =userWxMap.get(temp[0]);
sendMessageToWx(null== userTemp?null:userTemp.getWxMessage(), content);
warningInfo = new EkpBudgetWarningInfo(); warningInfo = new EkpBudgetWarningInfo();
warningInfo.setFdContent(content); warningInfo.setFdContent(content);
warningInfo.setFdReadStatus(CommonConstants.ZERO_STRING); warningInfo.setFdReadStatus(CommonConstants.ZERO_STRING);
warningInfo.setFdCreateTime(new Date()); warningInfo.setFdCreateTime(new Date());
warningInfo.setFdSubject(config.getKm()); warningInfo.setFdSubject(config.getKm());
warningInfo.setFdRecipientName(user.getNickname()); warningInfo.setFdRecipientName(null== userTemp?null:userTemp.getNickname());
warningInfo.setFdRecipientAccount(user.getUsername()); warningInfo.setFdRecipientAccount(null== userTemp?temp[0]:userTemp.getUsername());
if (Common.isNotKong(config.getTxr())){ warningInfo.setFdRecipientId(temp[1]);
String[] temp = config.getTxr().split(","); warningInfoMapper.insert(warningInfo);
if (temp.length > 1){
for (String t : temp){
if (t.indexOf(user.getUsername()) >= 0 && t.split("_").length > 1){
warningInfo.setFdRecipientId(t.split("_")[1]);
break;
}
}
} }
} }
warningInfoMapper.insert(warningInfo);
} }
} }
...@@ -153,7 +160,18 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E ...@@ -153,7 +160,18 @@ public class EkpAlertTableServiceImpl extends ServiceImpl<EkpAlertTableMapper, E
} }
return sysUserMap; return sysUserMap;
} }
private Map<String, List<String>> getMapInfoEkp(BudgetWarningVo vo) {
Map<String, List<String>> map = new HashMap<>();
if (Common.isNotKong(vo) && Common.isNotKong(vo.getTxr())) {
List<String> loginNames = Arrays.stream(vo.getTxr().split(","))
.filter(loginName -> !loginName.isEmpty())
.collect(Collectors.toList());
if (Common.isNotNull(loginNames)) {
map.put(vo.getKm() + "_" +vo.getCbzx(), loginNames);
}
}
return map;
}
private String getLoginNames(String txr) { private String getLoginNames(String txr) {
//txr格式 loginName_id 获取到所有的loginName //txr格式 loginName_id 获取到所有的loginName
if (Common.isEmpty(txr)) { if (Common.isEmpty(txr)) {
......
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