Commit bf1affd1 authored by hongguangwu's avatar hongguangwu

合同优化

parent 673f9ae0
...@@ -210,14 +210,14 @@ public class TEmployeeContractInfo extends BaseEntity { ...@@ -210,14 +210,14 @@ public class TEmployeeContractInfo extends BaseEntity {
* 合同岗位 * 合同岗位
*/ */
@Length(max = 32, message = "合同岗位不能超过32个字符") @Length(max = 32, message = "合同岗位不能超过32个字符")
@ExcelAttribute(name = "合同岗位", maxLength = 32, needExport = true) @ExcelAttribute(name = "合同岗位", isNotEmpty = true, errorInfo = "合同岗位不能为空", maxLength = 32, needExport = true)
@Schema(description = "合同岗位", name = "post") @Schema(description = "合同岗位", name = "post")
private String post; private String post;
/** /**
* 工时制(数据字典) 1标准工时 2 综合工时 3不定时工时制 * 工时制(数据字典) 1标准工时 2 综合工时 3不定时工时制
*/ */
@Length(max = 32, message = "工时制不能超过32个字符") @Length(max = 32, message = "工时制不能超过32个字符")
@ExcelAttribute(name = "工时制", maxLength = 32, isDataId = true, dataType = ExcelAttributeConstants.WORKING_HOURS) @ExcelAttribute(name = "工时制", isNotEmpty = true, errorInfo = "工时制不能为空", maxLength = 32, isDataId = true, dataType = ExcelAttributeConstants.WORKING_HOURS)
@Schema(description = "工时制(数据字典) 1标准工时 2 综合工时 3不定时工时制", name = "workingHours") @Schema(description = "工时制(数据字典) 1标准工时 2 综合工时 3不定时工时制", name = "workingHours")
private String workingHours; private String workingHours;
/** /**
...@@ -411,7 +411,9 @@ public class TEmployeeContractInfo extends BaseEntity { ...@@ -411,7 +411,9 @@ public class TEmployeeContractInfo extends BaseEntity {
/** /**
* 合同甲方 * 合同甲方
*/ */
@ExcelAttribute(name = "合同甲方") @NotBlank(message = "合同甲方不能为空")
@Length(max = 50, message = "合同甲方不能超过50个字符")
@ExcelAttribute(name = "合同甲方", isNotEmpty = true, errorInfo = "合同甲方不能为空", maxLength = 50, needExport = true)
@Schema(description = "合同甲方") @Schema(description = "合同甲方")
@Size(max = 50, message = "合同甲方不可超过50位") @Size(max = 50, message = "合同甲方不可超过50位")
private String contractParty; private String contractParty;
......
...@@ -34,6 +34,12 @@ public class EmployeeConstants { ...@@ -34,6 +34,12 @@ public class EmployeeConstants {
public static final String CHECK_NO_RESPONSE = "校验服务器未返回,请联系管理员!"; public static final String CHECK_NO_RESPONSE = "校验服务器未返回,请联系管理员!";
public static final String SITUATION_SIX = "作废"; public static final String SITUATION_SIX = "作废";
public static final String SITUATION_SEVEN = "终止"; public static final String SITUATION_SEVEN = "终止";
public static final String EMPID_NOT_EMPTY = "员工ID、项目ID不可为空;";
public static final String OTHERS = "其他";
public static final String SUB_MUST = "业务细分必填";
public static final String CONTRACT_END_MUST = "合同到期时间必填";
public static final String CONTRACT_TYPE_TWO = "2";
public static final String CONTRACT_NO_IN_USE = "暂无可操作的合同";
/** /**
* 无数据可更新 * 无数据可更新
......
...@@ -42,6 +42,7 @@ import lombok.RequiredArgsConstructor; ...@@ -42,6 +42,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.support.SimpleValueWrapper; import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -51,10 +52,13 @@ import javax.servlet.ServletOutputStream; ...@@ -51,10 +52,13 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 员工合同 * 员工合同
...@@ -68,7 +72,6 @@ import java.util.List; ...@@ -68,7 +72,6 @@ import java.util.List;
public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContractInfoMapper, TEmployeeContractInfo> implements TEmployeeContractInfoService { public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContractInfoMapper, TEmployeeContractInfo> implements TEmployeeContractInfoService {
private static final String ID_NOT_EMPTY = "ID,EMP_ID不可为空"; private static final String ID_NOT_EMPTY = "ID,EMP_ID不可为空";
private static final String EMPID_NOT_EMPTY = "员工ID、项目ID不可为空";
private static final String EMPINFO_IS_NOT_EXITS_BYID = "未找到人员档案与项目档案!"; private static final String EMPINFO_IS_NOT_EXITS_BYID = "未找到人员档案与项目档案!";
...@@ -113,7 +116,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -113,7 +116,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
public R<List<ErrorMessage>> saveNewContract(TEmployeeContractInfo tEmployeeContractInfo) { public R<List<ErrorMessage>> saveNewContract(TEmployeeContractInfo tEmployeeContractInfo) {
try { try {
if (Common.isEmpty(tEmployeeContractInfo.getEmpId()) || Common.isEmpty(tEmployeeContractInfo.getSettleDomain())) { if (Common.isEmpty(tEmployeeContractInfo.getEmpId()) || Common.isEmpty(tEmployeeContractInfo.getSettleDomain())) {
return R.failed(EMPID_NOT_EMPTY); return R.failed(EmployeeConstants.EMPID_NOT_EMPTY);
} }
return this.setBaseInfo(tEmployeeContractInfo); return this.setBaseInfo(tEmployeeContractInfo);
} catch (Exception e) { } catch (Exception e) {
...@@ -154,7 +157,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -154,7 +157,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
} }
if (this.saveContractAndAtta(tEmployeeContractInfo)) { if (this.saveContractAndAtta(tEmployeeContractInfo)) {
return R.ok(); return R.ok(null,"保存成功");
} else { } else {
return R.failed(); return R.failed();
} }
...@@ -200,6 +203,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -200,6 +203,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
private void initEmployeeContract(TEmployeeContractInfo tEmployeeContractInfo, TEmployeeInfo tEmployeeInfo private void initEmployeeContract(TEmployeeContractInfo tEmployeeContractInfo, TEmployeeInfo tEmployeeInfo
, TEmployeeProject tEmployeeProject, YifuUser user) { , TEmployeeProject tEmployeeProject, YifuUser user) {
tEmployeeContractInfo.setEmpId(tEmployeeInfo.getId()); tEmployeeContractInfo.setEmpId(tEmployeeInfo.getId());
tEmployeeContractInfo.setEmpNatrue(tEmployeeInfo.getEmpNatrue());
tEmployeeContractInfo.setEmpIdcard(tEmployeeInfo.getEmpIdcard()); tEmployeeContractInfo.setEmpIdcard(tEmployeeInfo.getEmpIdcard());
tEmployeeContractInfo.setEmpName(tEmployeeInfo.getEmpName()); tEmployeeContractInfo.setEmpName(tEmployeeInfo.getEmpName());
tEmployeeContractInfo.setEmpNo(tEmployeeInfo.getEmpCode()); tEmployeeContractInfo.setEmpNo(tEmployeeInfo.getEmpCode());
...@@ -684,10 +688,16 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -684,10 +688,16 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
@Transactional @Transactional
public void importContract(List<EmployeeContractVO> excelVOList, List<ErrorMessage> errorMessageList) { public void importContract(List<EmployeeContractVO> excelVOList, List<ErrorMessage> errorMessageList) {
/// 个性化校验逻辑 /// 个性化校验逻辑
ErrorMessage errorMsg; Map<Integer, Integer> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)) {
errorMessageList.forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(), CommonConstants.ONE_INT));
}
EmployeeContractVO excel; EmployeeContractVO excel;
// 执行数据插入操作 组装 // 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
if (errorMsgMap.get(i+2) != null) {
continue;
}
excel = excelVOList.get(i); excel = excelVOList.get(i);
// 存储 // 存储
this.insertExcel(excel, errorMessageList); this.insertExcel(excel, errorMessageList);
...@@ -702,22 +712,52 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr ...@@ -702,22 +712,52 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
BeanUtil.copyProperties(excel, insert); BeanUtil.copyProperties(excel, insert);
try { try {
if (Common.isEmpty(insert.getEmpIdcard()) || Common.isEmpty(insert.getDeptNo())) { StringBuilder errorInfo = new StringBuilder();
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EMPID_NOT_EMPTY)); if (EmployeeConstants.OTHERS.equals(insert.getContractName()) && Common.isEmpty(insert.getContractSubName())) {
errorInfo.append(EmployeeConstants.SUB_MUST);
}
if (!EmployeeConstants.CONTRACT_TYPE_TWO.equals(insert.getContractType())
&& Common.isEmpty(insert.getContractEnd())) {
errorInfo.append(EmployeeConstants.CONTRACT_END_MUST);
} }
TEmployeeProject project = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query().lambda() if (Common.isEmpty(insert.getEmpIdcard()) || Common.isEmpty(insert.getDeptNo())) {
.eq(TEmployeeProject::getEmpIdcard, insert.getEmpIdcard()) errorInfo.append(EmployeeConstants.EMPID_NOT_EMPTY);
.eq(TEmployeeProject::getDeptNo, insert.getDeptNo())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT).last(CommonConstants.LAST_ONE_SQL));
if (project == null) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EMPINFO_IS_NOT_EXITS_BYID));
} else { } else {
insert.setEmpId(project.getEmpId()); TEmployeeContractInfo contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
insert.setSettleDomain(project.getDeptId()); .eq(TEmployeeContractInfo::getEmpIdcard, insert.getEmpIdcard())
// 核心保存 .eq(TEmployeeContractInfo::getDeptNo, insert.getDeptNo())
R<List<ErrorMessage>> info = this.setBaseInfo(insert); .eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), info.getMsg())); .eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_STRING).last(CommonConstants.LAST_ONE_SQL));
if (contractInfo == null) {
errorInfo.append(EmployeeConstants.CONTRACT_NO_IN_USE);
}
}
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), errorInfo.toString()));
if (Common.isEmpty(errorInfo.toString())) {
TEmployeeProject project = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getEmpIdcard, insert.getEmpIdcard())
.eq(TEmployeeProject::getDeptNo, insert.getDeptNo())
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT).last(CommonConstants.LAST_ONE_SQL));
if (project == null) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EMPINFO_IS_NOT_EXITS_BYID));
} else {
insert.setEmpId(project.getEmpId());
insert.setSettleDomain(project.getDeptId());
// 批量直接待审核
insert.setAuditStatus(CommonConstants.ONE_INT);
if (Common.isEmpty(insert.getContractTerm())
&& Common.isNotNull(insert.getContractStart())
&& Common.isNotNull(insert.getContractEnd())) {
int monthDiff = DateUtil.getMonthDiff(insert.getContractStart(), insert.getContractEnd());
BigDecimal b = new BigDecimal(String.valueOf(monthDiff/12.0));
b = b.setScale(1, BigDecimal.ROUND_HALF_UP);
insert.setContractTerm(String.valueOf(b));
}
// 核心保存
R<List<ErrorMessage>> info = this.setBaseInfo(insert);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), info.getMsg()));
}
} }
} catch (Exception e) { } catch (Exception e) {
log.error("员工合同保存异常:" + e.getMessage()); log.error("员工合同保存异常:" + e.getMessage());
......
...@@ -858,6 +858,24 @@ public class DateUtil { ...@@ -858,6 +858,24 @@ public class DateUtil {
return false; return false;
} }
/**
* @param startDate
* @param endDate
* @Description: 计算年月的月份差值(202205-202205=0)想要1自己+1
* @Author: hgw
* @Date: 2022/7/15 12:16
* @return: int
**/
public static int getMonthDiff(Date startDate, Date endDate) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
return Integer.parseInt(sdf.format(endDate)) - Integer.parseInt(sdf.format(startDate));
} catch (IllegalFormatException e) {
log.error("计算日期月份差,方法名:getMonthDiff,出错:",e);
return 0;
}
}
public static int getMonthCountByDate(Date startDate, Date endDate) { public static int getMonthCountByDate(Date startDate, Date endDate) {
// type:1.当月缴当月的 2.当月缴次月的 // type:1.当月缴当月的 2.当月缴次月的
int monthC = 0; int monthC = 0;
......
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