Commit 93037923 authored by fangxinjiang's avatar fangxinjiang

上传vo调整

parent 8a8fb30c
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.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
......@@ -63,6 +64,7 @@ public class EmpDisabilityExcelVO implements Serializable {
*/
@NotNull(message = "伤残开始日期不能为空")
@Past
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残开始日期")
private LocalDateTime startTime;
......@@ -71,6 +73,7 @@ public class EmpDisabilityExcelVO implements Serializable {
*/
@NotNull(message = "伤残结束日期不能为空")
@Past
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残结束日期")
private LocalDateTime endTime;
......
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.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.v3.oas.annotations.media.Schema;
......@@ -38,12 +39,14 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 入学时间
*/
@DateTimeFormat("YYYY-MM-dd")
@Schema(description ="入学时间")
private LocalDateTime entryDate;
/**
* 结业日期
*/
@DateTimeFormat("YYYY-MM-dd")
@Schema(description ="毕业时间")
private LocalDateTime gradutionDate;
......
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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -10,6 +11,7 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 员工伤残excel 对应的实体
......@@ -53,8 +55,9 @@ public class EmpFamilyExcelVO implements Serializable {
* 出生日期
*/
@Past
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="出生日期")
private LocalDateTime birthday;
private Date birthday;
/**
* 工作/学习单位
......@@ -65,8 +68,8 @@ public class EmpFamilyExcelVO implements Serializable {
/**
* 联系电话
*/
@NotNull(message = "联系电话不可为空")
@ExcelProperty(value ="联系电话")
@NotNull(message = "手机号码不可为空")
@ExcelProperty(value ="手机号码")
private String contractTel;
/*JSR303 是一套JavaBean参数校验的标准,它定义了很多常用的校验注解,我们可以直接将这些注解加在我们JavaBean的属性上面,就可以在需要校验的时候进行校验了。注解如下:
......
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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -58,6 +59,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 开始工作日期
*/
@DateTimeFormat("YYYY-MM-dd")
@NotNull(message = "开始工作日期不可为空")
@ExcelProperty(value ="开始工作日期")
private LocalDateTime startDate;
......@@ -65,6 +67,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 结束工作日期
*/
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="结束工作日期")
private LocalDateTime endDate;
......
......@@ -167,6 +167,6 @@ public class TEmpFamilyController {
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives-family-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestExcel List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
return tEmpFamilyService.importEmpFamilys(excelVOList, bindingResult);
return tEmpFamilyService.importEmpFamily(excelVOList, bindingResult);
}
}
......@@ -34,7 +34,7 @@ import java.util.List;
*/
public interface TEmpFamilyService extends IService<TEmpFamily> {
R<List<ErrorMessage>> importEmpFamilys(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult);
R<List<ErrorMessage>> importEmpFamily(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult);
String checkRepeat(String empIdcard, String familyName, String updateId);
}
......@@ -53,28 +53,32 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
private final TEmployeeInfoMapper employeeInfoMapper;
/**
* @Author fxj
* @Description 家庭信息 批量导
* @Description 家庭信息 批量导
* @Date 9:45 2022/6/20
* @Param
* @return
**/
@Override
public R<List<ErrorMessage>> importEmpFamilys(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
public R<List<ErrorMessage>> importEmpFamily(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
List<ErrorMessage> errorList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long,ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)){
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
if (Common.isNotNull(errorList)){
errorList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
// 个性化校验逻辑
List<TEmpFamily> list = this.list();
TEmployeeInfo emp;
TEmpFamily exist;
Set<String> errorMsg;
List<ErrorMessage> temp = new ArrayList<>();
ErrorMessage errorMessage = null;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){
errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
continue;
}
errorMsg = new HashSet<>();
......@@ -95,15 +99,14 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
return R.ok(temp);
}
private void checkRes(List<TEmpFamily> list, TEmployeeInfo emp, Set<String> errorMsg, EmpFamilyExcelVO excel) {
......
......@@ -17,6 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.common.core.constant;
import java.util.List;
import java.util.Set;
/**
* @author lengleng
......@@ -218,4 +219,5 @@ public interface CommonConstants {
public static final int EMPLOYEE_INIT_NO_START = 7;
String SAVE_FAILED = "保存失败!";
String RESULT_EMPTY = "获取结果为空";
String SAVE_SUCCESS = "保存成功!";
}
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