Commit 2f7724c6 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/develop' into develop

parents 387284ed 5979f248
......@@ -20,12 +20,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
......@@ -52,66 +55,79 @@ public class FddContractAttachInfo extends BaseEntity {
* 合同id
*/
@Schema(description ="合同id")
@ExcelAttribute(name = "合同id", errorInfo = "员工合同id主键不能为空", maxLength = 32)
private String contractId;
/**
* 合同试用期开始时间
*/
@Schema(description ="合同试用期开始时间")
private Date periodStart;
@ExcelAttribute(name = "合同试用期开始时间")
private LocalDate periodStart;
/**
* 合同试用期结束时间
*/
@Schema(description ="合同试用期结束时间")
private Date periodEnd;
@ExcelAttribute(name = "合同试用期结束时间")
private LocalDate periodEnd;
/**
* 合同起始时间
*/
@Schema(description ="合同起始时间")
@ExcelAttribute(name = "合同起始时间", isNotEmpty = true, errorInfo = "合同起始时间不能为空")
private Date contractStart;
/**
* 合同到期时间
*/
@Schema(description ="合同到期时间")
@ExcelAttribute(name = "合同到期时间",needExport = true)
private Date contractEnd;
/**
* 试用期工资 元/月
*/
@Schema(description ="试用期工资 元/月")
@ExcelAttribute(name = "试用期工资")
private BigDecimal periodSalaryPerMonth;
/**
* 工资形式 1.计时工资 2.计件工资 3.其他
*/
@Schema(description ="工资形式 1.计时工资 2.计件工资 3.其他")
@ExcelAttribute(name = "工资形式", isDataId = true, dataType = "salary_type")
private String salaryType;
/**
* 计时工资 工资标准 元/月
*/
@Schema(description ="计时工资 工资标准 元/月")
@ExcelAttribute(name = "计时工资")
private BigDecimal salaryStandardPerHour;
/**
* 计件工资 工资标准单价/元
*/
@Schema(description ="计件工资 工资标准单价/元")
@ExcelAttribute(name = "计件工资")
private BigDecimal salaryStandardPerPiece;
/**
* 工作地点
*/
@Schema(description ="工作地点")
@Length(max=200,message = "工作地点不能超过200个字符")
@ExcelAttribute(name = "工作地点" , maxLength = 200 )
private String workSpace;
/**
* 岗位
*/
@Schema(description ="岗位")
@Length(max = 200, message = "岗位不能超过200个字符")
@ExcelAttribute(name = "岗位", isNotEmpty = true, errorInfo = "岗位不能为空", maxLength = 200, needExport = true)
private String post;
/**
......@@ -142,12 +158,14 @@ public class FddContractAttachInfo extends BaseEntity {
* 员工姓名
*/
@Schema(description ="员工姓名")
@ExcelAttribute(name = "员工姓名", isNotEmpty = true, errorInfo = "员工合同id姓名不能为空", maxLength = 32, needExport = true)
private String empName;
/**
* 身份证号码
*/
@Schema(description ="身份证号码")
@ExcelAttribute(name = "身份证号码", isNotEmpty = true, errorInfo = "身份证号码不能为空", maxLength = 32, needExport = true)
private String empIdcard;
/**
......
......@@ -27,8 +27,7 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -60,7 +59,7 @@ public class TEmployeeInfo extends BaseEntity {
/**
* 员工类型(字典值,0外包1派遣2代理)
*/
@ExcelAttribute(name = "员工类型", isDataId = true,dataType = ExcelAttributeConstants.EMP_NATRUE)
@ExcelAttribute(name = "员工类型", isDataId = true, dataType = ExcelAttributeConstants.EMP_NATRUE)
@Schema(description = "员工类型(字典值,0外包1派遣2代理)")
@NotNull(message = "员工类型不可为空")
@Size(max = 1, message = "员工类型不可超过1位")
......@@ -87,14 +86,14 @@ public class TEmployeeInfo extends BaseEntity {
*/
@Schema(description = "身份证有效期起")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDate validityStart;
private Date validityStart;
/**
* 身份证有效期止
*/
@Schema(description = "身份证有效期止")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDate validityEnd;
private Date validityEnd;
/**
* 性别
......@@ -106,7 +105,7 @@ public class TEmployeeInfo extends BaseEntity {
* 出生日期
*/
@Schema(description = "出生日期")
private LocalDate empBirthday;
private Date empBirthday;
/**
* 年龄
......@@ -227,14 +226,14 @@ public class TEmployeeInfo extends BaseEntity {
*/
@Schema(description = "入学时间")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDate admissionDate;
private Date admissionDate;
/**
* 毕业时间
*/
@Schema(description = "毕业时间")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDate gradutionDate;
private Date gradutionDate;
/**
* 备注
......@@ -321,7 +320,7 @@ public class TEmployeeInfo extends BaseEntity {
*/
@Schema(description = "离职时间")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDateTime leaveTime;
private Date leaveTime;
/**
* 离职原因
......
......@@ -319,6 +319,24 @@ public class TEmployeeProject extends BaseEntity {
@TableField(exist = false)
private Integer fileTown;
/**
* 社保-省
*/
@Schema(description = "社保-省")
private Integer socialProvince;
/**
* 社保-市
*/
@Schema(description = "社保-市")
private Integer socialCity;
/**
* 社保-县
*/
@Schema(description = "社保-县")
private Integer socialTown;
/**
* 员工合同状态(字典)
*/
......
......@@ -17,14 +17,15 @@
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;
/**
* 项目档案表excel对应的实体
......@@ -34,7 +35,7 @@ import java.time.LocalDate;
*/
@Data
@ColumnWidth(30)
public class EmployeeVO implements Serializable {
public class EmployeeVO extends RowIndex implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -48,6 +49,7 @@ public class EmployeeVO implements Serializable {
* 员工姓名
*/
@ExcelProperty(value = "员工姓名")
@ExcelAttribute(name = "员工姓名", isNotEmpty = true, maxLength = 20, needExport = true, errorInfo = "员工姓名必填且不可超过20位")
@Size(max = 20, message = "员工姓名不可超过20位")
private String empName;
......@@ -55,6 +57,7 @@ public class EmployeeVO implements Serializable {
* 身份证号
*/
@ExcelProperty(value = "身份证号")
@ExcelAttribute(name = "身份证号", isNotEmpty = true, maxLength = 20, needExport = true, errorInfo = "身份证号必填且不可超过20位")
@Size(max = 20, message = "身份证号不可超过20位")
private String empIdcard;
......@@ -62,6 +65,7 @@ public class EmployeeVO implements Serializable {
* 项目编码
*/
@ExcelProperty(value = "项目编码")
@ExcelAttribute(name = "项目编码", maxLength = 32, needExport = true, errorInfo = "身份证号必填且不可超过20位")
@Size(max = 32, message = "项目编码不可超过32位")
private String deptNo;
......@@ -75,14 +79,16 @@ public class EmployeeVO implements Serializable {
/**
* 身份证有效期起
*/
@DateTimeFormat("yyyy-MM-dd")
@ExcelProperty(value = "身份证开始日期")
private LocalDate validityStart;
private Date validityStart;
/**
* 身份证有效期止
*/
@DateTimeFormat("yyyy-MM-dd")
@ExcelProperty(value = "身份证截止日期")
private LocalDate validityEnd;
private Date validityEnd;
/**
* 婚姻状况
......@@ -188,14 +194,16 @@ public class EmployeeVO implements Serializable {
/**
* 入学时间
*/
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "入学时间")
private LocalDate admissionDate;
private Date admissionDate;
/**
* 毕业时间
*/
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "毕业时间")
private LocalDate gradutionDate;
private Date gradutionDate;
/**
* 备注
......
......@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @Author fxj
......@@ -133,7 +134,7 @@ public class TCertRecordVo implements Serializable {
*/
@ExcelAttribute(name = "离职时间" )
@Schema(description ="离职时间")
private LocalDateTime leaveTime;
private Date leaveTime;
/**
* 派减原因
......
......@@ -139,25 +139,25 @@ public class FddContractAttachInfoController {
@PostMapping("/batchAddFddEmpInfo")
public R batchAddFddEmpInfo(@RequestBody String jsonString) {
R<List<SysDictItem>> res = null;
R<Map<String,List<SysDictItem>>> res = null;
ExcelUtil<FddContractAttachInfo> util1 = null;
try {
// 调用字典服务,渲染字典值
res = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictList", null, Map.class, SecurityConstants.FROM_IN);
Map<String, String> dicMap = new HashMap<>();
if (null != res.getData()) {
for (SysDictItem dict : res.getData()) {
dicMap.put(dict.getType() + CommonConstants.DOWN_LINE_STRING + dict.getLabel(), dict.getValue());
}
}
// // 调用字典服务,渲染字典值
// res = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
// , "/dict/inner/getDictList", null, Map.class, SecurityConstants.FROM_IN);
//
// Map<String, String> dicMap = new HashMap<>();
// if (null != res.getData().get("data")) {
// for (SysDictItem dict : res.getData().get("data")) {
// dicMap.put(dict.getType() + CommonConstants.DOWN_LINE_STRING + dict.getLabel(), dict.getValue());
// }
// }
jsonString = URLDecoder.decode(jsonString, CommonConstants.UTF8).replace("=", "");
util1 = new ExcelUtil<>(FddContractAttachInfo.class);
//传参字典数据MAP具体见方法实现
util1.getJsonStringToList(jsonString, dicMap);
util1.getJsonStringToList(jsonString, null);
if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) {
return R.failed(util1.getErrorInfo(),"数据异常");
} else {
......@@ -172,8 +172,9 @@ public class FddContractAttachInfoController {
map.put(errorMessage.getLineNum(),util1.getEntityList().get(errorMessage.getLineNum()-2));
}
variableMap.put("data",map);
}
return R.ok(variableMap);
}
return new R<>(CommonConstants.dingleDigitIntArray[1], "", errorInfo);
} else {
return R.ok(null,"无数据可导入");
}
......
......@@ -40,6 +40,7 @@ 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.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
......@@ -47,6 +48,7 @@ import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
......@@ -364,35 +366,33 @@ public class TEmployeeInfoController {
}
/**
* @param excelList
* @param bindingResult
* @Description: 批量导入人员档案
* @Author: hgw
* @Date: 2022/6/22 11:57
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@SneakyThrows
@Operation(summary = "批量导入人员档案", description = "批量导入人员档案 hasPermission('employee_batch_import') 额外属性:isCanAdd:0不可以复档复项;1允许复档复项")
@SysLog("批量导入人员档案")
@PostMapping("/batchImportEmployee")
@PreAuthorize("@pms.hasPermission('employee_batch_import')")
public R<List<ErrorMessage>> batchImportEmployee(@RequestExcel List<EmployeeVO> excelList, BindingResult bindingResult, @RequestParam Integer isCanAdd) {
return tEmployeeInfoService.batchImportEmployee(excelList, bindingResult, isCanAdd);
public R<List<ErrorMessage>> batchImportEmployee(@RequestBody MultipartFile file, @RequestParam Integer isCanAdd) {
return tEmployeeInfoService.batchImportEmployee(file.getInputStream(), isCanAdd);
}
/**
* @param excelList
* @param bindingResult
* @Description: 批量更新人员档案
* @Author: hgw
* @Date: 2022/6/22 20:29
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@SneakyThrows
@Operation(summary = "批量更新人员档案", description = "批量更新人员档案 hasPermission('employee_batch_update')")
@SysLog("批量更新人员档案")
@PostMapping("/batchUpdateEmployee")
@PreAuthorize("@pms.hasPermission('employee_batch_update')")
public R<List<ErrorMessage>> batchUpdateEmployee(@RequestExcel List<EmployeeVO> excelList, BindingResult bindingResult) {
return tEmployeeInfoService.batchUpdateEmployee(excelList, bindingResult);
public R<List<ErrorMessage>> batchUpdateEmployee(@RequestBody MultipartFile file) {
return tEmployeeInfoService.batchUpdateEmployee(file.getInputStream());
}
/**
......
......@@ -30,6 +30,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
......@@ -154,17 +155,15 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Date: 2022/6/22 11:58
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchImportEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult, int isCanAdd);
R<List<ErrorMessage>> batchImportEmployee(InputStream inputStream, int isCanAdd);
/**
* @param excelVOList
* @param bindingResult
* @Description: 批量更新人员档案
* @Author: hgw
* @Date: 2022/6/22 20:30
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult);
R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream);
void updateEducationOfEmp(EmpEducationUpdateVO education);
......
......@@ -304,7 +304,7 @@ public class FddContractAttachInfoServiceImpl extends ServiceImpl<FddContractAtt
if (null != date) {
//初始化年龄
newEmployeeInfo.setEmpAge(IdCardUtil.IdNOToAge(fddContractAttachInfo.getEmpIdcard()));
newEmployeeInfo.setEmpBirthday(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
newEmployeeInfo.setEmpBirthday(date);
}
newEmployeeInfo.setEmpSex(IdCardUtil.getSex(fddContractAttachInfo.getEmpIdcard()));
tEmployeeInfoMapper.insert(newEmployeeInfo);
......
......@@ -71,6 +71,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -668,17 +671,17 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
if (attachInfo.getPeriodStart() == null) {
return R.failed("新签试用期开始时间为空");
}
paramter.put("fPeriodStartY", DateUtil.format(attachInfo.getPeriodStart(), "yyyy"));
paramter.put("fPeriodStartM", DateUtil.format(attachInfo.getPeriodStart(), "MM"));
paramter.put("fPeriodStartD", DateUtil.format(attachInfo.getPeriodStart(), "dd"));
paramter.put("fPeriodStartY", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "yyyy"));
paramter.put("fPeriodStartM", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "MM"));
paramter.put("fPeriodStartD", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "dd"));
}
if (Common.isNotNull(companyFieldMap.get("fPeriodEndY"))){
if (attachInfo.getPeriodEnd() == null) {
return R.failed("新签试用期结束时间为空");
}
paramter.put("fPeriodEndY", DateUtil.format(attachInfo.getPeriodEnd(), "yyyy"));
paramter.put("fPeriodEndM", DateUtil.format(attachInfo.getPeriodEnd(), "MM"));
paramter.put("fPeriodEndD", DateUtil.format(attachInfo.getPeriodEnd(), "dd"));
paramter.put("fPeriodEndY", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "yyyy"));
paramter.put("fPeriodEndM", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "MM"));
paramter.put("fPeriodEndD", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "dd"));
}
if (Common.isNotNull(companyFieldMap.get("periodSalaryPerMonth"))){
if (attachInfo.getPeriodSalaryPerMonth() == null) {
......@@ -807,15 +810,15 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
if (attachInfo.getPeriodStart() == null) {
return R.failed("新签试用期开始时间为空");
}
paramter.put("fPeriodStartY", DateUtil.format(attachInfo.getPeriodStart(), "yyyy"));
paramter.put("fPeriodStartM", DateUtil.format(attachInfo.getPeriodStart(), "MM"));
paramter.put("fPeriodStartD", DateUtil.format(attachInfo.getPeriodStart(), "dd"));
paramter.put("fPeriodStartY", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "yyyy"));
paramter.put("fPeriodStartM", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "MM"));
paramter.put("fPeriodStartD", DateUtil.format(localDate2Date(attachInfo.getPeriodStart()), "dd"));
if (attachInfo.getPeriodEnd() == null) {
return R.failed("新签试用期结束时间为空");
}
paramter.put("fPeriodEndY", DateUtil.format(attachInfo.getPeriodEnd(), "yyyy"));
paramter.put("fPeriodEndM", DateUtil.format(attachInfo.getPeriodEnd(), "MM"));
paramter.put("fPeriodEndD", DateUtil.format(attachInfo.getPeriodEnd(), "dd"));
paramter.put("fPeriodEndY", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "yyyy"));
paramter.put("fPeriodEndM", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "MM"));
paramter.put("fPeriodEndD", DateUtil.format(localDate2Date(attachInfo.getPeriodEnd()), "dd"));
if (attachInfo.getPeriodSalaryPerMonth() == null) {
return R.failed("新签试用期工资为空");
}
......@@ -859,6 +862,14 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
return new R<>(paramter.toJSONString());
}
public static Date localDate2Date(LocalDate localDate) {
if (null == localDate) {
return null;
}
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
return Date.from(zonedDateTime.toInstant());
}
/**
* @param entity
* @Author: huyc
......
......@@ -96,13 +96,12 @@ public class TEmpChangeInfoServiceImpl extends ServiceImpl<TEmpChangeInfoMapper,
updateTEmployeeProject.setUnitName(tEmpChangeInfo.getNewDept());
tEmployeeProjectService.updateById(updateTEmployeeProject);
tEmpChangeInfo.setProId(updateTEmployeeProject.getId());
// 记录变更日志
TEmployeeProject tEmployeeProjectOld = tEmployeeProjectService.getById(updateTEmployeeProject.getId());
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[1], "", updateTEmployeeProject.getId(), tEmployeeProjectOld, updateTEmployeeProject);
}
//保存档案划转记录
this.save(tEmpChangeInfo);
// 记录变更日志
TEmployeeProject tEmployeeProjectOld = tEmployeeProjectService.getById(tEmpChangeInfo.getProId());
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[1], "", updateTEmployeeProject.getId(), tEmployeeProjectOld, updateTEmployeeProject);
return R.ok();
}
......@@ -154,7 +153,8 @@ public class TEmpChangeInfoServiceImpl extends ServiceImpl<TEmpChangeInfoMapper,
//待划转员工已在目标结算主体下不可划转
TEmployeeProject tEmployeeProject = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getEmpIdcard, excel.getEmpIdcard()).eq(TEmployeeProject::getDeptNo,excel.getNewSettleCode())
.eq(TEmployeeProject::getDeleteFlag,CommonConstants.STATUS_NORMAL));
.eq(TEmployeeProject::getDeleteFlag,CommonConstants.STATUS_NORMAL)
.eq(TEmployeeProject::getProjectStatus,CommonConstants.ZERO_INT));
if (Common.isNotNull(tEmployeeProject)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.CHECKS_CHANGE_EMP_PROJECT, excel.getNewSettleCode()));
}
......@@ -165,7 +165,7 @@ public class TEmpChangeInfoServiceImpl extends ServiceImpl<TEmpChangeInfoMapper,
.eq(TEmployeeProject::getEmpIdcard, excel.getEmpIdcard()).eq(TEmployeeProject::getDeptNo,excel.getOldSettleCode())
.eq(TEmployeeProject::getDeleteFlag,CommonConstants.STATUS_NORMAL));
if (Common.isNotNull(updateTEmployeePro)) {
if (CommonConstants.ONE_STRING.equals(updateTEmployeePro.getProjectStatus())) {
if (CommonConstants.ONE_INT == updateTEmployeePro.getProjectStatus()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.PROJECT_PERSON_DELETE_EXIT, excel.getOldSettleCode()));
} else if (Common.isNotNull(tSettleDomain)) {
updateTEmployeePro.setDeptNo(tSettleDomain.getDepartNo());
......
......@@ -19,6 +19,10 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -46,6 +50,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
......@@ -57,10 +62,9 @@ import org.springframework.validation.BindingResult;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
......@@ -69,6 +73,7 @@ import java.util.*;
* @author hgw
* @date 2022-06-20 09:55:06
*/
@Log4j2
@Service
@RequiredArgsConstructor
@EnableConfigurationProperties({DaprUpmsProperties.class, DaprCheckProperties.class})
......@@ -424,7 +429,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
employee.setFileStatus(CommonConstants.ONE_INT);
employee.setLeaveUser(user.getId());
employee.setLeaveUserName(user.getNickname());
employee.setLeaveTime(LocalDateTime.now());
employee.setLeaveTime(new Date());
employee.setLeaveReason(excel.getLeaveReason());
employee.setLeaveRemark(excel.getLeaveRemark());
canDeleteList.add(employee);
......@@ -478,7 +483,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
employee.setFileStatus(CommonConstants.ONE_INT);
employee.setLeaveUser(user.getId());
employee.setLeaveUserName(user.getNickname());
employee.setLeaveTime(LocalDateTime.now());
employee.setLeaveTime(new Date());
employee.setLeaveReason(leaveReason);
employee.setLeaveRemark(leaveRemark);
this.updateById(employee);
......@@ -584,12 +589,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
**/
private void setBaseSexInfo(TEmployeeInfo employeeInfo) {
String idCard = employeeInfo.getEmpIdcard();
if (Common.isNotNull(idCard) && Common.isEmpty(employeeInfo.getEmpSex())) {
if (Common.isNotNull(idCard) && Common.isEmpty(employeeInfo.getEmpSex()) && idCard.length() > 14) {
// 出生日期
String idCardDate = idCard.substring(6, 14);
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate empBirthday = LocalDate.parse(idCardDate, fmt);
Date empBirthday = DateUtil.stringToDateByPatten(idCardDate, "yyyyMMdd");
employeeInfo.setEmpBirthday(empBirthday);
// 性别
......@@ -718,23 +722,78 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public R<List<ErrorMessage>> batchImportEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult, int isCanAdd) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
public R<List<ErrorMessage>> batchImportEmployee(InputStream inputStream, int isCanAdd) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmployeeVO> util1 = new ExcelUtil<>(EmployeeVO.class);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmployeeVO.class, new ReadListener<EmployeeVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmployeeVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmployeeVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
Set<String> errors = new HashSet<>();
errors.add(errorMessage.getMessage());
errorMessageList.add(new ErrorMessage(errorMessage.getLineNum() + 0L, errors));
} 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());
batchImportCore(cachedDataList, isCanAdd, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private R<List<ErrorMessage>> batchImportCore(List<EmployeeVO> excelVOList, int isCanAdd, List<ErrorMessage> errorMessageList) {
if (excelVOList == null || excelVOList.isEmpty()) {
return R.failed(CommonConstants.DATA_CAN_NOT_EMPTY);
}
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
}
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)) {
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(), errorMessage));
} else {
errorMessageList = new ArrayList<>();
}
// 获取身份证、手机号列表,批量查询档案
List<String> idCardList = new ArrayList<>();
List<String> phoneList = new ArrayList<>();
......@@ -1202,7 +1261,66 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult) {
public R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmployeeVO> util1 = new ExcelUtil<>(EmployeeVO.class);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmployeeVO.class, new ReadListener<EmployeeVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmployeeVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmployeeVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
Set<String> errors = new HashSet<>();
errors.add(errorMessage.getMessage());
errorMessageList.add(new ErrorMessage(errorMessage.getLineNum() + 0L, errors));
} 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());
batchUpdateCore(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);
}
return R.ok(errorMessageList);
}
private R<List<ErrorMessage>> batchUpdateCore(List<EmployeeVO> excelVOList, List<ErrorMessage> errorMessageList) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
......@@ -1211,7 +1329,6 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return R.failed(CommonConstants.DATA_CAN_NOT_EMPTY);
}
// 通用校验获取失败的数据
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));
......@@ -1656,8 +1773,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
education.setHighIdentification(CommonConstants.ZERO_STRING);
education.setSchool(employeeInfo.getSchool());
education.setMajor(employeeInfo.getMajor());
education.setEntryDate(LocalDateTimeUtils.convertLDToDate(employeeInfo.getAdmissionDate()));
education.setGradutionDate(LocalDateTimeUtils.convertLDToDate(employeeInfo.getGradutionDate()));
education.setEntryDate(employeeInfo.getAdmissionDate());
education.setGradutionDate(employeeInfo.getGradutionDate());
tEmpEducationService.insertEducationOfEmp(education);
}
}
......
......@@ -38,6 +38,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectMapper;
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.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.DoJointTask;
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.exception.ErrorCodes;
......@@ -46,6 +47,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
......@@ -70,13 +73,21 @@ import java.util.stream.Collectors;
@Log4j2
public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMapper, TEmployeeProject> implements TEmployeeProjectService {
private final TEmployeeLogService tEmployeeLogService;
@Autowired
private TEmployeeLogService tEmployeeLogService;
private final TEmployeeInfoMapper tEmployeeInfoMapper;
@Autowired
private TEmployeeInfoMapper tEmployeeInfoMapper;
private final TSettleDomainService tSettleDomainService;
@Autowired
private TSettleDomainService tSettleDomainService;
private final TCustomerInfoMapper tCustomerInfoMapper;
@Autowired
private TCustomerInfoMapper tCustomerInfoMapper;
@Autowired
@Lazy
private DoJointTask doJointTask;
@Override
public R addCheck(TEmployeeProject tEmployeeProject) {
......@@ -334,7 +345,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
.eq(TEmployeeProject::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeProject::getDeptNo, excel.getDeptNo())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.STATUS_NORMAL));
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT));
if (Common.isNotNull(tEmployeeProject)) {
if (tEmployeeProject.getInsuranceStatus() != CommonConstants.dingleDigitIntArray[0] || tEmployeeProject.getSocialStatus() != CommonConstants.dingleDigitIntArray[0] ||
......@@ -368,11 +379,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
}
}
}
} else {
idList.add(tEmployeeProject);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.PROJECT_PERSON_SEARCH_EXIT)));
}
TEmployeeInfo tEmployeeInfoOld = tEmployeeInfoMapper.selectById(tEmployeeProject.getEmpId());
TEmployeeInfo tEmployeeInfo = tEmployeeInfoMapper.selectById(tEmployeeProject.getEmpId());
List<String> projectIdList = idList.stream().map(TEmployeeProject::getId).collect(Collectors.toList());
......@@ -384,6 +390,11 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
newOld.setNewEmployee(tEmployeeInfo);
updateList.add(newOld);
}
} else {
idList.add(tEmployeeProject);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.PROJECT_PERSON_SEARCH_EXIT)));
}
}
if (errorMessageList.size() > CommonConstants.ZERO_INT) {
return R.failed(errorMessageList);
} else {
......@@ -408,7 +419,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
if (updateProjectList.size() > CommonConstants.dingleDigitIntArray[0]) {
for (EmployeeProjectNewOldVO newOldVO : updateProjectList) {
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[1]
,"", newOldVO.getNewProjectEmployee().getId()
, "", newOldVO.getNewProjectEmployee().getId()
, newOldVO.getOldProjectEmployee(), newOldVO.getNewProjectEmployee());
}
}
......@@ -679,9 +690,22 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
// 通用校验获取失败的数据
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
// 项目档案更新List
List<TEmployeeProject> updateList = new ArrayList<>();
// 人员档案更新List
List<TEmployeeInfo> updTEmployeeList = new ArrayList();
Map<String, Integer> checkCountMap = new HashMap<>();
// 新老档案List
List<EmployeeNewOldVO> updateInfoList = new ArrayList<>();
// 新老档案vo
EmployeeNewOldVO newOld;
// 新老项目档案vo
EmployeeProjectNewOldVO newOldProject;
// 新老项目档案List
List<EmployeeProjectNewOldVO> updateProjectList = new ArrayList<>();
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
......@@ -707,41 +731,46 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.CHECKS_EMP_EXIT_ERROR)));
}
}
// 数据合法情况
if (CollUtil.isEmpty(errorMessageList)) {
} else {
updateExcelProj(excel, updateList, tEmployeeProject);
if (Common.isNotNull(excel.getEmpNatrue())) {
if (!excel.getEmpNatrue().equals(tEmployeeProject.getEmpNatrue())) {
TEmployeeProject tEmployeeProjectOld = this.getById(tEmployeeProject.getId());
newOldProject = new EmployeeProjectNewOldVO();
newOldProject.setOldProjectEmployee(tEmployeeProjectOld);
newOldProject.setNewProjectEmployee(tEmployeeProject);
updateProjectList.add(newOldProject);
TEmployeeInfo tEmployeeInfo = tEmployeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeInfo::getFileStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.STATUS_NORMAL));
if (Common.isNotNull(tEmployeeInfo)) {
TEmployeeInfo tEmployeeInfoCof = tEmployeeInfoMapper.selectById(tEmployeeInfo.getId());
String empNature = tEmployeeInfo.getEmpNatrue();
if (CommonConstants.ZERO_STRING.equals(excel.getEmpNatrue())) {
tEmployeeInfo.setEmpNatrue(CommonConstants.ZERO_STRING);
} else if (CommonConstants.ONE_STRING.equals(excel.getEmpNatrue()) && !CommonConstants.ZERO_STRING.equals(empNature)) {
tEmployeeInfo.setEmpNatrue(CommonConstants.ONE_STRING);
}
tEmployeeInfoMapper.updateById(tEmployeeInfo);
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0], tEmployeeInfo.getId(), "", tEmployeeInfoCof, tEmployeeInfo);
}
}
}
updTEmployeeList.add(tEmployeeInfo);
}
}
// 数据合法情况
if (CollUtil.isEmpty(errorMessageList)) {
try {
if (updateList.size() > CommonConstants.dingleDigitIntArray[0]) {
baseMapper.updateExcelEmpProject(updateList);
}
if (updTEmployeeList.size()> CommonConstants.dingleDigitIntArray[0]) {
List<TEmployeeInfo> updEmpInfoList = updTEmployeeList.stream().distinct().collect(Collectors.toList());
doJointTask.doUpdateEmployeeInfo(updEmpInfoList);
}
// 记录变更日志
if (updateInfoList.size() > CommonConstants.dingleDigitIntArray[0]) {
for (EmployeeNewOldVO newOldInfo : updateInfoList) {
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0]
, newOldInfo.getOldEmployee().getId(), ""
, newOldInfo.getOldEmployee(), newOldInfo.getNewEmployee());
}
}
} catch (Exception e) {
log.error("数据更新异常", e);
}
}
}
/**
* 插入excel Pro
......@@ -971,9 +1000,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
YifuUser user = SecurityUtils.getUser();
tEmployeeProject.setUpdateBy(user.getId());
proupdateList.add(tEmployeeProject);
// 记录变更日志
TEmployeeProject tEmployeeProjectOld = this.getById(tEmployeeProject.getId());
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[1], "", tEmployeeProject.getId(), tEmployeeProjectOld, tEmployeeProject);
}
@Override
......@@ -1025,7 +1051,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
public R<Map<String, String>> getProjectByIdCard(String empIdCard) {
List<TEmployeeProject> projects = baseMapper.selectList(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.ZERO_STRING)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_STRING)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getEmpIdcard, empIdCard));
Map<String, String> projectMap = new HashMap<>();
if (Common.isNotNull(projects)) {
......@@ -1050,6 +1076,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
//从剩下的项目档案中查找员工类型
public void setEmpNature(String empIdcard, TEmployeeInfo tEmployeeInfo, List<String> idlist) {
if (Common.isNotNull(idlist)) {
List<TEmployeeProject> list = this.list(Wrappers.<TEmployeeProject>query().lambda()
.in(TEmployeeProject::getId, idlist)
.eq(TEmployeeProject::getEmpIdcard, empIdcard)
......@@ -1069,6 +1096,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
}
}
}
public boolean saveCheck(EmployeeXProjectVO employeeXProjectVO, TEmployeeProject tEmployeeProject) {
if (employeeXProjectVO.getDeptNo().equals(tEmployeeProject.getDeptNo()) &&
......
package com.yifu.cloud.plus.v1.yifu.archives.utils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
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.common.core.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 主要执行人员档案的员工类型同步更新
* @author huyc
* @Date 2022-07-08
* @Description 多线程的执行demo
*/
@Slf4j
@Component
public class DoJointTask {
@Autowired
private TEmployeeInfoService tEmployeeInfoService;
@Autowired
private TEmployeeProjectService tEmployeeProjectService;
@Autowired
private TEmployeeLogService tEmployeeLogService;
/**
* @Description: 合同-批量更换负责人
* @Author: huyc
* @Date: 2022-7-8
* @return: void
**/
@Async
public void doUpdateEmployeeInfo(List<TEmployeeInfo> tEmployeeInfoList) {
log.info("档案-批量更新人员档案-线程开始");
try {
for(TEmployeeInfo tEmployeeInfo:tEmployeeInfoList) {
TEmployeeInfo tEmployeeInfoOld = tEmployeeInfoService.getById(tEmployeeInfo.getId());
//查询该人员所有的项目档案
List<TEmployeeProject> list = tEmployeeProjectService.list(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getEmpIdcard, tEmployeeInfo.getEmpIdcard())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT));
for (TEmployeeProject tEmployeeProject:list) {
if (CommonConstants.ZERO_STRING.equals(tEmployeeProject.getEmpNatrue())) {
tEmployeeInfo.setEmpNatrue(CommonConstants.ZERO_STRING);
break;
} else if (CommonConstants.ONE_STRING.equals(tEmployeeProject.getEmpNatrue()) && !CommonConstants.ZERO_STRING.equals(tEmployeeInfo.getEmpNatrue())) {
tEmployeeInfo.setEmpNatrue(CommonConstants.ONE_STRING);
break;
}
tEmployeeInfo.setEmpNatrue(CommonConstants.TWO_STRING);
}
tEmployeeInfoService.updateById(tEmployeeInfo);
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0]
, tEmployeeInfo.getId(), "", tEmployeeInfoOld, tEmployeeInfo);
}
} catch (Exception e) {
log.error("档案-批量更新人员档案错误", e);
}
log.info("档案-批量更新人员档案结束");
}
}
......@@ -47,6 +47,9 @@
<result property="fileProvince" column="FILE_PROVINCE"/>
<result property="fileCity" column="FILE_CITY"/>
<result property="fileTown" column="FILE_TOWN"/>
<result property="socialProvince" column="SOCIAL_PROVINCE"/>
<result property="socialCity" column="SOCIAL_CITY"/>
<result property="socialTown" column="SOCIAL_TOWN"/>
<result property="empPhone" column="EMP_PHONE"/>
<result property="salaryStatus" column="SALARY_STATUS"/>
<result property="insuranceStatus" column="INSURANCE_STATUS"/>
......@@ -162,6 +165,9 @@
b.FILE_PROVINCE,
b.FILE_CITY,
b.FILE_TOWN,
a.SOCIAL_PROVINCE,
a.SOCIAL_CITY,
a.SOCIAL_TOWN,
a.SALARY_STATUS
</sql>
......@@ -198,6 +204,9 @@
b.FILE_PROVINCE,
b.FILE_CITY,
b.FILE_TOWN,
a.SOCIAL_PROVINCE,
a.SOCIAL_CITY,
a.SOCIAL_TOWN,
a.SALARY_STATUS,
b.VALIDITY_START,
b.VALIDITY_END,
......@@ -365,6 +374,15 @@
<if test="tEmployeeProject.fileTown != null">
AND b.FILE_TOWN = #{tEmployeeProject.fileTown}
</if>
<if test="tEmployeeProject.socialProvince != null">
AND a.SOCIAL_PROVINCE = #{tEmployeeProject.socialProvince}
</if>
<if test="tEmployeeProject.fileCity != null">
AND a.SOCIAL_CITY = #{tEmployeeProject.socialCity}
</if>
<if test="tEmployeeProject.fileTown != null">
AND a.SOCIAL_TOWN = #{tEmployeeProject.socialTown}
</if>
</if>
</sql>
......@@ -472,6 +490,15 @@
<if test="tEmployeeProject.fileTown != null">
AND b.FILE_TOWN = #{tEmployeeProject.fileTown}
</if>
<if test="tEmployeeProject.socialProvince != null">
AND a.SOCIAL_PROVINCE = #{tEmployeeProject.socialProvince}
</if>
<if test="tEmployeeProject.fileCity != null">
AND a.SOCIAL_CITY = #{tEmployeeProject.socialCity}
</if>
<if test="tEmployeeProject.fileTown != null">
AND a.SOCIAL_TOWN = #{tEmployeeProject.socialTown}
</if>
<if test="tEmployeeProject.idList != null">
AND a.id in
<foreach item="idStr" index="index" collection="tEmployeeProject.idList" open="(" separator="," close=")">
......
package com.yifu.cloud.plus.v1.yifu.common.core.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 异步线程池
* @Author fxj
* @Date 2021-05-20
* @return
**/
@Configuration
@EnableAsync
@Slf4j
public class AsyncConfig implements AsyncConfigurer {
// todo 幂等性如何保证
@Override
public Executor getAsyncExecutor() {
//定义线程池
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
/**
* <!-- 设置allowCoreThreadTimeout=true(默认false)时,核心线程会超时关闭 -->
*/
taskExecutor.setAllowCoreThreadTimeOut(true);
/**
* 核心线程数
* 1)<!-- 线程池维护线程的最少数量,即使没有任务需要执行,也会一直存活 -->
* 2)<!-- 设置allowCoreThreadTimeout=true(默认false)时,核心线程会超时关闭 -->
*/
taskExecutor.setCorePoolSize(2);
/**
* <!-- 允许的空闲时间,当线程空闲时间达到keepAliveTime时,线程会退出,直到线程数量=corePoolSize -->
* <!-- 如果allowCoreThreadTimeout=true,则会直到线程数量=0 -->
*/
taskExecutor.setKeepAliveSeconds(200);
/**
* <!-- 线程池维护线程的最大数量 -->
* <!-- 当线程数>=corePoolSize,且任务队列已满时。线程池会创建新线程来处理任务 -->
* <!-- 当线程数=maxPoolSize,且任务队列已满时,线程池会拒绝处理任务而抛出异常,异常见下
*/
taskExecutor.setMaxPoolSize(8);
/**
* <!-- 缓存队列(阻塞队列)当核心线程数达到最大时,新任务会放在队列中排队等待执行 -->
*/
taskExecutor.setQueueCapacity(100);
/**
* 建议配置threadNamePrefix属性,出问题时可以更方便的进行排查。
**/
taskExecutor.setThreadNamePrefix("CRM_TO_HRO_EXECUTOR");
// 捕捉线程队列满的 拒绝处理
taskExecutor.setRejectedExecutionHandler((Runnable r, ThreadPoolExecutor exe) -> {
log.info("当前任务线程池队列已满.");
});
//初始化
taskExecutor.initialize();
return taskExecutor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return null;
}
}
......@@ -343,6 +343,18 @@ public class DateUtil {
return stringToDate2(dateString, ISO_EXPANDED_DATE_FORMAT);
}
/**
* @param dateString
* @param patten 格式
* @Description:
* @Author: hgw
* @Date: 2022/7/8 12:02
* @return: java.util.Date
**/
public static Date stringToDateByPatten(String dateString, String patten) {
return stringToDate2(dateString, patten);
}
/**
* @param pattern
* @param date
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.core.config.JacksonConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.config.AsyncConfig,\
com.yifu.cloud.plus.v1.yifu.common.core.config.RedisTemplateConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.config.RestTemplateConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder,\
......
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