/** * 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> yjCheckList(DangerAreaCheckInfoDTO dto) { if (Func.isNull(dto.getWarnId())) { return R.fail("参数错误"); } if (dto.getWarnId().length() == 0) { return R.fail("参数错误"); } LambdaQueryWrapper wrapper = Wrappers.query().lambda(); wrapper.eq(DangerAreaCheckInfoEntity::getWarnId, dto.getWarnId()); wrapper.orderByAsc(DangerAreaCheckInfoEntity::getCreateTime); List list = danagerAreaCheckService.list(wrapper); List 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> 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 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 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 wrapper2 = Wrappers.query().lambda(); wrapper2.eq(DamageTransferPersonInfoEntity::getWarnId, entity.getWarnId()); List 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> yjTransferCount(DamageTransferPersonInfoDTO dto) { if (Func.isNull(dto.getWarnId())) { return R.fail("参数错误"); } LambdaQueryWrapper wrapper = Wrappers.query().lambda(); wrapper.eq(OriginalWarningInfoEntity::getWarnId, dto.getWarnId()); OriginalWarningInfoEntity warningInfoEntity = warningService.getOne(wrapper); if (Func.isNull(warningInfoEntity)) { return R.fail("预警数据空"); } List 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 wrapper2 = Wrappers.query().lambda(); wrapper2.eq(DamageTransferPersonInfoEntity::getIsDeleted, 0); wrapper2.eq(DamageTransferPersonInfoEntity::getWarnId, dto.getWarnId()); List 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); } }