This commit is contained in:
parent
7e66fc3ca9
commit
9b9ee02178
|
@ -1,9 +1,6 @@
|
|||
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;
|
||||
|
@ -25,10 +22,6 @@ 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;
|
||||
|
@ -38,7 +31,6 @@ 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.*;
|
||||
|
@ -131,33 +123,32 @@ public class PersonnelController extends BaseController {
|
|||
String fileName = URLEncoder.encode("企业人员申报.xlsx", StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
|
||||
Map<String, List<String>> dicData = getDictData();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// .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();
|
||||
|
|
|
@ -28,10 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -102,13 +99,19 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
|
|||
if (places.stream().anyMatch(e -> personnelService.count(Wrappers.lambdaQuery(Personnel.class).eq(Personnel::getRecruitNumber, e.getOdd())) > 0)) {
|
||||
return AjaxResult.fail("招聘单号已被使用!");
|
||||
}
|
||||
|
||||
places.forEach(e -> {
|
||||
Organization organization = organizationMapper.selectById(e.getOrganizationId());
|
||||
List<Places> placesList = placesMapper.selectList(Wrappers.lambdaQuery(Places.class).eq(Places::getOrganizationId, organization.getId()));
|
||||
long sum = placesList.stream().map(Places::getSum).mapToLong(Long::longValue).sum();
|
||||
CompanyName companyName = companyNameMapper.selectById(organization.getCompanyId());
|
||||
companyName.setResidualNumber(companyName.getResidualNumber() + sum);
|
||||
companyNameMapper.updateById(companyName);
|
||||
});
|
||||
int i = organizationMapper.deleteBatchIds(asList);
|
||||
if (i > 0) {
|
||||
personnelIndicatorsMapper.delete(new LambdaQueryWrapper<PersonnelIndicators>().in(PersonnelIndicators::getOrganizationId, asList));
|
||||
recruitmentMapper.delete(new LambdaQueryWrapper<Recruitment>().in(Recruitment::getCompanyId, asList));
|
||||
auditMapper.delete(new LambdaQueryWrapper<Audit>().eq(Audit::getPerType, ArgsConst.RECRUITMENT).in(Audit::getPersonnelId, asList));
|
||||
auditMapper.delete(new LambdaQueryWrapper<Audit>().eq(Audit::getPerType, ArgsConst.PERSONNEL_INDICATORS).in(Audit::getPersonnelId, asList));
|
||||
auditMapper.delete(new LambdaQueryWrapper<Audit>().in(Audit::getPerType, ArgsConst.RECRUITMENT, ArgsConst.PERSONNEL_INDICATORS).in(Audit::getPersonnelId, asList));
|
||||
return AjaxResult.ok().msg("删除成功!");
|
||||
}
|
||||
return AjaxResult.fail().msg("删除失败!");
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.ydool.common.base.BaseService;
|
|||
import com.ydool.common.cache.ConfigCache;
|
||||
import com.ydool.common.constant.ArgsConst;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.common.exception.ResultException;
|
||||
import com.ydool.common.utils.CacheUtil;
|
||||
import com.ydool.common.utils.ColumnUtil;
|
||||
import com.ydool.common.utils.EasyExcelAlibabaUtil;
|
||||
|
@ -648,8 +649,8 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
personnel.setCompanyName(selectOne.getId());
|
||||
personnel.setSocialCreditCode(selectOne.getCreditCode());
|
||||
}
|
||||
personnel.setBirthday(birthday(personnelExportVO.getNumberId()));
|
||||
personnel.setRetirementTime(retirementTime(personnelExportVO.getNumberId()));
|
||||
personnel.setBirthday(retirementTime(personnelExportVO.getNumberId(), "birthday"));
|
||||
personnel.setRetirementTime(retirementTime(personnelExportVO.getNumberId(), "retirementTime"));
|
||||
personnel.setFreshGraduate("是".equals(personnelExportVO.getFreshGraduate()) ? "1" : "0");
|
||||
personnel.setGender("男".equals(personnelExportVO.getGender()) ? "1" : "女".equals(personnelExportVO.getGender()) ? "0" : "2");
|
||||
// 保存
|
||||
|
@ -763,12 +764,6 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
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() + " 姓名不能为空 ");
|
||||
}
|
||||
|
@ -785,8 +780,8 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
if (selectOne != null) {
|
||||
failMsgVO.setSocialCreditCode(selectOne.getCreditCode());
|
||||
}
|
||||
failMsgVO.setBirthday(birthday(personnelExportVO.getNumberId()));
|
||||
failMsgVO.setRetirementTime(retirementTime(personnelExportVO.getNumberId()));
|
||||
failMsgVO.setBirthday(retirementTime(personnelExportVO.getNumberId(), "birthday"));
|
||||
failMsgVO.setRetirementTime(retirementTime(personnelExportVO.getNumberId(), "retirementTime"));
|
||||
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())));
|
||||
|
||||
|
@ -794,6 +789,8 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
if (pOptional.get() >= placesOptional.get().getSum()) {
|
||||
failMsgVO.setFailMsg("招聘名额已用完!");
|
||||
}
|
||||
} else {
|
||||
failMsgVO.setFailMsg("招聘单号不存在!");
|
||||
}
|
||||
|
||||
return failMsgVO;
|
||||
|
@ -804,37 +801,31 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
|
|||
* @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) {
|
||||
public LocalDate retirementTime(String numberId, String type) {
|
||||
if (StrUtil.isBlank(numberId)) {
|
||||
throw new ResultException(" 身份证号不能为空 ");
|
||||
}
|
||||
if (!IdcardUtil.isValidCard(numberId)) {
|
||||
throw new ResultException(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);
|
||||
LocalDate dateParam;
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateParam = LocalDate.parse(birthday, df);
|
||||
if (type.equals("retirementTime")) {
|
||||
String org_gender = numberId.substring(16, 17);
|
||||
String sex = Integer.parseInt(org_gender) % 2 == 1 ? "男" : "女";
|
||||
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);
|
||||
dateParam = LocalDate.parse(dateStr, df);
|
||||
} else {
|
||||
dateParam = LocalDate.parse(birthday, df);
|
||||
}
|
||||
System.out.println("String => LocalDate: " + dateParam);
|
||||
return dateParam;
|
||||
}
|
||||
|
||||
|
||||
public String verifyIds(String[] ids, String type) {
|
||||
String message = "";
|
||||
for (String id : ids) {
|
||||
|
|
Loading…
Reference in New Issue