修改导入模板
This commit is contained in:
parent
ac5577fecc
commit
109ac5d32e
|
@ -1,5 +1,9 @@
|
|||
package com.ydool.staff.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import com.ydool.common.base.BaseController;
|
||||
import com.ydool.common.constant.UrlConstant;
|
||||
|
@ -8,31 +12,37 @@ import com.ydool.staff.dto.PersonnelDto;
|
|||
import com.ydool.staff.dto.PersonnelUpdateDto;
|
||||
import com.ydool.staff.entity.SelectRequest;
|
||||
import com.ydool.staff.excel.ExcelPersonnel;
|
||||
import com.ydool.staff.request.ChangeRequest;
|
||||
import com.ydool.staff.excel.PersonnelExportVO;
|
||||
import com.ydool.staff.request.GiveAuditRequest;
|
||||
import com.ydool.staff.request.PersonnelDeleteRequest;
|
||||
import com.ydool.staff.request.PersonnelRequest;
|
||||
import com.ydool.staff.request.PersonnelUpdateRequest;
|
||||
import com.ydool.staff.service.IAttachmentService;
|
||||
import com.ydool.staff.service.IPersonnelService;
|
||||
import com.ydool.system.entity.DictData;
|
||||
import com.ydool.system.service.impl.DictDataServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.ss.usermodel.DataValidation;
|
||||
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
||||
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author msh
|
||||
|
@ -48,6 +58,8 @@ public class PersonnelController extends BaseController {
|
|||
private IPersonnelService personnelService;
|
||||
@Autowired
|
||||
IAttachmentService attachmentService;
|
||||
@Autowired
|
||||
DictDataServiceImpl dataService;
|
||||
|
||||
@PostMapping("personnelList")
|
||||
@ApiOperation(value = "人员列表", response = PersonnelDto.class)
|
||||
|
@ -79,11 +91,13 @@ public class PersonnelController extends BaseController {
|
|||
public AjaxResult savePersonnel(@Validated @RequestBody PersonnelRequest personnelRequest) {
|
||||
return personnelService.savePersonnel(personnelRequest);
|
||||
}
|
||||
|
||||
@PostMapping(value = "deletePersonnel")
|
||||
@ApiOperation(value = "删除/批量删除人员", response = PersonnelDeleteRequest.class)
|
||||
public AjaxResult deletePersonnel(@RequestBody PersonnelDeleteRequest request) {
|
||||
return personnelService.deleteByIds(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "updatePersonnel")
|
||||
@ApiOperation(value = "修改人员")
|
||||
public AjaxResult updatePersonnel(@RequestBody PersonnelUpdateRequest personnelDeleteRequest) {
|
||||
|
@ -108,6 +122,83 @@ public class PersonnelController extends BaseController {
|
|||
personnelService.export(personnelParam, response);
|
||||
}
|
||||
|
||||
@GetMapping("import-template")
|
||||
@ApiOperation(value = "导入模板")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
String fileName = URLEncoder.encode("企业人员申报.xlsx", StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
|
||||
Map<String, List<String>> dicData = getDictData();
|
||||
|
||||
// 创建ExcelWriter对象并指定模板
|
||||
EasyExcel.write(response.getOutputStream(), PersonnelExportVO.class)
|
||||
.registerWriteHandler(new SheetWriteHandler() {
|
||||
@Override
|
||||
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
Field[] declaredFields = writeSheetHolder.getClazz().getDeclaredFields();
|
||||
// 创建约束,指定下拉列表的选项
|
||||
for (int i = 0; i < declaredFields.length; i++) {
|
||||
String name = declaredFields[i].getName();
|
||||
List<String> listOfValues = dicData.get(name);
|
||||
if (listOfValues != null && !listOfValues.isEmpty()) {
|
||||
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 20000, i, i);
|
||||
DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper();
|
||||
DataValidationConstraint constraint = helper.createExplicitListConstraint(listOfValues.toArray(new String[0]));
|
||||
DataValidation dataValidation = helper.createValidation(constraint, cellRangeAddressList);
|
||||
dataValidation.setShowErrorBox(true);
|
||||
writeSheetHolder.getSheet().addValidationData(dataValidation);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.sheet("企业人员申报").doWrite(new ArrayList<PersonnelExportVO>()); // 这里传null是因为我们只是导出模板,没有数据需要写入
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getDictData() {
|
||||
Map<String, String> codeKeyMap = getStringStringMap();
|
||||
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
codeKeyMap.forEach((code, key) -> {
|
||||
List<DictData> dictDataList = dataService.listByCode(code);
|
||||
List<String> dataList = dictDataList.stream().map(DictData::getLabel).collect(Collectors.toList());
|
||||
map.put(key, dataList);
|
||||
});
|
||||
|
||||
List<DictData> dictSex = dataService.listByCode("t_dict_sex");
|
||||
List<String> gender = dictSex.stream().map(DictData::getValue).collect(Collectors.toList());
|
||||
map.put("gender", gender);
|
||||
map.put("personnelCharacter", Arrays.asList("年薪人员", "非年薪人员"));
|
||||
map.put("freshGraduate", Arrays.asList("是", "否"));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String, String> getStringStringMap() {
|
||||
Map<String, String> codeKeyMap = new HashMap<>();
|
||||
codeKeyMap.put("t_dict_nation", "nation");
|
||||
codeKeyMap.put("t_dict_politics_status", "politicsStatus");
|
||||
codeKeyMap.put("t_dict_education", "education");
|
||||
codeKeyMap.put("t_dict_specialty_name", "jobTitle");
|
||||
codeKeyMap.put("t_dict_position", "position");
|
||||
codeKeyMap.put("t_dict_personnel_type", "personnelType");
|
||||
codeKeyMap.put("t_dict_department", "presentDept");
|
||||
codeKeyMap.put("t_dict_contract_form", "contractModality");
|
||||
codeKeyMap.put("t_dict_hire", "hireType");
|
||||
codeKeyMap.put("t_dict_credentials", "qualification");
|
||||
codeKeyMap.put("t_dict_staff_state", "workState");
|
||||
return codeKeyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入员工
|
||||
*
|
||||
|
|
|
@ -7,10 +7,10 @@ import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
|||
import com.alibaba.excel.annotation.write.style.HeadStyle;
|
||||
import com.ydool.common.converter.EasyExcelLocalDateConverter;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
|
@ -31,16 +31,16 @@ public class ExcelPersonnel {
|
|||
private String socialCreditCode;
|
||||
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ExcelProperty("企业名称")
|
||||
@ApiModelProperty(value = "企业名称")
|
||||
private String companyName;
|
||||
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ExcelProperty("性别")
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String gender;
|
||||
|
|
|
@ -2,38 +2,37 @@ package com.ydool.staff.excel;
|
|||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadStyle;
|
||||
import com.ydool.common.converter.EasyExcelLocalDateConverter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(20)
|
||||
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
|
||||
@ContentStyle(verticalAlignment = VerticalAlignment.CENTER)
|
||||
public class PersonnelExportVO {
|
||||
|
||||
@ExcelProperty(value = "统一社会信用代码" )
|
||||
private String socialCreditCode;
|
||||
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ExcelProperty("企业名称")
|
||||
private String companyName;
|
||||
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String userName;
|
||||
|
||||
|
||||
@ExcelProperty("性别")
|
||||
private String gender;
|
||||
|
||||
|
||||
@ExcelProperty(value = "出生日期" , converter = EasyExcelLocalDateConverter.class)
|
||||
private LocalDate birthday;
|
||||
|
||||
|
||||
@ExcelProperty("身份证号")
|
||||
private String numberId;
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class PersonnelExportVO {
|
|||
private String hireType;
|
||||
|
||||
|
||||
@ExcelProperty("执业资格证书")
|
||||
@ExcelProperty("执业资格")
|
||||
private String qualification;
|
||||
|
||||
|
||||
|
@ -90,7 +89,7 @@ public class PersonnelExportVO {
|
|||
private String personnelType;
|
||||
|
||||
|
||||
@ExcelProperty("工作状态")
|
||||
@ExcelProperty("职工状态")
|
||||
private String workState;
|
||||
|
||||
|
||||
|
@ -106,10 +105,6 @@ public class PersonnelExportVO {
|
|||
private LocalDate hireDate;
|
||||
|
||||
|
||||
@ExcelProperty(value = "退休时间", converter = EasyExcelLocalDateConverter.class)
|
||||
private LocalDate retirementTime;
|
||||
|
||||
|
||||
@ExcelProperty(value = "离职时间", converter = EasyExcelLocalDateConverter.class)
|
||||
private LocalDate resignationTime;
|
||||
|
||||
|
@ -130,21 +125,4 @@ public class PersonnelExportVO {
|
|||
private String remark;
|
||||
|
||||
|
||||
@ExcelProperty("初审意见")
|
||||
private String firstTrialRemark;
|
||||
|
||||
|
||||
@ExcelProperty("终审意见")
|
||||
private String finalTrialRemark;
|
||||
|
||||
|
||||
@ExcelProperty("变更标志")
|
||||
private String alterationSign;
|
||||
|
||||
|
||||
@ExcelProperty("单据状态")
|
||||
private String receipts;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.ydool.staff.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadStyle;
|
||||
import com.ydool.common.converter.EasyExcelLocalDateConverter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
@ -14,8 +18,10 @@ import java.time.LocalDate;
|
|||
* @date 2023/2/14 11:55
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(20)
|
||||
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
|
||||
@ContentStyle(verticalAlignment = VerticalAlignment.CENTER)
|
||||
public class PersonnelFailMsgVO {
|
||||
|
||||
@ExcelProperty("统一社会信用代码")
|
||||
|
@ -133,22 +139,6 @@ public class PersonnelFailMsgVO {
|
|||
private String remark;
|
||||
|
||||
|
||||
@ExcelProperty("初审意见")
|
||||
private String firstTrialRemark;
|
||||
|
||||
|
||||
@ExcelProperty("终审意见")
|
||||
private String finalTrialRemark;
|
||||
|
||||
|
||||
@ExcelProperty("变更标志")
|
||||
private String alterationSign;
|
||||
|
||||
|
||||
|
||||
@ExcelProperty("单据状态")
|
||||
private String receipts;
|
||||
|
||||
@ExcelProperty(value = "结果")
|
||||
private String failMsg;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -93,6 +94,15 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
|
|||
if (CollectionUtil.isEmpty(asList)) {
|
||||
return AjaxResult.fail().msg("Id不能为空!");
|
||||
} else {
|
||||
List<String> organizationIds = organizationMapper.selectList(Wrappers.lambdaQuery(Organization.class).eq(Organization::getAuditState, 3).in(Organization::getId, asList))
|
||||
.stream().map(Organization::getId).collect(Collectors.toList());
|
||||
|
||||
List<Places> places = placesMapper.selectList(Wrappers.lambdaQuery(Places.class).in(Places::getOrganizationId, organizationIds));
|
||||
|
||||
if (places.stream().anyMatch(e -> personnelService.count(Wrappers.lambdaQuery(Personnel.class).eq(Personnel::getRecruitNumber, e.getOdd())) > 0)) {
|
||||
return AjaxResult.fail("招聘单号已被使用!");
|
||||
}
|
||||
|
||||
int i = organizationMapper.deleteBatchIds(asList);
|
||||
if (i > 0) {
|
||||
personnelIndicatorsMapper.delete(new LambdaQueryWrapper<PersonnelIndicators>().in(PersonnelIndicators::getOrganizationId, asList));
|
||||
|
|
|
@ -11,6 +11,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.base.BaseService;
|
||||
import com.ydool.common.cache.ConfigCache;
|
||||
|
@ -19,21 +20,13 @@ import com.ydool.common.data.dto.AjaxResult;
|
|||
import com.ydool.common.utils.CacheUtil;
|
||||
import com.ydool.common.utils.ColumnUtil;
|
||||
import com.ydool.common.utils.EasyExcelAlibabaUtil;
|
||||
import com.ydool.oa.workFlow.data.entity.WorkFlow;
|
||||
import com.ydool.oa.workFlow.data.entity.WorkFlowNotice;
|
||||
import com.ydool.oa.workFlow.service.WorkFlowNoticeService;
|
||||
import com.ydool.staff.dto.AttachmentDto;
|
||||
import com.ydool.staff.dto.PersonnelByExchangeDto;
|
||||
import com.ydool.staff.dto.PersonnelDto;
|
||||
import com.ydool.staff.dto.PersonnelUpdateDto;
|
||||
import com.ydool.staff.entity.Alteration;
|
||||
import com.ydool.staff.entity.Attachment;
|
||||
import com.ydool.staff.entity.Audit;
|
||||
import com.ydool.staff.entity.CompanyName;
|
||||
import com.ydool.staff.entity.Exchange;
|
||||
import com.ydool.staff.entity.Personnel;
|
||||
import com.ydool.staff.entity.PersonnelMiddle;
|
||||
import com.ydool.staff.entity.SelectRequest;
|
||||
import com.ydool.staff.entity.*;
|
||||
import com.ydool.staff.excel.ExcelPersonnel;
|
||||
import com.ydool.staff.excel.PersonnelExportVO;
|
||||
import com.ydool.staff.excel.PersonnelFailMsgVO;
|
||||
|
@ -54,32 +47,25 @@ import com.ydool.staff.service.IAttachmentService;
|
|||
import com.ydool.staff.service.IAuditService;
|
||||
import com.ydool.staff.service.IPersonnelMiddleService;
|
||||
import com.ydool.staff.service.IPersonnelService;
|
||||
import com.ydool.system.entity.Config;
|
||||
import com.ydool.system.entity.Dept;
|
||||
import com.ydool.system.entity.User;
|
||||
import com.ydool.system.entity.*;
|
||||
import com.ydool.system.mapper.ConfigMapper;
|
||||
import com.ydool.system.mapper.DeptMapper;
|
||||
import com.ydool.system.mapper.UserMapper;
|
||||
import com.ydool.system.service.impl.DictDataServiceImpl;
|
||||
import com.ydool.system.service.impl.DictTypeServiceImpl;
|
||||
import com.ydool.system.service.impl.UserServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -135,6 +121,10 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
@Autowired
|
||||
DictDataServiceImpl dictDataService;
|
||||
@Autowired
|
||||
DictTypeServiceImpl dictTypeService;
|
||||
|
||||
/**
|
||||
* 人员列表
|
||||
|
@ -350,7 +340,12 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
PersonnelMiddle middle = new PersonnelMiddle();
|
||||
String type = ArgsConst.CHANGE;
|
||||
PersonnelMiddle personnelMiddle = personnelMiddleMapper.selectOne(new LambdaQueryWrapper<PersonnelMiddle>().eq(PersonnelMiddle::getAfterId, request.getId()).eq(PersonnelMiddle::getState, "1"));
|
||||
String id = null;String card = null;String jobTitle = null;String engage = null;String education =null;String audit = null;
|
||||
String id = null;
|
||||
String card = null;
|
||||
String jobTitle = null;
|
||||
String engage = null;
|
||||
String education = null;
|
||||
String audit = null;
|
||||
if (ObjectUtil.isNotNull(personnelMiddle)) {
|
||||
id = personnelMiddle.getBeforeId();
|
||||
card = StringUtils.join(saveFilePath(cardFiles, ArgsConst.CARD_FILE, type, id), ',');
|
||||
|
@ -496,7 +491,8 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
for (AttachmentRequest request : file) {
|
||||
if (ArgsConst.UPDATE.equals(args)) {
|
||||
attachmentService.deleteById(type, id);
|
||||
} if (ArgsConst.CHANGE.equals(args)) {
|
||||
}
|
||||
if (ArgsConst.CHANGE.equals(args)) {
|
||||
attachmentService.deleteById(type, id);
|
||||
}
|
||||
path.add(request.getPath());
|
||||
|
@ -611,39 +607,34 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
if (ObjectUtil.isNotEmpty(dept)) {
|
||||
excelPersonnel.setPresentDept(dept.getName());
|
||||
}
|
||||
excelPersonnel.setGender("1".equals(excelPersonnel.getGender())?"男":"女");
|
||||
excelPersonnel.setGender("1".equals(excelPersonnel.getGender()) ? "男" : "0".equals(excelPersonnel.getGender()) ? "女" : "未知");
|
||||
excelPersonnel.setFreshGraduate("1".equals(excelPersonnel.getFreshGraduate()) ? "是" : "否");
|
||||
}
|
||||
String fileName = "企业人员申报" + System.currentTimeMillis() + ".xlsx";
|
||||
Set<String> includeColumnFiledNames = new HashSet<>();
|
||||
for (String s : param.getIds()) {
|
||||
includeColumnFiledNames.add(s);
|
||||
}
|
||||
Set<String> includeColumnFiledNames = new HashSet<>(Arrays.asList(param.getIds()));
|
||||
// 导出
|
||||
EasyExcelAlibabaUtil.exportDownload(response, ExcelPersonnel.class, personnelList, fileName, includeColumnFiledNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult importPersonnel(MultipartFile excl) {
|
||||
//判断文件类型
|
||||
String reg = ".+(.xlsx)$";
|
||||
String suffix = FileUtil.getSuffix(excl.getOriginalFilename());
|
||||
if (!Pattern.matches(reg, excl.getOriginalFilename())) {
|
||||
return AjaxResult.fail("必须上传后缀为" + suffix + "的文件");
|
||||
}
|
||||
if (!"企业人员申报模板.xlsx".equals(excl.getOriginalFilename())){
|
||||
return AjaxResult.fail("必须上传 企业人员申报模板.xlsx 文件");
|
||||
if (!"企业人员申报.xlsx".equals(excl.getOriginalFilename())) {
|
||||
return AjaxResult.fail("必须上传 企业人员申报.xlsx 文件");
|
||||
}
|
||||
// 导出数据
|
||||
List<PersonnelFailMsgVO> failList = new ArrayList<>();
|
||||
if (!excl.isEmpty()) {
|
||||
List<PersonnelExportVO> personnelExportVOS = EasyExcelAlibabaUtil.excelToList(excl,
|
||||
PersonnelExportVO.class);
|
||||
List<PersonnelExportVO> personnelExportVOS = EasyExcelAlibabaUtil.excelToList(excl, PersonnelExportVO.class);
|
||||
if (CollectionUtil.isEmpty(personnelExportVOS)) {
|
||||
return AjaxResult.fail("模板必须要有数据");
|
||||
return AjaxResult.fail("导入数据不能为空!");
|
||||
}
|
||||
for (PersonnelExportVO personnelExportVO : personnelExportVOS) {
|
||||
System.out.println("通讯录信息" + personnelExportVO);
|
||||
// 校验通讯录信息
|
||||
PersonnelFailMsgVO failMsgVO = checkPersonnelExportVO(personnelExportVO);
|
||||
// 错误数据 不保存
|
||||
|
@ -652,17 +643,24 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
} else {
|
||||
// 转义
|
||||
Personnel personnel = BeanUtil.copyProperties(personnelExportVO, Personnel.class);
|
||||
CompanyName selectOne = companyNameMapper.selectOne(Wrappers.lambdaQuery(CompanyName.class).eq(CompanyName::getCompanyName, personnelExportVO.getCompanyName()));
|
||||
if (selectOne != null) {
|
||||
personnel.setCompanyName(selectOne.getId());
|
||||
personnel.setSocialCreditCode(selectOne.getCreditCode());
|
||||
}
|
||||
personnel.setBirthday(birthday(personnelExportVO.getNumberId()));
|
||||
personnel.setRetirementTime(retirementTime(personnelExportVO.getNumberId()));
|
||||
personnel.setFreshGraduate("是".equals(personnelExportVO.getFreshGraduate()) ? "1" : "0");
|
||||
personnel.setGender("男".equals(personnelExportVO.getGender()) ? "1" : "女".equals(personnelExportVO.getGender()) ? "0" : "2");
|
||||
// 保存
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + (save(personnel) ? "导入成功" : "导入失败"));
|
||||
failList.add(failMsgVO);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 导出导入结果
|
||||
String download = EasyExcelAlibabaUtil.download(PersonnelFailMsgVO.class, failList, "通讯录导入结果");
|
||||
String download = EasyExcelAlibabaUtil.download(PersonnelFailMsgVO.class, failList, "企业人员申报导入结果");
|
||||
return AjaxResult.ok().data(download).msg("导入完成");
|
||||
}
|
||||
|
||||
|
@ -762,21 +760,78 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
PersonnelFailMsgVO failMsgVO = BeanUtil.copyProperties(personnelExportVO, PersonnelFailMsgVO.class);
|
||||
failMsgVO.setFailMsg("");
|
||||
// 联系人姓名不能为空
|
||||
if (StrUtil.isBlank(personnelExportVO.getCompanyName())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 企业名称不能为空 ");
|
||||
}
|
||||
if (StrUtil.isBlank(personnelExportVO.getNumberId())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 身份证号不能为空 ");
|
||||
}
|
||||
if (!IdcardUtil.isValidCard(personnelExportVO.getNumberId())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 身份证号不正确 ");
|
||||
}
|
||||
if (StrUtil.isBlank(personnelExportVO.getUserName())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 姓名不能为空 ");
|
||||
}
|
||||
//校验性别
|
||||
if (!"男".equals(personnelExportVO.getGender()) && !"女".equals(personnelExportVO.getGender())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 请输入正确性别,男或女 ");
|
||||
if (personnelExportVO.getHireDate() == null) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 入职日期不能为空 ");
|
||||
}
|
||||
//校验性别
|
||||
if (!"是".equals(personnelExportVO.getFreshGraduate()) && !"否".equals(personnelExportVO.getGender())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 请输入正确选项,是或否 ");
|
||||
if (StrUtil.isBlank(personnelExportVO.getRecruitNumber())) {
|
||||
failMsgVO.setFailMsg(failMsgVO.getFailMsg() + " 人员招聘单号不能为空 ");
|
||||
}
|
||||
if (personnelExportVO.getPersonnelCharacter().equals("非年薪人员")) {
|
||||
personnelExportVO.setAnnualSalary(0);
|
||||
}
|
||||
CompanyName selectOne = companyNameMapper.selectOne(Wrappers.lambdaQuery(CompanyName.class).eq(CompanyName::getCompanyName, personnelExportVO.getCompanyName()));
|
||||
if (selectOne != null) {
|
||||
failMsgVO.setSocialCreditCode(selectOne.getCreditCode());
|
||||
}
|
||||
failMsgVO.setBirthday(birthday(personnelExportVO.getNumberId()));
|
||||
failMsgVO.setRetirementTime(retirementTime(personnelExportVO.getNumberId()));
|
||||
Optional<Integer> pOptional = Optional.ofNullable(personnelMapper.selectCount(Wrappers.lambdaQuery(Personnel.class).eq(Personnel::getRecruitNumber, personnelExportVO.getRecruitNumber())));
|
||||
Optional<Places> placesOptional = Optional.ofNullable(placesMapper.selectOne(Wrappers.lambdaQuery(Places.class).eq(Places::getOdd, personnelExportVO.getRecruitNumber())));
|
||||
|
||||
if (pOptional.isPresent() && placesOptional.isPresent() && pOptional.get() > placesOptional.get().getSum()) {
|
||||
failMsgVO.setFailMsg("招聘名额已用完!");
|
||||
}
|
||||
|
||||
return failMsgVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算退休时间
|
||||
* @param numberId
|
||||
* @return
|
||||
*/
|
||||
public LocalDate retirementTime(String numberId) {
|
||||
// 330225 1996 09 05 0012
|
||||
String org_birthday = numberId.substring(6, 14);
|
||||
String org_gender = numberId.substring(16, 17);
|
||||
String sex = Integer.parseInt(org_gender) % 2 == 1 ? "男" : "女";
|
||||
String birthday = org_birthday.substring(0, 4) + "-" + org_birthday.substring(4, 6) + "-" + org_birthday.substring(6, 8);
|
||||
System.out.println("birthday = " + birthday);
|
||||
int plusNum = sex.equals("男") ? 60 : 50;
|
||||
String dateStr = (Integer.parseInt(org_birthday.substring(0, 4)) + plusNum) + "-" + org_birthday.substring(4, 6) + "-" + org_birthday.substring(6, 8);
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateParam = LocalDate.parse(dateStr, df);
|
||||
System.out.println("String => LocalDate: " + dateParam);
|
||||
return dateParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 出手日期
|
||||
* @param numberId
|
||||
* @return
|
||||
*/
|
||||
public LocalDate birthday(String numberId) {
|
||||
// 330225 1996 09 05 0012
|
||||
String org_birthday = numberId.substring(6, 14);
|
||||
String birthday = org_birthday.substring(0, 4) + "-" + org_birthday.substring(4, 6) + "-" + org_birthday.substring(6, 8);
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateParam = LocalDate.parse(birthday, df);
|
||||
System.out.println("String => LocalDate: " + dateParam);
|
||||
return dateParam;
|
||||
}
|
||||
|
||||
|
||||
public String verifyIds(String[] ids, String type) {
|
||||
String message = "";
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.base.BaseService;
|
||||
|
@ -18,6 +19,7 @@ import com.ydool.system.service.IDictDataService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -215,5 +217,15 @@ public class DictDataServiceImpl extends BaseService<DictDataMapper, DictData> i
|
|||
if (ObjectUtil.isNull(dictData)) return "";
|
||||
return dictData.getLabel();
|
||||
}
|
||||
|
||||
public List<DictData> listByCode(String typeCode) {
|
||||
DictType grapeDictType = dictTypeService.getOne(new LambdaQueryWrapper<DictType>().eq(DictType::getCode, typeCode));
|
||||
if (grapeDictType == null) return new ArrayList<>();
|
||||
List<DictData> list = list(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDataType, grapeDictType.getCode())
|
||||
.eq(DictData::getStatus, 1)
|
||||
.orderByAsc(DictData::getSortNo));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue