Commit 52f5e5b9 authored by chenhao's avatar chenhao

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

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