src/main/java/org/springblade/common/utils/ShapeFileUtil.java
@@ -74,6 +74,8 @@ String geomProperty = "the_geom"; String idProperty = "ID"; String nameProperty = "name"; String firmIdProperty = "firmId"; String firmNameProperty = "firmName"; //设置图形类型 if ("Polygon".equals(geomType)) { @@ -94,6 +96,8 @@ //设置对应属性类型 tb.add(idProperty, String.class); tb.add(nameProperty, String.class); tb.add(firmIdProperty, String.class); tb.add(firmNameProperty, String.class); //设置默认geometry tb.setDefaultGeometry(geomProperty); @@ -108,9 +112,13 @@ for (Map<String, Object> map : dataPropertiesList) { feature = writer.next(); //属性赋值 geometry要赋值wkt格式的 feature.setAttribute(geomProperty, new WKTReader().read((MapUtil.getStr(map, "geometry")))); if (map.containsKey("geometry")) { feature.setAttribute(geomProperty, new WKTReader().read((MapUtil.getStr(map, "geometry")))); } feature.setAttribute(idProperty, MapUtil.getStr(map, idProperty)); feature.setAttribute(nameProperty, MapUtil.getStr(map, nameProperty)); feature.setAttribute(firmIdProperty, MapUtil.getStr(map, firmIdProperty)); feature.setAttribute(firmNameProperty, MapUtil.getStr(map, firmNameProperty)); // String description = MapUtil.getStr(map, "描述"); // if (CharSequenceUtil.isNotBlank(description)) { // feature.setAttribute(descriptionProperty, description); src/main/java/org/springblade/modules/yw/controller/GeomInfoController.java
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.apache.logging.log4j.util.Strings; import org.springblade.common.constant.FileConstant; import org.springblade.common.utils.ShapeFileUtil; import org.springblade.common.utils.ZipUtil; @@ -14,7 +15,10 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.yw.entity.GeomInfoEntity; import org.springblade.modules.yw.service.IEmergencySpaceService; import org.springblade.modules.yw.service.IFirmInfoService; import org.springblade.modules.yw.service.IGeomInfoService; import org.springblade.modules.yw.vo.EmergencySpaceVO; import org.springblade.modules.yw.vo.GeomInfoVO; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -45,6 +49,8 @@ private final IGeomInfoService geomInfoService; private final FileConstant fileConstant; private final IEmergencySpaceService emergencySpaceService; /** * 空间信息表 详情 @@ -180,6 +186,49 @@ /** * 根据传入的点线面数据-导出空间信息shp zip 包 * @param response * @return */ @GetMapping("/exporEmergencySpaceShpZip") @ApiOperationSupport(order = 9) @ApiOperation(value = "根据传入的点线面数据-导出空间信息shp zip 包", notes = "传入空间数据") public void exporEmergencySpaceShpZip(HttpServletResponse response) throws IOException { Query query = new Query().setCurrent(1).setSize(100); IPage<EmergencySpaceVO> emergencySpaceVOIPage = emergencySpaceService.selectEmergencySpacePage(Condition.getPage(query), null); // 查询应急空间数据 List<EmergencySpaceVO> emergencySpaceVOList = emergencySpaceVOIPage.getRecords(); List<Map<String,Object>> propertyList = new ArrayList<>(); // 要导出的文件夹路径 String sourceFolderPath = fileConstant.getZipTempSavePath(); for (EmergencySpaceVO emergencySpaceVO : emergencySpaceVOList) { // 先生成文件 Map<String,Object> map = new HashMap<>(); map.put("ID", emergencySpaceVO.getId()); map.put("name", emergencySpaceVO.getName()); if (!Strings.isBlank(emergencySpaceVO.getLng())){ map.put("geometry","POINT("+emergencySpaceVO.getLng() +" " + emergencySpaceVO.getLng() + ")"); } map.put("firmId",emergencySpaceVO.getFirmId()); map.put("firmName",emergencySpaceVO.getFirmName()); propertyList.add(map); } // 导出shp 文件 ShapeFileUtil.exportShp(propertyList, "yikj", "Point",sourceFolderPath); // ZIP文件名 String zipFileName = System.currentTimeMillis() + "_exported_shp.zip"; response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment; filename=\"" + zipFileName + "\""); try ( BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); ZipOutputStream zipOut = new ZipOutputStream(bos); ) { ZipUtil.zipFolder(sourceFolderPath, zipOut); } } /** * 根据传入的点线面数据-导出空间信息shp zip 包 * @param geomInfoEntity * @return */ src/main/java/org/springblade/modules/yw/mapper/EmergencySuppliesMapper.java
@@ -25,4 +25,10 @@ List<EmergencySuppliesVO> selectEmergencySuppliesPage(IPage page, @Param("emergencySupplies") EmergencySuppliesVO emergencySupplies); /** * 查询企业对应的应急物资信息 * @param emergencySupplies * @return */ List<EmergencySuppliesVO> getEmergencySuppliesList(@Param("emergencySupplies") EmergencySuppliesVO emergencySupplies); } src/main/java/org/springblade/modules/yw/mapper/EmergencySuppliesMapper.xml
@@ -25,6 +25,7 @@ yes.*, yfi.name as firmName, ys.per_in_cha as personInCha,ys.per_in_cha_pho as personInChaPhone,ys.address supAdd, ys.lng,ys.lat, bdb.dict_value as emeSupType, concat(yes.num,bdb1.dict_value) as numUnit from @@ -53,4 +54,23 @@ </if> </select> <!--查询企业对应的应急物资信息--> <select id="getEmergencySuppliesList" resultType="org.springblade.modules.yw.vo.EmergencySuppliesVO"> select yes.*, yfi.name as firmName, ys.per_in_cha as personInCha,ys.per_in_cha_pho as personInChaPhone,ys.address supAdd, ys.lng,ys.lat, bdb.dict_value as emeSupType, concat(yes.num,bdb1.dict_value) as numUnit from yw_emergency_supplies yes left join yw_supplies ys on ys.id = yes.supplies_id and ys.is_deleted = 0 left join yw_firm_info yfi on yfi.id = yes.firm_id and yfi.is_deleted = 0 left join blade_dict_biz bdb on bdb.dict_key = yes.type and bdb.code = 'eme_sup_type' left join blade_dict_biz bdb1 on bdb1.dict_key = yes.unit and bdb1.code = 'unit' where yes.is_deleted = 0 and yes.firm_id = #{emergencySupplies.firmId} </select> </mapper> src/main/java/org/springblade/modules/yw/mapper/RiskSourceMapper.xml
@@ -30,6 +30,9 @@ <if test="riskSource.firmId!=null"> and yrs.firm_id = #{riskSource.firmId} </if> <if test="riskSource.name!=null and riskSource.name!=''"> and yrs.name like concat('%',#{riskSource.name},'%') </if> <if test="riskSource.riskLevel!=null"> and yrs.risk_level = #{riskSource.riskLevel} </if> src/main/java/org/springblade/modules/yw/service/impl/EmergencySuppliesServiceImpl.java
@@ -152,9 +152,7 @@ public Map<String, Object> getEmergencySuppliesList(EmergencySuppliesVO emergencySupplies) { Map<String, Object> map = new HashMap<>(); // 查询企业对应的应急物资信息 QueryWrapper<EmergencySuppliesEntity> wrapper = new QueryWrapper<>(); wrapper.eq("firm_id",emergencySupplies.getFirmId()).eq("is_deleted",0); List<EmergencySuppliesEntity> list = list(wrapper); List<EmergencySuppliesVO> list = baseMapper.getEmergencySuppliesList(emergencySupplies); map.put("dataList",list); // 查询企业对应应急物资的图片 QueryWrapper<YwAttachEntity> queryWrapper = new QueryWrapper<>(); src/main/java/org/springblade/modules/yw/vo/EmergencySuppliesVO.java
@@ -46,5 +46,15 @@ */ @ApiModelProperty(value = "物资仓库地址") private String supAdd; /** * 物资仓库经度 */ @ApiModelProperty(value = "物资仓库经度") private String lng; /** * 物资仓库纬度 */ @ApiModelProperty(value = "物资仓库纬度") private String lat; }