Commit e56ab73c authored by fangxinjiang's avatar fangxinjiang

员工合同续签待办发送配置人-fxj

parent 4612a98e
/*
* 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.archives.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.archives.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* @Author fxj
* @Description 项目客服信息
* @Date 17:35 2025/8/14
* @Param
* @return
**/
@Data
public class ProjectCustomerServiceVo implements Serializable {
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String departNo;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String departName;
/**
* 前端客服-登录账号
*/
@Schema(description ="登录账号")
private String csLoginName;
}
......@@ -11,4 +11,6 @@ public class EmployeeContractConstants {
public static final String NOT_AUDIT = "未审核通过,无法更新";
public static final String INVALID = "作废、终止,无法更新";
public static final String CONTRACT_ALERT_DEFAULT_PERSON = "CONTRACT_ALERT_DEFAULT_PERSON";
}
......@@ -236,4 +236,16 @@ public class TEmpContractAlertController {
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tEmpContractAlertService.importDiy(file.getInputStream());
}
/**
* @Author fxj
* @Description 每日09:00推送一条整合的续签代码信息给配置的人员
* @Date 16:03 2025/8/15
**/
@Operation(description = "每天10:00推送整合后的待办商险数据给对应项目的前端客服信息")
@Inner
@PostMapping("/inner/pushContractAlertToWx")
public void pushInsuranceAlertToWx() {
tEmpContractAlertService.pushContractAlertToWx();
}
}
package com.yifu.cloud.plus.v1.yifu.archives.mapper;/*
* 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.archives.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);
}
......@@ -110,4 +110,6 @@ public interface TEmployeeContractInfoMapper extends BaseMapper<TEmployeeContrac
String getMinDateByCardAndDeptId(@Param("vo") IdNameNoVo vo);
void updateContractEnd( @Param("tEmployeeContractInfo")TEmployeeContractInfo tEmployeeContractInfo);
List<TEmployeeContractInfo> getContractAlertDeptNosList();
}
......@@ -115,4 +115,5 @@ public interface TSettleDomainMapper extends BaseMapper<TSettleDomain> {
List<String> getAllDeptByCustomerLoginName(@Param(value = "userLoginName") String userLoginName);
List<ProjectCustomerServiceVo> getServiceInfoByCodes(@Param(value = "codes")List<String> deptNos);
}
......@@ -68,4 +68,5 @@ public interface TEmpContractAlertService extends IService<TEmpContractAlert> {
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void pushContractAlertToWx();
}
......@@ -31,24 +31,31 @@ 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.ekp.vo.EkpDeptInfoVo;
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.archives.config.WxConfig;
import com.yifu.cloud.plus.v1.yifu.archives.constants.ArchivesConstants;
import com.yifu.cloud.plus.v1.yifu.archives.constants.EmployeeContractConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.*;
import com.yifu.cloud.plus.v1.yifu.archives.service.FeedBackDetailService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpContractAlertService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ChangeFeedBackAllVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ContractAlertSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpContractAlertUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractCheckVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
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.*;
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.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.archives.entity.SysConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
......@@ -57,6 +64,7 @@ import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 员工合同续签待办
......@@ -79,6 +87,17 @@ public class TEmpContractAlertServiceImpl extends ServiceImpl<TEmpContractAlertM
private final FeedBackDetailService feedBackDetailService;
private final TSettleDomainMapper settleDomainMapper;
@Autowired
private UpmsDaprUtils upmsDaprUtils;
@Autowired
private SysConfigMapper sysConfigMapper;
@Autowired
private WxConfig wxConfig;
@Override
public IPage<TEmpContractAlert> pageDiy(Page page, ContractAlertSearchVo searchVo) {
LambdaQueryWrapper<TEmpContractAlert> wrapper = buildQueryWrapper(searchVo);
......@@ -789,4 +808,132 @@ public class TEmpContractAlertServiceImpl extends ServiceImpl<TEmpContractAlertM
}
return null;
}
/**
* @Author fxj
* @Description 获取合同续签但前端客服异常的数据发送给柳毅晨(可配置)
* @Date 17:05 2025/8/14
* @Param
* @return
**/
@Override
public void pushContractAlertToWx() {
try {
//获取所有合同提醒的数据--去重
List<TEmployeeContractInfo> contractAlertList = contractInfoMapper.getContractAlertDeptNosList();
//从contractAlertList 对象的 中获取所有元素的 deptNo 属性,要去空和去重。放到 deptNos 中
List<String> deptNos = new ArrayList<>();
if (contractAlertList != null) {
for (TEmployeeContractInfo contract : contractAlertList) {
if (Common.isNotNull(contract) && !Common.isEmpty(contract.getDeptNo())) {
deptNos.add(contract.getDeptNo());
}
}
}
//通过项目获取所有项目的前端客服信息
List<ProjectCustomerServiceVo> deptInfoVos = settleDomainMapper.getServiceInfoByCodes(deptNos);
//需要提醒的项目信息
StringBuilder sb = new StringBuilder();
if (!Common.isEmpty(deptInfoVos)){
StringBuilder userNames = new StringBuilder();
//获取所有项目对应的客服信息
initUserNames(deptInfoVos, sb, userNames);
Map<String, SysUser> sysUserMap = getSysUserMap(userNames);
if (Common.isNotKong(sysUserMap)){
SysUser user;
for (ProjectCustomerServiceVo dept : deptInfoVos) {
if (Common.isEmpty(dept.getCsLoginName())){
continue;
}
user = sysUserMap.get(dept.getCsLoginName());
if (!Common.isNotNull(user)){
Common.appendStr(sb,dept.getDepartNo(),CommonConstants.DUNHAO_STRING);
}else if (!CommonConstants.ZERO_STRING.equals(user.getLockFlag()) || !CommonConstants.ZERO_STRING.equals(user.getDelFlag())){
//锁定标识:lockFlag != 0 都算作异常 删除标识:deleteFlag != 0 算作异常
Common.appendStr(sb,dept.getDepartNo(),CommonConstants.DUNHAO_STRING);
}
}
}
if (sb.length() > 0){
// 获取默认提醒人
SysConfig sysConfig = sysConfigMapper.getSysConfigLimitByKey(EmployeeContractConstants.CONTRACT_ALERT_DEFAULT_PERSON);
if (Common.isNotNull(sysConfig) && Common.isNotKong(sysConfig.getConfigValue2())){
sendMessageToWx(sysConfig.getConfigValue2(),sb);
}
}
}
}catch (Exception e){
// 记录日志或进行适当异常处理
log.error("推送合同提醒到企业微信时发生异常", e);
}
}
//发送企业微信待办
private void sendMessageToWx(String useruserWx, StringBuilder content) {
if (Common.isEmpty(useruserWx) || Common.isEmpty(content)) {
return;
}
StringBuilder sendUser = null;
if (Common.isNotKong(useruserWx)) {
sendUser = new StringBuilder(useruserWx);
}
if (sendUser != null) {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> requestMap = new HashMap<>();
Map<String, Object> textcard = new HashMap<>();
textcard.put("title", "合同到期提醒");
textcard.put("url", String.format(SecurityConstants.WX_GET_MESSAGE_AUTH_URL, wxConfig.getCorpid(), wxConfig.getDomainName() + "/auth/oauth/wxLogin", "66" ));
content.append("的所属前端客服当前状态异常,请及时更新服务手册数据,跟进项目情况。");
textcard.put("description", "项目编码为"+content);
requestMap.put("touser", sendUser);
requestMap.put("agentid", wxConfig.getAgentid());
requestMap.put("msgtype", "textcard");
requestMap.put("textcard", textcard);
// 必须加上header说明
if (!wxConfig.sendTextCard(restTemplate, requestMap)) {
wxConfig.sendTextCard(restTemplate, requestMap);
}
}
}
private Map<String, SysUser> getSysUserMap(StringBuilder userNames) {
Map<String, SysUser> sysUserMap = null;
if (!Common.isEmpty(userNames.toString())) {
try {
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));
}
}catch (Exception e){
log.error("获取用户映射时发生异常", e);
}
}
return sysUserMap;
}
private void initUserNames(List<ProjectCustomerServiceVo> deptInfoVos, StringBuilder sb, StringBuilder userNames) {
// 使用 Set 来确保用户名唯一性
Set<String> uniqueUserNames = new HashSet<>();
for (ProjectCustomerServiceVo deptInfoVo : deptInfoVos) {
if (Common.isNotNull(deptInfoVo)) {
// 不为空后面要查询对应账号状态异常的
if (Common.isNotNull(deptInfoVo.getCsLoginName())) {
uniqueUserNames.add(deptInfoVo.getCsLoginName());
} else {
Common.appendStr(sb,deptInfoVo.getDepartNo(),CommonConstants.DUNHAO_STRING);
}
}
}
// 将去重后的用户名添加到 userNames 中
for (String userName : uniqueUserNames) {
Common.appendStr(userNames, userName,CommonConstants.COMMA_STRING);
}
}
}
<?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.archives.mapper.SysConfigMapper">
<resultMap id="sysConfigLimitMap" type="com.yifu.cloud.plus.v1.yifu.archives.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.archives.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>
......@@ -851,4 +851,14 @@
from t_employee_contract_info e
where e.EMP_IDCARD = #{vo.no} and e.SETTLE_DOMAIN = #{vo.id} and e.DELETE_FLAG = '0' and e.AUDIT_STATUS = '2'
</select>
<!--list-->
<select id="getContractAlertDeptNosList" resultMap="tEmployeeContrctInfoMap">
SELECT
distinct a.DEPT_NO
FROM t_employee_contract_info a
<where>
a.DELETE_FLAG = 0
</where>
</select>
</mapper>
......@@ -667,4 +667,20 @@
t_settle_domain a
where a.DELETE_FLAG = '0' and a.CS_LOGIN_NAME = #{userLoginName}
</select>
<select id="getServiceInfoByCodes" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.ProjectCustomerServiceVo">
SELECT
a.DEPART_NO as 'departNo',
a.DEPART_NAME as 'departName',
a.cs_login_name as 'csLoginName'
FROM t_settle_domain a
where 1=1
and a.DELETE_FLAG = '0'
<if test="codes != null and codes.size() > 0">
and a.DEPART_NO in
<foreach collection="codes" item="param" index="index" open="(" close=")" separator=",">
#{param}
</foreach>
</if>
</select>
</mapper>
......@@ -735,4 +735,20 @@ public class Common {
}
return true;
}
/**
* @Author fxj
* @Description
* @Date 17:43 2025/8/14
**/
public static void appendStr(StringBuilder sb,String str,String split){
if (Common.isNotNull(sb) && Common.isNotNull(str)){
if (sb.length()>0){
sb.append(Common.isEmpty(split)?",":split);
sb.append(str);
}else {
sb.append(str);
}
}
}
}
......@@ -109,4 +109,18 @@ public class ArchiveTask {
log.info("-------------每日刷新运营风险管控数据-定时任务开始------------");
}
/**
* @Author fxj
* @Description 每天10点刷新合同续签待办信息到微信
* @Date 16:06 2025/8/15
* @Param
* @return
**/
public void everyDaypushContractAlertToWx() {
log.info("-------------每天刷新合同续签待办信息到微信-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
"/tempcontractalert/inner/pushContractAlertToWx","", Void.class, SecurityConstants.FROM_IN);
log.info("-------------每天刷新合同续签待待办信息到微信-定时任务结束------------");
}
}
\ No newline at end of file
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