Commit 4f783f90 authored by fangxinjiang's avatar fangxinjiang

人员档案档案地 及通信地址 批量新增及批量更新 校验-fxj

parent 65ca8afc
...@@ -14,7 +14,7 @@ public class EmployeeConstants { ...@@ -14,7 +14,7 @@ public class EmployeeConstants {
public static final String VALIDITY_END_FORMAT = "身份证截止日期只能为日期格式:yyyy-MM-dd或者固定值:长期"; public static final String VALIDITY_END_FORMAT = "身份证截止日期只能为日期格式:yyyy-MM-dd或者固定值:长期";
public static final String EMP_NATIONAL = "民族必填"; public static final String EMP_NATIONAL = "民族必填";
public static final String ID_PROVINCE = "户籍所在地必填"; public static final String ID_PROVINCE = "户籍所在地必填";
public static final String FILE_PROVINCE = "档案所在地必填"; public static final String FILE_PROVINCE = "档案所在地(省市县)必填";
public static final String CONTACT_PROVINCE = "通信地址(省市县)必填"; public static final String CONTACT_PROVINCE = "通信地址(省市县)必填";
public static final String EMP_REGIS_TYPE = "户口性质必填"; public static final String EMP_REGIS_TYPE = "户口性质必填";
public static final String IS_COLLEGE = "是否大专及以上必填"; public static final String IS_COLLEGE = "是否大专及以上必填";
......
...@@ -343,8 +343,9 @@ public class TEmployeeInfoController { ...@@ -343,8 +343,9 @@ public class TEmployeeInfoController {
@SysLog("批量更新人员档案") @SysLog("批量更新人员档案")
@PostMapping("/batchUpdateEmployee") @PostMapping("/batchUpdateEmployee")
@PreAuthorize("@pms.hasPermission('employee_batch_update')") @PreAuthorize("@pms.hasPermission('employee_batch_update')")
public R<List<ErrorMessage>> batchUpdateEmployee(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> batchUpdateEmployee(@RequestBody MultipartFile file,
return tEmployeeInfoService.batchUpdateEmployee(file.getInputStream()); @RequestParam(name = "exportFields", required = true) String[] exportFields) {
return tEmployeeInfoService.batchUpdateEmployee(file.getInputStream(),exportFields);
} }
/** /**
......
...@@ -167,7 +167,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> { ...@@ -167,7 +167,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Date: 2022/6/22 20:30 * @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>> * @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/ **/
R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream); R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream,String[] exportFields);
void updateEducationOfEmp(EmpEducationUpdateVO education); void updateEducationOfEmp(EmpEducationUpdateVO education);
......
...@@ -21,6 +21,7 @@ import cn.hutool.core.collection.CollUtil; ...@@ -21,6 +21,7 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder; import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
...@@ -971,6 +972,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -971,6 +972,10 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
errorMsg.add(EmployeeConstants.FILE_PROVINCE); errorMsg.add(EmployeeConstants.FILE_PROVINCE);
errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.FILE_PROVINCE)); errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.FILE_PROVINCE));
} }
if (Common.isEmpty(employeeInfo.getFileTown())) {
errorMsg.add(EmployeeConstants.FILE_PROVINCE);
errorMsgMap.put(lineNum, new ErrorMessage(EmployeeConstants.FILE_PROVINCE));
}
if (Common.isEmpty(employeeInfo.getContactTown())) { if (Common.isEmpty(employeeInfo.getContactTown())) {
errorMsg.add(EmployeeConstants.CONTACT_PROVINCE); errorMsg.add(EmployeeConstants.CONTACT_PROVINCE);
...@@ -1620,7 +1625,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1620,7 +1625,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
@Override @Override
public R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream) { public R<List<ErrorMessage>> batchUpdateEmployee(InputStream inputStream,String[] exportFields) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmployeeInsertVO> util1 = new ExcelUtil<>(EmployeeInsertVO.class); ExcelUtil<EmployeeInsertVO> util1 = new ExcelUtil<>(EmployeeInsertVO.class);
// 写法2: // 写法2:
...@@ -1669,7 +1674,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1669,7 +1674,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
private void saveData() { private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size()); log.info("{}条数据,开始存储数据库!", cachedDataList.size());
if (!cachedDataList.isEmpty()) { if (!cachedDataList.isEmpty()) {
batchUpdateCore(cachedDataList, errorMessageList); batchUpdateCore(cachedDataList, errorMessageList,exportFields);
} }
log.info("存储数据库成功!"); log.info("存储数据库成功!");
} }
...@@ -1685,7 +1690,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1685,7 +1690,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
} }
private R<List<ErrorMessage>> batchUpdateCore(List<EmployeeInsertVO> excelVOList, List<ErrorMessage> errorMessageList) { private R<List<ErrorMessage>> batchUpdateCore(List<EmployeeInsertVO> excelVOList,
List<ErrorMessage> errorMessageList,
String[] exportFields) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
Set<String> errorMsg; Set<String> errorMsg;
if (user == null || Common.isEmpty(user.getId())) { if (user == null || Common.isEmpty(user.getId())) {
...@@ -1700,6 +1707,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1700,6 +1707,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
errorMessageList.add(new ErrorMessage(2L, errorMsg)); errorMessageList.add(new ErrorMessage(2L, errorMsg));
return R.failed(errorMessageList); return R.failed(errorMessageList);
} }
//初试化表头用于校验省市县
HashMap<String,String> headMap = new HashMap<>();
if (Common.isNotNull(exportFields)){
for (int i=0; i < exportFields.length; i++){
headMap.put(exportFields[i],exportFields[i]);
}
}
// 通用校验获取失败的数据 // 通用校验获取失败的数据
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>(); Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
...@@ -1991,6 +2006,27 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -1991,6 +2006,27 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
saveEmp.setContactAddress(excel.getContactAddress()); saveEmp.setContactAddress(excel.getContactAddress());
} }
} }
// 档案地和通信地址 校验
if (Common.isNotNull(headMap.get("档案所在省"))
|| Common.isNotNull(headMap.get("档案所在市"))
|| Common.isNotNull(headMap.get("档案所在县"))){
if (Common.isEmpty(excel.getFileTown())) {
errorMsg.add(EmployeeConstants.FILE_PROVINCE);
}
}
if (Common.isNotNull(headMap.get("通信地址-省"))
|| Common.isNotNull(headMap.get("通信地址-市"))
|| Common.isNotNull(headMap.get("通信地址-区/县"))){
if (Common.isEmpty(excel.getContactTown())) {
errorMsg.add(EmployeeConstants.CONTACT_PROVINCE);
}
}
if (Common.isNotNull(headMap.get("通信地址-详细地址"))){
if (Common.isEmpty(excel.getContactAddress())) {
errorMsg.add(EmployeeConstants.CONTACT_ADDRESS);
}
}
if (Common.isNotNull(excel.getRemark())) { if (Common.isNotNull(excel.getRemark())) {
if (excel.getRemark().length() > 200) { if (excel.getRemark().length() > 200) {
errorMsg.add(EmployeeConstants.REMARL_LENGTH); errorMsg.add(EmployeeConstants.REMARL_LENGTH);
......
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