Commit f429429f authored by 付培阳's avatar 付培阳

导入导出

parent ac1f0544
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.jcs.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.jcs.api.excel.RoleNameExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 航空器信息
*
* @author system_generator
* @date 2021-06-29
*/
* 航空器信息
*
* @author system_generator
* @date 2021-06-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="AircraftDto", description="航空器信息")
public class AircraftDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModel(value = "AircraftDto", description = "航空器信息")
public class AircraftDto extends BaseDto {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "飞机型号", index = 0)
@ApiModelProperty(value = "飞机型号")
private String aircraftModel;
@ExcelProperty(value = "中文全称", index = 1)
@ApiModelProperty(value = "中文全称")
private String fullName;
@ExcelProperty(value = "飞机长度", index = 2)
@ApiModelProperty(value = "飞机长度")
private Double aircraftLength;
@ExcelProperty(value = "机舱长度", index = 3)
@ApiModelProperty(value = "机舱长度")
private Double cabinLength;
@ExcelProperty(value = "尾翼高度", index = 4)
@ApiModelProperty(value = "尾翼高度")
private Double tailHeight;
@ExcelProperty(value = "翼展", index = 5)
@ApiModelProperty(value = "翼展")
private Double wingspan;
@ExcelProperty(value = "机身直径", index = 6)
@ApiModelProperty(value = "机身直径")
private Double fuselageDiameter;
@ExcelProperty(value = "翼展面积", index = 7)
@ApiModelProperty(value = "翼展面积")
private Double wingspanArea;
@ExplicitConstraint(type = "FDJLX", indexNum = 8, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "发动机类型", index = 8)
@ApiModelProperty(value = "发动机类型")
private String engineType;
@ExcelIgnore
@ApiModelProperty(value = "发动机类型code")
private String engineTypeCode;
@ExcelProperty(value = "发动机数量", index = 9)
@ApiModelProperty(value = "发动机数量")
private Integer enginesmNum;
@ExcelProperty(value = "发动机型号", index = 10)
@ApiModelProperty(value = "发动机型号")
private String engineModel;
@ExplicitConstraint(type = "RYLX", indexNum = 11, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "燃油类型", index = 11)
@ApiModelProperty(value = "燃油类型")
private String fuelType;
@ExcelIgnore
@ApiModelProperty(value = "燃油类型code")
private String fuelTypeCode;
@ExcelProperty(value = "最大载油量", index = 12)
@ApiModelProperty(value = "最大载油量")
private Double oilLoadMax;
@ExcelProperty(value = "标准燃油", index = 13)
@ApiModelProperty(value = "标准燃油")
private Double standardFuel;
@ExcelProperty(value = "空重", index = 14)
@ApiModelProperty(value = "空重")
private Double emptyWeight;
@ExcelProperty(value = "飞机主要构造材料", index = 15)
@ApiModelProperty(value = "飞机主要构造材料")
private String structuralMaterial;
@ExcelProperty(value = "氧气瓶数量", index = 16)
@ApiModelProperty(value = "氧气瓶数量")
private Integer oxygenCylinderNum;
@ExcelProperty(value = "氧气瓶位置描述", index = 17)
@ApiModelProperty(value = "氧气瓶位置描述")
private String oxygenCylinderLocation;
@ExcelProperty(value = "标准坐席数", index = 18)
@ApiModelProperty(value = "标准坐席数")
private Integer seatNum;
@ExcelProperty(value = "商载(吨)", index = 19)
@ApiModelProperty(value = "商载(吨)")
private Double commercialLoad;
@ExcelProperty(value = "货仓容积(立方米)", index = 20)
@ApiModelProperty(value = "货仓容积(立方米)")
private Double warehouseVolume;
@ExcelProperty(value = "最大起飞总重(吨)", index = 21)
@ApiModelProperty(value = "最大起飞总重(吨)")
private Double takeoffWeightNum;
@ExcelProperty(value = "最大巡航速度(马赫)", index = 22)
@ApiModelProperty(value = "最大巡航速度(马赫)")
private Double cruiseSpeedNum;
@ExcelProperty(value = "航程", index = 23)
@ApiModelProperty(value = "航程")
private Double voyage;
@ExcelProperty(value = "主要设施", index = 24)
@ApiModelProperty(value = "主要设施")
private String facilitie;
@ExcelProperty(value = "主要燃烧物质", index = 25)
@ApiModelProperty(value = "主要燃烧物质")
private String combustionMaterial;
@ExcelProperty(value = "疏散出口及安全通道", index = 26)
@ApiModelProperty(value = "疏散出口及安全通道")
private String exitPassage;
@ExcelProperty(value = "备注", index = 27)
@ApiModelProperty(value = "备注")
private String remark;
@ExcelProperty(value = "外观图", index = 28)
@ApiModelProperty(value = "外观图")
private String appearanceImages;
@ExcelProperty(value = "平面图", index = 29)
@ApiModelProperty(value = "平面图")
private String planeImages;
@ExcelProperty(value = "救援图", index = 30)
@ApiModelProperty(value = "救援图")
private String rescueImages;
@ExcelProperty(value = "方位图", index = 31)
@ApiModelProperty(value = "方位图")
private String positionImages;
@ExcelProperty(value = "三维模型", index = 32)
@ApiModelProperty(value = "三维模型")
private String models;
......
package com.yeejoin.amos.boot.module.jcs.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @title: ExcelSelectDto
* @Author fpy
* @Date: 2021/7/2 16:19
* @Version 1.0
*/
@Data
@AllArgsConstructor
public class ExcelSelectDto {
@ApiModelProperty(value = "下拉框的key")
private String code;
@ApiModelProperty(value = "下拉框的value")
private String name;
}
\ No newline at end of file
......@@ -13,18 +13,17 @@ import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 危化品
*
* @author system_generator
* @date 2021-06-29
*/
* 危化品
*
* @author system_generator
* @date 2021-06-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="FireChemicalDto", description="危化品")
public class FireChemicalDto extends BaseDto {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ApiModel(value = "FireChemicalDto", description = "危化品")
public class FireChemicalDto extends BaseDto {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "casNo")
......@@ -80,12 +79,12 @@ public class FireChemicalDto extends BaseDto {
@ExcelIgnore
@ApiModelProperty(value = "类型code")
private String typeCode;
@ExplicitConstraint(type="CHEMICALTYPE",indexNum=13,sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExplicitConstraint(type = "CHEMICALTYPE", indexNum = 13, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ApiModelProperty(value = "类型名称")
@ExcelProperty(value = "类型名称", index = 13)
private String type;
// @ExplicitConstraint(indexNum=14,source = {"男","女"}) //固定下拉内容
// @ExplicitConstraint(indexNum=14,source = {"男","女"}) //固定下拉内容
@ExcelProperty(value = "国标号", index = 14)
@ApiModelProperty(value = "国标号")
private String un;
......@@ -99,6 +98,6 @@ public class FireChemicalDto extends BaseDto {
@ExcelIgnore
@ApiModelProperty(value = "操作人名称")
private String recUserName;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.jcs.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.jcs.api.excel.RoleNameExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -17,90 +21,124 @@ import java.util.Date;
@ApiModel(value = "FireExpertsDto", description = "")
public class FireExpertsDto extends BaseDto {
@ExcelProperty(value = "姓名", index = 0)
@ApiModelProperty(value = "姓名")
private String name;
@ExcelProperty(value = "单位", index = 1)
@ApiModelProperty(value = "单位")
private String companyName;
@ExplicitConstraint(type = "RYZJLX", indexNum = 2, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "证件类型", index = 2)
@ApiModelProperty(value = "证件类型")
private String certificatesType;
@ExcelIgnore
@ApiModelProperty(value = "证件类型code")
private String certificatesTypeCode;
@ExcelProperty(value = "证件号", index = 3)
@ApiModelProperty(value = "证件号")
private Long certificatesNum;
@ApiModelProperty(value = "单位")
private String companyName;
private String certificatesNum;
@ExplicitConstraint(indexNum = 4, source = {"男", "女"}) //固定下拉内容
@ExcelProperty(value = "性别", index = 4)
@ApiModelProperty(value = "性别")
private String gender;
@ApiModelProperty(value = "名族")
@ExcelProperty(value = "出生日期", index = 5)
@ApiModelProperty(value = "出生日期")
private Date birthdayTime;
@ExcelProperty(value = "民族", index = 6)
@ApiModelProperty(value = "民族")
private String nation;
@ExcelProperty(value = "籍贯", index = 7)
@ApiModelProperty(value = "籍贯")
private String nativePlace;
@ExcelProperty(value = "政治面貌", index = 8)
@ApiModelProperty(value = "政治面貌")
private String politicalOutlook;
@ExcelProperty(value = "现居住地", index = 9)
@ApiModelProperty(value = "现居住地")
private String residence;
@ApiModelProperty(value = "现居住地")
@ExcelProperty(value = "居住地详情", index = 10)
@ApiModelProperty(value = "居住地详情")
private String residenceDetails;
@ApiModelProperty(value = "政治面貌")
private String politicalOutlook;
@ApiModelProperty(value = "办公用 电话")
@ExcelProperty(value = "办公电话", index = 11)
@ApiModelProperty(value = "办公电话")
private String officePhone;
@ExcelProperty(value = "移动电话", index = 12)
@ApiModelProperty(value = "移动电话")
private String mobilePhone;
@ExplicitConstraint(type = "XLLX", indexNum = 13, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "最高学历", index = 13)
@ApiModelProperty(value = "最高学历")
private String highestEducation;
@ExplicitConstraint(type = "GWMC", indexNum = 14, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "岗位名称", index = 14)
@ApiModelProperty(value = "岗位名称")
private String jobs;
@ExcelIgnore
@ApiModelProperty(value = "岗位名称code")
private String jobsCode;
@ExplicitConstraint(type = "ZJLY", indexNum = 15, sourceClass = RoleNameExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "消防专家领域", index = 15)
@ApiModelProperty(value = "消防专家领域")
private String expert;
@ExcelIgnore
@ApiModelProperty(value = "消防专家领域code")
private String expertCode;
@ExcelProperty(value = "人员照片", index = 16)
@ApiModelProperty(value = "人员照片")
private String personnelPhotos;
@ExcelProperty(value = "资质证书", index = 17)
@ApiModelProperty(value = "资质证书")
private String qualificationCertificate;
@ExcelIgnore
@ApiModelProperty(value = "人员状态,在职/离职")
private String state;
@ExcelIgnore
@ApiModelProperty(value = "人员状态,在职/离职code")
private String stateCode;
@ExcelIgnore
@ApiModelProperty(value = "消防机构id")
private Long fireTeamId;
@ExcelIgnore
@ApiModelProperty(value = "消防机构name")
private Long fireTeamName;
@ExcelProperty(value = "备注", index = 18)
@ApiModelProperty(value = "备注")
private String note;
@ExcelIgnore
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ExcelIgnore
@ApiModelProperty(value = "操作人名称")
private String recUserName;
@ApiModelProperty(value = "出生日期")
private Date birthdayTime;
@ExcelIgnore
@ApiModelProperty(value = "年龄")
private Integer age;
......
......@@ -31,7 +31,7 @@ public class FireExperts extends BaseEntity {
private String certificatesTypeCode;
@ApiModelProperty(value = "证件号")
private Long certificatesNum;
private String certificatesNum;
@ApiModelProperty(value = "单位")
private String companyName;
......
......@@ -14,7 +14,9 @@ public @interface ExplicitConstraint {
Class[]sourceClass()default {};
//列标号必须和字段下标一致
int indexNum() default 0;
//字典type
//字典type或接口类型
String type() default "";
//从接口获取值时的方法名
String method() default "";
}
......@@ -2,28 +2,30 @@ package com.yeejoin.amos.boot.module.jcs.api.excel;
import java.util.List;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jcs.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.jcs.api.mapper.DataDictionaryMapper;
/***
*
*
* 获取动态值
*
*
* **/
public class RoleNameExplicitConstraint implements ExplicitInterface {
@Override
public String[] source(String type,DataDictionaryMapper dataDictionaryMapper) {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
List<DataDictionary> list= dataDictionaryMapper.selectList(queryWrapper);
List<String> names = list.stream().map(dataDictionary->{
return dataDictionary.getName()+"@"+dataDictionary.getCode();
}
).collect(Collectors.toList());
String[] str=names.toArray(new String[names.size()]);
return str;
}
@Override
public String[] source(String type, DataDictionaryMapper dataDictionaryMapper) {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.isNull("parent");
queryWrapper.orderByAsc("sort_num");
List<DataDictionary> list = dataDictionaryMapper.selectList(queryWrapper);
List<String> names = list.stream().map(dataDictionary -> {
return dataDictionary.getName() + "@" + dataDictionary.getCode();
}
).collect(Collectors.toList());
String[] str = names.toArray(new String[names.size()]);
return str;
}
}
package com.yeejoin.amos.boot.module.jcs.api.excel;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.stream.Collectors;
/***
*
* 获取动态值
*
* **/
public class SelectionDataFromInterface implements SelectionDataInterface {
@Override
public String[] source(String methodName) {
switch (methodName) {
case "getBuildingList":
// List<MenuFrom> buildingList = equipmentService.getBuildingList();
// List<String> buildingNameList = buildingList.stream().map(item -> {
// return item.getName() + "@" + item.getKey();
// }
// ).collect(Collectors.toList());
// String[] buildingNameStr = buildingNameList.toArray(new String[buildingNameList.size()]);
// return buildingNameStr;
case "getFireSystemList":
// List<MenuFrom> fireSystemList = equipmentService.getFireSystemList();
// List<String> fireSystemNameList = fireSystemList.stream().map(item -> {
// return item.getName() + "@" + item.getKey();
// }
// ).collect(Collectors.toList());
// String[] fireSystemNameStr = fireSystemNameList.toArray(new String[fireSystemNameList.size()]);
// return fireSystemNameStr;
}
return null;
}
}
package com.yeejoin.amos.boot.module.jcs.api.excel;
import com.yeejoin.amos.boot.module.jcs.api.mapper.DataDictionaryMapper;
public interface SelectionDataInterface {
/**
* 动态下拉列表的内容数组
* @return
* type 字典类型
*/
String[] source(String methodName);
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.yeejoin.amos.boot.module.jcs.api.dto.WaterResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.WaterResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* Mapper 接口
*
* @author system_generator
* @date 2021-06-29
*/
* Mapper 接口
*
* @author system_generator
* @date 2021-06-29
*/
public interface WaterResourceMapper extends BaseMapper<WaterResource> {
List<WaterResourceDto> exportToExcel(Boolean isDelete);
}
......@@ -2,4 +2,58 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jcs.api.mapper.WaterResourceMapper">
<select id="exportToExcel" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.WaterResourceDto">
select r.name,
r.address,
r.resource_type_name,
r.belong_building,
r.belong_fighting_system,
r.management_unit,
r.maintenance_unit,
r.build_date,
r.enable_date,
r.orientation_img,
r.reality_img,
r.contact_user,
r.contact_phone,
(case r.resource_type when 'crane' then rc.height when 'natural' then rn.height end) height,
(case r.resource_type when 'crane' then rc.status when 'pool' then rp.status when 'natural' then rn.status end) status,
(case r.resource_type when 'crane' then rc.section when 'pool' then rp.section end) section,
(case r.resource_type when 'crane' then rc.pipe_network when 'hydarant' then rh.pipe_network end) pipe_network,
(case r.resource_type when 'crane' then rc.pipe_type_name when 'hydarant' then rh.pipe_type_name when 'pool' then rp.pipe_type_name end) pipe_type_name,
(case r.resource_type when 'crane' then rc.pipe_diameter when 'hydarant' then rh.pipe_diameter end) pipe_diameter,
rc.inlet_pipe_diameter,
rc.outlet_pipe_diameter,
rc.waterfilling_lane_num,
(case r.resource_type when 'crane' then rc.water_supply_name when 'hydarant' then rh.water_supply_name when 'pool' then rp.water_supply_name end) water_supply_name,
(case when 'hydrant' then rh.type when 'natural' then rn.type end) type,
rh.system_type,
rh.facilities_category,
rh.road_junction_info,
rh.place_form,
rh.hose_connection,
(case r.resource_type when 'hydrant' then rh.intake_form when 'pool' then rp.intake_form end) intake_form,
(case r.resource_type when 'natural' then rn.volume when 'pool' then rp.volume end) volume,
rn.area,
rn.quality_situation_info,
rn.season_change_info,
rn.has_dry_season,
rn.dry_period_span,
rp.intake_height,
rp.elevation_difference,
rp.parking_position,
rp.parking_num,
ri.iot_water_storage,
ri.iot_flow_rate,
ri.iot_status,
ri.iot_pipe_pressure
from cb_water_resource r
left join cb_water_resource_pool rp
on r.sequence_nbr = rp.resource_id
left join cb_water_resource_crane rc on r.sequence_nbr = rc.resource_id
left join cb_water_resource_hydrant rh on r.sequence_nbr = rh.resource_id
left join cb_water_resource_natural rn on r.sequence_nbr = rn.resource_id
left join cb_water_resource_iot ri on r.sequence_nbr = ri.resource_id
where r.is_delete = #{isDelete}
</select>
</mapper>
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,7 +39,7 @@ import io.swagger.annotations.ApiOperation;
public class ExcelController extends BaseController {
@Autowired
@Resource
DataDictionaryMapper dataDictionaryMapper;
@Autowired
FireChemicalServiceImpl fireChemicalServiceImpl;
......@@ -63,7 +64,7 @@ public class ExcelController extends BaseController {
@GetMapping("/getFireStationFile")
public void getFireStationFile(HttpServletResponse response,ExcelDto excelDto ) {
try {
List<FireChemicalDto> date= fireChemicalServiceImpl.queryForFireChemicalList();
List<FireChemicalDto> date= fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), date,FireChemicalDto.class, dataDictionaryMapper,false);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -8,9 +8,14 @@ import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.dto.ExcelDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireChemicalDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireExpertsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.jcs.api.entity.FireChemical;
import com.yeejoin.amos.boot.module.jcs.api.entity.FireExperts;
import com.yeejoin.amos.boot.module.jcs.api.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.jcs.api.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireExpertsServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.utils.BeanDtoVoUtils;
......@@ -19,11 +24,15 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
......@@ -48,6 +57,9 @@ public class FireExpertsController extends BaseController {
@Autowired
DataDictionaryServiceImpl dataDictionaryService;
@Resource
DataDictionaryMapper dataDictionaryMapper;
/**
* 新增
*
......@@ -200,5 +212,53 @@ public class FireExpertsController extends BaseController {
return ResponseHelper.buildResponse(menuList);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量导入消防专家")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile, HttpServletResponse response) 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, dataDictionaryMapper, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常");
}
}
}
......@@ -6,6 +6,8 @@ import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.*;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.enums.WaterResourceTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.jcs.api.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -15,10 +17,13 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,6 +33,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* @author system_generator
......@@ -50,6 +58,8 @@ public class WaterResourceController extends BaseController {
WaterResourcePoolServiceImpl waterResourcePoolService;
@Autowired
WaterResourceIotServiceImpl waterResourceIotService;
@Resource
DataDictionaryMapper dataDictionaryMapper;
/**
* 新增
......@@ -322,4 +332,50 @@ public class WaterResourceController extends BaseController {
public ResponseModel<List<WaterResourceDto>> selectForList() {
return ResponseHelper.buildResponse(waterResourceServiceImpl.queryForWaterResourceList(true));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量导入消防水源")
@PostMapping("/import_batch")
public void importByExcel(MultipartFile multipartFile, HttpServletResponse response) 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, dataDictionaryMapper, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常");
}
}
}
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.AircraftDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireChemicalDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.WaterResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft;
import com.yeejoin.amos.boot.module.jcs.api.enums.AircraftFileTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.AircraftMapper;
......@@ -45,8 +47,8 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
* @throws Exception
*/
public AircraftDto createAircraft(String agencyCode, AircraftDto aircraftDto) throws Exception {
aircraftDto.setIsDelete(false);
aircraftDto.setIsDelete(false);
//持久化航空器信息
aircraftDto = this.createWithModel(aircraftDto);
//持久化航空器附件信息
......@@ -117,9 +119,9 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
public List<Long> multDeleteAircraft(String agencyCode, String ids) throws Exception {
List<Long> seqs = StringUtil.String2LongList(ids);
for (Long id : seqs) {
AircraftDto aircraftDto = this.queryBySeq(id);
aircraftDto.setIsDelete(true);
this.updateWithModel(aircraftDto);
AircraftDto aircraftDto = this.queryBySeq(id);
aircraftDto.setIsDelete(true);
this.updateWithModel(aircraftDto);
// //删除附件信息
// Systemctl.fileInfoClient.deleteByAlias(agencyCode, Aircraft.class.getSimpleName(),
// String.valueOf(id), null);
......@@ -159,27 +161,32 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
//外观图
if (!ValidationUtil.isEmpty(aircraftDto.getAppearanceImages())) {
List<String> appearanceImages = StringUtil.String2List(aircraftDto.getAppearanceImages());
fileInfoModelList.addAll(buildFileInfo(agencyCode, appearanceImages, aircraftDto, AircraftFileTypeEnum.APPEARANCE.getCode()));
fileInfoModelList.addAll(buildFileInfo(agencyCode, appearanceImages, aircraftDto,
AircraftFileTypeEnum.APPEARANCE.getCode()));
}
//平面图
if (!ValidationUtil.isEmpty(aircraftDto.getPlaneImages())) {
List<String> planeImages = StringUtil.String2List(aircraftDto.getPlaneImages());
fileInfoModelList.addAll(buildFileInfo(agencyCode, planeImages, aircraftDto, AircraftFileTypeEnum.PLANE.getCode()));
fileInfoModelList.addAll(buildFileInfo(agencyCode, planeImages, aircraftDto,
AircraftFileTypeEnum.PLANE.getCode()));
}
//救援图
if (!ValidationUtil.isEmpty(aircraftDto.getRescueImages())) {
List<String> rescueImages = StringUtil.String2List(aircraftDto.getRescueImages());
fileInfoModelList.addAll(buildFileInfo(agencyCode, rescueImages, aircraftDto, AircraftFileTypeEnum.RESCUE.getCode()));
fileInfoModelList.addAll(buildFileInfo(agencyCode, rescueImages, aircraftDto,
AircraftFileTypeEnum.RESCUE.getCode()));
}
//方位图
if (!ValidationUtil.isEmpty(aircraftDto.getPositionImages())) {
List<String> positionImages = StringUtil.String2List(aircraftDto.getPositionImages());
fileInfoModelList.addAll(buildFileInfo(agencyCode, positionImages, aircraftDto, AircraftFileTypeEnum.POSITION.getCode()));
fileInfoModelList.addAll(buildFileInfo(agencyCode, positionImages, aircraftDto,
AircraftFileTypeEnum.POSITION.getCode()));
}
//三维模型
if (!ValidationUtil.isEmpty(aircraftDto.getModels())) {
List<String> models = StringUtil.String2List(aircraftDto.getModels());
fileInfoModelList.addAll(buildFileInfo(agencyCode, models, aircraftDto, AircraftFileTypeEnum.MODEL.getCode()));
fileInfoModelList.addAll(buildFileInfo(agencyCode, models, aircraftDto,
AircraftFileTypeEnum.MODEL.getCode()));
}
if (!ValidationUtil.isEmpty(fileInfoModelList)) {
......@@ -218,11 +225,19 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
/**
* 图片转成逗号分割String
*
* @param fileInfoModels
* @param fileCategory
* @return
*/
private String processToStr(List<FileInfoModel> fileInfoModels, String fileCategory){
private String processToStr(List<FileInfoModel> fileInfoModels, String fileCategory) {
return fileInfoModels.stream().filter(x -> fileCategory.equals(x.getFileCategory())).map(FileInfoModel::getFilename).collect(Collectors.joining(","));
}
/**
* 列表查询 示例
*/
public List<AircraftDto> queryAircraftDtoForList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
}
......@@ -36,8 +36,8 @@ public class FireChemicalServiceImpl extends BaseService<FireChemicalDto,FireChe
/**
* 列表查询 示例
*/
public List<FireChemicalDto> queryForFireChemicalList() {
return this.queryForList("" , false);
public List<FireChemicalDto> queryForFireChemicalList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("" , false,isDelete);
}
/**
* 删除
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.*;
import com.yeejoin.amos.boot.module.jcs.api.entity.WaterResource;
import com.yeejoin.amos.boot.module.jcs.api.enums.WaterResourceTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.WaterResourceMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IWaterResourceService;
import com.yeejoin.amos.boot.module.jcs.api.dto.WaterResourceDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
/**
* 服务实现类
......@@ -20,6 +31,20 @@ import java.util.List;
*/
@Service
public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, WaterResource, WaterResourceMapper> implements IWaterResourceService {
@Autowired
WaterResourceCraneServiceImpl waterResourceCraneService;
@Autowired
WaterResourceHydrantServiceImpl waterResourceHydrantService;
@Autowired
WaterResourceNaturalServiceImpl waterResourceNaturalService;
@Autowired
WaterResourcePoolServiceImpl waterResourcePoolService;
@Autowired
WaterResourceIotServiceImpl waterResourceIotService;
@Resource
WaterResourceMapper waterResourceMapper;
/**
* 分页查询
*/
......@@ -36,4 +61,84 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
public List<WaterResourceDto> queryForWaterResourceList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
/**
* excel导入
*
* @param model
* @return
*/
public WaterResourceDto importByExcel(WaterResourceDto model) {
String resourceType = model.getResourceType();
Optional<WaterResourceTypeEnum> resourceTypeEnum = EnumsUtils.getEnumObject(WaterResourceTypeEnum.class,
e -> e.getCode().equals(resourceType));
model.setResourceTypeName(resourceTypeEnum.get().getName());
model.setRealityImg(JSONArray.toJSONString(model.getRealityImgList()));
model.setOrientationImg(JSONArray.toJSONString(model.getOrientationImgList()));
if (!StringUtils.isEmpty(resourceType)) {
switch (resourceType) {
case "hydrant":
// 新增基础信息
model.setIsIot(true);
createWithModel(model);
// 新增属性信息
WaterResourceHydrantDto waterResourceHydrantDto = new WaterResourceHydrantDto();
BeanUtils.copyProperties(model, waterResourceHydrantDto);
waterResourceHydrantDto.setSequenceNbr(null);
waterResourceHydrantDto.setResourceId(model.getSequenceNbr());
waterResourceHydrantService.createWithModel(waterResourceHydrantDto);
break;
case "crane":
// 新增基础信息
model.setIsIot(true);
createWithModel(model);
WaterResourceCraneDto waterResourceCraneDto = new WaterResourceCraneDto();
BeanUtils.copyProperties(model, waterResourceCraneDto);
waterResourceCraneDto.setSequenceNbr(null);
waterResourceCraneDto.setResourceId(model.getSequenceNbr());
waterResourceCraneService.createWithModel(waterResourceCraneDto);
break;
case "natural":
// 新增基础信息
model.setIsIot(false);
createWithModel(model);
WaterResourceNaturalDto waterResourceNaturalDto = new WaterResourceNaturalDto();
BeanUtils.copyProperties(model, waterResourceNaturalDto);
waterResourceNaturalDto.setSequenceNbr(null);
waterResourceNaturalDto.setResourceId(model.getSequenceNbr());
waterResourceNaturalService.createWithModel(waterResourceNaturalDto);
break;
case "pool":
// 新增基础信息
model.setIsIot(true);
createWithModel(model);
WaterResourcePoolDto waterResourcePoolDto = new WaterResourcePoolDto();
BeanUtils.copyProperties(model, waterResourcePoolDto);
waterResourcePoolDto.setSequenceNbr(null);
waterResourcePoolDto.setResourceId(model.getSequenceNbr());
waterResourcePoolService.createWithModel(waterResourcePoolDto);
break;
}
// 新增物联信息
if (model.getIsIot()) {
WaterResourceIotDto waterResourceIotDto = new WaterResourceIotDto();
BeanUtils.copyProperties(model, waterResourceIotDto);
waterResourceIotDto.setSequenceNbr(null);
waterResourceIotDto.setResourceType(model.getResourceType());
waterResourceIotDto.setResourceId(model.getSequenceNbr());
waterResourceIotService.createWithModel(waterResourceIotDto);
}
} else {
createWithModel(model);
}
return model;
}
/**
* 导出列表
*/
public List<WaterResourceDto> exportToExcel(@Condition(Operator.eq) Boolean isDelete) {
return waterResourceMapper.exportToExcel(isDelete);
}
}
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