Commit 52f5e5b9 authored by chenhao's avatar chenhao

添加excle导入时默认的操作人

parent 21ac79b6
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn; import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance; import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
...@@ -26,6 +32,10 @@ import com.yeejoin.amos.boot.module.common.biz.service.impl.*; ...@@ -26,6 +32,10 @@ import com.yeejoin.amos.boot.module.common.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jcs.api.dto.AircraftDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AircraftDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft; import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft;
import com.yeejoin.amos.boot.module.jcs.api.enums.ExcelEnums; import com.yeejoin.amos.boot.module.jcs.api.enums.ExcelEnums;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import ch.qos.logback.core.subst.Token;
import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.ConvertUtils;
import org.apache.ibatis.annotations.Case; import org.apache.ibatis.annotations.Case;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
...@@ -38,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -38,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -63,6 +74,9 @@ public class ExcelServiceImpl { ...@@ -63,6 +74,9 @@ public class ExcelServiceImpl {
private static final String NOT_DUTY = "休班"; private static final String NOT_DUTY = "休班";
private static final String PERSON = "PERSON"; private static final String PERSON = "PERSON";
private static final String MAINTENANCE_PERSON = "maintenancePerson"; private static final String MAINTENANCE_PERSON = "maintenancePerson";
@Autowired
private RedisUtils redisUtils;
@Autowired @Autowired
DataSourcesImpl dataSourcesImpl; DataSourcesImpl dataSourcesImpl;
@Autowired @Autowired
...@@ -111,8 +125,8 @@ public class ExcelServiceImpl { ...@@ -111,8 +125,8 @@ public class ExcelServiceImpl {
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException { public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl(); String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url); Class<?> clz = Class.forName(url);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), null, clz, ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), null, clz, dataSourcesImpl,
dataSourcesImpl, true); true);
} }
public void commonExport(HttpServletResponse response, ExcelDto excelDto) { public void commonExport(HttpServletResponse response, ExcelDto excelDto) {
...@@ -125,18 +139,18 @@ public class ExcelServiceImpl { ...@@ -125,18 +139,18 @@ public class ExcelServiceImpl {
break; break;
case "XFZJ": case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false); List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireExpertsDtoList,
fireExpertsDtoList, FireExpertsDto.class, dataSourcesImpl, false); FireExpertsDto.class, dataSourcesImpl, false);
break; break;
case "SYXX": case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true); List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), waterResourceDtoList,
waterResourceDtoList, WaterResourceDto.class, dataSourcesImpl, false); WaterResourceDto.class, dataSourcesImpl, false);
break; break;
case "HKQ": case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false); List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), aircraftDtoList,
aircraftDtoList, AircraftDto.class, dataSourcesImpl, false); AircraftDto.class, dataSourcesImpl, false);
break; break;
case "XFDW": case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false); List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
...@@ -145,8 +159,8 @@ public class ExcelServiceImpl { ...@@ -145,8 +159,8 @@ public class ExcelServiceImpl {
break; break;
case "WXXFZ": case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false); List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireStationDtoList,
fireStationDtoList, FireStationDto.class, null, false); FireStationDto.class, null, false);
break; break;
case "XFRY": case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false); List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
...@@ -154,27 +168,27 @@ public class ExcelServiceImpl { ...@@ -154,27 +168,27 @@ public class ExcelServiceImpl {
firefightersExcelDtoList, FirefightersExcelDto.class, null, false); firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break; break;
case "WBRY": case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = maintenanceCompanyService
maintenanceCompanyService.exportToMaintenancePersonExcel(); .exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false); maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break; break;
case "KEYSITE": case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel(); List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), keySiteDtoList,
keySiteDtoList, KeySiteExcleDto.class, null, false); KeySiteExcleDto.class, null, false);
break; break;
case "JCDWRY": case "JCDWRY":
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportToExcel(); List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), orgUsrList,
orgUsrList, OrgUsrExcelDto.class, null, false); OrgUsrExcelDto.class, null, false);
break; break;
case "LDDW": case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel(); List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
LinkageUnitDtoList, LinkageUnitDto.class, null, false); LinkageUnitDto.class, null, false);
break; break;
default: default:
break; break;
...@@ -235,13 +249,14 @@ public class ExcelServiceImpl { ...@@ -235,13 +249,14 @@ public class ExcelServiceImpl {
} }
private void excelImportLinkageUnitTGRYDto(MultipartFile multipartFile) throws Exception { private void excelImportLinkageUnitTGRYDto(MultipartFile multipartFile) throws Exception {
List<SpecialPositionStaffDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<SpecialPositionStaffDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
SpecialPositionStaffDto.class, 1); SpecialPositionStaffDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){ if (excelDtoList != null && excelDtoList.size() > 0) {
outer : for(SpecialPositionStaffDto positionStaffDto : excelDtoList) { outer: for (SpecialPositionStaffDto positionStaffDto : excelDtoList) {
String code = ""; String code = "";
if(positionStaffDto.getPositionName()!=null){ if (positionStaffDto.getPositionName() != null) {
String[] certificates = positionStaffDto.getPositionName().split("@"); String[] certificates = positionStaffDto.getPositionName().split("@");
positionStaffDto.setPositionName(certificates[0]); positionStaffDto.setPositionName(certificates[0]);
positionStaffDto.setPositionNameCode(certificates[1]); positionStaffDto.setPositionNameCode(certificates[1]);
...@@ -249,16 +264,17 @@ public class ExcelServiceImpl { ...@@ -249,16 +264,17 @@ public class ExcelServiceImpl {
} else { } else {
continue; continue;
} }
if(positionStaffDto.getCompany()!=null){ if (positionStaffDto.getCompany() != null) {
String[] certificates = positionStaffDto.getCompany().split("@"); String[] certificates = positionStaffDto.getCompany().split("@");
positionStaffDto.setCompany(certificates[0]); positionStaffDto.setCompany(certificates[0]);
positionStaffDto.setCompanyId(Long.parseLong(certificates[1])); positionStaffDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取特岗人员已经存在的岗位 如果存在则不导入 // 获取特岗人员已经存在的岗位 如果存在则不导入
LambdaQueryWrapper<SpecialPositionStaff> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SpecialPositionStaff> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SpecialPositionStaff::getCompanyId,Long.parseLong(certificates[1])).eq(SpecialPositionStaff::getIsDelete,false); queryWrapper.eq(SpecialPositionStaff::getCompanyId, Long.parseLong(certificates[1]))
.eq(SpecialPositionStaff::getIsDelete, false);
List<SpecialPositionStaff> tempList = specialPositionStaffServiceImpl.list(queryWrapper); List<SpecialPositionStaff> tempList = specialPositionStaffServiceImpl.list(queryWrapper);
for(SpecialPositionStaff temp : tempList) { for (SpecialPositionStaff temp : tempList) {
if(temp.getPositionNameCode().equals(code)) { if (temp.getPositionNameCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环 continue outer; // 已经存在则不导入继续循环
} }
} }
...@@ -271,12 +287,12 @@ public class ExcelServiceImpl { ...@@ -271,12 +287,12 @@ public class ExcelServiceImpl {
} }
private void excelImportLinkageUnitJYZBDto(MultipartFile multipartFile) throws Exception { private void excelImportLinkageUnitJYZBDto(MultipartFile multipartFile) throws Exception {
List<RescueEquipmentDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<RescueEquipmentDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, RescueEquipmentDto.class,
RescueEquipmentDto.class, 1); 1);
if(excelDtoList!=null&&excelDtoList.size()>0){ if (excelDtoList != null && excelDtoList.size() > 0) {
outer : for(RescueEquipmentDto rescueEquipmentDto : excelDtoList ) { outer: for (RescueEquipmentDto rescueEquipmentDto : excelDtoList) {
String code = ""; String code = "";
if(rescueEquipmentDto.getVehicleType()!=null){ if (rescueEquipmentDto.getVehicleType() != null) {
String[] certificates = rescueEquipmentDto.getVehicleType().split("@"); String[] certificates = rescueEquipmentDto.getVehicleType().split("@");
rescueEquipmentDto.setVehicleType(certificates[0]); rescueEquipmentDto.setVehicleType(certificates[0]);
rescueEquipmentDto.setVehicleTypeCode(certificates[1]); rescueEquipmentDto.setVehicleTypeCode(certificates[1]);
...@@ -284,21 +300,22 @@ public class ExcelServiceImpl { ...@@ -284,21 +300,22 @@ public class ExcelServiceImpl {
} else { } else {
continue; continue;
} }
if(rescueEquipmentDto.getCompany()!=null){ if (rescueEquipmentDto.getCompany() != null) {
String[] certificates = rescueEquipmentDto.getCompany().split("@"); String[] certificates = rescueEquipmentDto.getCompany().split("@");
rescueEquipmentDto.setCompany(certificates[0]); rescueEquipmentDto.setCompany(certificates[0]);
rescueEquipmentDto.setCompanyId(Long.parseLong(certificates[1])); rescueEquipmentDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取救援装备已经存在的装备 如果存在则不导入 // 获取救援装备已经存在的装备 如果存在则不导入
LambdaQueryWrapper<RescueEquipment> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RescueEquipment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueEquipment::getCompanyId,Long.parseLong(certificates[1])).eq(RescueEquipment::getIsDelete,false); queryWrapper.eq(RescueEquipment::getCompanyId, Long.parseLong(certificates[1]))
.eq(RescueEquipment::getIsDelete, false);
List<RescueEquipment> tempList = rescueEquipmentServiceImpl.list(queryWrapper); List<RescueEquipment> tempList = rescueEquipmentServiceImpl.list(queryWrapper);
for(RescueEquipment temp : tempList) { for (RescueEquipment temp : tempList) {
if(temp.getVehicleTypeCode().equals(code)) { if (temp.getVehicleTypeCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环 continue outer; // 已经存在则不导入继续循环
} }
} }
} else { } else {
continue ; continue;
} }
rescueEquipmentServiceImpl.createWithModel(rescueEquipmentDto); rescueEquipmentServiceImpl.createWithModel(rescueEquipmentDto);
...@@ -307,20 +324,17 @@ public class ExcelServiceImpl { ...@@ -307,20 +324,17 @@ public class ExcelServiceImpl {
} }
} }
private void excelImportLinkageUnitZhDto(MultipartFile multipartFile) throws Exception { private void excelImportLinkageUnitZhDto(MultipartFile multipartFile) throws Exception {
List<LinkageUnitDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<LinkageUnitDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, LinkageUnitDto.class, 1);
LinkageUnitDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){ if (excelDtoList != null && excelDtoList.size() > 0) {
excelDtoList.forEach(linkageUnitDto->{ excelDtoList.forEach(linkageUnitDto -> {
if(linkageUnitDto.getLinkageUnitType()!=null){ if (linkageUnitDto.getLinkageUnitType() != null) {
String[] certificates = linkageUnitDto.getLinkageUnitType().split("@"); String[] certificates = linkageUnitDto.getLinkageUnitType().split("@");
linkageUnitDto.setLinkageUnitType(certificates[0]); linkageUnitDto.setLinkageUnitType(certificates[0]);
linkageUnitDto.setLinkageUnitTypeCode(certificates[1]); linkageUnitDto.setLinkageUnitTypeCode(certificates[1]);
} }
if(linkageUnitDto.getEmergencyLinkageUnit()!=null){ if (linkageUnitDto.getEmergencyLinkageUnit() != null) {
String[] certificates = linkageUnitDto.getEmergencyLinkageUnit().split("@"); String[] certificates = linkageUnitDto.getEmergencyLinkageUnit().split("@");
linkageUnitDto.setEmergencyLinkageUnit(certificates[0]); linkageUnitDto.setEmergencyLinkageUnit(certificates[0]);
linkageUnitDto.setEmergencyLinkageUnitCode(certificates[1]); linkageUnitDto.setEmergencyLinkageUnitCode(certificates[1]);
...@@ -330,19 +344,15 @@ public class ExcelServiceImpl { ...@@ -330,19 +344,15 @@ public class ExcelServiceImpl {
}); });
} }
} }
private void excelImportOrgUsrExcelDto(MultipartFile multipartFile) throws Exception { private void excelImportOrgUsrExcelDto(MultipartFile multipartFile) throws Exception {
List<OrgUsrExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<OrgUsrExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, OrgUsrExcelDto.class, 1);
OrgUsrExcelDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){ if (excelDtoList != null && excelDtoList.size() > 0) {
excelDtoList.forEach(orgUsrExcelDto->{ excelDtoList.forEach(orgUsrExcelDto -> {
if(orgUsrExcelDto.getParentId()!=null){ if (orgUsrExcelDto.getParentId() != null) {
String[] certificates = orgUsrExcelDto.getParentId().split("@"); String[] certificates = orgUsrExcelDto.getParentId().split("@");
orgUsrExcelDto.setParentId(certificates[1]); orgUsrExcelDto.setParentId(certificates[1]);
} }
...@@ -350,18 +360,18 @@ public class ExcelServiceImpl { ...@@ -350,18 +360,18 @@ public class ExcelServiceImpl {
List<DynamicFormInitDto> dynamicFormColumn = dynamicFormColumnServiceImpl.getFormlist("246"); List<DynamicFormInitDto> dynamicFormColumn = dynamicFormColumnServiceImpl.getFormlist("246");
List<DynamicFormInstanceDto> dynamicFormValue =new ArrayList<>(); List<DynamicFormInstanceDto> dynamicFormValue = new ArrayList<>();
List<DynamicFormInstance> dynamicFormInstancelist =new ArrayList<>(); List<DynamicFormInstance> dynamicFormInstancelist = new ArrayList<>();
dynamicFormColumn.forEach(DynamicFormInitDto->{ dynamicFormColumn.forEach(DynamicFormInitDto -> {
dynamicFormValue.add(DynamicFormInitDto.getFormItemDescr()); dynamicFormValue.add(DynamicFormInitDto.getFormItemDescr());
}); });
dynamicFormValue.forEach(dynamicFormInstanceDto->{ dynamicFormValue.forEach(dynamicFormInstanceDto -> {
switch (dynamicFormInstanceDto.getFieldCode()) { switch (dynamicFormInstanceDto.getFieldCode()) {
case "administrativePositionCode": case "administrativePositionCode":
if(orgUsrExcelDto.getAdministrativePositionCode()!=null){ if (orgUsrExcelDto.getAdministrativePositionCode() != null) {
String[] certificates = orgUsrExcelDto.getAdministrativePositionCode().split("@"); String[] certificates = orgUsrExcelDto.getAdministrativePositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -369,7 +379,7 @@ public class ExcelServiceImpl { ...@@ -369,7 +379,7 @@ public class ExcelServiceImpl {
} }
break; break;
case "auditCycle": case "auditCycle":
if(orgUsrExcelDto.getAuditCycle()!=null){ if (orgUsrExcelDto.getAuditCycle() != null) {
String[] certificates = orgUsrExcelDto.getAuditCycle().split("@"); String[] certificates = orgUsrExcelDto.getAuditCycle().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -380,7 +390,7 @@ public class ExcelServiceImpl { ...@@ -380,7 +390,7 @@ public class ExcelServiceImpl {
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getCertificatesNumber()); dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getCertificatesNumber());
break; break;
case "certificatesTypeCode": case "certificatesTypeCode":
if(orgUsrExcelDto.getCertificatesTypeCode()!=null){ if (orgUsrExcelDto.getCertificatesTypeCode() != null) {
String[] certificates = orgUsrExcelDto.getCertificatesTypeCode().split("@"); String[] certificates = orgUsrExcelDto.getCertificatesTypeCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -388,14 +398,14 @@ public class ExcelServiceImpl { ...@@ -388,14 +398,14 @@ public class ExcelServiceImpl {
} }
break; break;
case "certificateType": case "certificateType":
if(orgUsrExcelDto.getCertificateType()!=null){ if (orgUsrExcelDto.getCertificateType() != null) {
String[] certificates = orgUsrExcelDto.getCertificateType().split("@"); String[] certificates = orgUsrExcelDto.getCertificateType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
} }
case "fireManagementPostCode": case "fireManagementPostCode":
if(orgUsrExcelDto.getFireManagementPostCode()!=null){ if (orgUsrExcelDto.getFireManagementPostCode() != null) {
String[] certificates = orgUsrExcelDto.getFireManagementPostCode().split("@"); String[] certificates = orgUsrExcelDto.getFireManagementPostCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -406,7 +416,7 @@ public class ExcelServiceImpl { ...@@ -406,7 +416,7 @@ public class ExcelServiceImpl {
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getGender()); dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getGender());
break; break;
case "internalPositionCode": case "internalPositionCode":
if(orgUsrExcelDto.getInternalPositionCode()!=null){ if (orgUsrExcelDto.getInternalPositionCode() != null) {
String[] certificates = orgUsrExcelDto.getInternalPositionCode().split("@"); String[] certificates = orgUsrExcelDto.getInternalPositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -417,7 +427,7 @@ public class ExcelServiceImpl { ...@@ -417,7 +427,7 @@ public class ExcelServiceImpl {
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getPersonNumber()); dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getPersonNumber());
break; break;
case "positionType": case "positionType":
if(orgUsrExcelDto.getPositionType()!=null){ if (orgUsrExcelDto.getPositionType() != null) {
String[] certificates = orgUsrExcelDto.getPositionType().split("@"); String[] certificates = orgUsrExcelDto.getPositionType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -425,7 +435,7 @@ public class ExcelServiceImpl { ...@@ -425,7 +435,7 @@ public class ExcelServiceImpl {
} }
break; break;
case "safetyTraining": case "safetyTraining":
if(orgUsrExcelDto.getSafetyTraining()!=null){ if (orgUsrExcelDto.getSafetyTraining() != null) {
String[] certificates = orgUsrExcelDto.getSafetyTraining().split("@"); String[] certificates = orgUsrExcelDto.getSafetyTraining().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -433,7 +443,7 @@ public class ExcelServiceImpl { ...@@ -433,7 +443,7 @@ public class ExcelServiceImpl {
} }
break; break;
case "stateCode": case "stateCode":
if(orgUsrExcelDto.getStateCode()!=null){ if (orgUsrExcelDto.getStateCode() != null) {
String[] certificates = orgUsrExcelDto.getStateCode().split("@"); String[] certificates = orgUsrExcelDto.getStateCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]); dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]); dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
...@@ -446,7 +456,7 @@ public class ExcelServiceImpl { ...@@ -446,7 +456,7 @@ public class ExcelServiceImpl {
} }
DynamicFormInstance dynamicFormInstance=new DynamicFormInstance(); DynamicFormInstance dynamicFormInstance = new DynamicFormInstance();
BeanUtils.copyProperties(dynamicFormInstanceDto, dynamicFormInstance); BeanUtils.copyProperties(dynamicFormInstanceDto, dynamicFormInstance);
dynamicFormInstancelist.add(dynamicFormInstance); dynamicFormInstancelist.add(dynamicFormInstance);
...@@ -454,7 +464,6 @@ public class ExcelServiceImpl { ...@@ -454,7 +464,6 @@ public class ExcelServiceImpl {
orgUsrExcelDto.setDynamicFormValue(dynamicFormInstancelist); orgUsrExcelDto.setDynamicFormValue(dynamicFormInstancelist);
try { try {
orgUsrService.saveOrgPersonExcel(orgUsrExcelDto); orgUsrService.saveOrgPersonExcel(orgUsrExcelDto);
} catch (Exception e) { } catch (Exception e) {
...@@ -463,26 +472,16 @@ public class ExcelServiceImpl { ...@@ -463,26 +472,16 @@ public class ExcelServiceImpl {
}); });
} }
} }
private void excelImportFirefighters(MultipartFile multipartFile) throws Exception { private void excelImportFirefighters(MultipartFile multipartFile) throws Exception {
List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
FirefightersExcelDto.class, 1); FirefightersExcelDto.class, 1);
excelDtoList.forEach( excelDtoList.forEach(item -> {
item -> {
Firefighters firefighters = new Firefighters(); Firefighters firefighters = new Firefighters();
FirefightersContacts firefightersContacts = new FirefightersContacts(); FirefightersContacts firefightersContacts = new FirefightersContacts();
firefighters = Bean.toPo(item, firefighters); firefighters = Bean.toPo(item, firefighters);
firefighters = Bean.toPo(getCurrentInfo(), firefighters);
firefightersContacts = Bean.toPo(item, firefightersContacts); firefightersContacts = Bean.toPo(item, firefightersContacts);
if (item.getFireTeam() != null) { if (item.getFireTeam() != null) {
Long fireTeamId = Long.valueOf(item.getFireTeam().split("@")[1]); Long fireTeamId = Long.valueOf(item.getFireTeam().split("@")[1]);
...@@ -507,17 +506,17 @@ public class ExcelServiceImpl { ...@@ -507,17 +506,17 @@ public class ExcelServiceImpl {
String relationship = firefightersContacts.getRelationship().split("@")[1]; String relationship = firefightersContacts.getRelationship().split("@")[1];
firefightersContacts.setRelationship(relationship); firefightersContacts.setRelationship(relationship);
} }
if(firefighters.getCompanyName() != null) { if (firefighters.getCompanyName() != null) {
String[] tempCompany = firefighters.getCompanyName().split("@"); String[] tempCompany = firefighters.getCompanyName().split("@");
firefighters.setCompanyName(tempCompany[0]); firefighters.setCompanyName(tempCompany[0]);
firefighters.setCompany(tempCompany[1]); firefighters.setCompany(tempCompany[1]);
} }
if(firefighters.getNativePlaceValue() != null) { if (firefighters.getNativePlaceValue() != null) {
String[] tempCity = firefighters.getNativePlaceValue().split("@"); String[] tempCity = firefighters.getNativePlaceValue().split("@");
firefighters.setNativePlaceValue(tempCity[0]); firefighters.setNativePlaceValue(tempCity[0]);
firefighters.setNativePlace(tempCity[1]); firefighters.setNativePlace(tempCity[1]);
} }
if(firefighters.getResidence() != null) { if (firefighters.getResidence() != null) {
String[] tempCity = firefighters.getResidence().split("@"); String[] tempCity = firefighters.getResidence().split("@");
firefighters.setResidence(tempCity[0]); firefighters.setResidence(tempCity[0]);
firefighters.setResidenceDetails(tempCity[1]); firefighters.setResidenceDetails(tempCity[1]);
...@@ -525,17 +524,16 @@ public class ExcelServiceImpl { ...@@ -525,17 +524,16 @@ public class ExcelServiceImpl {
// BUG 2760 修改消防人员导出模板和 导入问题 bykongfm // BUG 2760 修改消防人员导出模板和 导入问题 bykongfm
FirefightersInfoDto firefightersInfo = new FirefightersInfoDto(firefighters, firefightersContacts); FirefightersInfoDto firefightersInfo = new FirefightersInfoDto(firefighters, firefightersContacts);
firefightersService.saveFirefighters(firefightersInfo); firefightersService.saveFirefighters(firefightersInfo);
} });
);
} }
private void excelImportFireStation(MultipartFile multipartFile) throws Exception { private void excelImportFireStation(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1); List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
List<FireStation> excelEntityList = new ArrayList<>(); List<FireStation> excelEntityList = new ArrayList<>();
excelDtoList.forEach( excelDtoList.forEach(item -> {
item -> {
FireStation fireStation = new FireStation(); FireStation fireStation = new FireStation();
fireStation = Bean.toPo(item, fireStation); fireStation = Bean.toPo(item, fireStation);
fireStation = Bean.toPo(getCurrentInfo(), fireStation);
if (fireStation.getWhereBuilding() != null) { if (fireStation.getWhereBuilding() != null) {
String[] whereBuilding = fireStation.getWhereBuilding().split("@"); String[] whereBuilding = fireStation.getWhereBuilding().split("@");
fireStation.setWhereBuilding(whereBuilding[0]); fireStation.setWhereBuilding(whereBuilding[0]);
...@@ -548,18 +546,17 @@ public class ExcelServiceImpl { ...@@ -548,18 +546,17 @@ public class ExcelServiceImpl {
fireStation.setBizCompanyCode(bizCompany[2]); fireStation.setBizCompanyCode(bizCompany[2]);
} }
excelEntityList.add(fireStation); excelEntityList.add(fireStation);
} });
);
fireStationService.saveBatch(excelEntityList); fireStationService.saveBatch(excelEntityList);
} }
private void excelImportFireTeam(MultipartFile multipartFile) throws Exception { private void excelImportFireTeam(MultipartFile multipartFile) throws Exception {
List<FireTeamDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireTeamDto.class, 1); List<FireTeamDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireTeamDto.class, 1);
List<FireTeam> excelEntityList = new ArrayList<>(); List<FireTeam> excelEntityList = new ArrayList<>();
excelDtoList.forEach( excelDtoList.forEach(item -> {
item -> {
FireTeam fireTeam = new FireTeam(); FireTeam fireTeam = new FireTeam();
fireTeam = Bean.toPo(item, fireTeam); fireTeam = Bean.toPo(item, fireTeam);
fireTeam = Bean.toPo(getCurrentInfo(), fireTeam);
if (fireTeam.getType() != null) { if (fireTeam.getType() != null) {
String[] type = fireTeam.getType().split("@"); String[] type = fireTeam.getType().split("@");
fireTeam.setType(type[0]); fireTeam.setType(type[0]);
...@@ -575,18 +572,17 @@ public class ExcelServiceImpl { ...@@ -575,18 +572,17 @@ public class ExcelServiceImpl {
fireTeam.setParent(Long.valueOf(parentName[1])); fireTeam.setParent(Long.valueOf(parentName[1]));
} }
excelEntityList.add(fireTeam); excelEntityList.add(fireTeam);
} });
);
fireTeamService.saveBatch(excelEntityList); fireTeamService.saveBatch(excelEntityList);
} }
private void excelImportAircraft(MultipartFile multipartFile) throws Exception { private void excelImportAircraft(MultipartFile multipartFile) throws Exception {
List<AircraftDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, AircraftDto.class, 1); List<AircraftDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, AircraftDto.class, 1);
List<Aircraft> excelEntityList = new ArrayList<>(); List<Aircraft> excelEntityList = new ArrayList<>();
excelDtoList.forEach( excelDtoList.forEach(item -> {
item -> {
Aircraft aircraft = new Aircraft(); Aircraft aircraft = new Aircraft();
aircraft = Bean.toPo(item, aircraft); aircraft = Bean.toPo(item, aircraft);
aircraft = Bean.toPo(getCurrentInfo(), aircraft);
if (aircraft.getEngineType() != null) { if (aircraft.getEngineType() != null) {
String[] engineType = aircraft.getEngineType().split("@"); String[] engineType = aircraft.getEngineType().split("@");
aircraft.setEngineType(engineType[0]); aircraft.setEngineType(engineType[0]);
...@@ -598,34 +594,30 @@ public class ExcelServiceImpl { ...@@ -598,34 +594,30 @@ public class ExcelServiceImpl {
aircraft.setFuelTypeCode(fuelType[1]); aircraft.setFuelTypeCode(fuelType[1]);
} }
excelEntityList.add(aircraft); excelEntityList.add(aircraft);
} });
);
aircraftServiceImpl.saveBatch(excelEntityList); aircraftServiceImpl.saveBatch(excelEntityList);
} }
private void excelImportFireChemical(MultipartFile multipartFile) throws Exception { private void excelImportFireChemical(MultipartFile multipartFile) throws Exception {
List<FireChemicalDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireChemicalDto.class, 1); List<FireChemicalDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireChemicalDto.class, 1);
List<FireChemical> excelEntityList = new ArrayList<>(); List<FireChemical> excelEntityList = new ArrayList<>();
excelDtoList.forEach( excelDtoList.forEach(item -> {
item -> {
FireChemical fireChemical = new FireChemical(); FireChemical fireChemical = new FireChemical();
fireChemical = Bean.toPo(item, fireChemical); fireChemical = Bean.toPo(item, fireChemical);
fireChemical = Bean.toPo(getCurrentInfo(), fireChemical);
if (fireChemical.getType() != null) { if (fireChemical.getType() != null) {
String[] type = fireChemical.getType().split("@"); String[] type = fireChemical.getType().split("@");
fireChemical.setType(type[0]); fireChemical.setType(type[0]);
fireChemical.setTypeCode(type[1]); fireChemical.setTypeCode(type[1]);
} }
excelEntityList.add(fireChemical); excelEntityList.add(fireChemical);
} });
);
fireChemicalServiceImpl.saveBatch(excelEntityList); fireChemicalServiceImpl.saveBatch(excelEntityList);
} }
private void excelImportWaterResource(MultipartFile multipartFile) throws Exception { private void excelImportWaterResource(MultipartFile multipartFile) throws Exception {
List<WaterResourceDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<WaterResourceDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, WaterResourceDto.class, 1);
WaterResourceDto.class, 1); excelDtoList.forEach(item -> {
excelDtoList.forEach(
item -> {
if (item.getResourceTypeName() != null) { if (item.getResourceTypeName() != null) {
String[] resourceTypeName = item.getResourceTypeName().split("@"); String[] resourceTypeName = item.getResourceTypeName().split("@");
item.setResourceTypeName(resourceTypeName[0]); item.setResourceTypeName(resourceTypeName[0]);
...@@ -685,17 +677,15 @@ public class ExcelServiceImpl { ...@@ -685,17 +677,15 @@ public class ExcelServiceImpl {
item.setType(type[0]); item.setType(type[0]);
item.setTypeCode(type[1]); item.setTypeCode(type[1]);
} }
item = Bean.toPo(getCurrentInfo(), item);
waterResourceServiceImpl.importByExcel(item); waterResourceServiceImpl.importByExcel(item);
} });
);
} }
private void excelImportFireExperts(MultipartFile multipartFile) throws Exception { private void excelImportFireExperts(MultipartFile multipartFile) throws Exception {
List<FireExpertsDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<FireExpertsDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireExpertsDto.class, 1);
FireExpertsDto.class, 1);
List<FireExperts> excelEntityList = new ArrayList<>(); List<FireExperts> excelEntityList = new ArrayList<>();
excelDtoList.forEach( excelDtoList.forEach(fireExpertsDto -> {
fireExpertsDto -> {
FireExperts fireExperts = new FireExperts(); FireExperts fireExperts = new FireExperts();
fireExperts = Bean.toPo(fireExpertsDto, fireExperts); fireExperts = Bean.toPo(fireExpertsDto, fireExperts);
if (fireExperts.getCertificatesType() != null) { if (fireExperts.getCertificatesType() != null) {
...@@ -718,8 +708,7 @@ public class ExcelServiceImpl { ...@@ -718,8 +708,7 @@ public class ExcelServiceImpl {
fireExperts.setHighestEducation(highestEducation[0]); fireExperts.setHighestEducation(highestEducation[0]);
} }
excelEntityList.add(fireExperts); excelEntityList.add(fireExperts);
} });
);
fireExpertsServiceImpl.saveBatch(excelEntityList); fireExpertsServiceImpl.saveBatch(excelEntityList);
} }
...@@ -729,7 +718,8 @@ public class ExcelServiceImpl { ...@@ -729,7 +718,8 @@ public class ExcelServiceImpl {
if (fileName == null) { if (fileName == null) {
throw new Exception("文件不存在!"); throw new Exception("文件不存在!");
} }
if (!fileName.toLowerCase().endsWith(ExcelTypeEnum.XLS.getValue()) && !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) { if (!fileName.toLowerCase().endsWith(ExcelTypeEnum.XLS.getValue())
&& !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) {
throw new Exception("文件类型异常!"); throw new Exception("文件类型异常!");
} }
InputStream input = multipartFile.getInputStream(); InputStream input = multipartFile.getInputStream();
...@@ -737,7 +727,7 @@ public class ExcelServiceImpl { ...@@ -737,7 +727,7 @@ public class ExcelServiceImpl {
XSSFSheet sheet = workbook.getSheetAt(0); XSSFSheet sheet = workbook.getSheetAt(0);
List<Map<String, Object>> dataList = new ArrayList<>(); List<Map<String, Object>> dataList = new ArrayList<>();
if (sheet != null) { if (sheet != null) {
//获取表头月份 // 获取表头月份
Row titleRow = sheet.getRow(0); Row titleRow = sheet.getRow(0);
Cell monthCell = titleRow.getCell(5); Cell monthCell = titleRow.getCell(5);
String dateStr = monthCell == null ? "" : monthCell.toString(); String dateStr = monthCell == null ? "" : monthCell.toString();
...@@ -754,10 +744,10 @@ public class ExcelServiceImpl { ...@@ -754,10 +744,10 @@ public class ExcelServiceImpl {
} }
private void initDutyCarData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyCarData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
//遍历行,i = 1,从第二行开始,第一行是表头跳过。 // 遍历行,i = 1,从第二行开始,第一行是表头跳过。
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyCarDto dutyCarDto = new DutyCarDto(); DutyCarDto dutyCarDto = new DutyCarDto();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据 // row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
if (row == null) { if (row == null) {
continue; continue;
...@@ -804,10 +794,10 @@ public class ExcelServiceImpl { ...@@ -804,10 +794,10 @@ public class ExcelServiceImpl {
} }
private void initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
//遍历行,i = 1,从第二行开始,第一行是表头跳过。 // 遍历行,i = 1,从第二行开始,第一行是表头跳过。
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyPersonDto dutyPersonDto = new DutyPersonDto(); DutyPersonDto dutyPersonDto = new DutyPersonDto();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据 // row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
if (row == null) { if (row == null) {
continue; continue;
...@@ -852,8 +842,8 @@ public class ExcelServiceImpl { ...@@ -852,8 +842,8 @@ public class ExcelServiceImpl {
private void excelImportMaintenancePerson(MultipartFile multipartFile) throws Exception { private void excelImportMaintenancePerson(MultipartFile multipartFile) throws Exception {
List<MaintenancePersonExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<MaintenancePersonExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
MaintenancePersonExcleDto.class, 1); MaintenancePersonExcleDto.class, 1);
List<DynamicFormColumn> columns = List<DynamicFormColumn> columns = dynamicFormColumnService.list(
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, MAINTENANCE_PERSON)); new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, MAINTENANCE_PERSON));
List<MaintenanceCompany> maintenanceCompanyList = new ArrayList<MaintenanceCompany>(); List<MaintenanceCompany> maintenanceCompanyList = new ArrayList<MaintenanceCompany>();
List<DynamicFormInstance> dynamicFormInstanceList = new ArrayList<DynamicFormInstance>(); List<DynamicFormInstance> dynamicFormInstanceList = new ArrayList<DynamicFormInstance>();
for (MaintenancePersonExcleDto maintenancePersonExcleDto : excelDtoList) { for (MaintenancePersonExcleDto maintenancePersonExcleDto : excelDtoList) {
...@@ -882,18 +872,10 @@ public class ExcelServiceImpl { ...@@ -882,18 +872,10 @@ public class ExcelServiceImpl {
} }
private void excelImportKeySite(MultipartFile multipartFile) throws Exception { private void excelImportKeySite(MultipartFile multipartFile) throws Exception {
List<KeySiteExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<KeySiteExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, KeySiteExcleDto.class, 1);
KeySiteExcleDto.class, 1);
keySiteService.saveExcel(excelDtoList); keySiteService.saveExcel(excelDtoList);
} }
public void dutyTemplateExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto, public void dutyTemplateExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto,
String ids) { String ids) {
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
...@@ -903,17 +885,16 @@ public class ExcelServiceImpl { ...@@ -903,17 +885,16 @@ public class ExcelServiceImpl {
data = initDutyPersonTemplate(ids); data = initDutyPersonTemplate(ids);
} }
// 获取日期 // 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
endDate);
List<String> dayByMonth = new ArrayList<>(); List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date"))); rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true); exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true);
} }
public void dutyInfoExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto) throws ParseException { public void dutyInfoExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto)
throws ParseException {
// 获取日期 // 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
endDate);
List<String> dayByMonth = new ArrayList<>(); List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date"))); rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
...@@ -983,14 +964,16 @@ public class ExcelServiceImpl { ...@@ -983,14 +964,16 @@ public class ExcelServiceImpl {
return data; return data;
} }
private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth, private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth,
ExcelDto excelDto, List<? extends Object> data, Boolean flag) { ExcelDto excelDto, List<? extends Object> data, Boolean flag) {
try { try {
// 获取排班类型 // 获取排班类型
String[] dutyNameList = getDutyNameList(); String[] dutyNameList = getDutyNameList();
Class<?> clz = Class.forName(classUrl); Class<?> clz = Class.forName(classUrl);
ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data, ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data, clz,
clz, dayByMonth, dutyNameList, dataSourcesImpl, flag); dayByMonth, dutyNameList, dataSourcesImpl, flag);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1003,7 +986,8 @@ public class ExcelServiceImpl { ...@@ -1003,7 +986,8 @@ public class ExcelServiceImpl {
return dutyShiftList.toArray(new String[dutyShiftList.size()]); return dutyShiftList.toArray(new String[dutyShiftList.size()]);
} }
private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth) throws ParseException { private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException {
// 查询已值班数据 // 查询已值班数据
List<DutyCarDto> contentList = dutyCarService.downloadList(beginDate, endDate); List<DutyCarDto> contentList = dutyCarService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
...@@ -1041,7 +1025,8 @@ public class ExcelServiceImpl { ...@@ -1041,7 +1025,8 @@ public class ExcelServiceImpl {
} }
} }
private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth) throws ParseException { private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException {
// 查询已值班数据 // 查询已值班数据
List<DutyPersonDto> contentList = iDutyPersonService.downloadList(beginDate, endDate); List<DutyPersonDto> contentList = iDutyPersonService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
...@@ -1065,8 +1050,6 @@ public class ExcelServiceImpl { ...@@ -1065,8 +1050,6 @@ public class ExcelServiceImpl {
return data; return data;
} }
public void exportByParams(HttpServletResponse response, ExcelDto excelDto, String params) { public void exportByParams(HttpServletResponse response, ExcelDto excelDto, String params) {
switch (excelDto.getType()) { switch (excelDto.getType()) {
...@@ -1077,18 +1060,18 @@ public class ExcelServiceImpl { ...@@ -1077,18 +1060,18 @@ public class ExcelServiceImpl {
break; break;
case "XFZJ": case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false); List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireExpertsDtoList,
fireExpertsDtoList, FireExpertsDto.class, dataSourcesImpl, false); FireExpertsDto.class, dataSourcesImpl, false);
break; break;
case "SYXX": case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true); List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), waterResourceDtoList,
waterResourceDtoList, WaterResourceDto.class, dataSourcesImpl, false); WaterResourceDto.class, dataSourcesImpl, false);
break; break;
case "HKQ": case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false); List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), aircraftDtoList,
aircraftDtoList, AircraftDto.class, dataSourcesImpl, false); AircraftDto.class, dataSourcesImpl, false);
break; break;
case "XFDW": case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false); List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
...@@ -1097,8 +1080,8 @@ public class ExcelServiceImpl { ...@@ -1097,8 +1080,8 @@ public class ExcelServiceImpl {
break; break;
case "WXXFZ": case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false); List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireStationDtoList,
fireStationDtoList, FireStationDto.class, null, false); FireStationDto.class, null, false);
break; break;
case "XFRY": case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false); List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
...@@ -1106,15 +1089,15 @@ public class ExcelServiceImpl { ...@@ -1106,15 +1089,15 @@ public class ExcelServiceImpl {
firefightersExcelDtoList, FirefightersExcelDto.class, null, false); firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break; break;
case "WBRY": case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = maintenanceCompanyService
maintenanceCompanyService.exportToMaintenancePersonExcel(); .exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false); maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break; break;
case "KEYSITE": case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel(); List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), keySiteDtoList,
keySiteDtoList, KeySiteExcleDto.class, null, false); KeySiteExcleDto.class, null, false);
break; break;
case "JCDWRY": case "JCDWRY":
// 机场单位人员参数传递为 parentId = xxxxxxx // 机场单位人员参数传递为 parentId = xxxxxxx
...@@ -1126,17 +1109,31 @@ public class ExcelServiceImpl { ...@@ -1126,17 +1109,31 @@ public class ExcelServiceImpl {
throw new BadRequest("导出机场单位时未传递正确parentId"); throw new BadRequest("导出机场单位时未传递正确parentId");
} }
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportPersonToExcelByParentId(parentId); List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportPersonToExcelByParentId(parentId);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), orgUsrList,
orgUsrList, OrgUsrExcelDto.class, null, false); OrgUsrExcelDto.class, null, false);
break; break;
case "LDDW": case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel(); List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
LinkageUnitDtoList, LinkageUnitDto.class, null, false); LinkageUnitDto.class, null, false);
break; break;
default: default:
break; break;
} }
} }
public BaseEntity getCurrentInfo() {
BaseEntity userModel= new BaseEntity();
/* String keyString= RequestContext.getExeUserId();
String token=RequestContext.getToken();
ReginParams params = JSONObject.parseObject(redisUtils
.get(RedisKey.buildReginKey(keyString, token)).toString(),
ReginParams.class);*/
userModel.setRecUserId("3141675");
userModel.setRecUserName("admin_jcs");
userModel.setRecDate( new Date());
userModel.setIsDelete(false);
return userModel;
}
} }
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