Commit bf1affd1 authored by hongguangwu's avatar hongguangwu

合同优化

parent 673f9ae0
......@@ -210,14 +210,14 @@ public class TEmployeeContractInfo extends BaseEntity {
* 合同岗位
*/
@Length(max = 32, message = "合同岗位不能超过32个字符")
@ExcelAttribute(name = "合同岗位", maxLength = 32, needExport = true)
@ExcelAttribute(name = "合同岗位", isNotEmpty = true, errorInfo = "合同岗位不能为空", maxLength = 32, needExport = true)
@Schema(description = "合同岗位", name = "post")
private String post;
/**
* 工时制(数据字典) 1标准工时 2 综合工时 3不定时工时制
*/
@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")
private String workingHours;
/**
......@@ -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 = "合同甲方")
@Size(max = 50, message = "合同甲方不可超过50位")
private String contractParty;
......
......@@ -34,6 +34,12 @@ public class EmployeeConstants {
public static final String CHECK_NO_RESPONSE = "校验服务器未返回,请联系管理员!";
public static final String SITUATION_SIX = "作废";
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;
import lombok.extern.log4j.Log4j2;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -51,10 +52,13 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 员工合同
......@@ -68,7 +72,6 @@ import java.util.List;
public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContractInfoMapper, TEmployeeContractInfo> implements TEmployeeContractInfoService {
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 = "未找到人员档案与项目档案!";
......@@ -113,7 +116,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
public R<List<ErrorMessage>> saveNewContract(TEmployeeContractInfo tEmployeeContractInfo) {
try {
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);
} catch (Exception e) {
......@@ -154,7 +157,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
}
if (this.saveContractAndAtta(tEmployeeContractInfo)) {
return R.ok();
return R.ok(null,"保存成功");
} else {
return R.failed();
}
......@@ -200,6 +203,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
private void initEmployeeContract(TEmployeeContractInfo tEmployeeContractInfo, TEmployeeInfo tEmployeeInfo
, TEmployeeProject tEmployeeProject, YifuUser user) {
tEmployeeContractInfo.setEmpId(tEmployeeInfo.getId());
tEmployeeContractInfo.setEmpNatrue(tEmployeeInfo.getEmpNatrue());
tEmployeeContractInfo.setEmpIdcard(tEmployeeInfo.getEmpIdcard());
tEmployeeContractInfo.setEmpName(tEmployeeInfo.getEmpName());
tEmployeeContractInfo.setEmpNo(tEmployeeInfo.getEmpCode());
......@@ -684,10 +688,16 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
@Transactional
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;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
if (errorMsgMap.get(i+2) != null) {
continue;
}
excel = excelVOList.get(i);
// 存储
this.insertExcel(excel, errorMessageList);
......@@ -702,9 +712,28 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
BeanUtil.copyProperties(excel, insert);
try {
StringBuilder errorInfo = new StringBuilder();
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);
}
if (Common.isEmpty(insert.getEmpIdcard()) || Common.isEmpty(insert.getDeptNo())) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EMPID_NOT_EMPTY));
errorInfo.append(EmployeeConstants.EMPID_NOT_EMPTY);
} else {
TEmployeeContractInfo contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getEmpIdcard, insert.getEmpIdcard())
.eq(TEmployeeContractInfo::getDeptNo, insert.getDeptNo())
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.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())
......@@ -715,10 +744,21 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
} 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) {
log.error("员工合同保存异常:" + e.getMessage());
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_FAILED));
......
......@@ -858,6 +858,24 @@ public class DateUtil {
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) {
// type:1.当月缴当月的 2.当月缴次月的
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