Commit 3e4b44b6 authored by hongguangwu's avatar hongguangwu

1.5.6-EMPCONCTRACT-续签待办批量更新

parent 4063de7e
/*
* 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.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 员工合同续签待办-批量更新的VO
*
* @author hgw
* @date 2023-7-17 10:50:47
*/
@Data
@Schema(description = "员工合同续签待办-批量更新的VO")
public class EmpContractAlertUpdateVO extends RowIndex implements Serializable {
/**
* 姓名
*/
@ExcelAttribute(name = "姓名")
@Schema(description = "姓名")
private String empName;
/**
* 身份证号
*/
@ExcelAttribute(name = "身份证号")
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
private String empIdCard;
/**
* 项目编码
*/
@ExcelAttribute(name = "项目编码")
@Schema(description = "项目编码")
private String projectNo;
/**
* 未续签原因
*/
@ExcelAttribute(name = "未续签原因")
@Schema(description = "未续签原因")
private String feedbackReason;
/**
* 具体描述
*/
@ExcelAttribute(name = "具体描述")
@Schema(description = "具体描述")
private String feedbackDetail;
/**
* 异常原因
*/
@ExcelAttribute(name = "异常原因")
@Schema(description = "异常原因")
private String errorInfo;
}
......@@ -23,8 +23,10 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContractAlert;
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.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.ErrorMessage;
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.MenuUtil;
......@@ -34,8 +36,10 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -201,5 +205,21 @@ public class TEmpContractAlertController {
return R.ok(tEmpContractAlertService.getFeedbackDetail(applyNo));
}
/**
* 批量更新-合同续签待办
* @param file
* @return
* @Author hgw
* @Date 2023-7-17 09:45:07
**/
@SneakyThrows
@Operation(description = "批量更新-合同续签待办 hasPermission('tempcontractalert_batch_update')")
@SysLog("批量更新-合同续签待办")
@PostMapping("/batchUpdate")
@PreAuthorize("@pms.hasPermission('tempcontractalert_batch_update')")
public R<List<EmpContractAlertUpdateVO>> batchUpdate(@RequestBody MultipartFile file) {
return tEmpContractAlertService.batchUpdate(file.getInputStream());
}
}
......@@ -20,9 +20,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContractAlert;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ChangeFeedBackAllVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpContractAlertUpdateVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 员工合同续签待办
*
......@@ -36,4 +39,6 @@ public interface TEmpContractAlertMapper extends BaseMapper<TEmpContractAlert> {
boolean changeFeedBackAll(@Param("changeFeedBackAllVo") ChangeFeedBackAllVo changeFeedBackAllVo);
List<TEmpContractAlert> getAlertInfoList(@Param("idCardList") List<String> idCardList);
}
/*
* 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.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FeedBackDetail;
/**
* 员工合同续签待办-原因表
*
* @author hgw
* @date 2023-7-17 15:14:25
*/
public interface FeedBackDetailService extends IService<FeedBackDetail> {
}
......@@ -24,9 +24,12 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.FeedBackDetail;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContractAlert;
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.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
......@@ -56,5 +59,11 @@ public interface TEmpContractAlertService extends IService<TEmpContractAlert> {
List<FeedBackDetail> getFeedbackDetail(String applyNo);
/**
* @Description: 批量更新-合同续签待办
* @Author: hgw
* @Date: 2023-7-17 09:46:40
**/
R<List<EmpContractAlertUpdateVO>> batchUpdate(InputStream inputStream);
}
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FeedBackDetail;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FeedBackDetailMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.FeedBackDetailService;
import org.springframework.stereotype.Service;
/**
* @author hgw
* @date s2023-7-17 15:16:10
*/
@Service
public class FeedBackDetailServiceImpl extends ServiceImpl<FeedBackDetailMapper, FeedBackDetail> implements FeedBackDetailService {
}
......@@ -19,7 +19,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -29,20 +34,24 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.constants.ArchivesConstants;
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.common.core.constant.CommonConstants;
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.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
......@@ -53,6 +62,7 @@ import java.util.*;
* @author fxj
* @date 2022-07-01 14:15:05
*/
@Log4j2
@RequiredArgsConstructor
@Service
public class TEmpContractAlertServiceImpl extends ServiceImpl<TEmpContractAlertMapper, TEmpContractAlert> implements TEmpContractAlertService {
......@@ -65,6 +75,8 @@ public class TEmpContractAlertServiceImpl extends ServiceImpl<TEmpContractAlertM
private final FeedBackDetailMapper feedbackDetailMapper;
private final FeedBackDetailService feedBackDetailService;
@Override
public IPage<TEmpContractAlert> pageDiy(Page page, ContractAlertSearchVo searchVo) {
LambdaQueryWrapper<TEmpContractAlert> wrapper = buildQueryWrapper(searchVo);
......@@ -449,5 +461,149 @@ public class TEmpContractAlertServiceImpl extends ServiceImpl<TEmpContractAlertM
return feedbackDetailMapper.getDetail(applyNo);
}
/**
* @param inputStream
* @Description: 批量更新-合同续签待办
* @Author: hgw
* @Date: 2023/7/17 9:47
**/
@Override
public R<List<EmpContractAlertUpdateVO>> batchUpdate(InputStream inputStream) {
List<EmpContractAlertUpdateVO> errorMessageList = new ArrayList<>();
ExcelUtil<EmpContractAlertUpdateVO> util1 = new ExcelUtil<>(EmpContractAlertUpdateVO.class);
Map<String,String> reasonMap = new HashMap<>();
reasonMap.put("已确定待续签","已经和客户单位或员工沟通好,因时间或地点原因未能签订的");
reasonMap.put("未确定是否续签","因客户单位原因,暂时不能确定是否与员工继续签订劳动合同;");
reasonMap.put("商务合同未签","业务部门未进行商务合同的续签");
reasonMap.put("已签待更新","已完成劳动合同续签未进行人力云系统更新的");
reasonMap.put("离职/退休/待派减","经确定离职、退休的员工,等待人力云系统派单减少");
reasonMap.put("产假/工伤/病假","因产假、工伤、病假原因暂时无法正常续签的");
reasonMap.put("其他","其他原因,添加具体原因备注");
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcelFactory.read(inputStream, EmpContractAlertUpdateVO.class, new ReadListener<EmpContractAlertUpdateVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpContractAlertUpdateVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpContractAlertUpdateVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
data.setErrorInfo(errorMessage.getMessage());
errorMessageList.add(data);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
if (!cachedDataList.isEmpty()) {
updateInfo(reasonMap, cachedDataList, errorMessageList);
}
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
if (!errorMessageList.isEmpty()) {
return R.failed(errorMessageList);
} else {
return R.ok();
}
}
public void updateInfo(Map<String, String> reasonMap, List<EmpContractAlertUpdateVO> excelVOList, List<EmpContractAlertUpdateVO> errorMessageList) {
YifuUser user = SecurityUtils.getUser();
List<String> idCardList = new ArrayList<>();
for (EmpContractAlertUpdateVO vo : excelVOList) {
if (Common.isNotNull(vo.getEmpIdCard())) {
idCardList.add(vo.getEmpIdCard());
}
}
Map<String, TEmpContractAlert> curMap = new HashMap<>();
if (!idCardList.isEmpty()) {
List<TEmpContractAlert> alertList = baseMapper.getAlertInfoList(idCardList);
if (alertList != null && !alertList.isEmpty()) {
for (TEmpContractAlert alert : alertList) {
curMap.put(alert.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + alert.getProjectNo(), alert);
}
}
}
TEmpContractAlert cur;
FeedBackDetail feedbackDetail;
List<FeedBackDetail> saveDetail = new ArrayList<>();
List<TEmpContractAlert> updateAlert = new ArrayList<>();
for (EmpContractAlertUpdateVO updateInfo : excelVOList) {
if (Common.isEmpty(updateInfo.getEmpIdCard()) || Common.isEmpty(updateInfo.getProjectNo()) || Common.isEmpty(updateInfo.getFeedbackReason())) {
updateInfo.setErrorInfo("请检查必填项!");
errorMessageList.add(updateInfo);
continue;
}
cur = curMap.get(updateInfo.getEmpIdCard() + CommonConstants.DOWN_LINE_STRING + updateInfo.getProjectNo());
if (cur != null) {
cur.setIsFeedback(CommonConstants.ONE_INTEGER);
cur.setFeedbackPerson(user.getNickname());
cur.setFeedbackTime(DateTime.now());
cur.setFeedbackReason(updateInfo.getFeedbackReason());
String reasonDetail = reasonMap.get(updateInfo.getFeedbackReason());
if (Common.isEmpty(reasonDetail)) {
updateInfo.setErrorInfo("请输入正确的未续签原因!");
errorMessageList.add(updateInfo);
continue;
}
if (Common.isNotNull(updateInfo.getFeedbackDetail())) {
reasonDetail = updateInfo.getFeedbackDetail();
}
cur.setFeedbackDetail(reasonDetail);
updateAlert.add(cur);
feedbackDetail = new FeedBackDetail();
feedbackDetail.setFeedbackPerson(user.getNickname());
feedbackDetail.setFeedbackTime(DateTime.now());
feedbackDetail.setApplyNo(cur.getApplyNo());
feedbackDetail.setFeedbackReason(updateInfo.getFeedbackReason());
feedbackDetail.setFeedbackDetail(reasonDetail);
feedbackDetail.setIsFeedback(CommonConstants.ONE_INT);
saveDetail.add(feedbackDetail);
} else {
updateInfo.setErrorInfo("根据身份证号与项目编码未找到要更新的数据!");
errorMessageList.add(updateInfo);
}
}
if (!saveDetail.isEmpty()) {
feedBackDetailService.saveBatch(saveDetail);
}
if (!updateAlert.isEmpty()) {
this.updateBatchById(updateAlert);
}
}
}
......@@ -72,4 +72,18 @@
</foreach>
</update>
<select id="getAlertInfoList" resultMap="tEmpContractAlertMap">
select
a.ID,
a.EMP_NAME,
a.PROJECT_NO,
a.APPLY_NO,
a.EMP_IDCARD
from t_emp_contract_alert a
where a.EMP_IDCARD in
<foreach item="idStr" index="index" collection="idCardList" open="(" separator="," close=")">
#{idStr}
</foreach>
</select>
</mapper>
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