|
@@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.sop.business.bean.dto.CustomImportDto;
|
|
|
import com.qmth.sop.business.bean.dto.SysMessageExportDto;
|
|
|
import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
|
|
|
-import com.qmth.sop.business.bean.result.SysCustomResult;
|
|
|
+import com.qmth.sop.business.bean.params.UserArchivesParam;
|
|
|
+import com.qmth.sop.business.bean.query.UserArchivesQuery;
|
|
|
import com.qmth.sop.business.bean.result.SysMessageResult;
|
|
|
import com.qmth.sop.business.bean.result.TBDingCountQueryResult;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
@@ -14,10 +15,10 @@ import com.qmth.sop.business.templete.service.TaskLogicService;
|
|
|
import com.qmth.sop.business.util.ImportExportUtil;
|
|
|
import com.qmth.sop.business.util.excel.BasicExcelListener;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
-import com.qmth.sop.common.enums.FlowStatusEnum;
|
|
|
-import com.qmth.sop.common.enums.ProductTypeEnum;
|
|
|
-import com.qmth.sop.common.enums.UploadFileEnum;
|
|
|
+import com.qmth.sop.common.enums.*;
|
|
|
+import com.qmth.sop.common.util.DateDisposeUtils;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -63,6 +64,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
SysMessageService sysMessageService;
|
|
|
@Resource
|
|
|
TBDingService tbDingService;
|
|
|
+ @Resource
|
|
|
+ private SysSupplierService sysSupplierService;
|
|
|
+ @Resource
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
+ @Resource
|
|
|
+ private TBUserArchivesService tbUserArchivesService;
|
|
|
|
|
|
/**
|
|
|
* 处理导入人员档案数据
|
|
@@ -77,6 +84,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
InputStream inputStream = null;
|
|
|
try {
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
+ SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
inputStream = importExportUtil.getUploadFileInputStream(tbTask);
|
|
|
LinkedMultiValueMap<String, UserArchivesImportDto> userArchivesImportDtoLinkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
StringJoiner errorData = new StringJoiner("");
|
|
@@ -92,7 +100,84 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
map.computeIfAbsent(SystemConstant.EXCEL_DATA, v -> userArchivesImportDtoLinkedMultiValueMap);
|
|
|
map.computeIfAbsent(SystemConstant.EXCEL_DATA_ERROR, v -> errorData.toString());
|
|
|
|
|
|
- //TODO 处理数据逻辑
|
|
|
+ List<UserArchivesImportDto> userArchivesImportDtoList = userArchivesImportDtoLinkedMultiValueMap.get(BasicExcelListener.SUCCESS);
|
|
|
+ if (CollectionUtils.isNotEmpty(userArchivesImportDtoList)) {
|
|
|
+ List<String> supplierNameList = userArchivesImportDtoList.stream().map(UserArchivesImportDto::getSupplierName).distinct().collect(Collectors.toList());
|
|
|
+ Map<String, Long> roleMap = new HashMap<>();
|
|
|
+ List<SysRole> regionCoordinatorList = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.REGION_COORDINATOR));
|
|
|
+ if (CollectionUtils.isNotEmpty(regionCoordinatorList)) {
|
|
|
+ SysRole regionCoordinator = regionCoordinatorList.get(0);
|
|
|
+ roleMap.put(regionCoordinator.getType().getDesc(), regionCoordinator.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysRole> effectEngineerList = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.EFFECT_ENGINEER));
|
|
|
+ if (CollectionUtils.isNotEmpty(effectEngineerList)) {
|
|
|
+ SysRole effectEngineer = effectEngineerList.get(0);
|
|
|
+ roleMap.put(effectEngineer.getType().getDesc(), effectEngineer.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysRole> assistantEngineerList = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.ASSISTANT_ENGINEER));
|
|
|
+ if (CollectionUtils.isNotEmpty(assistantEngineerList)) {
|
|
|
+ SysRole assistantEngineer = assistantEngineerList.get(0);
|
|
|
+ roleMap.put(assistantEngineer.getType().getDesc(), assistantEngineer.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Long> supplierMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(supplierNameList)) {
|
|
|
+ List<SysSupplier> supplierList = sysSupplierService.list(new QueryWrapper<SysSupplier>().lambda().select(SysSupplier::getId, SysSupplier::getName).in(SysSupplier::getName, supplierNameList));
|
|
|
+ supplierMap = supplierList.stream().collect(Collectors.toMap(SysSupplier::getName, SysSupplier::getId));
|
|
|
+ }
|
|
|
+ for (UserArchivesImportDto userArchivesImportDto : userArchivesImportDtoList) {
|
|
|
+ UserArchivesParam userArchivesParam = new UserArchivesParam();
|
|
|
+ // TODO: 2023/8/15 临时生成编号方法
|
|
|
+ userArchivesParam.setCode(String.valueOf(SystemConstant.getDbUuid()));
|
|
|
+ userArchivesParam.setName(userArchivesImportDto.getName());
|
|
|
+ userArchivesParam.setProvince(userArchivesImportDto.getProvince());
|
|
|
+ userArchivesParam.setCity(userArchivesImportDto.getCity());
|
|
|
+ userArchivesParam.setArea(userArchivesImportDto.getArea());
|
|
|
+ userArchivesParam.setGender(GenderEnum.convertTitleToEnum(userArchivesImportDto.getGender()));
|
|
|
+ String identity = userArchivesImportDto.getIdentity();
|
|
|
+ userArchivesParam.setIdentity(identity);
|
|
|
+ List<TBUserArchives> tbUserArchivesList = tbUserArchivesService.list(new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getIdentity, identity));
|
|
|
+ if (tbUserArchivesList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("存在多个相同身份证异常[" + identity + "]");
|
|
|
+ } else if (tbUserArchivesList.size() == 1) {
|
|
|
+ // 身份证相同则编辑用户
|
|
|
+ userArchivesParam.setId(tbUserArchivesList.get(0).getId());
|
|
|
+ }
|
|
|
+ userArchivesParam.setEducation(EducationEnum.convertTitleToEnum(userArchivesImportDto.getEducation()));
|
|
|
+ userArchivesParam.setMobileNumber(userArchivesImportDto.getMobileNumber());
|
|
|
+ userArchivesParam.setEmail(userArchivesImportDto.getEmail());
|
|
|
+
|
|
|
+ String supplierName = userArchivesImportDto.getSupplierName();
|
|
|
+ Long supplierId = supplierMap.get(supplierName);
|
|
|
+ if (supplierId != null && supplierId > 0) {
|
|
|
+ userArchivesParam.setSupplierId(supplierId);
|
|
|
+ }
|
|
|
+ String archivesTimeStr = userArchivesImportDto.getArchivesTimeStr();
|
|
|
+ Long archivesTime = DateDisposeUtils.parseDate(archivesTimeStr).getTime();
|
|
|
+ userArchivesParam.setArchivesTime(archivesTime);
|
|
|
+
|
|
|
+ String roleNames = userArchivesImportDto.getRoleNames();
|
|
|
+ List<Long> roleIdList = new ArrayList<>();
|
|
|
+ for (String roleName : roleNames.split(",")) {
|
|
|
+ Long roleId = roleMap.get(roleName);
|
|
|
+ if (roleId != null && roleId > 0) {
|
|
|
+ roleIdList.add(roleId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userArchivesParam.setRoleIds(roleIdList.toArray(new Long[0]));
|
|
|
+ userArchivesParam.setAuthenticationScore(userArchivesImportDto.getAuthenticationScore());
|
|
|
+
|
|
|
+ String authenticationValidTimeStr = userArchivesImportDto.getAuthenticationValidTimeStr();
|
|
|
+ Long authenticationValidTime = DateDisposeUtils.parseDate(authenticationValidTimeStr).getTime();
|
|
|
+ userArchivesParam.setAuthenticationTime(authenticationValidTime);
|
|
|
+ userArchivesParam.setRemark(userArchivesImportDto.getRemark());
|
|
|
+ tbUserArchivesService.editUserArchives(userArchivesParam, requestUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
} finally {
|
|
|
if (Objects.nonNull(inputStream)) {
|
|
|
inputStream.close();
|
|
@@ -139,7 +224,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
sysCustom.setArea(e.getArea());
|
|
|
sysCustom.setCity(e.getCity());
|
|
|
sysCustom.setCode(e.getCode());
|
|
|
- ProductTypeEnum type=ProductTypeEnum.OFFICE.getTitle().equals(e.getType())?ProductTypeEnum.OFFICE:ProductTypeEnum.CLOUD_MARK;
|
|
|
+ ProductTypeEnum type = ProductTypeEnum.OFFICE.getTitle().equals(e.getType()) ? ProductTypeEnum.OFFICE : ProductTypeEnum.CLOUD_MARK;
|
|
|
sysCustom.setType(type);
|
|
|
sysCustom.setProvince(e.getProvince());
|
|
|
sysCustom.setPeoperDay(e.getPeoperDay());
|
|
@@ -181,10 +266,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
|
|
|
|
|
|
List<SysMessageResult> lists = sysMessageService.query((Long) map.get("noticeId"), (String) map.get("city"), (Long) map.get("supplierId"), (Boolean) map.get("status"));
|
|
|
- //List<SysMessageResult> 转化成 List<SysMessageExportDto>
|
|
|
+ //List<SysMessageResult> 转化成 List<SysMessageExportDto>
|
|
|
|
|
|
- List<SysMessageExportDto> sysMessageExportDtoList = lists.stream().map(e->{
|
|
|
- SysMessageExportDto dto=new SysMessageExportDto();
|
|
|
+ List<SysMessageExportDto> sysMessageExportDtoList = lists.stream().map(e -> {
|
|
|
+ SysMessageExportDto dto = new SysMessageExportDto();
|
|
|
dto.setCity(e.getCity());
|
|
|
dto.setCode(e.getCode());
|
|
|
dto.setCountry(e.getCountry());
|
|
@@ -193,12 +278,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
dto.setName(e.getName());
|
|
|
dto.setProvince(e.getProvince());
|
|
|
dto.setService(e.getService());
|
|
|
- dto.setStatus(e.getStatus()?"已阅":"未阅");
|
|
|
+ dto.setStatus(e.getStatus() ? "已阅" : "未阅");
|
|
|
dto.setSupplier(e.getSupplier());
|
|
|
//时间戳转化为日期字符串
|
|
|
dto.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(e.getReceiveTime()));
|
|
|
dto.setType(e.getType().getTitle());
|
|
|
- return dto;
|
|
|
+ return dto;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
EasyExcel.write(fileTemp, SysMessageExportDto.class).sheet("回执明细导出").doWrite(sysMessageExportDtoList);
|
|
@@ -221,7 +306,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
|
|
|
|
|
|
List<TBDingCountQueryResult> tbDingCountQueryResults = tbDingService.query((Long) map.get("serviceId"), (String) map.get("status"), (Long) map.get("createId"), (String) map.get("userName"), (Long) map.get("supplierId"), (String) map.get("String"), (String) map.get("sopNo"), (Long) map.get("days"));
|
|
|
- tbDingCountQueryResults.forEach(e->{
|
|
|
+ tbDingCountQueryResults.forEach(e -> {
|
|
|
e.setStatus(FlowStatusEnum.convertToEnum(e.getStatus()).getTitle());
|
|
|
});
|
|
|
EasyExcel.write(fileTemp, TBDingCountQueryResult.class).sheet("考勤打卡统计导出").doWrite(tbDingCountQueryResults);
|
|
@@ -250,11 +335,18 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
File fileTemp = null;
|
|
|
try {
|
|
|
fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
|
|
|
- //TODO 数据读取逻辑start
|
|
|
- List<UserArchivesImportDto> archivesImportDtoList = new ArrayList<>();
|
|
|
- archivesImportDtoList.add(new UserArchivesImportDto("1", "2", "123", "aaa", "bbb"));
|
|
|
- archivesImportDtoList.add(new UserArchivesImportDto("4", "5", "789", "ccc", "ddd"));
|
|
|
- //TODO 数据读取逻辑end
|
|
|
+ //数据读取逻辑start
|
|
|
+ UserArchivesQuery query = (UserArchivesQuery) map.get(SystemConstant.QUERY);
|
|
|
+ String city = query.getCity();
|
|
|
+ Long supplierId = query.getSupplierId();
|
|
|
+ String archivesName = query.getArchivesName();
|
|
|
+ RoleTypeEnum roleType = query.getRoleType();
|
|
|
+ Boolean authenticationStatus = query.getAuthenticationStatus();
|
|
|
+ Long archivesTimeStart = query.getArchivesTimeStart();
|
|
|
+ Long archivesTimeEnd = query.getArchivesTimeEnd();
|
|
|
+ Integer remainValidDay = query.getRemainValidDay();
|
|
|
+ List<UserArchivesImportDto> archivesImportDtoList = tbUserArchivesService.findExportData(city, supplierId, archivesName, roleType, authenticationStatus, archivesTimeStart, archivesTimeEnd, remainValidDay);
|
|
|
+ //数据读取逻辑end
|
|
|
EasyExcel.write(fileTemp, UserArchivesImportDto.class).sheet("人员档案导出").doWrite(archivesImportDtoList);
|
|
|
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.saveAttachment(fileTemp, UploadFileEnum.FILE);
|
|
@@ -267,6 +359,4 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+}
|