Commit 9b2de18a authored by suhuiguang's avatar suhuiguang

电子预案:

1.绑定资源设备数据项查询
parent 6ffdde97
......@@ -15,9 +15,12 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/api/visual")
@Api(tags="预案可视化API")
@Api(tags = "预案可视化API")
public class PlanVisual3dController extends BaseController {
private final Logger log = LoggerFactory.getLogger(PlanVisual3dController.class);
......@@ -40,10 +43,26 @@ public class PlanVisual3dController extends BaseController {
/**
* 资源设备信息查询
*/
@ApiOperation(httpMethod = "GET",value = "资源查询",notes = "资源查询")
@ApiOperation(httpMethod = "GET", value = "资源查询", notes = "资源查询")
@Authorization(ingore = true)
@GetMapping(value="/resource/{type}/list")
public CommonResponse getResourceList(@ApiParam(value = "资源类型", required = true) @PathVariable String type){
@GetMapping(value = "/resource/{type}/list")
public CommonResponse getResourceList(@ApiParam(value = "资源类型", required = true) @PathVariable String type) {
return planVisual3dService.getResourceListByType(type);
}
/**
* 资源设备数据项查询
*
* @param id
* @return
*/
@Authorization(ingore = true)
@GetMapping(value = "/{type}/detail/{id}")
@ApiOperation(value = "数据项查询", notes = "按照分类及id查询数据项")
public CommonResponse getResourceDetail(
@ApiParam(value = "资源类型", required = true) @PathVariable String type,
@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
List<Map<String, Object>> list = planVisual3dService.getResourceById(type, id);
return CommonResponseUtil.success(list);
}
}
......@@ -3,7 +3,10 @@ package com.yeejoin.amos.fas.business.dao.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public interface PlanVisual3dMapper extends BaseMapper {
List<HashMap<String,String>> getResourceListByType(@Param("type") String type);
Map<String, Object> queryOneByTypeAndId(@Param("type") String type, @Param("id") Long id);
}
......@@ -16,10 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service("planVisual3dService")
public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
......@@ -42,7 +40,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
CommonResponse response = maasVisualServer.getTree();
List<TreeSubjectVo> treeSubjectVos = Lists.newArrayList();
if (null != response.getDataList()) {
List<Object> res = (List<Object>)response.getDataList();
List<Object> res = (List<Object>) response.getDataList();
if (!CollectionUtils.isEmpty(res)) {
treeSubjectVos = listToTree(res);
}
......@@ -134,11 +132,47 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
dict.setDictCode(FasConstant.PLAN_SOURCE_TYPE);
dict.setDictValue(type);
List<Dict> dictList = dictService.getDictList(dict);
if(CollectionUtils.isEmpty(dictList)){
if (CollectionUtils.isEmpty(dictList)) {
return CommonResponseUtil.failure(type + "字典类型不存在");
}
//2.返回存在的数据
return CommonResponseUtil.success(planVisual3dMapper.getResourceListByType(type));
}
@Override
public List<Map<String, Object>> getResourceById(String type, Long id) {
//1.查询出要返回数据
Map<String, Object> map = planVisual3dMapper.queryOneByTypeAndId(type, id);
//1.1无数据则返回
if (CollectionUtils.isEmpty(map)) {
return new ArrayList<>();
}
//2.加工数据
//2.0查询出中英文对照字典映射
Dict dict = new Dict();
dict.setDictCode(type);
List<Dict> dictList = dictService.getDictList(dict);
Map<String, String> dicts = dictList.stream().collect(
Collectors.toMap(Dict::getDictValue, Dict::getDictName, (key1, key2) -> key2));
//2.1换key为中文
Map<String, Object> tempMap = new HashMap<String, Object>();
map.forEach((k, v) -> {
if (dicts.containsKey(k)) {
tempMap.put(dicts.get(k), v);
}
});
//2.2map转list
List<Map<String, Object>> list = new ArrayList<>();
list = tempMap.entrySet().stream().map(e -> {
Map<String, Object> newMap = new HashMap<String, Object>();
newMap.put("label", e.getKey());
newMap.put("value", e.getValue());
return newMap;
}).collect(Collectors.toList());
return list;
}
}
......@@ -33,4 +33,6 @@ public interface IPlanVisual3dService {
TextPlan getTextPlanInfoById(Long id);
CommonResponse getResourceListByType(String type);
List<Map<String,Object>> getResourceById(String type,Long id);
}
......@@ -27,7 +27,7 @@
(select a.id,a.`name`,a.`code` from f_equipment a) as rs
</when>
<when test="type=='fireStrength'">
(select a.id,a.`name`,a.`code` from f_equipment a) as rs
(select a.id,a.`username` as name ,a.`code` from f_fire_strength a) as rs
</when>
<when test="type=='fireChamber'">
(select a.id,a.`name`,a.`code` from f_fire_station a where a.type = '1') as rs
......@@ -43,4 +43,46 @@
</when>
</choose>
</select>
<select id="queryOneByTypeAndId" resultType="hashmap">
SELECT
*
from
<choose>
<when test="type=='fireCar'">
(SELECT * FROM `f_fire_car` a) as rs
</when>
<when test="type=='monitorEquipment'">
(select * from f_fire_equipment a where a.equip_classify = 0) as rs
</when>
<when test="type=='fireConsumables'">
(select * from f_fire_equipment a where a.equip_classify = 1) as rs
</when>
<when test="type=='video'">
(select * from f_fire_equipment a where a.equip_classify = 2) as rs
</when>
<when test="type=='fireEquipment'">
(select * from f_fire_equipment a where a.equip_classify = 3) as rs
</when>
<when test="type=='impEquipment'">
(select * from f_equipment a) as rs
</when>
<when test="type=='fireStrength'">
(select * from f_fire_strength a) as rs
</when>
<when test="type=='fireChamber'">
(select * from f_fire_station a where a.type = '1') as rs
</when>
<when test="type=='fireFoamRoom'">
(select * from f_fire_station a where a.type = '2') as rs
</when>
<when test="type=='hydrant'">
(SELECT * FROM `f_water_resource` a where a.type = '1') as rs
</when>
<when test="type=='pool'">
(SELECT * FROM `f_water_resource` a where a.type = '2') as rs
</when>
</choose>
where rs.id = #{id}
</select>
</mapper>
\ No newline at end of file
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