Commit 59ebd1d6 authored by huyuchen's avatar huyuchen

huyc 项目档案代码提交

parent 10f90f65
......@@ -194,4 +194,19 @@ public class TEmployeeProjectController {
return tEmployeeProjectService.importListAdd(excelVOList, bindingResult, idAdd);
}
/**
* 批量更新项目档案信息
*
* @param excelVOList
* @return R<List>
* @Author huyc
* @Date 2022-06-21
**/
@Operation(description = "批量更新项目档案信息 hasPermission('archives_project_importListUpdate')")
@SysLog("批量更新项目档案信息")
@PostMapping("/importListUpate")
@PreAuthorize("@pms.hasPermission('archives_project_importListUpdate')")
public R<List<ErrorMessage>> importListUpate(@RequestExcel List<EmployeeProjectVO> excelVOList, BindingResult bindingResult) {
return tEmployeeProjectService.importEmpProjectUpdate(excelVOList, bindingResult);
}
}
......@@ -41,4 +41,8 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
List<TEmployeeInfo> getList(@Param("employeeInfo") TEmployeeInfo employeeInfo);
int updateEducationOfEmp(@Param("education") EmpEducationUpdateVo education);
void updateExcelEmployeeInfo(@Param("list") List<TEmployeeInfo> list);
int insertExcelEmployeeInfo(@Param("list") List<TEmployeeInfo> list);
}
......@@ -22,25 +22,28 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeLog;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
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.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeLogService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeProjectService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeProjectVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.NoUtil;
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.security.util.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;
import java.util.*;
import java.util.stream.Collectors;
/**
* 项目档案表
......@@ -55,13 +58,11 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
private TEmployeeLogService tEmployeeLogService;
private final String content1 = "复档";
private TEmployeeInfoMapper tEmployeeInfoMapper;
private final String content2 = "复项";
private TEmployeeProjectMapper tEmployeeProjectMapper;
private final String content3 = "复档复项";
private final String content4 = "减档减项";
private TSettleDomainService tSettleDomainService;
@Override
public R addCheck(TEmployeeProject tEmployeeProject) {
......@@ -124,13 +125,13 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getById(empId);
tEmployeeInfo.setFileStatus(CommonConstants.dingleDigitIntArray[0]);
tEmployeeInfoService.updateById(tEmployeeInfo);
addEmpLog(CommonConstants.dingleDigitIntArray[0],empId,"",content1);
addEmpLog(CommonConstants.dingleDigitIntArray[0],empId,"", ArchivesConstants.EMP_CONTENT);
} else if (Common.isEmpty(empId) && !Common.isEmpty(empProId)) {
//复项
TEmployeeProject tEmployeeProject = this.getById(empProId);
tEmployeeProject.setProjectStatus(CommonConstants.dingleDigitIntArray[0]);
this.updateById(tEmployeeProject);
addEmpLog(CommonConstants.dingleDigitIntArray[1],"",empProId,content2);
addEmpLog(CommonConstants.dingleDigitIntArray[1],"",empProId,ArchivesConstants.PROJECT_CONTENT);
} else {
//复档复项
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getById(empId);
......@@ -139,7 +140,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
tEmployeeInfoService.updateById(tEmployeeInfo);
tEmployeeProject.setProjectStatus(CommonConstants.dingleDigitIntArray[0]);
this.updateById(tEmployeeProject);
addEmpLog(CommonConstants.dingleDigitIntArray[2],empId,empProId,content3);
addEmpLog(CommonConstants.dingleDigitIntArray[2],empId,empProId,ArchivesConstants.EMP_PROJECT_CONTENT);
}
} else {
return R.failed("传参为空!");
......@@ -163,7 +164,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
tEmployeeProject.setProjectStatus(CommonConstants.dingleDigitIntArray[1]);
this.updateById(tEmployeeProject);
addEmpLog(CommonConstants.dingleDigitIntArray[2],tEmployeeInfo.getId(),tEmployeeProject.getId(),content4);
addEmpLog(CommonConstants.dingleDigitIntArray[2],tEmployeeInfo.getId(),tEmployeeProject.getId(),ArchivesConstants.REDUCE_EMP_PROJECT_CONTENT);
return R.ok();
}
return R.failed("传参为空!");
......@@ -199,17 +200,169 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
public R<List<ErrorMessage>> importListAdd(List<EmployeeProjectVO> excelVOList, BindingResult bindingResult, String idAdd) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long,ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)){
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
List<TEmployeeInfo> insertList = new ArrayList();
List<TEmployeeInfo> updateList = new ArrayList();
List<TEmployeeProject> proInsList = new ArrayList();
List<TEmployeeProject> proupdateList = new ArrayList();
// 执行数据插入操作 组装 PostDto
for (int i = 0; i < excelVOList.size(); i++) {
EmployeeProjectVO excel = excelVOList.get(i);
Set<String> errorMsg = new HashSet<>();
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){
continue;
}
//根据身份证获取人员档案
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.STATUS_NORMAL));
//根据身份证和项目编码获取项目档案
TEmployeeProject tEmployeeProject = this.getOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeProject::getDeptNo, excel.getDeptNo())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL));
//不存在复档或复项的情况
//档案无(在档人员、离职库皆无),项目无
if (Common.isEmpty(tEmployeeInfo) && Common.isEmpty(tEmployeeProject)) {
insertExcelPost(excel, insertList);
insertExcelPro(excel, proInsList);
//档案有(在档人员),项目无
} else if (Common.isNotNull(tEmployeeInfo) && Common.isEmpty(tEmployeeProject)
&& CommonConstants.dingleDigitIntArray[0] == tEmployeeInfo.getFileStatus()) {
updateExcelPost(excel, updateList, tEmployeeInfo);
insertExcelPro(excel, proInsList);
//档案有(在档人员),项目有(草稿/已审核);
} else if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[0] == tEmployeeInfo.getFileStatus()
&& Common.isNotNull(tEmployeeProject) && CommonConstants.dingleDigitIntArray[0] == tEmployeeProject.getProjectStatus()) {
updateExcelPost(excel, updateList, tEmployeeInfo);
updateExcelPro(excel, proupdateList, tEmployeeProject);
}
//存在复档或复项的情况,允许复档复项
if (CommonConstants.ZERO_STRING.equals(idAdd)) {
//档案有(离职库),项目(已减档)
if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[1] == tEmployeeInfo.getFileStatus()
&& Common.isNotNull(tEmployeeProject) && CommonConstants.dingleDigitIntArray[1] == tEmployeeProject.getProjectStatus()) {
updateExcelPost(excel, updateList, tEmployeeInfo);
updateExcelPro(excel, proupdateList, tEmployeeProject);
//档案有(离职库),项目无;
} else if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[1] == tEmployeeInfo.getFileStatus()
&& Common.isEmpty(tEmployeeProject) ) {
updateExcelPost(excel, updateList, tEmployeeInfo);
insertExcelPro(excel, proInsList);
//档案有(在档人员),项目(已减档)
} else if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[0] == tEmployeeInfo.getFileStatus()
&& Common.isNotNull(tEmployeeProject) && CommonConstants.dingleDigitIntArray[1] == tEmployeeProject.getProjectStatus()) {
updateExcelPost(excel, updateList, tEmployeeInfo);
updateExcelPro(excel, proupdateList, tEmployeeProject);
}
//不允许复档复项
} else {
//档案有(离职库),项目(已减档)
if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[1] == tEmployeeInfo.getFileStatus()
&& Common.isNotNull(tEmployeeProject) && CommonConstants.dingleDigitIntArray[1] == tEmployeeProject.getProjectStatus()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.CHECKS_EMP_PROJECT_ERROR));
} else if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[1] == tEmployeeInfo.getFileStatus()
&& Common.isEmpty(tEmployeeProject)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.CHECKS_REDUCE_EMP_ERROR));
//档案有(在档人员),项目(已减档)
} else if (Common.isNotNull(tEmployeeInfo) && CommonConstants.dingleDigitIntArray[0] == tEmployeeInfo.getFileStatus()
&& Common.isNotNull(tEmployeeProject) && CommonConstants.dingleDigitIntArray[1] == tEmployeeProject.getProjectStatus()){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.CHECKS_REDUCE_PROJECT_ERROR));
}
}
if (!CollUtil.isEmpty(errorMsg)) {
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
try {
if (insertList.size() > CommonConstants.dingleDigitIntArray[0]) {
tEmployeeInfoMapper.insertExcelEmployeeInfo(insertList);
}
if (updateList.size() > CommonConstants.dingleDigitIntArray[0]) {
tEmployeeInfoMapper.updateExcelEmployeeInfo(updateList);
}
if (proInsList.size() > CommonConstants.dingleDigitIntArray[0]) {
tEmployeeProjectMapper.insertExcelEmpProject(proInsList);
List<String> idList = proInsList.stream().map(TEmployeeProject::getEmpIdcard).collect(Collectors.toList());
List<TEmployeeInfo> updList = tEmployeeInfoMapper.selectList(Wrappers.<TEmployeeInfo>query().lambda().in(TEmployeeInfo::getEmpIdcard,idList));
tEmployeeProjectMapper.updateEmpIdById(updList);
}
if (proupdateList.size() > CommonConstants.dingleDigitIntArray[0]) {
tEmployeeProjectMapper.updateExcelEmpProject(proupdateList);
}
} catch (Exception e) {
log.error("数据更新异常",e);
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
}
/**
* @Author huyc
* @Description 批量更新项目档案信息
* @Date 19:25 2022/6/21
**/
@Override
public R<List<ErrorMessage>> importEmpProjectUpdate(List<EmployeeProjectVO> excelVOList, BindingResult bindingResult) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long,ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)){
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
List<TEmployeeProject> updateList = new ArrayList<>();
// 个性化校验逻辑
List<TEmployeeProject> list = this.list();
// 执行数据插入操作 组装 PostDto
Set<String> errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i + 2))) {
continue;
}
errorMsg = new HashSet<>();
EmployeeProjectVO excel = excelVOList.get(i);
Set<String> errorMsg = new HashSet<>();
//根据身份证和项目编码获取项目档案
TEmployeeProject tEmployeeProject = this.getOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeProject::getDeptNo, excel.getDeptNo())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL));
if (Common.isEmpty(tEmployeeProject)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.CHECKS_EMP_EXIT_ERROR, excel.getEmpName()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
updateExcelPro(excel,updateList,tEmployeeProject);
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
try {
if (updateList.size() > CommonConstants.dingleDigitIntArray[0]) {
tEmployeeProjectMapper.updateExcelEmpProject(updateList);
}
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
} catch (Exception e) {
log.error("数据更新异常",e);
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
......@@ -220,9 +373,65 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
/**
* 插入excel Post
*/
private void insertExcelPost(EmployeeProjectVO excel) {
TEmployeeProject insert = new TEmployeeProject();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
private void insertExcelPost(EmployeeProjectVO excel,List<TEmployeeInfo> insertList) {
TEmployeeInfo insTEmployeeInfo = new TEmployeeInfo();
BeanUtil.copyProperties(excel, insTEmployeeInfo);
insTEmployeeInfo.setFileStatus(CommonConstants.dingleDigitIntArray[0]);
insTEmployeeInfo.setDeleteFlag(CommonConstants.STATUS_NORMAL);
insTEmployeeInfo.setStatus(CommonConstants.dingleDigitIntArray[0]);
//TODO HUYC 员工编码生成规则
insTEmployeeInfo.setEmpCode("");
YifuUser user = SecurityUtils.getUser();
insTEmployeeInfo.setCreateBy(user.getId());
insTEmployeeInfo.setCreateName(user.getNickname());
insertList.add(insTEmployeeInfo);
}
/**
* 插入excel Pro
*/
private void insertExcelPro(EmployeeProjectVO excel,List<TEmployeeProject> proInsList) {
TEmployeeProject insTEmployeePro = new TEmployeeProject();
BeanUtil.copyProperties(excel, insTEmployeePro);
insTEmployeePro.setId(String.valueOf(UUID.randomUUID()).replaceAll("-",""));
insTEmployeePro.setDeleteFlag(CommonConstants.STATUS_NORMAL);
insTEmployeePro.setStatus(CommonConstants.dingleDigitIntArray[0]);
//人员档案主表id先设置成空,后面更新id
insTEmployeePro.setEmpId(CommonConstants.EMPTY_STRING);
String str = "";
String EmpNo = tEmployeeProjectMapper.findEmployeeMaxOnlyNoByDepId(insTEmployeePro.getDeptNo());
if (!Common.isEmpty(EmpNo)) {
str = NoUtil.productionNo(EmpNo, CommonConstants.EMPLOYEE_INIT_NO_START);
} else {
str = insTEmployeePro.getDeptNo() + CommonConstants.EMPLOYEE_INIT_NO;
}
insTEmployeePro.setEmpNo(str);
//TODO HUYC 员工编码生成规则
insTEmployeePro.setEmpCode("");
YifuUser user = SecurityUtils.getUser();
insTEmployeePro.setCreateBy(user.getId());
insTEmployeePro.setCreateName(user.getNickname());
proInsList.add(insTEmployeePro);
}
/**
* 更新人员档案
*/
private void updateExcelPost(EmployeeProjectVO excel,List<TEmployeeInfo> updateList,TEmployeeInfo tEmployeeInfo) {
BeanUtil.copyProperties(excel, tEmployeeInfo);
YifuUser user = SecurityUtils.getUser();
tEmployeeInfo.setUpdateBy(user.getId());
updateList.add(tEmployeeInfo);
}
/**
* 更新项目档案
*/
private void updateExcelPro(EmployeeProjectVO excel,List<TEmployeeProject> proupdateList,TEmployeeProject tEmployeeProject) {
BeanUtil.copyProperties(excel, tEmployeeProject);
YifuUser user = SecurityUtils.getUser();
tEmployeeProject.setUpdateBy(user.getId());
proupdateList.add(tEmployeeProject);
}
}
......@@ -173,4 +173,72 @@
order by a.CREATE_TIME desc
</select>
<update id="updateExcelEmployeeInfo" parameterType="java.util.List">
update t_employee_info
<trim prefix="set" suffixOverrides=",">
<trim prefix="EMP_NATRUE =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.empNatrue!=null">
when ID=#{i.id} then #{i.empNatrue}
</if>
</foreach>
</trim>
<trim prefix="EMP_NAME =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.empName!=null">
when ID=#{i.id} then #{i.empName}
</if>
</foreach>
</trim>
<trim prefix="EMP_IDCARD =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.empIdcard!=null">
when ID=#{i.id} then #{i.empIdcard}
</if>
</foreach>
</trim>
<trim prefix="FILE_STATUS =case" suffix="end,">
<foreach collection="list" item="i" index="index">
when ID=#{i.id} then 0
</foreach>
</trim>
<trim prefix="UPDATE_TIME =case" suffix="end,">
<foreach collection="list" item="i" index="index">
when ID=#{i.id} then now()
</foreach>
</trim>
<trim prefix="UPDATE_BY =case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.updateBy!=null">
when ID=#{i.id} then #{i.updateBy}
</if>
</foreach>
</trim>
</trim>
where
<foreach collection="list" separator="or" item="i" index="index" >
ID=#{i.id}
</foreach>
</update>
<insert id="insertExcelEmployeeInfo" parameterType="java.util.List">
insert into t_employee_info
(ID,EMP_NATRUE,EMP_NAME,EMP_IDCARD,STATUS,FILE_STATUS,EMP_CODE,DELETE_FLAG,CREATE_BY,CREATE_NAME,CREATE_TIME)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
REPLACE(UUID(),"-",""),
#{item.empNatrue,jdbcType=VARCHAR},
#{item.empName,jdbcType=VARCHAR},
#{item.empIdcard,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR},
0,
#{item.empCode,jdbcType=VARCHAR},
#{item.deleteFlag,jdbcType=VARCHAR},
#{item.createBy,jdbcType=VARCHAR},
#{item.createName,jdbcType=VARCHAR},
now()
)
</foreach>
</insert>
</mapper>
dapr.upms.appUrl=http://yifu-upms.qas-mvp.svc.cluster.local:3500/v1.0/invoke/
dapr.upms.appUrl=http://localhost:3500/v1.0/invoke/
dapr.upms.appId=yifu-upms
dapr.upms.appPort=4000
dapr.upms.httpPort=3500
dapr.upms.grpcPort=52000
dapr.upms.metricsPort=9094
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