| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- /**
- * Copyright 2019 DH
- * All right reserved.
- * 项目名称: 运维系统
- * 创建日期:2023/11/10
- */
- package org.springblade.share;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.AllArgsConstructor;
- import org.springblade.constant.BusinessConstant;
- import org.springblade.core.boot.ctrl.BladeController;
- import org.springblade.core.tool.api.R;
- import org.springblade.core.tool.utils.Func;
- import org.springblade.modules.system.entity.User;
- import org.springblade.modules.system.service.IUserService;
- import org.springblade.modules.yjxt.base.map.entity.DangerAreaEntity;
- import org.springblade.modules.yjxt.base.map.service.IDangerAreaService;
- import org.springblade.modules.yjxt.business.check.dto.DangerAreaCheckInfoDTO;
- import org.springblade.modules.yjxt.business.check.entity.DangerAreaCheckInfoEntity;
- import org.springblade.modules.yjxt.business.check.service.IDangerAreaCheckService;
- import org.springblade.modules.yjxt.business.resident.dto.DangerAreaResidentInfoDTO;
- import org.springblade.modules.yjxt.business.resident.service.IDangerAreaResidentService;
- import org.springblade.modules.yjxt.business.transfer.dto.DamageTransferPersonInfoDTO;
- import org.springblade.modules.yjxt.business.transfer.entity.DamageTransferPersonInfoEntity;
- import org.springblade.modules.yjxt.business.transfer.service.IDamageTransferPersonService;
- import org.springblade.modules.yjxt.business.warn.dto.OriginalWarningInfoDTO;
- import org.springblade.modules.yjxt.business.warn.entity.OriginalWarningInfoEntity;
- import org.springblade.modules.yjxt.business.warn.service.IOriginalWarningService;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.time.LocalDateTime;
- import java.time.ZoneId;
- import java.time.format.DateTimeFormatter;
- import java.util.*;
- /***
- * Date:2023/11/10
- * Title:文件所属模块(必须填写)
- * Description:对本文件的详细描述,原则上不能少于30字
- * @author dylan
- * @version 1.0
- * Remark:认为有必要的其他信息
- */
- @RestController
- @RequestMapping("ywxt-business/public/data/share")
- @AllArgsConstructor
- @Api(value = "共享管理接口", tags = "提供第三方查询接口")
- public class DataShareController extends BladeController {
- private final IUserService userService;
- private final IDangerAreaCheckService danagerAreaCheckService;
- private final IDamageTransferPersonService damageTransferPersonService;
- private final IDangerAreaResidentService dangerAreaResidentService;
- private final IOriginalWarningService warningService;
- private final IDangerAreaService dangerAreaService;
- private final IOriginalWarningService originalWarningService;
- /**
- * 巡查巡检列表查询,不分页
- */
- @GetMapping("/yj/check/list")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "warnId", value = "预警ID", paramType = "query", dataType = "string")
- })
- @ApiOperationSupport(order = 1)
- @ApiOperation(value = "不分页", notes = "")
- public R<List<JSONObject>> yjCheckList(DangerAreaCheckInfoDTO dto) {
- if (Func.isNull(dto.getWarnId())) {
- return R.fail("参数错误");
- }
- if (dto.getWarnId().length() == 0) {
- return R.fail("参数错误");
- }
- LambdaQueryWrapper<DangerAreaCheckInfoEntity> wrapper = Wrappers.<DangerAreaCheckInfoEntity>query().lambda();
- wrapper.eq(DangerAreaCheckInfoEntity::getWarnId, dto.getWarnId());
- wrapper.orderByAsc(DangerAreaCheckInfoEntity::getCreateTime);
- List<DangerAreaCheckInfoEntity> list = danagerAreaCheckService.list(wrapper);
- List<JSONObject> datas = new ArrayList<>(list.size());
- for (DangerAreaCheckInfoEntity entity : list) {
- JSONObject d = new JSONObject();
- d.put("warnId", entity.getWarnId());
- User user = userService.getById(entity.getCreateUser());
- if (!Func.isNull(user)) {
- d.put("checkPerson", user.getRealName());
- } else {
- d.put("checkPerson", "");
- }
- d.put("checkTime", entity.getCreateTime().getTime());
- if (!Func.isNull(entity.getLongitude())) {
- d.put("lng", entity.getLongitude());
- }
- if (!Func.isNull(entity.getLatitude())) {
- d.put("lat", entity.getLatitude());
- }
- if (!Func.isNull(entity.getAddress())) {
- d.put("location", entity.getAddress());
- }
- d.put("isFlood", entity.getIsFlood());
- d.put("isDamage", entity.getIsDamage());
- if (!Func.isNull(entity.getRemark())) {
- d.put("remark", entity.getRemark());
- }
- JSONArray photos = new JSONArray();
- if (!Func.isNull(entity.getCheckPhotos())) {
- String photo = entity.getCheckPhotos();
- String[] photoArr = photo.trim().split(",");
- for (String url : photoArr) {
- JSONObject p = new JSONObject();
- p.put("url", BusinessConstant.OSS_BASE_PATH + url);
- photos.add(p);
- }
- }
- d.put("photos", photos);
- datas.add(d);
- }
- return R.data(datas);
- }
- /**
- * 灾害转移统计查询
- * 根据危险区统计
- */
- @GetMapping("/yj/transfer/dangerarea/count")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "dangerAreaPid", value = "危险区ID", paramType = "query", dataType = "string"),
- @ApiImplicitParam(name = "startTime", value = "预警开始时间", paramType = "query", dataType = "string"),
- @ApiImplicitParam(name = "endTime", value = "预警结束时间", paramType = "query", dataType = "string"),
- @ApiImplicitParam(name = "warnLevelCode", value = "预警等级", paramType = "query", dataType = "string"),
- })
- @ApiOperationSupport(order = 1)
- @ApiOperation(value = "不分页", notes = "")
- public R<List<JSONObject>> yjTransferCountByDangerarea(DamageTransferPersonInfoDTO dto) {
- if (Func.isNull(dto.getDangerAreaPid())) {
- return R.fail("危险区ID参数错误");
- }
- // if (Func.isNull(dto.getStartTime()) || Func.isNull(dto.getEndTime())) {
- // return R.fail("查询时间参数错误");
- // }
- // if (Func.isNull(dto.getWarnLevelCode())) {
- // return R.fail("预警等级参数错误");
- // }
- List<JSONObject> datas = new ArrayList<>();
- OriginalWarningInfoDTO originalWarningInfoDTO = new OriginalWarningInfoDTO();
- originalWarningInfoDTO.setDangerAreaPid(dto.getDangerAreaPid());
- if (Func.notNull(dto.getWarnLevelCode())) {
- originalWarningInfoDTO.setWarnLevelCode(dto.getWarnLevelCode());
- }
- if (Func.notNull(dto.getStartTime()) && Func.notNull(dto.getEndTime())) {
- LocalDateTime startDateTime = LocalDateTime.parse(dto.getStartTime(), DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
- originalWarningInfoDTO.setStartTime(Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()));
- LocalDateTime endDateTime = LocalDateTime.parse(dto.getEndTime(), DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
- originalWarningInfoDTO.setEndTime(Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant()));
- } else if (Func.notNull(dto.getStartTime())) {
- LocalDateTime startDateTime = LocalDateTime.parse(dto.getStartTime(), DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
- originalWarningInfoDTO.setStartTime(Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()));
- }
- List<OriginalWarningInfoEntity> originalWarningInfoEntityList = originalWarningService.selectDangerAreaList(originalWarningInfoDTO);
- if (Func.notNull(originalWarningInfoEntityList)) {
- for (OriginalWarningInfoEntity entity : originalWarningInfoEntityList) {
- JSONObject vo = new JSONObject();
- vo.put("warnId", entity.getWarnId());
- vo.put("warnTime", entity.getWarnTime().getTime());
- vo.put("warnLevelCode",entity.getWarnLevelCode());
- DangerAreaResidentInfoDTO residentInfoDTO = new DangerAreaResidentInfoDTO();
- residentInfoDTO.setDangerAreaCode(entity.getWarnAdcd());
- long totalTransferPerson = dangerAreaResidentService.residentCount(residentInfoDTO);
- DamageTransferPersonInfoDTO transferPersonInfoDTO = new DamageTransferPersonInfoDTO();
- transferPersonInfoDTO.setWarnId(entity.getWarnId());
- long safetyTransferPerson = damageTransferPersonService.transferPersonCount(transferPersonInfoDTO);
- vo.put("totalTransferPerson", totalTransferPerson);
- vo.put("safetyTransferPerson", safetyTransferPerson);
- JSONArray personList = new JSONArray();
- LambdaQueryWrapper<DamageTransferPersonInfoEntity> wrapper2 = Wrappers.<DamageTransferPersonInfoEntity>query().lambda();
- wrapper2.eq(DamageTransferPersonInfoEntity::getWarnId, entity.getWarnId());
- List<DamageTransferPersonInfoEntity> transferPersonInfoEntityList = damageTransferPersonService.list(wrapper2);
- if (Func.notNull(transferPersonInfoEntityList)) {
- for (DamageTransferPersonInfoEntity transferPersonInfoEntity : transferPersonInfoEntityList) {
- JSONObject person = new JSONObject();
- person.put("personName", transferPersonInfoEntity.getPersonName());
- person.put("recordTime", transferPersonInfoEntity.getCreateTime().getTime());
- personList.add(person);
- }
- }
- vo.put("transferPersonList", personList);
- datas.add(vo);
- }
- }
- return R.data(datas);
- }
- /**
- * 灾害转移统计查询
- * 根据预警ID查询
- *
- * @param dto
- * @return
- */
- @GetMapping("/yj/transfer/count")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "warnId", value = "预警ID", paramType = "query", dataType = "string")
- })
- @ApiOperationSupport(order = 1)
- @ApiOperation(value = "不分页", notes = "")
- public R<List<JSONObject>> yjTransferCount(DamageTransferPersonInfoDTO dto) {
- if (Func.isNull(dto.getWarnId())) {
- return R.fail("参数错误");
- }
- LambdaQueryWrapper<OriginalWarningInfoEntity> wrapper = Wrappers.<OriginalWarningInfoEntity>query().lambda();
- wrapper.eq(OriginalWarningInfoEntity::getWarnId, dto.getWarnId());
- OriginalWarningInfoEntity warningInfoEntity = warningService.getOne(wrapper);
- if (Func.isNull(warningInfoEntity)) {
- return R.fail("预警数据空");
- }
- List<JSONObject> datas = new ArrayList<>(1);
- JSONObject vo = new JSONObject();
- DangerAreaResidentInfoDTO residentInfoDTO = new DangerAreaResidentInfoDTO();
- residentInfoDTO.setDangerAreaCode(warningInfoEntity.getWarnAdcd());
- long totalTransferPerson = dangerAreaResidentService.residentCount(residentInfoDTO);
- DamageTransferPersonInfoDTO transferPersonInfoDTO = new DamageTransferPersonInfoDTO();
- transferPersonInfoDTO.setWarnId(dto.getWarnId());
- long safetyTransferPerson = damageTransferPersonService.transferPersonCount(transferPersonInfoDTO);
- vo.put("totalTransferPerson", totalTransferPerson);
- vo.put("safetyTransferPerson", safetyTransferPerson);
- JSONArray personList = new JSONArray();
- LambdaQueryWrapper<DamageTransferPersonInfoEntity> wrapper2 = Wrappers.<DamageTransferPersonInfoEntity>query().lambda();
- wrapper2.eq(DamageTransferPersonInfoEntity::getIsDeleted, 0);
- wrapper2.eq(DamageTransferPersonInfoEntity::getWarnId, dto.getWarnId());
- List<DamageTransferPersonInfoEntity> transferPersonInfoEntityList = damageTransferPersonService.list(wrapper2);
- if (!Func.isNull(transferPersonInfoEntityList)) {
- for (DamageTransferPersonInfoEntity transferPersonInfoEntity : transferPersonInfoEntityList) {
- JSONObject person = new JSONObject();
- person.put("personName", transferPersonInfoEntity.getPersonName());
- person.put("recordTime", transferPersonInfoEntity.getCreateTime().getTime());
- personList.add(person);
- }
- }
- vo.put("transferPersonList", personList);
- datas.add(vo);
- return R.data(datas);
- }
- }
|