|
@@ -13,9 +13,14 @@ import com.zhongzheng.common.utils.poi.EasyPoiUtil;
|
|
|
import com.zhongzheng.modules.company.domain.Company;
|
|
|
import com.zhongzheng.modules.company.domain.CompanyCertificate;
|
|
|
import com.zhongzheng.modules.company.domain.CompanyDepartment;
|
|
|
+import com.zhongzheng.modules.company.service.ICompanyDepartmentService;
|
|
|
+import com.zhongzheng.modules.company.service.ICompanyService;
|
|
|
import com.zhongzheng.modules.staff.bo.*;
|
|
|
import com.zhongzheng.modules.staff.domain.*;
|
|
|
+import com.zhongzheng.modules.staff.service.IStaffService;
|
|
|
+import com.zhongzheng.modules.staff.vo.ExcelStaffCertificateVo;
|
|
|
import com.zhongzheng.modules.staff.vo.ExcelStaffVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -24,6 +29,7 @@ import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.modules.staff.mapper.StaffCertificateMapper;
|
|
|
import com.zhongzheng.modules.staff.vo.StaffCertificateVo;
|
|
|
import com.zhongzheng.modules.staff.service.IStaffCertificateService;
|
|
|
+import org.springframework.test.context.junit4.statements.SpringRepeat;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -37,6 +43,10 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
public class StaffCertificateServiceImpl extends ServiceImpl<StaffCertificateMapper, StaffCertificate> implements IStaffCertificateService {
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService iCompanyService;
|
|
|
+ @Autowired
|
|
|
+ private IStaffService iStaffService;
|
|
|
|
|
|
@Override
|
|
|
public StaffCertificateVo queryById(Long certificateId) {
|
|
@@ -50,19 +60,19 @@ public class StaffCertificateServiceImpl extends ServiceImpl<StaffCertificateMap
|
|
|
if (CollectionUtils.isEmpty(staffCertificateVos)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- staffCertificateVos.forEach(item->{
|
|
|
- if (ObjectUtil.isAllNotEmpty(item.getStartTime(),item.getEndTime())){
|
|
|
+ staffCertificateVos.forEach(item -> {
|
|
|
+ if (ObjectUtil.isAllNotEmpty(item.getStartTime(), item.getEndTime())) {
|
|
|
Date effectivedate = new Date(item.getEndTime() * 1000L);
|
|
|
- if (effectivedate.compareTo(new Date())>0){
|
|
|
+ if (effectivedate.compareTo(new Date()) > 0) {
|
|
|
item.setExpirationTime(0L);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//查询实时证书过期时间更新证书预警状态
|
|
|
StaffCertificate staffCertificate = new StaffCertificate();
|
|
|
staffCertificate.setUpdateTime(DateUtils.getNowTime());
|
|
|
staffCertificate.setWarningStatus(2);
|
|
|
staffCertificate.setStaffCertificateId(item.getStaffCertificateId());
|
|
|
this.baseMapper.updateById(staffCertificate);
|
|
|
- long l = DateUtil.between(effectivedate,new Date(), DateUnit.DAY);
|
|
|
+ long l = DateUtil.between(effectivedate, new Date(), DateUnit.DAY);
|
|
|
item.setWarningStatus(2);
|
|
|
item.setExpirationTime(l);
|
|
|
}
|
|
@@ -196,137 +206,89 @@ public class StaffCertificateServiceImpl extends ServiceImpl<StaffCertificateMap
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public Integer getStaffCertificateType(String StaffCertificateType) {
|
|
|
+ //公司类型判断
|
|
|
+ switch (StaffCertificateType) {
|
|
|
+ case "注册证书":
|
|
|
+ return 1;
|
|
|
+ case "技术职称":
|
|
|
+ return 2;
|
|
|
+ case "现场管理":
|
|
|
+ return 3;
|
|
|
+ case "安管三类":
|
|
|
+ return 4;
|
|
|
+ case "职业技能":
|
|
|
+ return 5;
|
|
|
+ case "待种作业":
|
|
|
+ return 6;
|
|
|
+ case "其他":
|
|
|
+ return 7;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean importStaffCertificateList(MultipartFile file) {
|
|
|
- List<ExcelStaffVo> excelStaffVos = EasyPoiUtil.importExcel(file, 1, 1, ExcelStaffVo.class);
|
|
|
- if (ObjectUtil.isEmpty(excelStaffVos)) {
|
|
|
+ List<ExcelStaffCertificateVo> excelStaffCertificateVos = EasyPoiUtil.importExcel(file, 0, 1, ExcelStaffCertificateVo.class);
|
|
|
+ if (ObjectUtil.isEmpty(excelStaffCertificateVos)) {
|
|
|
throw new CustomException("文档数据为空");
|
|
|
}
|
|
|
- Map<String, List<ExcelStaffVo>> excelList = excelStaffVos.stream().collect(Collectors.groupingBy(ExcelStaffVo::getIdCard));
|
|
|
+ Map<String, List<ExcelStaffCertificateVo>> excelList = excelStaffCertificateVos.stream().collect(Collectors.groupingBy(ExcelStaffCertificateVo::getIdCard));
|
|
|
+ ArrayList<StaffCertificateMajorInfo> staffCertificateMajorInfos = new ArrayList<>();
|
|
|
excelList.forEach((k, v) -> {
|
|
|
- List<ExcelStaffVo> excelStaffVosList = excelList.get(k);
|
|
|
- ExcelStaffVo excelStaffVo = excelStaffVosList.get(0);
|
|
|
- if (ObjectUtil.isAllNotEmpty(excelStaffVo.getStaffName(), excelStaffVo.getIdCard(), excelStaffVo.getTelephone(), excelStaffVo.getCompanyName())) {
|
|
|
- List<Company> companies = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, excelStaffVo.getCompanyName()).eq(Company::getStatus, 1));
|
|
|
+ List<ExcelStaffCertificateVo> excelStaffVosList = excelList.get(k);
|
|
|
+ ExcelStaffCertificateVo excelStaffCertificateVo = excelStaffVosList.get(0);
|
|
|
+ if (ObjectUtil.isAllNotEmpty(excelStaffCertificateVo.getStaffName(), excelStaffCertificateVo.getIdCard(), excelStaffCertificateVo.getCompanyName())) {
|
|
|
+ List<Company> companies = iCompanyService.list(new LambdaQueryWrapper<Company>().eq(Company::getCompanyName, excelStaffCertificateVo.getCompanyName()).eq(Company::getStatus, 1));
|
|
|
if (ObjectUtil.isNotEmpty(companies)) {
|
|
|
Company company = companies.get(0);
|
|
|
- Staff staff = new Staff();
|
|
|
- staff.setStaffName(excelStaffVo.getStaffName());
|
|
|
- staff.setIdCard(excelStaffVo.getIdCard());
|
|
|
- staff.setTelephone(excelStaffVo.getTelephone());
|
|
|
- staff.setEmail(excelStaffVo.getEmail());
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getSex())) {
|
|
|
- Integer sexType = getSexType(excelStaffVo.getSex());
|
|
|
- staff.setSex(Long.valueOf(sexType));
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getBirthday())) {
|
|
|
- String birthday = excelStaffVo.getBirthday();
|
|
|
- Long timeSec = DateUtils.dateTimeSec("yyyy/MM/dd", birthday);
|
|
|
- staff.setBirthday(timeSec);
|
|
|
- }
|
|
|
- staff.setNation(excelStaffVo.getNation());
|
|
|
- staff.setPoliticsFace(excelStaffVo.getPoliticsFace());
|
|
|
- staff.setHkLocation(excelStaffVo.getHkLocation());
|
|
|
- staff.setHomeAddress(excelStaffVo.getHomeAddress());
|
|
|
- staff.setCompanyId(company.getCompanyId());
|
|
|
- staff.setStaffNumber(excelStaffVo.getStaffNumber());
|
|
|
- staff.setCompanyName(company.getCompanyName());
|
|
|
- staff.setDepartmentName(excelStaffVo.getDepartmentName());
|
|
|
- List<CompanyDepartment> departments = iCompanyDepartmentService.list(new LambdaQueryWrapper<CompanyDepartment>().eq(CompanyDepartment::getDepartmentName, excelStaffVo.getDepartmentName()).eq(CompanyDepartment::getStatus, 1));
|
|
|
- if (ObjectUtil.isNotEmpty(departments)){
|
|
|
- CompanyDepartment companyDepartment = departments.get(0);
|
|
|
- staff.setDepartmentId(companyDepartment.getDepartmentId());
|
|
|
- }
|
|
|
- staff.setPosition(excelStaffVo.getPosition());
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getPositionStatus())) {
|
|
|
- staff.setPositionStatus(Long.valueOf(getPositionStatus(excelStaffVo.getPositionStatus())));
|
|
|
- }
|
|
|
- staff.setRecruitmentChannel(excelStaffVo.getRecruitmentChannel());
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getWorkDate())) {
|
|
|
- staff.setWorkDate(DateUtils.dateTimeSec("yyyy/MM/dd", excelStaffVo.getWorkDate()));
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getEntryDate())) {
|
|
|
- staff.setEntryDate(DateUtils.dateTimeSec("yyyy/MM/dd", excelStaffVo.getEntryDate()));
|
|
|
+ StaffCertificate staffCertificate = new StaffCertificate();
|
|
|
+ staffCertificate.setCompanyId(company.getCompanyId());
|
|
|
+ staffCertificate.setStaffName(excelStaffCertificateVo.getStaffName());
|
|
|
+ staffCertificate.setIdCard(excelStaffCertificateVo.getIdCard());
|
|
|
+ staffCertificate.setCompanyName(excelStaffCertificateVo.getCompanyName());
|
|
|
+ if (ObjectUtil.isNotEmpty(excelStaffCertificateVo.getCertificateType())) {
|
|
|
+ Integer certificateType = getStaffCertificateType(excelStaffCertificateVo.getCertificateType());
|
|
|
+ staffCertificate.setCertificateType(certificateType);
|
|
|
}
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getLeaveDate())) {
|
|
|
- staff.setLeaveDate(DateUtils.dateTimeSec("yyyy/MM/dd", excelStaffVo.getLeaveDate()));
|
|
|
+ staffCertificate.setCertificateName(excelStaffCertificateVo.getCertificateName());
|
|
|
+ staffCertificate.setCertificateAddress(excelStaffCertificateVo.getCertificateAddress());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(excelStaffCertificateVo.getStartTime())) {
|
|
|
+ String startTime = excelStaffCertificateVo.getStartTime();
|
|
|
+ Long timeSec = DateUtils.dateTimeSec("yyyy/MM/dd", startTime);
|
|
|
+ staffCertificate.setStartTime(timeSec);
|
|
|
}
|
|
|
- staff.setIssuingOrganization(excelStaffVo.getIssuingOrganization());
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getStartDate())) {
|
|
|
- staff.setStartDate(DateUtils.dateTimeSec("yyyy/MM/dd", excelStaffVo.getStartDate()));
|
|
|
+ if (ObjectUtil.isNotEmpty(excelStaffCertificateVo.getEndTime())) {
|
|
|
+ String endTime = excelStaffCertificateVo.getEndTime();
|
|
|
+ Long timeSec = DateUtils.dateTimeSec("yyyy/MM/dd", endTime);
|
|
|
+ staffCertificate.setEndTime(timeSec);
|
|
|
}
|
|
|
- if (ObjectUtil.isNotEmpty(excelStaffVo.getEndDate())) {
|
|
|
- staff.setEndDate(DateUtils.dateTimeSec("yyyy/MM/dd", excelStaffVo.getEndDate()));
|
|
|
+ List<Staff> staffs = iStaffService.list(new LambdaQueryWrapper<Staff>().eq(Staff::getIdCard, excelStaffCertificateVo.getIdCard()).eq(Staff::getStatus, 1));
|
|
|
+ if (ObjectUtil.isNotEmpty(staffs)) {
|
|
|
+ Staff staff = staffs.get(0);
|
|
|
+ staffCertificate.setStaffId(staff.getStaffId());
|
|
|
+ staffCertificate.setDepartmentId(staff.getDepartmentId());
|
|
|
+ staffCertificate.setDepartmentName(staff.getDepartmentName());
|
|
|
}
|
|
|
- staff.setCreateTime(DateUtils.getNowTime());
|
|
|
- staff.setUpdateTime(DateUtils.getNowTime());
|
|
|
- this.baseMapper.insert(staff);
|
|
|
+ staffCertificate.setCreateTime(DateUtils.getNowTime());
|
|
|
+ staffCertificate.setUpdateTime(DateUtils.getNowTime());
|
|
|
excelStaffVosList.forEach(item -> {
|
|
|
- List<Staff> staffList = this.baseMapper.selectList(new LambdaQueryWrapper<Staff>().eq(Staff::getIdCard, item.getIdCard()).eq(Staff::getStatus, 1));
|
|
|
- if (ObjectUtil.isNotEmpty(staffList)) {
|
|
|
- Staff staff1 = staffList.get(0);
|
|
|
- StaffEduBg staffEduBg = new StaffEduBg();
|
|
|
- if (ObjectUtil.isNotEmpty(item.getStartTime())) {
|
|
|
- staffEduBg.setStartDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getStartTime()));
|
|
|
+ StaffCertificateMajorInfo staffCertificateMajorInfo = new StaffCertificateMajorInfo();
|
|
|
+ staffCertificateMajorInfo.setCertificateMajor(item.getCertificateMajor());
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getEffectiveGo())) {
|
|
|
+ staffCertificateMajorInfo.setStartEffectiveDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getEffectiveGo()));
|
|
|
}
|
|
|
- if (ObjectUtil.isNotEmpty(item.getEndTime())) {
|
|
|
- staffEduBg.setEndDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getEndTime()));
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getEffectiveEnd())) {
|
|
|
+ staffCertificateMajorInfo.setEndEffectiveDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getEffectiveEnd()));
|
|
|
}
|
|
|
- staffEduBg.setStaffId(staff1.getStaffId());
|
|
|
- staffEduBg.setGraduationSchool(item.getGraduationSchool());
|
|
|
- staffEduBg.setMajor(item.getMajor());
|
|
|
- staffEduBg.setLearningType(Long.valueOf(getLearnIngType(item.getLearnType())));
|
|
|
- staffEduBg.setDegree(Long.valueOf(getLearnIngType(item.getLearnType())));
|
|
|
- staffEduBg.setCreateTime(DateUtils.getNowTime());
|
|
|
- staffEduBg.setUpdateTime(DateUtils.getNowTime());
|
|
|
- staffEduBg.setCompanyId(company.getCompanyId());
|
|
|
- StaffEduBgAddBo staffEduBgAddBo = BeanUtil.toBean(staffEduBg, StaffEduBgAddBo.class);
|
|
|
- staffEduBgAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
- staffEduBgAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
- iStaffEduBgService.insertByAddBo(staffEduBgAddBo);
|
|
|
- StaffEmergencyContact staffEmergencyContact = new StaffEmergencyContact();
|
|
|
- staffEmergencyContact.setRelation(item.getRelation());
|
|
|
- staffEmergencyContact.setCompanyId(company.getCompanyId());
|
|
|
- staffEmergencyContact.setStaffId(staff1.getStaffId());
|
|
|
- staffEmergencyContact.setContactName(item.getContactName());
|
|
|
- staffEmergencyContact.setContactTelephone(item.getContactTelephone());
|
|
|
- StaffEmergencyContactAddBo staffEmergencyContactAddBo = BeanUtil.toBean(staffEmergencyContact, StaffEmergencyContactAddBo.class);
|
|
|
- staffEmergencyContactAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
- staffEmergencyContactAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
- iStaffEmergencyContactService.insertByAddBo(staffEmergencyContactAddBo);
|
|
|
- StaffBankInfo staffBankInfo = new StaffBankInfo();
|
|
|
- staffBankInfo.setStaffId(staff1.getStaffId());
|
|
|
- staffBankInfo.setCompanyId(company.getCompanyId());
|
|
|
- staffBankInfo.setOpenName(item.getOpenName());
|
|
|
- staffBankInfo.setOpenBank(item.getOpenBank());
|
|
|
- staffBankInfo.setBankNumber(item.getBankNumber());
|
|
|
- StaffBankInfoAddBo staffBankInfoAddBo = BeanUtil.toBean(staffBankInfo, StaffBankInfoAddBo.class);
|
|
|
- staffBankInfoAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
- staffBankInfoAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
- iStaffBankInfoService.insertByAddBo(staffBankInfoAddBo);
|
|
|
- StaffContractArchives staffContractArchives = new StaffContractArchives();
|
|
|
- staffContractArchives.setStaffId(staff1.getStaffId());
|
|
|
- staffContractArchives.setCompanyId(company.getCompanyId());
|
|
|
- staffContractArchives.setArchivesNumber(item.getArchivesNumber());
|
|
|
- staffContractArchives.setArchivesName(item.getArchivesName());
|
|
|
- staffContractArchives.setArchivesType(getArchivesType(item.getArchivesType()));
|
|
|
- if (ObjectUtil.isNotEmpty(item.getSigningDate())) {
|
|
|
- staffContractArchives.setSigningDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getSigningDate()));
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(item.getEffectiveDate())) {
|
|
|
- staffContractArchives.setEffectiveDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getEffectiveDate()));
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(item.getOutDate())) {
|
|
|
- staffContractArchives.setEndDate(DateUtils.dateTimeSec("yyyy/MM/dd", item.getOutDate()));
|
|
|
- }
|
|
|
- StaffContractArchivesAddBo staffContractArchivesAddBo = BeanUtil.toBean(staffContractArchives, StaffContractArchivesAddBo.class);
|
|
|
- iStaffContractArchivesService.insertByAddBo(staffContractArchivesAddBo);
|
|
|
- }
|
|
|
+ staffCertificateMajorInfos.add(staffCertificateMajorInfo);
|
|
|
});
|
|
|
+ staffCertificate.setCertificateMajor(JSONArray.toJSONString(staffCertificateMajorInfos));
|
|
|
+ this.baseMapper.insert(staffCertificate);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return true;
|
|
|
}
|
|
|
- }
|
|
|
}
|