Commit 7007eaf3 authored by hongguangwu's avatar hongguangwu

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

parents b5066073 4208c051
...@@ -65,7 +65,7 @@ public class EmployeeXProjectVO extends RowIndex implements Serializable { ...@@ -65,7 +65,7 @@ public class EmployeeXProjectVO extends RowIndex implements Serializable {
*/ */
@ExcelProperty(value ="减项原因") @ExcelProperty(value ="减项原因")
@NotNull(message = "减项原因不能为空") @NotNull(message = "减项原因不能为空")
@ExcelAttribute(name = "减项原因",isNotEmpty = true, errorInfo = "减项原因不能为空",maxLength = 100) @ExcelAttribute(name = "减项原因",isNotEmpty = true, errorInfo = "减项原因不能为空",maxLength = 100,isDataId = true,dataType = "reduce_project_reason")
private String leaveReason; private String leaveReason;
/** /**
......
...@@ -186,12 +186,13 @@ public class TEmployeeProjectController { ...@@ -186,12 +186,13 @@ public class TEmployeeProjectController {
* @Author huyc * @Author huyc
* @Date 2022-06-20 * @Date 2022-06-20
*/ */
@SneakyThrows
@Operation(summary = "批量减项", description = "批量减项") @Operation(summary = "批量减项", description = "批量减项")
@SysLog("批量减项" ) @SysLog("批量减项" )
@PostMapping("/batchDeleteEmpPro") @PostMapping("/batchDeleteEmpPro")
@PreAuthorize("@pms.hasPermission('archives_temployeeproject_batchdelempproinfo')" ) @PreAuthorize("@pms.hasPermission('archives_temployeeproject_batchdelempproinfo')" )
public R<List<ErrorMessage>> batchDeleteEmpPro(@RequestExcel List<EmployeeXProjectVO> excelVOList, BindingResult bindingResult) { public R<List<ErrorMessage>> batchDeleteEmpPro(@RequestBody MultipartFile file) {
return tEmployeeProjectService.batchDeleteEmpPro(excelVOList,bindingResult); return tEmployeeProjectService.batchDeleteEmpPro(file.getInputStream());
} }
/** /**
......
...@@ -103,7 +103,7 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> { ...@@ -103,7 +103,7 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
* @Date: 2022/6/21 10:30 * @Date: 2022/6/21 10:30
* @return: R * @return: R
**/ **/
R<List<ErrorMessage>> batchDeleteEmpPro(List<EmployeeXProjectVO> list, BindingResult bindingResult); R<List<ErrorMessage>> batchDeleteEmpPro(InputStream inputStream);
/** /**
* @param inputStream * @param inputStream
......
...@@ -45,10 +45,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -45,10 +45,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.*; import java.io.*;
import java.util.Arrays; import java.util.*;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
...@@ -170,6 +167,7 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM ...@@ -170,6 +167,7 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
zipFile = new ZipFile(srcFile, CharsetUtil.CHARSET_GBK); zipFile = new ZipFile(srcFile, CharsetUtil.CHARSET_GBK);
Enumeration<?> entries = zipFile.entries(); Enumeration<?> entries = zipFile.entries();
Map<String,String> insMap = new HashMap<>();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement(); ZipEntry entry = (ZipEntry) entries.nextElement();
//添加进filesName //添加进filesName
...@@ -209,13 +207,21 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM ...@@ -209,13 +207,21 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
}else { }else {
return R.failed("未找到身份证对应的档案信息,身份证号:" + idCard); return R.failed("未找到身份证对应的档案信息,身份证号:" + idCard);
} }
TElecEmployeeInfo tElecEmployeeInfo = new TElecEmployeeInfo(); TElecEmployeeInfo tElecEmployeeInfo = new TElecEmployeeInfo();
tElecEmployeeInfo.setEmpIdcard(idCard); tElecEmployeeInfo.setEmpIdcard(idCard);
tElecEmployeeInfo.setEmpName(empName); tElecEmployeeInfo.setEmpName(empName);
if (Common.isNotNull(elecTypeMap)) { if (Common.isNotNull(elecTypeMap)) {
tElecEmployeeInfo.setDataType(elecTypeMap.get(dataType)); if (Common.isNotNull(elecTypeMap.get(dataType))) {
tElecEmployeeInfo.setDataType(elecTypeMap.get(dataType));
} else {
return R.failed("资料类型错误:" + dataType);
}
}
if (!elecTypeMap.get(dataType).equals(insMap.get(idCard))) {
insMap.put(idCard, elecTypeMap.get(dataType));
this.save(tElecEmployeeInfo);
} }
this.save(tElecEmployeeInfo);
//文件上传并保存附件信息 //文件上传并保存附件信息
R<FileVo> fileVo =fileUploadService.uploadImg(fileCovertMultipartFile(targetFile),"", CommonConstants.EIGHT_INT,""); R<FileVo> fileVo =fileUploadService.uploadImg(fileCovertMultipartFile(targetFile),"", CommonConstants.EIGHT_INT,"");
......
...@@ -394,7 +394,14 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -394,7 +394,14 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
} }
} }
} }
tEmployeeInfo.setProjectNum(tEmployeeInfo.getProjectNum() - CommonConstants.ONE_INT); if (tEmployeeInfo.getProjectNum() != CommonConstants.ZERO_INT) {
tEmployeeInfo.setProjectNum(tEmployeeInfo.getProjectNum() - CommonConstants.ONE_INT);
}
tEmployeeInfo.setLeaveReason(tEmployeeProject.getLeaveReason());
if (Common.isNotNull(tEmployeeProject.getLeaveRemark())) {
tEmployeeInfo.setLeaveRemark(tEmployeeProject.getLeaveRemark());
}
tEmployeeInfo.setLeaveTime(DateUtil.getCurrentDateTime());
tEmployeeInfoMapper.updateById(tEmployeeInfo); tEmployeeInfoMapper.updateById(tEmployeeInfo);
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0], tEmployeeInfo.getId(), "", tEmployeeInfoOld, tEmployeeInfo); tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[0], tEmployeeInfo.getId(), "", tEmployeeInfoOld, tEmployeeInfo);
...@@ -410,9 +417,64 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -410,9 +417,64 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
} }
@Override @Override
public R<List<ErrorMessage>> batchDeleteEmpPro(List<EmployeeXProjectVO> excelVOList, BindingResult bindingResult) { public R<List<ErrorMessage>> batchDeleteEmpPro(InputStream inputStream) {
// 通用校验获取失败的数据 List<ErrorMessage> errorMessageList = new ArrayList<>();
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget(); ExcelUtil<EmployeeXProjectVO> util1 = new ExcelUtil<>(EmployeeXProjectVO.class);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmployeeXProjectVO.class, new ReadListener<EmployeeXProjectVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmployeeXProjectVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmployeeXProjectVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} 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());
deleteListAdd(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);
}
public R<List<ErrorMessage>> deleteListAdd(List<EmployeeXProjectVO> excelVOList, List<ErrorMessage> errorMessageList) {
//项目档案更新list //项目档案更新list
List<TEmployeeProject> updProjectList = new ArrayList<>(); List<TEmployeeProject> updProjectList = new ArrayList<>();
...@@ -423,24 +485,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -423,24 +485,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
// 新老项目档案List // 新老项目档案List
List<EmployeeProjectNewOldVO> updateProjectList = new ArrayList<>(); List<EmployeeProjectNewOldVO> updateProjectList = new ArrayList<>();
// 调用字典服务,渲染字典值
R<Map<String, Map<String, Map<String, String>>>> dictR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictToLable", null, Map.class, SecurityConstants.FROM_IN);
Map<String, Map<String, Map<String, String>>> dictDataMap;
Map<String, Map<String, String>> dictMap;
// 民族
Map<String, String> empLabelMap;
if (dictR == null || dictR.getData() == null) {
return R.failed("获取字典失败!");
} else {
dictDataMap = dictR.getData();
dictMap = dictDataMap.get("data");
if (dictMap == null) {
return R.failed("获取字典失败!!");
}
empLabelMap = dictMap.get("reduce_project_reason");
}
// 执行数据插入操作 组装 PostDto // 执行数据插入操作 组装 PostDto
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
EmployeeXProjectVO excel = excelVOList.get(i); EmployeeXProjectVO excel = excelVOList.get(i);
...@@ -460,14 +504,8 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -460,14 +504,8 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
} else { } else {
TEmployeeProject tEmployeeProjectOld = this.getById(tEmployeeProject.getId()); TEmployeeProject tEmployeeProjectOld = this.getById(tEmployeeProject.getId());
tEmployeeProject.setProjectStatus(CommonConstants.dingleDigitIntArray[1]); tEmployeeProject.setProjectStatus(CommonConstants.dingleDigitIntArray[1]);
// 校验字典数据是否正确-减项原因
if (Common.isNotNull(excel.getLeaveReason())) { tEmployeeProject.setLeaveReason(excel.getLeaveReason());
if (empLabelMap.get(excel.getLeaveReason()) == null) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_REDUCE_ERROR)));
} else {
tEmployeeProject.setLeaveReason(empLabelMap.get(excel.getLeaveReason()));
}
}
tEmployeeProject.setLeaveRemark(excel.getLeaveRemark()); tEmployeeProject.setLeaveRemark(excel.getLeaveRemark());
tEmployeeProject.setLeaveTime(LocalDateTime.now()); tEmployeeProject.setLeaveTime(LocalDateTime.now());
updProjectList.add(tEmployeeProject); updProjectList.add(tEmployeeProject);
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
1=1 AND a.DELETE_FLAG = '0' AND b.DELETE_FLAG = '0' 1=1 AND a.DELETE_FLAG = '0' AND b.DELETE_FLAG = '0'
<include refid="tElecEmployeeInfo_where"/> <include refid="tElecEmployeeInfo_where"/>
</where> </where>
GROUP BY a.EMP_IDCARD GROUP BY a.EMP_IDCARD,a.CREATE_TIME
ORDER BY a.CREATE_TIME desc ORDER BY a.CREATE_TIME desc
</select> </select>
</mapper> </mapper>
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