Commit ed358836 authored by huyuchen's avatar huyuchen

huych-合同自动化代码提交

parent 319d0e2f
......@@ -194,8 +194,11 @@ public class TEmployeeContractPre extends BaseEntity {
@Schema(description = "工资发放方式 0 直接发放/委托银行代发")
private String paymentType;
@Schema(description = "派遣期限")
private String dispatchPeriod;
@Schema(description = "派遣期限-年")
private String dispatchPeriodYear;
@Schema(description = "派遣期限-月")
private String dispatchPeriodMonth;
@Schema(description = "派遣开始日期")
private Date dispatchPeriodStart;
......
......@@ -223,4 +223,11 @@ public class EmployeeContractVO extends RowIndex implements Serializable {
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value ="试用期")
private String tryPeriod;
/**
* id
*/
@ExcelAttribute(name = "id")
@ExcelProperty(value ="id")
private String id;
}
......@@ -87,6 +87,13 @@ public class TEmployeeContractPreVo extends RowIndex implements Serializable {
@Schema(description = "入职日期")
@ExcelProperty("入职日期")
private Date joinLeaveDate;
/**
* 新合同发起时间
*/
@ExcelAttribute(name = "新合同发起时间")
@Schema(description = "新合同发起时间 入职日期 0、入职3天后 3、入职1周后 7、入职2周后 14、入职3周后 21")
@ExcelProperty("新合同发起时间")
private int registType;
/**
* 合同类型
*/
......@@ -228,19 +235,13 @@ public class TEmployeeContractPreVo extends RowIndex implements Serializable {
@ExcelAttribute(name = "合同年限", errorInfo = "合同年限不能为空")
@Schema(description = "合同年限")
private String contractTerm;
/**
* 合同年限-年
*/
@Length(max = 11, message = "合同年限-年 不能超过11 个字符")
@ExcelAttribute(name = "合同年限-年", maxLength = 11)
@ExcelAttribute(name = "合同年限-年")
@Schema(description = "合同年限-年")
@ExcelProperty("合同年限-年")
private String contractDuratioYear;
/**
* 合同年限-月
*/
@Length(max = 11, message = "合同年限-月 不能超过11 个字符")
@ExcelAttribute(name = "合同年限-月", maxLength = 11)
@ExcelAttribute(name = "合同年限-月")
@Schema(description = "合同年限-月")
@ExcelProperty("合同年限-月")
private String contractDuratioMonth;
......@@ -292,11 +293,17 @@ public class TEmployeeContractPreVo extends RowIndex implements Serializable {
/**
* 试用期(单位月)
*/
@Length(max = 5, message = "试用期(单位月) 不能超过5 个字符")
@ExcelAttribute(name = "试用期(单位月)", maxLength = 5)
@Schema(description = "试用期(单位月)")
@ExcelProperty("试用期(单位月)")
private String tryPeriod;
/**
* 试用期(单位月)
*/
@ExcelAttribute(name = "试用期月份数字")
@Schema(description = "试用期月份数字 1、2、3、4...")
@ExcelProperty("试用期月份数字")
private String tryPeriodNum;
/**
* 试用期工资 元/月
*/
......@@ -415,11 +422,19 @@ public class TEmployeeContractPreVo extends RowIndex implements Serializable {
/**
* 派遣期限
*/
@Length(max = 1, message = "派遣期限 不能超过1 个字符")
@ExcelAttribute(name = "派遣期限", maxLength = 1)
@Schema(description = "派遣期限")
@ExcelProperty("派遣期限")
private String dispatchPeriod;
@Length(max = 1, message = "派遣期限-年 不能超过1 个字符")
@ExcelAttribute(name = "派遣期限-年", maxLength = 1)
@Schema(description = "派遣期限-年")
@ExcelProperty("派遣期限-年")
private String dispatchPeriodYear;
/**
* 派遣期限
*/
@Length(max = 1, message = "派遣期限-月 不能超过1 个字符")
@ExcelAttribute(name = "派遣期限-月", maxLength = 1)
@Schema(description = "派遣期限-月")
@ExcelProperty("派遣期限-月")
private String dispatchPeriodMonth;
/**
* 派遣开始日期
*/
......@@ -474,21 +489,22 @@ public class TEmployeeContractPreVo extends RowIndex implements Serializable {
@Schema(description = "其他工作时间 (工作方式为第二种方式)")
@ExcelProperty("其他工作时间 (工作方式为第二种方式)")
private String otherWorkDay;
/**
* 实习期限 无/一个月/两个月.../十二个月
*/
@Length(max = 5, message = "实习期限 无/一个月/两个月.../十二个月 不能超过5 个字符")
@ExcelAttribute(name = "实习期限 无/一个月/两个月.../十二个月", maxLength = 5)
@ExcelAttribute(name = "实习期限 无/一个月/两个月.../十二个月")
@Schema(description = "实习期限 无/一个月/两个月.../十二个月")
@ExcelProperty("实习期限 无/一个月/两个月.../十二个月")
private String internshipPeriod;
/**
* 实习开始日期
*/
@ExcelAttribute(name = "实习期限月数 0、1、2、3...")
@Schema(description = "实习期限月数 0、1、2、3...")
@ExcelProperty("实习期限月数 1、2、3...")
private String internshipPeriodNum;
@ExcelAttribute(name = "实习开始日期", isDate = true)
@Schema(description = "实习开始日期")
@ExcelProperty("实习开始日期")
private Date internshipPeriodStart;
/**
* 实习结束日期
*/
......
package com.yifu.cloud.plus.v1.yifu.archives.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
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.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @Author: huyc
* @Date: 2023/7/28
* @Description:
* @return: 企业微信配置
**/
@Configuration
@Data
@Slf4j
public class WxConfig {
@Value("${wx.corpid}")
private String corpid;
@Value("${wx.corpsecret}")
private String corpsecret;
@Value("${wx.agentid}")
private String agentid;
@Value("${wx.authUrl}")
private String authUrl;
@Value("${wx.domainName}")
private String domainName;
@Autowired
private RedisTemplate redisTemplate;
//未授权
private String accossTokenInvliad = "40014";
/**
* @param
* @Author: huyc
* @Date: 2023/7/28
* @Description: 获取微信accos_token
* @return: java.lang.String
**/
public String getAccessToken(RestTemplate restTemplate) {
if (Common.isNotNull(agentid)) {
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
public String getAccessToken(RestTemplate restTemplate,String corpsecret)throws AuthenticationServiceException {
if(Common.isEmpty(corpsecret)){
throw new AuthenticationServiceException("未找到对应的corpsecret请联系管理员配置");
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
/**
* @param restTemplate
* @param tokenKey
* @param corpsecretKey
* @Description: 获取token
* @Author: huyc
* @Date: 2023/7/28 14:46
* @return: java.lang.String
**/
public String getToken(RestTemplate restTemplate,String tokenKey, String corpsecretKey) {
Object wxToken = redisTemplate.opsForValue().get(tokenKey);
if (null != wxToken) {
return String.valueOf(wxToken);
}
String requestTokenUrl = String.format(SecurityConstants.WX_GET_ACCOSS_TOKEN, corpid, corpsecretKey);
String result = restTemplate.getForObject(requestTokenUrl, String.class);
if (Common.isEmpty(result)) {
throw new CheckedException("微信授权失败");
}
String token = JSON.parseObject(result).getString("access_token");
if (Common.isEmpty(token)) {
log.info(result);
throw new CheckedException("获取微信token失败");
}
redisTemplate.opsForValue().set(tokenKey, token);
redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS);
return token;
}
/**
* @param
* @Author: huyc
* @Date: 2023/7/28 14:43
* @Description: 移除微信accossToken
* @return: java.lang.String
**/
public void removeAccessToken() {
redisTemplate.delete(CacheConstants.WX_ACCOSS_TOKEN);
}
/**
* @param restTemplate
* @param requestMap 请求内容
* @Author: huyc
* @Date: 2023/7/28 14:48
* @Description: 发送卡片消息
* @return: java.lang.String
**/
public boolean sendTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) {
// 必须加上header说明
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Gson gson = new Gson();
log.debug("发企业微信===请求:{}", gson.toJson(requestMap));
HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers);
String accessToken = getAccessToken(restTemplate);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class);
log.debug("发企业微信===返回:{}",JSON.toJSONString(responseEntity));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity));
JSONObject jsonBody = jsonObject.getJSONObject("body");
if (jsonBody != null) {
String errcode = jsonBody.getString("errcode");
if (accossTokenInvliad.equals(errcode)) {
//删除accossToken缓存
removeAccessToken();
return false;
}
if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志
log.info(jsonObject.toJSONString());
}
} else {
log.info(jsonObject.toJSONString());
}
return true;
}
/**
* 功能描述: 获取微信accos_token
* @Author: huyc
* @Date: 2023/7/28 14:50
* @return: java.lang.String
*/
public String getAppAccessToken(RestTemplate restTemplate) {
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
}
......@@ -209,4 +209,30 @@ public class TEmployeeContractPreController {
.last(CommonConstants.LAST_ONE_SQL));
return R.ok(employeeContractInfo);
}
/**
* 派单当日8点30分统一推送确认信息
* @author huych
* @date 2025-06-16 11:26:16
* @return void
*/
@SysLog("派单当日8点30分统一推送确认信息")
@Inner
@PostMapping("/inner/pushWxConfrimMessage")
public void pushWxConfrimMessage() {
tEmployeeContractPreService.pushWxConfrimMessage();
}
/**
* 每天上午9点推送待派单数据
* @author huych
* @date 2025-06-16 14:18:26
* @return void
*/
@SysLog("每天上午9点推送待派单数据")
@Inner
@PostMapping("/inner/pushDisConfrimContracts")
public void pushDisConfrimContracts() {
tEmployeeContractPreService.pushDisConfrimContracts();
}
}
......@@ -34,4 +34,8 @@ public interface TEmployeeContractPreMapper extends BaseMapper<TEmployeeContract
List<TEmployeeContractPreExportVo> getTEmployeeContractPreExport(@Param("tEmployeeContractPre") TEmployeeContractPreSearchVo tEmployeeContractPre);
List<EmployeeContractVO> getDisPatcherContractList(@Param("idList") List<String> idList,@Param("statusList") List<String> statusList);
List<TEmployeeContractPre> getAllUnconfimData();
List<String> getAllUnDisData();
}
......@@ -71,4 +71,8 @@ public interface TEmployeeContractPreService extends IService<TEmployeeContractP
*/
R revokeSign(List<TEmployeeAutoRegistRevokeVo> registRevokeVoList);
void pushWxConfrimMessage();
void pushDisConfrimContracts();
}
......@@ -8,6 +8,8 @@ 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.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.archives.config.WxConfig;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractAudit;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractPre;
......@@ -19,19 +21,25 @@ import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
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.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -52,6 +60,12 @@ public class TEmployeeContractPreServiceImpl extends ServiceImpl<TEmployeeContra
private final TEmployeeContractInfoService contractInfoService;
@Autowired
private WxConfig wxConfig;
@Autowired
private UpmsDaprUtils upmsDaprUtils;
/**
* 合同待签订任务记录表简单分页查询
* @param tEmployeeContractPre 合同待签订任务记录表
......@@ -247,17 +261,51 @@ public class TEmployeeContractPreServiceImpl extends ServiceImpl<TEmployeeContra
List<TEmployeeContractPre> contractPreList = baseMapper.selectList(Wrappers.<TEmployeeContractPre>query()
.lambda().in(TEmployeeContractPre::getId, idList)
.in(TEmployeeContractPre::getProcessStatus, CommonConstants.socialInfoStatus));
// 如果没有找到任何未处理的合同待派单数据,返回失败消息
if (Common.isEmpty(contractPreList)) {
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
//发起派单
List<ErrorMessage> errorMessageList = new ArrayList<>();
List<ErrorMessage> errorMessageListAll = new ArrayList<>();
List<EmployeeContractVO> excelVOList = baseMapper.getDisPatcherContractList(idList,CommonConstants.socialInfoStatus);
if (Common.isNotNull(excelVOList) && !excelVOList.isEmpty()) {
//调用批量派单接口
contractInfoService.importContract(excelVOList, errorMessageList);
List<EmployeeContractVO> disList;
int k = 0;
int i = (int) Math.ceil((double) excelVOList.size() / CommonConstants.INTEGER_HUNDRED);
for (int j = 0; j < i; j++) {
if (j == i - 1) {
disList = excelVOList.subList(k, excelVOList.size());
} else {
disList = excelVOList.subList(k, k + 100);
}
k = k + 100;
if (Common.isNotNull(disList)) {
//调用批量派单接口100条处理一次,同原合同派单保持一致
List<ErrorMessage> errorMessageList = new ArrayList<>();
contractInfoService.importContract(disList, errorMessageList);
List<String> idUpdList = disList.stream().map(EmployeeContractVO::getId).collect(Collectors.toList());
if (errorMessageList.stream().allMatch(message -> message.getMessage().equals(CommonConstants.SAVE_SUCCESS))) {
//更新合同状态为2线下签待审核
LambdaUpdateWrapper<TEmployeeContractPre> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(TEmployeeContractPre::getId, idUpdList)
.in(TEmployeeContractPre::getProcessStatus, CommonConstants.socialInfoStatus)
.set(TEmployeeContractPre::getProcessStatus, CommonConstants.TWO_STRING);
// 执行更新操作
this.update(updateWrapper);
} else {
errorMessageListAll.addAll(errorMessageList);
//更新合同状态为5发起失败
LambdaUpdateWrapper<TEmployeeContractPre> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(TEmployeeContractPre::getId, idUpdList)
.in(TEmployeeContractPre::getProcessStatus, CommonConstants.socialInfoStatus)
.set(TEmployeeContractPre::getProcessStatus, CommonConstants.FIVE_STRING);
// 执行更新操作
this.update(updateWrapper);
}
}
}
}
return R.ok(errorMessageList);
return R.ok(errorMessageListAll);
}
@Override
......@@ -337,6 +385,73 @@ public class TEmployeeContractPreServiceImpl extends ServiceImpl<TEmployeeContra
}
}
@Override
public void pushWxConfrimMessage() {
//获取所有预计派单时间为当天而且状态是待确认的合同待签署数据
List<TEmployeeContractPre> unConfirmList = baseMapper.getAllUnconfimData();
if (Common.isNotNull(unConfirmList) && !unConfirmList.isEmpty()) {
for (TEmployeeContractPre pre : unConfirmList) {
try {
sendMessageToWx(pre);
} catch (Exception e) {
log.error("执行异常", e);
}
}
}
}
@Override
public void pushDisConfrimContracts() {
//获取所有待派单的数据
List<String> unConfirmList = baseMapper.getAllUnDisData();
if (null != unConfirmList && !unConfirmList.isEmpty()) {
try {
this.dispatcherContract(unConfirmList);
} catch (Exception e) {
log.error("执行异常", e);
}
}
}
//发送企业微信待办
private void sendMessageToWx(TEmployeeContractPre pre) {
//获取前端客服
SysUser user;
if (Common.isEmpty(pre.getCustomerUserLoginname())) {
return;
}
R<SysUser> res = upmsDaprUtils.getSimpleUserByLoginName(pre.getCustomerUserLoginname());
if (Common.isNotNull(res) && Common.isNotNull(res.getData())) {
user = res.getData();
} else {
return;
}
StringBuilder sendUser = null;
if (Common.isNotKong(user.getWxMessage())) {
sendUser = new StringBuilder(user.getWxMessage());
}
if (sendUser != null) {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> requestMap = new HashMap<>();
Map<String, Object> textcard = new HashMap<>();
String authUrl = String.format(SecurityConstants.WX_GET_MESSAGE_AUTH_URL, wxConfig.getCorpid(), wxConfig.getDomainName() + "/auth/oauth/wxLogin", "03" + pre.getCustomerUserLoginname());
StringBuilder description = new StringBuilder();
String title = "合同待签署确认";
description.append("您有新的合同待签署确认数据,请及时确认").append("<br>");
textcard.put("title", title);
textcard.put("url", authUrl);
textcard.put("description", description.toString());
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);
}
}
}
public boolean haveRole(YifuUser user, long roleId) {
List<Long> roleList = user.getClientRoleMap().get(ClientNameConstants.CLIENT_MVP);
for (Long role : roleList) {
......
......@@ -27,6 +27,13 @@ spring:
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
wx:
corpid: wwbcb090af0dfe50e5
corpsecret: R0nKkvsY-oF41fuQvUXZ-kFG3_g_Ce0bpZt6mByx524
agentid: 1000009
authUrl: https://wx.worfu.com/yifu-auth/method/oauth/wxLogin
domainName: https://wx.worfu.com
......@@ -47,4 +47,11 @@ fdd:
serverUrl: https://sandboxapi.fadada.com/api/v3/
connectTimeout: 10000
readTimeout: 10000
hrmsUrl: http://2349f6a315.wicp.vip:39468/v1.0/invoke/yifu-archives/method
\ No newline at end of file
hrmsUrl: http://2349f6a315.wicp.vip:39468/v1.0/invoke/yifu-archives/method
wx:
corpid: wwbcb090af0dfe50e5
corpsecret: 16kqEL_eU-ARwYyqLgEBWHgxm8gXVnkzv_eJMLy9NpU
agentid: 1000010
authUrl: https://test-wx.worfu.com/yifu-auth/method/oauth/wxLogin
domainName: https://test-wx.worfu.com
\ No newline at end of file
......@@ -56,7 +56,8 @@
<result property="settlementCycle" column="SETTLEMENT_CYCLE"/>
<result property="paymentTime" column="PAYMENT_TIME"/>
<result property="paymentType" column="PAYMENT_TYPE"/>
<result property="dispatchPeriod" column="DISPATCH_PERIOD"/>
<result property="dispatchPeriodYear" column="DISPATCH_PERIOD_YEAR"/>
<result property="dispatchPeriodMonth" column="DISPATCH_PERIOD_MONTH"/>
<result property="dispatchPeriodStart" column="DISPATCH_PERIOD_START"/>
<result property="registerId" column="register_id"/>
<result property="revokeReason" column="revoke_reason"/>
......@@ -145,7 +146,7 @@
a.create_name,
a.create_time,
a.update_by,a.contract_term,a.sign_flag,a.error_info,a.contract_id,a.revoke_reason,
a.working_hours,a.working_reward
a.working_hours,a.working_reward,DISPATCH_PERIOD_YEAR,DISPATCH_PERIOD_MONTH
</sql>
<sql id="tEmployeeContractPre_where">
<if test="tEmployeeContractPre != null">
......@@ -302,15 +303,6 @@
<if test="tEmployeeContractPre.paymentType != null and tEmployeeContractPre.paymentType.trim() != ''">
AND a.PAYMENT_TYPE = #{tEmployeeContractPre.paymentType}
</if>
<if test="tEmployeeContractPre.dispatchPeriod != null and tEmployeeContractPre.dispatchPeriod.trim() != ''">
AND a.DISPATCH_PERIOD = #{tEmployeeContractPre.dispatchPeriod}
</if>
<if test="tEmployeeContractPre.dispatchPeriodStart != null">
AND a.DISPATCH_PERIOD_START = #{tEmployeeContractPre.dispatchPeriodStart}
</if>
<if test="tEmployeeContractPre.dispatchPeriodEnd != null">
AND a.DISPATCH_PERIOD_END = #{tEmployeeContractPre.dispatchPeriodEnd}
</if>
<if test="tEmployeeContractPre.workType != null and tEmployeeContractPre.workType.trim() != ''">
AND a.WORK_TYPE = #{tEmployeeContractPre.workType}
</if>
......@@ -439,6 +431,7 @@
<!--tEmployeeContractPre合同派单查询-->
<select id="getDisPatcherContractList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractVO">
SELECT
(@i :=@i+1) as rowIndex,
a.employee_name empName,
a.emp_idcard empIdcard,
a.dept_no deptNo,
......@@ -465,8 +458,9 @@
null reduceReason,
null remark,
null changeContractAndEmployee,
a.TRY_PERIOD tryPeriod
FROM t_employee_contract_pre a
a.TRY_PERIOD tryPeriod,
a.id
FROM t_employee_contract_pre a,(select @i:=0) as itable
<where>
1=1
AND a.id in
......@@ -479,4 +473,21 @@
</foreach>
</where>
</select>
<select id="getAllUnconfimData" resultMap="tEmployeeContractPreMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_employee_contract_pre a
where a.process_status = '0' and DATE_FORMAT(a.expected_collection_time,"%Y-%m-%d") = CURDATE()
group by a.customer_user_loginname
</select>
<select id="getAllUnDisData" resultType="java.lang.String">
SELECT
id
FROM t_employee_contract_pre a
where a.process_status in ('1','3','5','7')
and DATE_FORMAT(a.expected_collection_time,"%Y-%m-%d") <![CDATA[ <= ]]> CURDATE()
</select>
</mapper>
......@@ -199,4 +199,15 @@ public class SocialDaprUtils {
public R<Boolean> checkIsWorkDay(TEmployeeInsuranceWorkDayVo vo) {
return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tholidayinfo/inner/checkIsWorkDay", JSON.toJSONString(vo), Boolean.class, SecurityConstants.FROM_IN);
}
/**
* @Author huyc
* @Description 合同:查询最近的工作日期
* @Date 16:39 2025/6/16
* @Param
* @return
**/
public R<TEmployeeInsuranceWorkDayVo> getContractAfterWorkDay(TEmployeeInsuranceWorkDayVo vo) {
return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tholidayinfo/inner/selectBeforeOrAfterWorkDayCommon", JSON.toJSONString(vo), TEmployeeInsuranceWorkDayVo.class, SecurityConstants.FROM_IN);
}
}
package com.yifu.cloud.plus.v1.csp.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 查询工作日vo
*
* @author huych
* @date 2025-04-07 10:30:13
*/
@Data
public class TEmployeeContractDateVo implements Serializable {
@Schema(description = "开始日期")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
private Date registDate;
@Schema(description = "月份后 0、1、2、3...")
private int monthAfter;
@Schema(description = "年份后 0、1、2、3...")
private int yearAfter;
}
......@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.csp.entity.EmployeeRegistration;
import com.yifu.cloud.plus.v1.csp.service.EmployeeRegistrationService;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationCustomerUserUpdateVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationReceiveVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationSearchVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationUpdateVo;
import com.yifu.cloud.plus.v1.csp.vo.*;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProjectBelongDept;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeRegistrationPreVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeProjectBelongDeptSearchCspVo;
......@@ -356,4 +353,17 @@ public class EmployeeRegistrationController {
menuUtil.setAuthSql(user, searchVo);
return R.ok(employeeRegistrationService.getRegisterPreCount(searchVo));
}
/**
* 查询多少年多少月后对应的日期
*
* @author huych
* @date 2025-06-16 10:03:16
**/
@Operation(summary = "查询多少年多少月后对应的日期")
@SysLog("查询多少年多少月后对应的日期")
@PostMapping("/addYearsMonths")
public R addYearsMonths(@RequestBody TEmployeeContractDateVo vo) {
return R.ok(employeeRegistrationService.addYearsMonths(vo));
}
}
......@@ -4,10 +4,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.csp.entity.EmployeeRegistration;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationCustomerUserUpdateVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationReceiveVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationSearchVo;
import com.yifu.cloud.plus.v1.csp.vo.EmployeeRegistrationUpdateVo;
import com.yifu.cloud.plus.v1.csp.vo.*;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProjectBelongDept;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeRegistrationPreVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeProjectBelongDeptSearchCspVo;
......@@ -16,6 +13,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
/**
......@@ -171,4 +169,6 @@ public interface EmployeeRegistrationService extends IService<EmployeeRegistrati
R<EmployeeRegistration> getDetailInfoById(String id);
Date addYearsMonths(TEmployeeContractDateVo vo);
}
......@@ -57,11 +57,10 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.ZoneId;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -703,11 +702,74 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
employeeContractPreVo.setCreateName(user.getNickname());
// 设置更新者ID
employeeContractPreVo.setUpdateBy(user.getId());
//预计确认提醒时间、预计合同发起时间日期赋值
R<TEmployeeInsuranceWorkDayVo> dataR;
if (Common.isNotNull(employeeContractPreVo.getRegistType())
&& Common.isEmpty(employeeContractPreVo.getExpectedCollectionTime())
&& Common.isEmpty(employeeContractPreVo.getExpectedConfirmTime())) {
TEmployeeInsuranceWorkDayVo dayVo = new TEmployeeInsuranceWorkDayVo();
dayVo.setType(CommonConstants.TWO_STRING);
dayVo.setRegistDate(registration.getJoinLeaveDate());
dayVo.setRegistType(employeeContractPreVo.getRegistType());
dataR = socialDaprUtils.getContractAfterWorkDay(dayVo);
if (Common.isNotNull(dataR) && Common.isNotNull(dataR.getData())
&& Common.isNotNull(dataR.getData().getRegistDate())) {
employeeContractPreVo.setExpectedCollectionTime(dataR.getData().getRegistDate());
employeeContractPreVo.setExpectedConfirmTime(dataR.getData().getRegistDate());
} else {
employeeContractPreVo.setExpectedCollectionTime(registration.getJoinLeaveDate());
employeeContractPreVo.setExpectedConfirmTime(registration.getJoinLeaveDate()); }
}
TEmployeeContractDateVo vo = new TEmployeeContractDateVo();
//合同开始日期、合同截止日期
if (Common.isEmpty(employeeContractPreVo.getContractStart())
&& Common.isNotNull(employeeContractPreVo.getContractDuratioYear())
&& Common.isNotNull(employeeContractPreVo.getContractDuratioMonth())) {
employeeContractPreVo.setContractStart(employeeContractPreVo.getExpectedCollectionTime());
vo.setMonthAfter(Integer.parseInt(employeeContractPreVo.getContractDuratioMonth()));
vo.setYearAfter(Integer.parseInt(employeeContractPreVo.getContractDuratioYear()));
vo.setRegistDate(employeeContractPreVo.getContractStart());
employeeContractPreVo.setContractEnd(this.addYearsMonths(vo));
}
//合同开始日期
if (Common.isEmpty(employeeContractPreVo.getContractStart())
&& Common.isEmpty(employeeContractPreVo.getContractDuratioYear())
&& Common.isEmpty(employeeContractPreVo.getContractDuratioMonth())) {
employeeContractPreVo.setContractStart(employeeContractPreVo.getExpectedCollectionTime());
}
//试用期开始日期、试用期截止日期
if (Common.isEmpty(employeeContractPreVo.getPeriodStart())
&& Common.isNotNull(employeeContractPreVo.getTryPeriodNum())) {
employeeContractPreVo.setPeriodStart(employeeContractPreVo.getExpectedCollectionTime());
vo.setMonthAfter(Integer.parseInt(employeeContractPreVo.getTryPeriodNum()));
vo.setYearAfter(0);
vo.setRegistDate(employeeContractPreVo.getPeriodStart());
employeeContractPreVo.setPeriodEnd(this.addYearsMonths(vo));
}
//派遣开始日期、派遣结束日期
if (Common.isEmpty(employeeContractPreVo.getDispatchPeriodStart())
&& Common.isNotNull(employeeContractPreVo.getDispatchPeriodYear())
&& Common.isNotNull(employeeContractPreVo.getDispatchPeriodMonth())) {
employeeContractPreVo.setDispatchPeriodStart(employeeContractPreVo.getExpectedCollectionTime());
vo.setMonthAfter(Integer.parseInt(employeeContractPreVo.getDispatchPeriodMonth()));
vo.setYearAfter(Integer.parseInt(employeeContractPreVo.getDispatchPeriodYear()));
vo.setRegistDate(employeeContractPreVo.getDispatchPeriodStart());
employeeContractPreVo.setDispatchPeriodEnd(this.addYearsMonths(vo));
}
//实习开始日期、实习结束日期
if (Common.isEmpty(employeeContractPreVo.getInternshipPeriodStart())
&& Common.isNotNull(employeeContractPreVo.getInternshipPeriodNum())) {
employeeContractPreVo.setInternshipPeriodStart(employeeContractPreVo.getExpectedCollectionTime());
vo.setMonthAfter(Integer.parseInt(employeeContractPreVo.getInternshipPeriodNum()));
vo.setYearAfter(0);
vo.setRegistDate(employeeContractPreVo.getInternshipPeriodStart());
employeeContractPreVo.setInternshipPeriodEnd(this.addYearsMonths(vo));
}
// 预计提醒时间、预计合同发起时间
employeeContractPreVo.setExpectedCollectionTime(DateUtil.parseDate(DateUtil.dateToString(
employeeContractPreVo.getExpectedCollectionTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " 15:20", DateUtil.DATETIME_PATTERN_MINUTE));
employeeContractPreVo.getExpectedCollectionTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " 9:00", DateUtil.DATETIME_PATTERN_MINUTE));
employeeContractPreVo.setExpectedConfirmTime(DateUtil.parseDate(DateUtil.dateToString(
employeeContractPreVo.getExpectedConfirmTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " 15:20", DateUtil.DATETIME_PATTERN_MINUTE));
employeeContractPreVo.getExpectedConfirmTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT) + " 8:30", DateUtil.DATETIME_PATTERN_MINUTE));
}
......@@ -861,10 +923,11 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
TEmployeeInsurancePreVo insurancePreVo = preVo.getEmployeeInsurancePreVos().get(0);
initInsruancePreInfo(registration, insurancePreVo, user,domainR.getData());
insuranceDaprUtil.saveInsurancePreInfo(preVo);
if (Common.isNotNull(preVo.getEmployeeContractPreVo()) &&
CommonConstants.ONE_STRING.equals(preVo.getEmployeeContractPreVo().getContractFlag())) {
TEmployeeContractPreVo employeeContractPreVo = preVo.getEmployeeContractPreVo();
if (Common.isNotNull(employeeContractPreVo) && Common.isNotNull(employeeContractPreVo.getContractFlag())
&& CommonConstants.ONE_STRING.equals(employeeContractPreVo.getContractFlag())) {
//生成合同待购买数据
initContractPreInfo(registration, preVo.getEmployeeContractPreVo(), user, domainR.getData());
initContractPreInfo(registration, employeeContractPreVo, user, domainR.getData());
}
}
}catch (Exception e) {
......@@ -1261,6 +1324,24 @@ public class EmployeeRegistrationServiceImpl extends ServiceImpl<EmployeeRegistr
return R.ok(employeeRegistration);
}
@Override
public Date addYearsMonths(TEmployeeContractDateVo vo) {
if (vo == null || vo.getRegistDate() == null) return null;
// 转换为LocalDate(自动处理时区)
LocalDate localDate = vo.getRegistDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
// 添加年数和月数
localDate = localDate
.plusYears(vo.getYearAfter())
.plusMonths(vo.getMonthAfter());
// 转回Date类型
return Date.from(localDate.atStartOfDay()
.atZone(ZoneId.systemDefault())
.toInstant());
}
/**
* @Description: 批量处理日志
* @Author: hgw
......
......@@ -30,4 +30,7 @@ public class TEmployeeInsuranceWorkDayVo implements Serializable {
@Schema(description = "类型 1 新增 2 其他")
private String addOrBatch;
@Schema(description = "新合同发起时间 入职日期 0、入职3天后 3、入职1周后 7、入职2周后 14、入职3周后 21")
private int registType;
}
......@@ -186,7 +186,7 @@ public class THolidayInfoController {
/**
* @Author huyc
* @Description 查询日期的前一个/后一个工作日
* @Description 商险派单预计派单日期使用:查询日期的前一个/后一个工作日
* @Date 10:27 2025/4/7
**/
@PostMapping("/selectBeforeOrAfterWorkDay")
......@@ -196,7 +196,7 @@ public class THolidayInfoController {
/**
* @Author huyc
* @Description 查询日期的前一个/后一个工作日
* @Description 商险派单预计派单日期使用:查询日期的前一个/后一个工作日
* @Date 10:27 2025/4/7
**/
@Inner
......@@ -205,6 +205,27 @@ public class THolidayInfoController {
return tHolidayInfoService.getInitBeforeOrAfterWorkDay(vo);
}
/**
* @Author huyc
* @Description 合同开始日期使用:获取传入日期的后一个工作日
* @Date 10:27 2025/6/13
**/
@PostMapping("/selectBeforeOrAfterWorkDayCommon")
public R selectBeforeOrAfterWorkDayCommon(@RequestBody TEmployeeInsuranceWorkDayVo vo) {
return R.ok(tHolidayInfoService.selectBeforeOrAfterWorkDayCommon(vo));
}
/**
* @Author huyc
* @Description 合同开始日期使用:获取传入日期的后一个工作日
* @Date 10:27 2025/6/13
**/
@Inner
@PostMapping("/inner/selectBeforeOrAfterWorkDayCommon")
public R selectBeforeOrAfterWorkDayInnerCommon(@RequestBody TEmployeeInsuranceWorkDayVo vo) {
return R.ok(tHolidayInfoService.selectBeforeOrAfterWorkDayCommon(vo));
}
/**
* @Author huyc
* @Description 判断日期是否为节假日
......
......@@ -55,5 +55,7 @@ public interface THolidayInfoService extends IService<THolidayInfo> {
TEmployeeInsuranceWorkDayVo selectBeforeOrAfterWorkDay(TEmployeeInsuranceWorkDayVo vo);
TEmployeeInsuranceWorkDayVo selectBeforeOrAfterWorkDayCommon(TEmployeeInsuranceWorkDayVo vo);
Boolean checkIsWorkDay(TEmployeeInsuranceWorkDayVo vo);
}
......@@ -50,6 +50,7 @@ import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*;
/**
......@@ -298,6 +299,47 @@ public class THolidayInfoServiceImpl extends ServiceImpl<THolidayInfoMapper, THo
return vo;
}
@Override
public TEmployeeInsuranceWorkDayVo selectBeforeOrAfterWorkDayCommon(TEmployeeInsuranceWorkDayVo vo) {
//获取当年所有假期配置表
Date date = new Date();
List<THolidayInfo> holidayInfos = baseMapper.selectList(Wrappers.<THolidayInfo>query().lambda()
.eq(THolidayInfo::getYear,DateUtil.getYear(date)));
Map<Date,String> holidayMap = new HashMap<>();
if (Common.isNotNull(holidayInfos)){
for (THolidayInfo h:holidayInfos){
holidayMap.put(h.getDate(),h.getDay());
}
}
//根据入职类型,判断最终的传入日期
// 转换为LocalDate进行操作
LocalDate localDate = vo.getRegistDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate()
.plusDays(vo.getRegistType());
// 转回Date类型
vo.setRegistDate(Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//判断传入日期是否大于今天
LocalDate givenLocalDate = vo.getRegistDate().toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDate();
// 获取今天的 LocalDate
LocalDate today = LocalDate.now();
// 判断给定日期是否小于今天,日期小于今天则返回今天
if (givenLocalDate.isBefore(today) || givenLocalDate.isEqual(today)) {
//判断是否是工作日
vo.setRegistDate(LocalDateTimeUtils.convertLDToDate(today));
}
if (Boolean.TRUE.equals(checkIsWorkDay(vo))){
//非工作日找下一个工作日
getWorkDay(holidayMap,vo);
return vo;
}
return vo;
}
@Override
public TEmployeeInsuranceWorkDayVo getInitBeforeOrAfterWorkDay(TEmployeeInsuranceWorkDayVo vo) {
//获取当年所有假期配置表
......
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