Commit 740f217a authored by fangxinjiang's avatar fangxinjiang

商险到期提醒停用客服替换为项目前端客服-fxj

parent a9b2d37f
......@@ -95,7 +95,18 @@ public class UpmsDaprUtils {
}
return allUserVoR;
}
/**
* @Author fxj
* @Description 通过用户ID 获取 在用的MVP系统的用户
* @Date 17:24 2025/3/12
**/
public R<SysUsersVo> getUserVoByUserIds(String userIds) {
R<SysUsersVo> allUserVoR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getUserVoByUserIds", userIds, SysUsersVo.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(allUserVoR)){
return R.failed("获取指定用户IDS对应用户信息失败!");
}
return allUserVoR;
}
public R<SysUser> getSimpleUser(String userId) {
R<SysUser> userR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getSimpleUser",userId, SysUser.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(userR)){
......
......@@ -1319,4 +1319,9 @@ public class InsurancesConstants {
* 商险到期提醒批量导出
*/
public static final String INSURANCE_ALERT_EXPORT = "商险到期提醒批量导出";
/**
* 商险到期提醒默认提醒人配置KEY
*/
public static final String INSURANCE_ALERT_DEFAULT_PERSON = "INSURANCE_ALERT_DEFAULT_PERSON";
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.insurances.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @Author fxj
* @Description 系统配置表
* @Date 9:38 2025/3/13
* @Param
* @return
**/
@Data
@TableName("sys_config")
@Schema(description = "系统配置表")
public class SysConfig {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* 配置键
*/
@ExcelAttribute(name = "配置键", isNotEmpty = true, errorInfo = "配置键不能为空", maxLength = 32)
@NotBlank(message = "配置键不能为空")
@Length(max = 32, message = "配置键不能超过32个字符")
@ExcelProperty("配置键")
@Schema(description = "配置键")
private String configKey;
/**
* 配置值
*/
@ExcelAttribute(name = "配置值", isNotEmpty = true, errorInfo = "配置值不能为空")
@NotBlank(message = "配置值不能为空")
@ExcelProperty("配置值")
@Schema(description = "配置值")
private String configValue;
/**
* 配置值1
*/
@ExcelAttribute(name = "配置值1")
@ExcelProperty("配置值1")
@Schema(description = "配置值1")
private String configValue1;
/**
* 配置值2
*/
@ExcelAttribute(name = "配置值2")
@ExcelProperty("配置值2")
@Schema(description = "配置值2")
private String configValue2;
/**
* 备注
*/
@ExcelAttribute(name = "备注", maxLength = 255)
@Length(max = 255, message = "备注不能超过255个字符")
@ExcelProperty("备注")
@Schema(description = "备注")
private String remark;
}
package com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances;/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.SysConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @Author fxj
* @Description 系统配置表
* @Date 9:40 2025/3/13
* @Param
* @return
**/
@Mapper
public interface SysConfigMapper extends BaseMapper<SysConfig> {
/**
* 系统限制配置表简单分页查询
*
* @param configKey 键
* @return
*/
SysConfig getSysConfigLimitByKey(@Param("configKey") String configKey);
}
......@@ -2,13 +2,30 @@ package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUsersVo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
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.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.insurances.constants.InsurancesConstants;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.SysConfig;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceAlert;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.SysConfigMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsuranceWarnMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsuranceWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -18,6 +35,13 @@ import java.util.List;
*/
@Service
public class TInsuranceWarnServiceImpl extends ServiceImpl<TInsuranceWarnMapper, TInsuranceAlert> implements TInsuranceWarnService {
@Autowired
private UpmsDaprUtils upmsDaprUtils;
@Autowired
private ArchivesDaprUtil archivesDaprUtil;
@Autowired
private SysConfigMapper sysConfigMapper;
@Override
public void createInsuranceAlert() {
......@@ -26,6 +50,132 @@ public class TInsuranceWarnServiceImpl extends ServiceImpl<TInsuranceWarnMapper,
.eq(TInsuranceAlert::getExpireIgnoreFlag, CommonConstants.ONE_STRING));
//批量生成或者更新商险到期提醒数据
List<TInsuranceAlert> list = baseMapper.selectInsuranceAlert();
this.saveOrUpdateBatch(list);
//获取所有在用的(未删除未锁定)MVP的用户信息
String userIds;
if (Common.isNotKong(list)){
try {
SysConfig sysConfig = sysConfigMapper.getSysConfigLimitByKey(InsurancesConstants.INSURANCE_ALERT_DEFAULT_PERSON);
userIds = list.stream().map(BaseEntity::getCreateBy).distinct().collect(Collectors.joining(","));
// 获取停用账号信息
Map<String, SysUser> userMap = null;
// 前端客服对应的账号信息
Map<String,SysUser> sysUserMap = null;
//账号停用的提醒对应的项目信息
Map<String, TSettleDomain> domainHashMap = new HashMap<>();
userMap = getStopSysUserMap(userIds, userMap);
//获取停用账户对应的项目的前端客服信息
if (!Common.isEmpty(userMap)) {
Map<String, SysUser> finalUserMap = userMap;
List<String> codes = new ArrayList<>();
list.stream().forEach(vo -> {
if (Common.isNotNull(finalUserMap.get(vo.getCreateBy()))) {
codes.add(vo.getDeptNo());
}
});
if (Common.isNotKong(codes)) {
//获取对应项目信息
R<TSettleDomainListVo> infoByCodes = archivesDaprUtil.getSettleInfoByCodes(codes);
if (null != infoByCodes && Common.isNotNull(infoByCodes.getData()) && Common.isNotNull(infoByCodes.getData().getMapVO())) {
domainHashMap = infoByCodes.getData().getMapVO();
}
// 获取项目对应的前端客服用户信息
sysUserMap = getStringSysUserMap(sysUserMap, domainHashMap);
}
}
// 停用的账号的提醒信息对应的项目信息不为空 ,遍历更新 前端客服名称及前端客服ID
initStopInfo(list, userMap, sysUserMap, domainHashMap,sysConfig);
}catch (Exception e){
log.error("商险不购买提醒初始化停用客服异常:",e);
}
this.saveOrUpdateBatch(list);
}
}
/**
* @Author fxj
* @Description 获取停用账号信息
* @Date 19:09 2025/3/12
**/
private Map<String, SysUser> getStopSysUserMap(String userIds, Map<String, SysUser> userMap) {
if (Common.isNotKong(userIds)){
R<SysUsersVo> res = upmsDaprUtils.getUserVoByUserIds(userIds);
if (Common.isNotNull(res) && Common.isNotNull(res.getData()) && Common.isNotNull(res.getData().getUserList())){
userMap = res.getData().getUserList();
}
}
return userMap;
}
/**
* @Author fxj
* @Description 更加项目编码CODES 获取项目前端客服用户信息
* @Date 19:07 2025/3/12
**/
private Map<String, SysUser> getStringSysUserMap(Map<String, SysUser> sysUserMap, Map<String, TSettleDomain> domainHashMap) {
if (Common.isNotKong(domainHashMap)) {
StringBuilder userNames = new StringBuilder();
for (TSettleDomain val : domainHashMap.values()) {
if (Common.isEmpty(userNames.toString())) {
userNames.append(val.getCsLoginName());
} else {
userNames.append(CommonConstants.COMMA_STRING);
userNames.append(val.getCsLoginName());
}
}
if (!Common.isEmpty(userNames.toString())) {
R<SysUserListVo> res = upmsDaprUtils.getUserIdsByUserNames(userNames.toString());
List<SysUser> users = null;
if (Common.isNotNull(res) && Common.isNotNull(res.getData()) && Common.isNotNull(res.getData().getUserList())) {
users = res.getData().getUserList();
}
if (Common.isNotKong(users)) {
sysUserMap = users.stream().collect(Collectors.toMap(k -> k.getUsername(), v -> v));
}
}
}
return sysUserMap;
}
/**
* @Author fxj
* @Description 封装停用账号为项目前端客服账号
* @Date 19:05 2025/3/12
**/
private void initStopInfo(List<TInsuranceAlert> list,
Map<String, SysUser> userMap,
Map<String, SysUser> sysUserMap,
Map<String, TSettleDomain> domainHashMap,
SysConfig sysConfig) {
if (Common.isNotNull(userMap) && Common.isNotKong(domainHashMap)){
TSettleDomain domain;
SysUser user = null;
String loginName;
String nickName = null;
String userId = null;
for (TInsuranceAlert alert: list){
if (Common.isNotNull(userMap.get(alert.getCreateBy()))){
domain = domainHashMap.get(alert.getDeptNo());
if (Common.isNotNull(domain)){
loginName = domain.getCsLoginName();
if (Common.isNotNull(loginName)){
user = null==sysUserMap?null:sysUserMap.get(loginName);
if (Common.isNotNull(user) && !CommonConstants.NINE_STRING.equals(user.getLockFlag())){
userId = user.getUserId();
nickName = user.getNickname();
}
}
}
// 找不到对应前端客服或前端客服停用 发给徐瑞玲
if (Common.isEmpty(userId) && Common.isNotNull(sysConfig)){
userId = sysConfig.getConfigValue();
nickName= sysConfig.getConfigValue1();
}
if (Common.isNotNull(nickName) && Common.isNotNull(userId)){
alert.setCreateBy(userId);
alert.setCreateName(nickName);
}
}
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.SysConfigMapper">
<resultMap id="sysConfigLimitMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.SysConfig">
<id property="id" column="ID"/>
<result property="configKey" column="CONFIG_KEY"/>
<result property="configValue" column="CONFIG_VALUE"/>
<result property="configValue1" column="CONFIG_VALUE_1"/>
<result property="configValue2" column="CONFIG_VALUE_2"/>
<result property="remark" column="REMARK"/>
</resultMap>
<!-- 根据key获取value -->
<select id="getSysConfigLimitByKey" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.SysConfig">
SELECT a.CONFIG_VALUE,CONFIG_VALUE_1,CONFIG_VALUE_2
FROM sys_config a
where a.CONFIG_KEY = #{configKey} limit 1
</select>
</mapper>
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @Author fxj
* @Description 通过用户ID 获取 在用的MVP系统的用户
* @Date 17:26 2025/3/12
**/
@Data
public class SysUsersVo implements Serializable {
private Map<String,SysUser> userList;
}
......@@ -50,10 +50,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lengleng
......@@ -690,4 +688,32 @@ public class UserController {
public R<SysCspDeptVo> selectCspDeptByUserDeptId(@RequestBody SysCspDeptVo vo) {
return R.ok(userService.selectCspDeptByUserDeptId(vo));
}
/**
* @return
* @Author fxj
* @Description 获取所有用户-- 指定用户名
* @Date 18:20 2022/8/16
* @Param
**/
@Inner
@PostMapping(value = {"/inner/getUserVoByUserIds"})
public SysUsersVo getUserVoByUserIds(@RequestBody String userIds) {
SysUsersVo naVo = new SysUsersVo();
if (Common.isEmpty(userIds)) {
return naVo;
}
//获取锁定或删除账号
List<SysUser> sysUsers = userService.list(Wrappers.<SysUser>query().lambda()
.and( obj ->
obj.eq(SysUser::getLockFlag,CommonConstants.NINE_STRING)
.or().eq(SysUser::getDelFlag,CommonConstants.ONE_STRING)
).in(SysUser::getUserId, Common.getList(userIds)));
if (Common.isNotEmpty(sysUsers)) {
Map<String,SysUser> userMap;
userMap = sysUsers.stream().collect(Collectors.toMap(k->k.getUserId(),v->v));
naVo.setUserList(userMap);
}
return naVo;
}
}
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