Commit 200042c7 authored by 付培阳's avatar 付培阳

导入导出

parent 601734d0
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.common.api.enums.ExcelSelectData;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint;
...@@ -52,18 +53,22 @@ public class FireExpertsDto extends BaseDto { ...@@ -52,18 +53,22 @@ public class FireExpertsDto extends BaseDto {
@ApiModelProperty(value = "出生日期") @ApiModelProperty(value = "出生日期")
private Date birthdayTime; private Date birthdayTime;
@ExplicitConstraint(indexNum = 6, sourceClass = RoleNameExplicitConstraint.class, method = "getNations") //固定下拉内容
@ExcelProperty(value = "民族", index = 6) @ExcelProperty(value = "民族", index = 6)
@ApiModelProperty(value = "民族") @ApiModelProperty(value = "民族")
private String nation; private String nation;
// @ExplicitConstraint(indexNum = 7, sourceClass = RoleNameExplicitConstraint.class, method = "getAdministrativeDivisions") //固定下拉内容
@ExcelProperty(value = "籍贯", index = 7) @ExcelProperty(value = "籍贯", index = 7)
@ApiModelProperty(value = "籍贯") @ApiModelProperty(value = "籍贯")
private String nativePlace; private String nativePlace;
@ExplicitConstraint(indexNum = 8, sourceClass = RoleNameExplicitConstraint.class, method = "getPoliticalOutlook") //固定下拉内容
@ExcelProperty(value = "政治面貌", index = 8) @ExcelProperty(value = "政治面貌", index = 8)
@ApiModelProperty(value = "政治面貌") @ApiModelProperty(value = "政治面貌")
private String politicalOutlook; private String politicalOutlook;
// @ExplicitConstraint(indexNum = 9, sourceClass = RoleNameExplicitConstraint.class, method = "getAdministrativeDivisions") //固定下拉内容
@ExcelProperty(value = "现居住地", index = 9) @ExcelProperty(value = "现居住地", index = 9)
@ApiModelProperty(value = "现居住地") @ApiModelProperty(value = "现居住地")
private String residence; private String residence;
......
...@@ -4,6 +4,8 @@ import com.alibaba.excel.annotation.ExcelIgnore; ...@@ -4,6 +4,8 @@ import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -32,6 +34,7 @@ public class FireStationDto extends BaseDto { ...@@ -32,6 +34,7 @@ public class FireStationDto extends BaseDto {
@ApiModelProperty(value = "所在建筑物id") @ApiModelProperty(value = "所在建筑物id")
private String whereBuildingId; private String whereBuildingId;
@ExplicitConstraint(indexNum = 1, sourceClass = RoleNameExplicitConstraint.class, method = "getBuildingList")
@ExcelProperty(value = "所在建筑", index = 1) @ExcelProperty(value = "所在建筑", index = 1)
@ApiModelProperty(value = "所在建筑物名称") @ApiModelProperty(value = "所在建筑物名称")
private String whereBuilding; private String whereBuilding;
...@@ -56,6 +59,7 @@ public class FireStationDto extends BaseDto { ...@@ -56,6 +59,7 @@ public class FireStationDto extends BaseDto {
@ApiModelProperty(value = "单位id") @ApiModelProperty(value = "单位id")
private Long bizCompanyId; private Long bizCompanyId;
@ExplicitConstraint(indexNum = 6, sourceClass = RoleNameExplicitConstraint.class, method = "getBizCompanyList")
@ExcelProperty(value = "所属单位", index = 6) @ExcelProperty(value = "所属单位", index = 6)
@ApiModelProperty(value = "所属单位名称") @ApiModelProperty(value = "所属单位名称")
private String bizCompany; private String bizCompany;
......
...@@ -75,6 +75,7 @@ public class FireTeamDto extends BaseDto { ...@@ -75,6 +75,7 @@ public class FireTeamDto extends BaseDto {
@ApiModelProperty(value = "联系人id") @ApiModelProperty(value = "联系人id")
private Long contactUserId; private Long contactUserId;
@ExplicitConstraint(indexNum = 7, sourceClass = RoleNameExplicitConstraint.class,method = "getFirefighters") //动态下拉内容
@ExcelProperty(value = "联系人", index = 7) @ExcelProperty(value = "联系人", index = 7)
@ApiModelProperty(value = "联系人") @ApiModelProperty(value = "联系人")
private String contactUser; private String contactUser;
......
...@@ -22,7 +22,7 @@ import java.util.Date; ...@@ -22,7 +22,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "OrgUsr对象", description = "人员信息") @ApiModel(value = "OrgUsr对象", description = "人员信息")
public class ExcelOrgPersonDto extends BaseDto { public class OrgPersonExcelDto extends BaseDto {
@ExcelIgnore @ExcelIgnore
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -50,8 +50,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -50,8 +50,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "所在建筑id") @ApiModelProperty(value = "所在建筑id")
private Long belongBuildingId; private Long belongBuildingId;
// @ExplicitConstraint(indexNum = 3, sourceClass = SelectionDataFromInterface.class, method = "getBuildingList") @ExplicitConstraint(indexNum = 3, sourceClass = RoleNameExplicitConstraint.class, method = "getBuildingList")
//动态下拉内容
@ExcelProperty(value = "所在建筑", index = 3) @ExcelProperty(value = "所在建筑", index = 3)
@ApiModelProperty(value = "所在建筑") @ApiModelProperty(value = "所在建筑")
private String belongBuilding; private String belongBuilding;
...@@ -60,9 +59,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -60,9 +59,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "所属消防系统id") @ApiModelProperty(value = "所属消防系统id")
private Long belongFightingSystemId; private Long belongFightingSystemId;
// @ExplicitConstraint(indexNum = 4, sourceClass = SelectionDataFromInterface.class, method = @ExplicitConstraint(indexNum = 4, sourceClass = RoleNameExplicitConstraint.class, method = "getFireSystemList")
// "getFireSystemList")
//动态下拉内容
@ExcelProperty(value = "所属消防系统", index = 4) @ExcelProperty(value = "所属消防系统", index = 4)
@ApiModelProperty(value = "所属消防系统") @ApiModelProperty(value = "所属消防系统")
private String belongFightingSystem; private String belongFightingSystem;
...@@ -71,6 +68,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -71,6 +68,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "管理单位id") @ApiModelProperty(value = "管理单位id")
private Long managementUnitId; private Long managementUnitId;
@ExplicitConstraint(indexNum = 5, sourceClass = RoleNameExplicitConstraint.class, method = "getCompanyList")
@ExcelProperty(value = "管理单位", index = 5) @ExcelProperty(value = "管理单位", index = 5)
@ApiModelProperty(value = "管理单位") @ApiModelProperty(value = "管理单位")
private String managementUnit; private String managementUnit;
...@@ -79,6 +77,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -79,6 +77,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "维保单位id") @ApiModelProperty(value = "维保单位id")
private Long maintenanceUnitId; private Long maintenanceUnitId;
@ExplicitConstraint(indexNum = 6, sourceClass = RoleNameExplicitConstraint.class, method = "getCompanyList")
@ExcelProperty(value = "维保单位", index = 6) @ExcelProperty(value = "维保单位", index = 6)
@ApiModelProperty(value = "维保单位") @ApiModelProperty(value = "维保单位")
private String maintenanceUnit; private String maintenanceUnit;
...@@ -147,6 +146,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -147,6 +146,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "水源可用状态类别代码") @ApiModelProperty(value = "水源可用状态类别代码")
private String statusCode; private String statusCode;
@ExplicitConstraint(type = "SYKYZT", indexNum = 14, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "水源可用状态", index = 14) @ExcelProperty(value = "水源可用状态", index = 14)
@ApiModelProperty(value = "水源可用状态类别名称") @ApiModelProperty(value = "水源可用状态类别名称")
private String status; private String status;
...@@ -163,6 +163,7 @@ public class WaterResourceDto extends BaseDto { ...@@ -163,6 +163,7 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "消防给水管网形式类型代码") @ApiModelProperty(value = "消防给水管网形式类型代码")
private String pipeTypeCode; private String pipeTypeCode;
@ExplicitConstraint(type = "XFJSGWXS", indexNum = 17, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "消防给水管网形式", index = 17) @ExcelProperty(value = "消防给水管网形式", index = 17)
@ApiModelProperty(value = "消防给水管网形式") @ApiModelProperty(value = "消防给水管网形式")
private String pipeTypeName; private String pipeTypeName;
...@@ -226,14 +227,16 @@ public class WaterResourceDto extends BaseDto { ...@@ -226,14 +227,16 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "消防水带接口code") @ApiModelProperty(value = "消防水带接口code")
private String hoseConnectionCode; private String hoseConnectionCode;
@ExcelProperty(value = "取水方式", index = 28) @ExplicitConstraint(type = "QSXS", indexNum = 28, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ApiModelProperty(value = "取水方式") @ExcelProperty(value = "取水形式", index = 28)
@ApiModelProperty(value = "取水形式")
private String intakeForm; private String intakeForm;
@ExcelIgnore @ExcelIgnore
@ApiModelProperty(value = "水源类型代码") @ApiModelProperty(value = "水源类型代码")
private String typeCode; private String typeCode;
@ExplicitConstraint(type = "TRSYLX", indexNum = 29, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "水源类型", index = 29) @ExcelProperty(value = "水源类型", index = 29)
@ApiModelProperty(value = "水源类型") @ApiModelProperty(value = "水源类型")
private String type; private String type;
......
package com.yeejoin.amos.boot.module.common.api.enums;
/**
* @title: ExcelSelectData
* @Author fpy
* @Date: 2021/7/7 11:11
* @Version 1.0
*/
public class ExcelSelectData {
public static final String[] NATION = {"汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族",
"侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族",
"柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族",
"乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族",
"高山族"};
public static final String[] POLITICAL_OUTLOOK = {"中共党员", "中共预备党员", "共青团员", "民革会员", "民盟盟员", "民建会员", "民进会员",
"农工党党员", "致公党党员", "九三学社社员", "台盟盟员", "无党派人士", "群众"};
}
\ No newline at end of file
...@@ -8,5 +8,5 @@ import java.util.List; ...@@ -8,5 +8,5 @@ import java.util.List;
* *
* ***/ * ***/
public interface DataSources { public interface DataSources {
String[] selectList(String type,String method); String[] selectList(String type,String method) throws Exception;
} }
...@@ -35,7 +35,6 @@ public class ExcelUtil { ...@@ -35,7 +35,6 @@ public class ExcelUtil {
* @param sheetName sheet名 * @param sheetName sheet名
* @param data 导出的数据 * @param data 导出的数据
* @param model 导出的头 * @param model 导出的头
* @param heardHeight 头行高
* @param flag true模板填充下拉 false 不填充 * @param flag true模板填充下拉 false 不填充
*/ */
public static void createTemplate(HttpServletResponse response, String fileName, public static void createTemplate(HttpServletResponse response, String fileName,
...@@ -75,7 +74,7 @@ public class ExcelUtil { ...@@ -75,7 +74,7 @@ public class ExcelUtil {
* @param header 指定不读取的表头行数, * @param header 指定不读取的表头行数,
* @param <T> * @param <T>
* @return 集合数据 * @return 集合数据
* @throws ExcelException * @throws Exception
*/ */
public static <T> List<T> readFirstSheetExcel(MultipartFile excel, Class<T> rowType,int header) throws Exception { public static <T> List<T> readFirstSheetExcel(MultipartFile excel, Class<T> rowType,int header) throws Exception {
ExcelReader reader = getReader(excel, header); ExcelReader reader = getReader(excel, header);
...@@ -116,7 +115,7 @@ public class ExcelUtil { ...@@ -116,7 +115,7 @@ public class ExcelUtil {
* @param excel 需要解析的 Excel 文件 * @param excel 需要解析的 Excel 文件
* @param header 指定不读取表头行数, * @param header 指定不读取表头行数,
* @return * @return
* @throws ExcelException * @throws Exception
*/ */
public static ExcelReader getReader(MultipartFile excel,int header) throws Exception { public static ExcelReader getReader(MultipartFile excel,int header) throws Exception {
String fileName = excel.getOriginalFilename(); String fileName = excel.getOriginalFilename();
...@@ -168,6 +167,8 @@ public class ExcelUtil { ...@@ -168,6 +167,8 @@ public class ExcelUtil {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} }
} }
return null; return null;
......
...@@ -7,5 +7,5 @@ public interface ExplicitInterface { ...@@ -7,5 +7,5 @@ public interface ExplicitInterface {
* @return * @return
* type 字典类型 * type 字典类型
*/ */
String[] source(String type,String method,DataSources dataDictionaryMapper); String[] source(String type,String method,DataSources dataDictionaryMapper) throws Exception;
} }
...@@ -8,7 +8,7 @@ package com.yeejoin.amos.boot.module.common.api.excel; ...@@ -8,7 +8,7 @@ package com.yeejoin.amos.boot.module.common.api.excel;
public class RoleNameExplicitConstraint implements ExplicitInterface { public class RoleNameExplicitConstraint implements ExplicitInterface {
@Override @Override
public String[] source(String type, String method, DataSources dataDictionaryMapper) { public String[] source(String type, String method, DataSources dataDictionaryMapper) throws Exception {
return dataDictionaryMapper.selectList(type, method); return dataDictionaryMapper.selectList(type, method);
} }
......
...@@ -30,7 +30,7 @@ public class TemplateCellWriteHandlerDate implements SheetWriteHandler { ...@@ -30,7 +30,7 @@ public class TemplateCellWriteHandlerDate implements SheetWriteHandler {
/** /**
* 避免生成的导入模板下拉值获取不到 * 避免生成的导入模板下拉值获取不到
*/ */
private static final Integer LIMIT_NUMBER = 50; private static final Integer LIMIT_NUMBER = 10;
......
package com.yeejoin.amos.boot.module.common.api.mapper; package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.dto.ExcelOrgPersonDto; import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonExcelDto;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr; import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -29,5 +29,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -29,5 +29,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode); List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode);
List<ExcelOrgPersonDto> queryOrgPersonDtoList(boolean isDelete); List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete);
} }
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
and biz_org_code like concat(#{bizOrgCode}, '%') and biz_org_code like concat(#{bizOrgCode}, '%')
</select> </select>
<select id="queryOrgPersonDtoList" resultType="com.yeejoin.amos.boot.module.common.api.dto.ExcelOrgPersonDto"> <select id="queryOrgPersonDtoList" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgPersonExcelDto">
select u.*, select u.*,
v.person_number, v.person_number,
v.certificates_type, v.certificates_type,
......
package com.yeejoin.amos.boot.module.jcs.api.enums; package com.yeejoin.amos.boot.module.jcs.api.enums;
/** /**
* * 导出类型常量
* 导出类型常量 ***/
* public class ExcelEnums {
* ***/ public static final String WHP = "WHP";// ("WHP","危险品"),
public class ExcelEnums { public static final String XFZJ = "XFZJ";//("XFZJ","消防专家"),
public static final String WHP = "WHP";// ("WHP","危险品"), public static final String SYXX = "SYXX";//("SYXX","水源信息"),
public static final String XFZJ = "XFZJ";//("XFZJ","消防专家"), public static final String HKQ = "HKQ";//("HKQ","航空器");
public static final String SYXX = "SYXX";//("SYXX","水源信息"), public static final String XFDW = "XFDW";//("XFDW","消防队伍")
public static final String HKQ = "HKQ";//("HKQ","航空器"); public static final String WXXFZ = "WXXFZ";//("WXXFZ","微型消防站")
} }
...@@ -127,40 +127,4 @@ public class FireChemicalController extends BaseController { ...@@ -127,40 +127,4 @@ public class FireChemicalController extends BaseController {
public ResponseModel<List<FireChemicalDto>> selectForList() { public ResponseModel<List<FireChemicalDto>> selectForList() {
return ResponseHelper.buildResponse(fireChemicalServiceImpl.queryForFireChemicalList(false)); return ResponseHelper.buildResponse(fireChemicalServiceImpl.queryForFireChemicalList(false));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入危化品")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception {
List<FireChemicalDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireChemicalDto.class,
1);
List<FireChemical> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireChemical fireChemical = new FireChemical();
fireChemical = Bean.toPo(item, fireChemical);
if (fireChemical.getType() != null) {
String[] type = fireChemical.getType().split("@");
fireChemical.setType(type[0]);
fireChemical.setTypeCode(type[1]);
}
excelEntityList.add(fireChemical);
}
);
fireChemicalServiceImpl.saveBatch(excelEntityList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出危化品")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<FireChemicalDto> data = fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireChemicalDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
} }
...@@ -203,54 +203,4 @@ public class FireExpertsController extends BaseController { ...@@ -203,54 +203,4 @@ public class FireExpertsController extends BaseController {
// 创建挂在主节点 // 创建挂在主节点
return ResponseHelper.buildResponse(menuList); return ResponseHelper.buildResponse(menuList);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量导入消防专家")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception {
List<FireExpertsDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireExpertsDto.class, 1);
List<FireExperts> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
fireExpertsDto -> {
FireExperts fireExperts = new FireExperts();
fireExperts = Bean.toPo(fireExpertsDto, fireExperts);
if (fireExperts.getCertificatesType() != null) {
String[] certificates = fireExperts.getCertificatesType().split("@");
fireExperts.setCertificatesType(certificates[0]);
fireExperts.setCertificatesTypeCode(certificates[1]);
}
if (fireExperts.getJobs() != null) {
String[] jobs = fireExperts.getJobs().split("@");
fireExperts.setJobs(jobs[0]);
fireExperts.setJobsCode(jobs[1]);
}
if (fireExperts.getExpert() != null) {
String[] expert = fireExperts.getExpert().split("@");
fireExperts.setExpert(expert[0]);
fireExperts.setExpertCode(expert[1]);
}
if (fireExperts.getHighestEducation() != null) {
String[] highestEducation = fireExperts.getHighestEducation().split("@");
fireExperts.setHighestEducation(highestEducation[0]);
}
excelEntityList.add(fireExperts);
}
);
fireExpertsServiceImpl.saveBatch(excelEntityList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出消防专家")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireExpertsDtoList,
FireExpertsDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常");
}
}
} }
...@@ -139,34 +139,4 @@ public class FireStationController extends BaseController { ...@@ -139,34 +139,4 @@ public class FireStationController extends BaseController {
public ResponseModel<List<FireStationDto>> selectForList() { public ResponseModel<List<FireStationDto>> selectForList() {
return ResponseHelper.buildResponse(fireStationServiceImpl.queryForFireStationList(false)); return ResponseHelper.buildResponse(fireStationServiceImpl.queryForFireStationList(false));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入微型消防站")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
List<FireStation> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireStation fireStation = new FireStation();
fireStation = Bean.toPo(item, fireStation);
excelEntityList.add(fireStation);
}
);
fireStationServiceImpl.saveBatch(excelEntityList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出微型消防站")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<FireStationDto> data = fireStationServiceImpl.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireStationDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
} }
...@@ -220,7 +220,7 @@ public class OrgPersonController { ...@@ -220,7 +220,7 @@ public class OrgPersonController {
@ApiOperation(value = "导入机场单位") @ApiOperation(value = "导入机场单位")
@PostMapping("/import_batch") @PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception { public void importByExcel(MultipartFile multipartFile) throws Exception {
List<ExcelOrgPersonDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, ExcelOrgPersonDto.class, 1); List<OrgPersonExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, OrgPersonExcelDto.class, 1);
iOrgUsrService.importByExcel(excelDtoList); iOrgUsrService.importByExcel(excelDtoList);
} }
...@@ -229,9 +229,9 @@ public class OrgPersonController { ...@@ -229,9 +229,9 @@ public class OrgPersonController {
@GetMapping("/export") @GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) { public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try { try {
List<ExcelOrgPersonDto> data = iOrgUsrService.queryOrgPersonDtoList(false); List<OrgPersonExcelDto> data = iOrgUsrService.queryOrgPersonDtoList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data, ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
ExcelOrgPersonDto.class, null, false); OrgPersonExcelDto.class, null, false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("系统异常!"); throw new RuntimeException("系统异常!");
......
...@@ -321,50 +321,4 @@ public class WaterResourceController extends BaseController { ...@@ -321,50 +321,4 @@ public class WaterResourceController extends BaseController {
public ResponseModel<List<WaterResourceDto>> selectForList() { public ResponseModel<List<WaterResourceDto>> selectForList() {
return ResponseHelper.buildResponse(waterResourceServiceImpl.queryForWaterResourceList(true)); return ResponseHelper.buildResponse(waterResourceServiceImpl.queryForWaterResourceList(true));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量导入消防水源")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception {
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]);
item.setResourceType(resourceTypeName[1]);
}
if (item.getSystemType() != null) {
String[] systemType = item.getSystemType().split("@");
item.setSystemType(systemType[0]);
item.setSystemTypeCode(systemType[1]);
}
if (item.getPlaceForm() != null) {
String[] placeForm = item.getPlaceForm().split("@");
item.setPlaceForm(placeForm[0]);
item.setPlaceFormCode(placeForm[1]);
}
if (item.getHoseConnection() != null) {
String[] hoseConnection = item.getHoseConnection().split("@");
item.setHoseConnection(hoseConnection[0]);
item.setHoseConnectionCode(hoseConnection[1]);
}
waterResourceServiceImpl.importByExcel(item);
}
);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出消防水源")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), waterResourceDtoList,
WaterResourceDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常");
}
}
} }
...@@ -29,7 +29,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -29,7 +29,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant; import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.module.common.api.dto.DynamicFormColumnDto; import com.yeejoin.amos.boot.module.common.api.dto.DynamicFormColumnDto;
import com.yeejoin.amos.boot.module.common.api.dto.DynamicFormInstanceDto; import com.yeejoin.amos.boot.module.common.api.dto.DynamicFormInstanceDto;
import com.yeejoin.amos.boot.module.common.api.dto.ExcelOrgPersonDto; import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonExcelDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue; import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentDto; import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentFormDto; import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentFormDto;
...@@ -763,7 +763,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -763,7 +763,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return sb.toString(); return sb.toString();
} }
public void importByExcel(List<ExcelOrgPersonDto> list) { public void importByExcel(List<OrgPersonExcelDto> list) {
list.forEach(item -> { list.forEach(item -> {
OrgPersonDto orgPersonDto = new OrgPersonDto(); OrgPersonDto orgPersonDto = new OrgPersonDto();
orgPersonDto = Bean.toPo(item, orgPersonDto); orgPersonDto = Bean.toPo(item, orgPersonDto);
...@@ -878,9 +878,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -878,9 +878,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
); );
} }
public List<ExcelOrgPersonDto> queryOrgPersonDtoList(boolean isDelete) { public List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete) {
List<ExcelOrgPersonDto> excelOrgPersonDtoList = orgUsrMapper.queryOrgPersonDtoList(isDelete); List<OrgPersonExcelDto> excelOrgPersonDtoList = orgUsrMapper.queryOrgPersonDtoList(isDelete);
return excelOrgPersonDtoList; return excelOrgPersonDtoList;
} }
......
...@@ -129,59 +129,4 @@ public class AircraftController extends BaseController { ...@@ -129,59 +129,4 @@ public class AircraftController extends BaseController {
return ResponseHelper.buildResponse(aircraftServiceImpl.queryForAircraftPage(page, false, aircraftModel, return ResponseHelper.buildResponse(aircraftServiceImpl.queryForAircraftPage(page, false, aircraftModel,
engineType, fuelType)); engineType, fuelType));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入航空器")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile) throws Exception {
List<AircraftDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, AircraftDto.class,
1);
List<Aircraft> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
Aircraft aircraft = new Aircraft();
aircraft = Bean.toPo(item, aircraft);
if (aircraft.getEngineType() != null) {
String[] engineType = aircraft.getEngineType().split("@");
aircraft.setEngineType(engineType[0]);
aircraft.setEngineTypeCode(engineType[1]);
}
if (aircraft.getFuelType() != null) {
String[] fuelType = aircraft.getFuelType().split("@");
aircraft.setFuelType(fuelType[0]);
aircraft.setFuelTypeCode(fuelType[1]);
}
excelEntityList.add(aircraft);
}
);
aircraftServiceImpl.saveBatch(excelEntityList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出航空器")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<AircraftDto> data = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
AircraftDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "下载航空器模板")
@GetMapping("/template")
public void template(HttpServletResponse response, ExcelDto excelDto) {
try {
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), null,
AircraftDto.class, dataSourcesImpl, true);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
} }
...@@ -53,7 +53,7 @@ public class FireTeamController extends BaseController { ...@@ -53,7 +53,7 @@ public class FireTeamController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍") @ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍")
public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) { public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) {
iFireTeamService.save(fireTeam); iFireTeamService.save(fireTeam);
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
...@@ -67,7 +67,7 @@ public class FireTeamController extends BaseController { ...@@ -67,7 +67,7 @@ public class FireTeamController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除") @ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public ResponseModel<Object> deleteById(HttpServletRequest request, @PathVariable Long id) { public ResponseModel<Object> deleteById(HttpServletRequest request, @PathVariable Long id) {
iFireTeamService.update(new UpdateWrapper<FireTeam>().eq("sequence_nbr", id).set("is_delete", 1)); iFireTeamService.update(new UpdateWrapper<FireTeam>().eq("sequence_nbr", id).set("is_delete", 1));
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
...@@ -183,40 +183,4 @@ public class FireTeamController extends BaseController { ...@@ -183,40 +183,4 @@ public class FireTeamController extends BaseController {
page = iFireTeamService.page(pageBean, fireTeamQueryWrapper); page = iFireTeamService.page(pageBean, fireTeamQueryWrapper);
return page; return page;
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入消防队伍")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile, HttpServletResponse response) throws Exception {
List<FireTeamDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireTeamDto.class,
1);
List<FireTeam> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireTeam fireTeam = new FireTeam();
fireTeam = Bean.toPo(item, fireTeam);
if (fireTeam.getType() != null) {
String[] type = fireTeam.getType().split("@");
fireTeam.setType(type[0]);
fireTeam.setTypeCode(type[1]);
}
excelEntityList.add(fireTeam);
}
);
iFireTeamService.saveBatch(excelEntityList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出消防队伍")
@GetMapping("/export")
public void exportToExcel(HttpServletResponse response, ExcelDto excelDto) {
try {
List<FireTeamDto> data = iFireTeamService.queryFireTeamForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireTeamDto.class, null, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.entity.DataDictionary; import com.yeejoin.amos.boot.module.common.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.common.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.enums.ExcelSelectData;
import com.yeejoin.amos.boot.module.common.api.excel.DataSources; import com.yeejoin.amos.boot.module.common.api.excel.DataSources;
import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -15,14 +29,134 @@ public class DataSourcesImpl implements DataSources { ...@@ -15,14 +29,134 @@ public class DataSourcesImpl implements DataSources {
@Resource @Resource
DataDictionaryMapper dataDictionaryMapper; DataDictionaryMapper dataDictionaryMapper;
@Autowired
EquipmentServiceImpl equipmentService;
@Autowired
OrgUsrServiceImpl orgUsrService;
@Autowired
FirefightersServiceImpl firefightersService;
@Autowired
private RestTemplate restTemplate;
@Value("${security.systemctl.name}")
private String systemctl;
@Override @Override
public String[] selectList(String type, String method) { public String[] selectList(String type, String method) throws Exception {
String[] str = {};
if (StringUtils.isNotEmpty(type)) {
str = getDataDictionary(type);
} else {
switch (method) {
case "getNations":
str = ExcelSelectData.NATION;
break;
case "getPoliticalOutlook":
str = ExcelSelectData.POLITICAL_OUTLOOK;
break;
case "getAdministrativeDivisions":
// 设置请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.valueOf("application/json; charset=utf-8"));
// 用HttpEntity封装整个请求报文
HttpEntity<Object> httpEntity = new HttpEntity<>(null, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange("http://" + systemctl + "/systemctl" +
"/v1" +
"/region/tree/parent", HttpMethod.GET,
httpEntity, String.class);
String body = responseEntity.getBody();
break;
case "getBuildingList":
str = getBuildingList();
break;
case "getFireSystemList":
str = getFireSystemList();
break;
case "getCompanyList":
str = getCompanyList();
break;
case "getFirefighters":
str = getFirefighters();
break;
case "getBizCompanyList":
str = getBizCompanyList();
break;
}
}
return str;
}
private String[] getBizCompanyList() throws Exception {
List<OrgMenuDto> orgUsrTree = orgUsrService.getTree(null, orgUsrService.selectCompanyDepartmentMsg(),
OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType");
List<String> stringList = new ArrayList<String>();
initBizCompanyList(orgUsrTree, stringList);
String[] str = stringList.toArray(new String[stringList.size()]);
return str;
}
private void initBizCompanyList(List<OrgMenuDto> orgUsrTree, List<String> stringList) {
for (OrgMenuDto orgMenuDto : orgUsrTree) {
stringList.add(orgMenuDto.getName() + "@" + orgMenuDto.getKey() + "@" + orgMenuDto.getBizOrgCode());
List<OrgMenuDto> children = orgMenuDto.getChildren();
if (children != null && children.size() > 0) {
initCompanyList(children, stringList);
}
}
}
private String[] getFirefighters() {
List<Firefighters> firefighters = firefightersService.getFirefighters(1, Integer.MAX_VALUE,
new FirefightersDto());
List<String> names = firefighters.stream().map(item -> {
return item.getName() + "@" + item.getSequenceNbr();
}).collect(Collectors.toList());
String[] str = names.toArray(new String[names.size()]);
return str;
}
private String[] getCompanyList() throws Exception {
List<OrgMenuDto> orgUsrTree = orgUsrService.getTree(null, orgUsrService.selectCompanyDepartmentMsg(),
OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType");
List<String> stringList = new ArrayList<String>();
initCompanyList(orgUsrTree, stringList);
String[] str = stringList.toArray(new String[stringList.size()]);
return str;
}
private void initCompanyList(List<OrgMenuDto> orgUsrTree, List<String> stringList) {
for (OrgMenuDto orgMenuDto : orgUsrTree) {
stringList.add(orgMenuDto.getName() + "@" + orgMenuDto.getKey());
List<OrgMenuDto> children = orgMenuDto.getChildren();
if (children != null && children.size() > 0) {
initCompanyList(children, stringList);
}
}
}
private String[] getFireSystemList() {
List<MenuFrom> fireSystemList = equipmentService.getFireSystemList();
List<String> names = fireSystemList.stream().map(item -> {
return item.getName() + "@" + item.getKey();
}).collect(Collectors.toList());
String[] str = names.toArray(new String[names.size()]);
return str;
}
private String[] getBuildingList() {
List<MenuFrom> buildingList = equipmentService.getBuildingList();
List<String> buildingNames = buildingList.stream().map(item -> {
return item.getName() + "@" + item.getKey();
}).collect(Collectors.toList());
String[] str = buildingNames.toArray(new String[buildingNames.size()]);
return str;
}
private String[] getDataDictionary(String type) {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>(); QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type); queryWrapper.eq("type", type);
if ("ZJLY".equals(type)) {
queryWrapper.isNull("parent");
}
queryWrapper.orderByAsc("sort_num"); queryWrapper.orderByAsc("sort_num");
List<DataDictionary> list = dataDictionaryMapper.selectList(queryWrapper); List<DataDictionary> list = dataDictionaryMapper.selectList(queryWrapper);
List<String> names = list.stream().map(dataDictionary -> { List<String> names = list.stream().map(dataDictionary -> {
......
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