Commit ef7d400a authored by taabe's avatar taabe

装备服务-消防建筑树接口

parent 8febe2ad
......@@ -62,8 +62,19 @@ public class MenuFrom {
this.title = title;
this.label = label;
this.name = name;
this.parentId = parentId;
this.parentId = parentId;
}
public MenuFrom(String key, String name, String parentId) {
super();
this.id = key;
this.value = key;
this.key = key;
this.title = name;
this.label = name;
this.name = name;
this.parentId = parentId;
}
public MenuFrom() {
super();
}
......
......@@ -74,4 +74,12 @@ public interface EquipFeignClient {
*/
@RequestMapping(value = "/fire-fighting-system/list", method = RequestMethod.GET)
ResponseModel<Object> getFireSystemListAll();
/**
* 获取消防系统列表
*
* @return
*/
@RequestMapping(value = "/building/tree", method = RequestMethod.GET)
ResponseModel<Object> getBuildingTree();
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireSystemDto;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.EquipmentServiceImpl;
import io.swagger.annotations.Api;
......@@ -32,7 +33,14 @@ public class EquipmentController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/fireSystem/list")
@ApiOperation(value = "获取消防系统列表")
public ResponseModel<List<FireSystemDto>> getFireSystemList() {
public ResponseModel<List<MenuFrom>> getFireSystemList() {
return ResponseHelper.buildResponse(equipmentService.getFireSystemList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/building/tree")
@ApiOperation(value = "获取消防建筑树")
public ResponseModel<List<MenuFrom>> getBuildingList() {
return ResponseHelper.buildResponse(equipmentService.getBuildingList());
}
}
......@@ -4,18 +4,23 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireChemicalDto;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireChemicalServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
......@@ -64,9 +69,9 @@ public class FireChemicalController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@DeleteMapping(value = "/batch")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除危化品", notes = "根据sequenceNbr删除危化品")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") String sequenceNbr){
public ResponseModel<Boolean> deleteBySequenceNbr(@RequestParam(value = "ids") String sequenceNbr) {
@SuppressWarnings("rawtypes")
List lt = Arrays.asList(sequenceNbr.split(","));
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireSystemDto;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
......@@ -21,20 +25,49 @@ public class EquipmentServiceImpl {
@Autowired
EquipFeignClient equipFeignClient;
public List<FireSystemDto> getFireSystemList() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
public List<MenuFrom> getFireSystemList() {
ResponseModel<Object> response = equipFeignClient.getFireSystemListAll();
stopWatch.stop();
System.out.printf("耗时%f秒/n", stopWatch.getTotalTimeSeconds());
List<Map<String, Object>> fireSystemMapList = (List<Map<String, Object>>) response.getResult();
List<FireSystemDto> fireSystemDtoList = Lists.newArrayList();
List<MenuFrom> fireSystemDtoList = Lists.newArrayList();
fireSystemMapList.forEach(system -> {
FireSystemDto fireSystemDto = new FireSystemDto();
fireSystemDto.setId((String) system.get("id"));
fireSystemDto.setName((String) system.get("name"));
fireSystemDtoList.add(fireSystemDto);
MenuFrom menuFrom = new MenuFrom((String) system.get("id"), (String) system.get("name"), "0");
fireSystemDtoList.add(menuFrom);
});
return fireSystemDtoList;
}
public List<MenuFrom> getBuildingList() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ResponseModel<Object> response = equipFeignClient.getBuildingTree();
stopWatch.stop();
System.out.printf("耗时%f秒/n", stopWatch.getTotalTimeSeconds());
List<Map<String, Object>> buildingMapList = (List<Map<String, Object>>) response.getResult();
List<MenuFrom> buildingTreeList = Lists.newArrayList();
buildingMapList.forEach(building -> {
MenuFrom menuFrom = new MenuFrom((String) building.get("id"), "全部建筑", (String) building.get("parentId"));
List<Map<String, Object>> children = (List<Map<String, Object>>) building.get("children");
menuFrom.setChildren(parseTree(menuFrom, children));
menuFrom.setIsLeaf(false);
buildingTreeList.add(menuFrom);
});
return buildingTreeList.get(0).getChildren();
}
private List<MenuFrom> parseTree(MenuFrom parent, List<Map<String, Object>> children) {
List<MenuFrom> menuFromList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(children)) {
children.forEach(child -> {
MenuFrom menuFrom = new MenuFrom((String) child.get("id"), (String) child.get("name"), (String) child.get("parentId"));
if (!ValidationUtil.isEmpty(child.get("children"))) {
parseTree(menuFrom, (List<Map<String, Object>>) child.get("children"));
} else {
parent.setIsLeaf(false);
}
menuFromList.add(menuFrom);
parent.setChildren(menuFromList);
});
}
return menuFromList;
}
}
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