Commit 06ce9146 authored by 刘林's avatar 刘林

fix(cylinder):气瓶区域信息查询

parent 4b9fca96
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -15,6 +16,7 @@ import lombok.EqualsAndHashCode; ...@@ -15,6 +16,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Builder
@ApiModel(value="CityCylinderInfoDto", description="地市气瓶信息汇总") @ApiModel(value="CityCylinderInfoDto", description="地市气瓶信息汇总")
public class CityCylinderInfoDto extends BaseDto { public class CityCylinderInfoDto extends BaseDto {
...@@ -31,10 +33,10 @@ public class CityCylinderInfoDto extends BaseDto { ...@@ -31,10 +33,10 @@ public class CityCylinderInfoDto extends BaseDto {
private boolean isAlarm; private boolean isAlarm;
@ApiModelProperty(value = "气站数量") @ApiModelProperty(value = "气站数量")
private Integer stationCount; private Long stationCount;
@ApiModelProperty(value = "气瓶数量") @ApiModelProperty(value = "气瓶数量")
private Integer cylindersCount; private Long cylindersCount;
@ApiModelProperty(value = "经度") @ApiModelProperty(value = "经度")
private String longitude; private String longitude;
......
...@@ -42,4 +42,13 @@ public class CylinderAreaDataDto extends BaseDto { ...@@ -42,4 +42,13 @@ public class CylinderAreaDataDto extends BaseDto {
@ApiModelProperty(value = "预警数量") @ApiModelProperty(value = "预警数量")
private Long warnNum; private Long warnNum;
@ApiModelProperty(value = "区域层级")
private String level;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
} }
...@@ -64,4 +64,20 @@ public class CylinderAreaData extends BaseEntity { ...@@ -64,4 +64,20 @@ public class CylinderAreaData extends BaseEntity {
@TableField("warn_num") @TableField("warn_num")
private Long warnNum; private Long warnNum;
/**
* 区域层级
*/
@TableField("level")
private String level;
/**
* 经度
*/
@TableField("longitude")
private String longitude;
/**
* 纬度
*/
@TableField("latitude")
private String latitude;
} }
...@@ -56,6 +56,4 @@ public interface ICylinderInfoService { ...@@ -56,6 +56,4 @@ public interface ICylinderInfoService {
void saveCylinderInfo2ES(List<CylinderInfoDto> records); void saveCylinderInfo2ES(List<CylinderInfoDto> records);
Integer getInfoTotal(); Integer getInfoTotal();
List<CityCylinderInfoDto> getCityCylinderData(String level);
} }
...@@ -100,6 +100,8 @@ public class CylinderInfoController extends BaseController { ...@@ -100,6 +100,8 @@ public class CylinderInfoController extends BaseController {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired
private CylinderAreaDataServiceImpl cylinderAreaDataService;
/** /**
* 新增气瓶基本信息 * 新增气瓶基本信息
* *
...@@ -1342,7 +1344,7 @@ public class CylinderInfoController extends BaseController { ...@@ -1342,7 +1344,7 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/getCityCylinderData") @GetMapping(value = "/getCityCylinderData")
@ApiOperation(httpMethod = "GET", value = "获取地市气瓶,气站信息统计", notes = "获取地市气瓶,气站信息统计") @ApiOperation(httpMethod = "GET", value = "获取地市气瓶,气站信息统计", notes = "获取地市气瓶,气站信息统计")
public ResponseModel<Collection<CityCylinderInfoDto>> getCityCylinderData(@RequestParam( value="level") String level) { public ResponseModel<Collection<CityCylinderInfoDto>> getCityCylinderData(@RequestParam( value="level") String level) {
List<CityCylinderInfoDto> result = cylinderInfoServiceImpl.getCityCylinderData(level); List<CityCylinderInfoDto> result = cylinderAreaDataService.getCityCylinderData(level);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
......
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl; package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData; import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService; import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService;
...@@ -8,6 +9,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -8,6 +9,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 气瓶区域统计表服务实现类 * 气瓶区域统计表服务实现类
...@@ -30,4 +32,18 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -30,4 +32,18 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
public List<CylinderAreaDataDto> queryForCylinderAreaDataList() { public List<CylinderAreaDataDto> queryForCylinderAreaDataList() {
return this.queryForList("" , false); return this.queryForList("" , false);
} }
public List<CityCylinderInfoDto> getCityCylinderData(String level) {
return this.queryForList("", false, level).stream()
.map(v -> CityCylinderInfoDto.builder()
.regionName(v.getAreaName())
.regionCode(v.getRegionCode())
.longitude(v.getLongitude())
.latitude(v.getLatitude())
.isAlarm(v.getWarnNum() != 0)
.cylindersCount(v.getCylinderNum())
.stationCount(v.getUnitNum())
.build())
.collect(Collectors.toList());
}
} }
\ No newline at end of file
...@@ -281,6 +281,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -281,6 +281,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
temp.setRegionCode(regionModel.getRegionCode() + ""); temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal)); temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal); temp.setWarnNum((long) warmTotal);
temp.setLevel(regionModel.getLevel().trim());
temp.setLatitude(regionModel.getLatitude());
temp.setLongitude(regionModel.getLongitude());
cylinderAreaDataServiceImpl.createWithModel(temp); cylinderAreaDataServiceImpl.createWithModel(temp);
}); });
} }
...@@ -857,32 +860,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -857,32 +860,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
@Override @Override
public List<CityCylinderInfoDto> getCityCylinderData(String level) {
List<RegionModel> result = Systemctl.regionClient.queryByLevel(level).getResult();
List<CityCylinderInfoDto> cylinderInfoDtoList = cylinderUnitServiceImpl.getCylinderDataByLevel(level);
Map<String, CityCylinderInfoDto> dtoMap = cylinderInfoDtoList.stream()
.collect(Collectors.toMap(CityCylinderInfoDto::getRegionCode, dto -> dto));
result.forEach(regionModel -> {
String regionCode = regionModel.getRegionCode()+"";
CityCylinderInfoDto dto = dtoMap.computeIfAbsent(regionCode, key -> {
CityCylinderInfoDto newDto = new CityCylinderInfoDto();
newDto.setRegionCode(regionCode);
newDto.setRegionName(regionModel.getRegionName());
newDto.setLatitude(regionModel.getLatitude());
newDto.setLongitude(regionModel.getLongitude());
cylinderInfoDtoList.add(newDto);
return newDto;
});
dto.setLatitude(regionModel.getLatitude());
dto.setLongitude(regionModel.getLongitude());
dto.setRegionName(regionModel.getRegionName());
});
return cylinderInfoDtoList;
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) { public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto(); ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci, esCylinderInfoDto); BeanUtils.copyProperties(ci, esCylinderInfoDto);
......
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