添加接口:/download/firepoint
导出火点信息列表
This commit is contained in:
parent
d612c906e2
commit
823db4f82e
@ -182,6 +182,11 @@ public class FirePointController {
|
|||||||
return firePointService.downloadVipUserFilePoint(request, response);
|
return firePointService.downloadVipUserFilePoint(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/download/firepoint", method = RequestMethod.GET)
|
||||||
|
public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) {
|
||||||
|
return firePointService.downloadFirePoint(request, response, ids);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态多条件查询火点列表
|
* 动态多条件查询火点列表
|
||||||
*
|
*
|
||||||
|
@ -86,6 +86,8 @@ public interface FirePointService {
|
|||||||
*/
|
*/
|
||||||
String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response);
|
String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
|
String downloadFirePoint(HttpServletRequest request, HttpServletResponse response,String ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态多条件查询火点列表
|
* 动态多条件查询火点列表
|
||||||
*
|
*
|
||||||
|
@ -459,6 +459,39 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) {
|
||||||
|
|
||||||
|
List<String> idList = ListUtils.toStringList(ids, ",");
|
||||||
|
if (idList.isEmpty()) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
||||||
|
}
|
||||||
|
List<Map<String, String>> list = new ArrayList<>();
|
||||||
|
List<FirePointEntity> sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList));
|
||||||
|
for (FirePointEntity source : sourceList) {
|
||||||
|
Map<String, String> record = new HashMap<>();
|
||||||
|
record.put("所在区县", source.getCountyName());
|
||||||
|
record.put("所在街道", source.getStreetName());
|
||||||
|
record.put("发现时间", source.getSatelliteTime());
|
||||||
|
record.put("地物类型", source.getLandType());
|
||||||
|
record.put("经度", String.valueOf(source.getLongitude()));
|
||||||
|
record.put("纬度", String.valueOf(source.getLatitude()));
|
||||||
|
record.put("详细地址", source.getFirePointAddress());
|
||||||
|
list.add(record);
|
||||||
|
}
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth());
|
||||||
|
response.setContentType("application/octet-stream; charset=UTF8");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
||||||
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
try {
|
||||||
|
downloadXlsx(list, response.getOutputStream());
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("download fire point fail: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态多条件查询火点列表
|
* 动态多条件查询火点列表
|
||||||
*
|
*
|
||||||
|
@ -57,4 +57,13 @@ public class ListUtils {
|
|||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Long> stringListToLongList(List<String> stringList) {
|
||||||
|
List<Long> longList = new ArrayList<>();
|
||||||
|
for (String string:stringList) {
|
||||||
|
longList.add(Long.parseLong(string));
|
||||||
|
}
|
||||||
|
return longList;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user