Commit 9217e705 authored by lisong's avatar lisong

修改救援站相关接口

parent 89dfe822
......@@ -81,4 +81,9 @@ public class RescueStationDto extends BaseDto {
@ApiModelProperty(value = "适用于监管单位code")
private String codeOrg;
@ApiModelProperty(value = "经纬度")
private String longitudeLatitude;
}
......@@ -76,4 +76,6 @@ public class RescueStation extends BaseEntity {
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "经纬度")
private String longitudeLatitude;
}
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.elevator.api.entity.RescueStation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
......@@ -27,4 +28,6 @@ public interface RescueStationMapper extends BaseMapper<RescueStation> {
List<RescueStationDto> selectExportData(@Param("ids") List<String> ids);
IPage<RescueStation> getRescueStationList(@Param("page") IPage<RescueStation> page,@Param("dto") RescueStationDto dto);
Map<String, Object> getDetailById(@Param("id") Long id);
}
......@@ -92,5 +92,27 @@
<if test="dto.rescueLeaderPhone != null and dto.rescueLeaderPhone != ''">
and trs.rescue_leader_phone = #{dto.rescueLeaderPhone}
</if>
order by rec_date desc
</select>
<select id="getDetailById" resultType="java.util.Map">
select sequence_nbr as sequenceNbr,
name,
province,
city,
district,
region_code as regionCode,
address,
longitude,
latitude,
principal_id as principalId,
principal ,
principal_phone as principalPhone,
rescue_leader as rescueLeader,
rescue_leader_phone as rescueLeaderPhone,
rescue_leader_id as rescueLeaderId,
affiliated_unit as affiliatedUnit,
affiliated_unit_id as affiliatedUnitId,
longitude_latitude as longitudeLatitude
from tcb_rescue_station where sequence_nbr = #{id}
</select>
</mapper>
package com.yeejoin.amos.boot.module.elevator.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
......@@ -66,14 +70,30 @@ public class RescueStationController extends BaseController {
/**
* 新增救援站
*
* @param rescueStationDto 救援站
* @param map 救援站
* @return 返回结果
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增救援站", notes = "新增救援站")
public ResponseModel<Boolean> saveRescueStation(@RequestBody RescueStationDto rescueStationDto) {
public ResponseModel<Boolean> saveRescueStation(@RequestBody Map<String, Object> map) {
Object addressJson = map.get("address");
RescueStationDto rescueStationDto = BeanUtil.copyProperties(map, RescueStationDto.class);
String[] city = rescueStationDto.getCity().split("_");
String[] district = rescueStationDto.getDistrict().split("_");
String[] province = rescueStationDto.getProvince().split("_");
String[] unit = rescueStationDto.getAffiliatedUnit().split("_");
rescueStationDto.setAffiliatedUnit(unit[1]);
rescueStationDto.setAffiliatedUnitId(Long.valueOf(unit[0]));
rescueStationDto.setCity(city[1]);
rescueStationDto.setDistrict(district[1]);
rescueStationDto.setProvince(province[1]);
rescueStationDto.setRegionCode(province[0] + "#" + city[0] + "#" + district[0]);
JSONObject address = JSONUtil.parseObj(addressJson);
rescueStationDto.setLongitudeLatitude(JSONUtil.toJsonStr(address));
rescueStationDto.setAddress(ObjectUtils.isEmpty(address.get("address")) ? null : String.valueOf(address.get("address")));
rescueStationDto.setLatitude(ObjectUtils.isEmpty(address.get("latitude")) ? null : String.valueOf(address.get("latitude")));
rescueStationDto.setLongitude(ObjectUtils.isEmpty(address.get("longitude")) ? null : String.valueOf(address.get("longitude")));
return ResponseHelper.buildResponse(rescueStationServiceImpl.saveRescueStation(rescueStationDto));
}
......@@ -108,15 +128,29 @@ public class RescueStationController extends BaseController {
/**
* 修改救援站
*
* @param rescueStationDto 救援站
* @param map 救援站
* @return 返回结果
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改救援站", notes = "修改救援站")
public ResponseModel<Boolean> updateByIdRescueStation(@RequestBody RescueStationDto rescueStationDto) {
RescueStation rescueStation = BeanDtoVoUtils.convert(rescueStationDto, RescueStation.class);
public ResponseModel<Boolean> updateByIdRescueStation(@RequestBody Map<String, Object> map) {
// RescueStation rescueStation = BeanDtoVoUtils.convert(rescueStationDto, RescueStation.class);
Object addressJson = map.get("address");
RescueStation rescueStation = BeanUtil.copyProperties(map, RescueStation.class);
String[] city = rescueStation.getCity().split("_");
String[] district = rescueStation.getDistrict().split("_");
String[] unit = rescueStation.getAffiliatedUnit().split("_");
rescueStation.setAffiliatedUnit(unit[1]);
rescueStation.setAffiliatedUnitId(Long.valueOf(unit[0]));
rescueStation.setCity(city[1]);
rescueStation.setDistrict(district[1]);
rescueStation.setRegionCode("610000" + "#" + city[0] + "#" + district[0]);
JSONObject address = JSONUtil.parseObj(addressJson);
rescueStation.setLongitudeLatitude(JSONUtil.toJsonStr(address));
rescueStation.setAddress(ObjectUtils.isEmpty(address.get("address")) ? null : String.valueOf(address.get("address")));
rescueStation.setLatitude(ObjectUtils.isEmpty(address.get("latitude")) ? null : String.valueOf(address.get("latitude")));
rescueStation.setLongitude(ObjectUtils.isEmpty(address.get("longitude")) ? null : String.valueOf(address.get("longitude")));
rescueStation.setRecUserId(RequestContext.getExeUserId());
rescueStation.setRecDate(new Date());
boolean update = iRescueStationService.updateById(rescueStation);
......@@ -132,10 +166,19 @@ public class RescueStationController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel<RescueStationDto> selectById(@PathVariable Long id) {
RescueStation rescueStation = iRescueStationService.getById(id);
RescueStationDto rescueStationDto = BeanDtoVoUtils.convert(rescueStation, RescueStationDto.class);
return ResponseHelper.buildResponse(rescueStationDto);
public ResponseModel<Map<String, Object>> selectById(@PathVariable Long id) {
Map<String, Object> detail = rescueStationMapper.getDetailById(id);
detail.put("address", String.valueOf(detail.get("longitudeLatitude")).contains("{") ? JSON.parseObject(String.valueOf(detail.get("longitudeLatitude"))) : detail.get("address"));
List<String> strings = Arrays.asList(String.valueOf(detail.get("regionCode")).split("#"));
detail.put("city", strings.get(1) + "_" + detail.get("city"));
detail.put("district", strings.get(2) + "_" + detail.get("district"));
// RescueStation rescueStation = iRescueStationService.getById(id);
// List<String> strings = Arrays.asList(rescueStation.getRegionCode().split("#"));
// rescueStation.setCity(strings.get(1)+"_"+rescueStation.getCity());
// rescueStation.setDistrict(strings.get(2)+"_"+rescueStation.getDistrict());
// RescueStationDto rescueStationDto = BeanDtoVoUtils.convert(rescueStation, RescueStationDto.class);
return ResponseHelper.buildResponse(detail);
}
/**
......
......@@ -148,7 +148,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
//判断行政区划查询街道
private static final String STREET_END_CODE = "00";
private static final String STREET = "STREET";
private static final String STREET_LEVEL = "4";
private static final String CITY_LEVEL = "2";
private static final String REGION_LEVEL = "3";
@Autowired
RestHighLevelClient restHighLevelClient;
......@@ -357,19 +362,21 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<LinkedHashMap> getRegion(String level, String parentId) {
List<LinkedHashMap> list;
List<LinkedHashMap> list = new ArrayList<>();
if (!ObjectUtils.isEmpty(level)) {
list = (List<LinkedHashMap>) redisUtils.get(PROVINCE);
return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list;
} else if (!ObjectUtils.isEmpty(parentId)) {
String regionCode = parentId.split("_")[0];
//regionCode以0000结果查询市、否则查询区
Map<String, Object> map = regionCode.endsWith(END_CODE) ? (Map<String, Object>) redisUtils.get(CITY) : (Map<String, Object>) redisUtils.get(REGION);
if (ObjectUtils.isEmpty(map)) {
map = getRegionList();
//regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
if (!regionCode.endsWith(STREET_END_CODE)) {
list = ObjectUtils.isEmpty(redisUtils.get(STREET)) ? getProvinceList(STREET_LEVEL) : (List<LinkedHashMap>) redisUtils.get(STREET);
} else if (regionCode.endsWith(END_CODE)) {
list = ObjectUtils.isEmpty(redisUtils.get(CITY)) ? getProvinceList(CITY_LEVEL) : (List<LinkedHashMap>) redisUtils.get(CITY);
} else {
list = ObjectUtils.isEmpty(redisUtils.get(REGION)) ? getProvinceList(REGION_LEVEL) : (List<LinkedHashMap>) redisUtils.get(REGION);
}
list = (List<LinkedHashMap>) map.get(regionCode);
return list;
return list.stream().filter(r -> regionCode.equals(r.get("parentRegionCode").toString())).collect(Collectors.toList());
} else {
return new ArrayList<>();
}
......
......@@ -106,7 +106,7 @@
CI.manufacturing_unit,
CI.manufacturing_date,
CI.valve_manufactur_unit,
CI.nominal_work_pressure,
round(CI.nominal_work_pressure, 1) as nominalWorkPressure,
CI.volume,
CI.product_qualified,
CI.proof_quality,
......
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