Commit b9725bdc authored by taabe's avatar taabe

消防力量调派资源树接口

parent 03bbb6e0
......@@ -7,6 +7,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 消防队伍
*
......@@ -59,4 +61,15 @@ public class FireTeamDto extends BaseDto {
@ApiModelProperty(value = "操作人名称")
private String recUserName;
@ApiModelProperty(value = "消防队类型(专职消防队,监控大队)")
private String type;
@ApiModelProperty(value = "执勤车辆数")
private String onDutyCount;
@ApiModelProperty(value = "出动车辆数")
private String outCount;
@ApiModelProperty(value = "队伍下车辆")
private List<FireCarDto> children;
}
package com.yeejoin.amos.boot.module.jcs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 消防队伍类型枚举
*
* @author DELL
*/
@Getter
@AllArgsConstructor
public enum FireBrigadeTypeEnum {
专职消防队("fullTime", "116", "专职消防队"),
监控大队("monitorTeam", "118", "监控大队");
private String key;
private String code;
private String name;
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
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.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 警情接警记录
*
* @author tb
* @date 2021-06-17
*/
@RestController
@Api(tags = "警情接警记录Api")
@RequestMapping(value = "/alert-called")
public class AlertCalledController extends BaseController {
@Autowired
AlertCalledServiceImpl iAlertCalledService;
@Autowired
AlertFormValueServiceImpl iAlertFormValueService;
@Autowired
private ESAlertCalledService eSAlertCalledService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增警情接警记录
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增警情接警记录", notes = "新增警情接警记录")
@Transactional
public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request,
@RequestBody AlertCalledVo alertCalledVo) throws Exception{
if (ValidationUtil.isEmpty(alertCalledVo)
|| ValidationUtil.isEmpty(alertCalledVo.getAlertCalled()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(iAlertCalledService.createAlertCalled(alertCalledVo));
}
/**
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iAlertCalledService.removeById(id);
}
/**
* 修改警情接警记录
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改警情接警记录", notes = "修改警情接警记录")
public boolean updateByIdAlertCalled(HttpServletRequest request, @RequestBody AlertCalled alertCalled) {
return iAlertCalledService.updateById(alertCalled);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel<Object> selectById(HttpServletRequest request, @PathVariable Long id) {
if(redisUtils.hasKey(RedisKey.ALERTCALLED_ID+id)){
Object obj= redisUtils.get(RedisKey.ALERTCALLED_ID+id);
return ResponseHelper.buildResponse(obj);
}else{
// 警情基本信息
AlertCalled alertCalled = iAlertCalledService.getById(id);
QueryWrapper<AlertFormValue> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("alert_called_id", id);
// 警情动态表单数据
List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
List<FormValue> formValue = new ArrayList<FormValue>();
if(list!=null&&list.size()>0) {
for (AlertFormValue alertFormValue : list) {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
formValue.add(value);
}
}
AlertCalledFormVo alertCalledFormVo = new AlertCalledFormVo(alertCalled, formValue);
redisUtils.set(RedisKey.ALERTCALLED_ID+id,JSON.toJSON(alertCalledFormVo),time);
return ResponseHelper.buildResponse(alertCalledFormVo);
}
}
/**
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public ResponseModel<IPage<AlertCalled>> listPage(String pageNum, String pageSize,String sort, AlertCalled alertCalled) {
Page<AlertCalled> pageBean;
IPage<AlertCalled> page;
QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort);
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
return ResponseHelper.buildResponse(page);
}
/**
*
* <pre>
* 相似警情分页查询
* </pre>
*
* @param alertCalled
* @param current
* @param size
* @return
* @throws Exception
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "相似警情分页查询")
@RequestMapping(value = "/page/similar", method = RequestMethod.POST)
public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar(
@RequestBody ESAlertCalledRequestDto alertCalledVo,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) throws Exception {
return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size));
}
/**
*
* <pre>
* 初始化ES
* </pre>
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "初始化ES")
@RequestMapping(value = "/es/init", method = RequestMethod.PUT)
public ResponseModel<Boolean> initEs() throws Exception {
return ResponseHelper.buildResponse(eSAlertCalledService.initEs());
}
/**
* 列表无分页查询
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getList", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表无分页查询", notes = "列表无分页查询")
public ResponseModel<List<AlertCalled>> list(AlertCalled alertCalled) {
QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
setQueryWrapper(alertCalledQueryWrapper, alertCalled,null);
List<AlertCalled> list = iAlertCalledService.list(alertCalledQueryWrapper);
return ResponseHelper.buildResponse(list);
}
private QueryWrapper<AlertCalled> setQueryWrapper(QueryWrapper<AlertCalled> queryWrapper, AlertCalled alertCalled,String sort){
Class<? extends AlertCalled> aClass = alertCalled.getClass();
queryWrapper.eq("is_delete", 0);
if(sort!=null) {
String[] date= sort.split(",");
if(date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
}else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
}else {
queryWrapper.orderByDesc("call_time");
}
if (alertCalled.getCallTimeStart() != null && alertCalled.getCallTimeEnd() != null) {
queryWrapper.between("call_time", alertCalled.getCallTimeStart(), alertCalled.getCallTimeEnd());
}
if (alertCalled.getIsFatherAlert()) { // 0:接警;1:处警
queryWrapper.isNull("father_alert");
}
if (!ValidationUtil.isEmpty(alertCalled.getAlertSourceCodeStr())){
String[] arr = alertCalled.getAlertSourceCodeStr().split(",");
List<String> collect = Arrays.stream(arr).collect(Collectors.toList());
queryWrapper.in("alert_source_code", collect);
}
Stream<Field> fieldStream = Arrays.stream(aClass.getDeclaredFields()).filter(field -> {
String name = NameUtils.camel2Underline(field.getName());
return !("IS_FATHER_ALERT".equals(name) || "ALERT_SOURCE_CODE_STR".equals(name));
});
fieldStream.forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(alertCalled);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(alertCalled);
queryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(alertCalled);
queryWrapper.eq(name, fileValue);
} else if (type.equals(Boolean.class)) {
Boolean fileValue = (Boolean) field.get(alertCalled);
queryWrapper.eq(name, fileValue);
}else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(alertCalled);
queryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常");
}
});
return queryWrapper;
}
}
\ No newline at end of file
//package com.yeejoin.amos.boot.module.jcs.biz.controller;
//
//import java.lang.reflect.Field;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//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.foundation.utils.ValidationUtil;
//import org.typroject.tyboot.core.restful.doc.TycloudOperation;
//import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
//import org.typroject.tyboot.core.restful.utils.ResponseHelper;
//import org.typroject.tyboot.core.restful.utils.ResponseModel;
//
//import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.yeejoin.amos.boot.biz.common.controller.BaseController;
//import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
//import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
//import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
//import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo;
//import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo;
//import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//
///**
// * 警情接警记录
// *
// * @author tb
// * @date 2021-06-17
// */
//@RestController
//@Api(tags = "警情接警记录Api")
//@RequestMapping(value = "/alert-called")
//public class AlertCalledController extends BaseController {
//
// @Autowired
// AlertCalledServiceImpl iAlertCalledService;
// @Autowired
// AlertFormValueServiceImpl iAlertFormValueService;
// @Autowired
// private ESAlertCalledService eSAlertCalledService;
// @Autowired
// RedisUtils redisUtils;
// @Value("${redis.cache.failure.time}")
// private long time;
// /**
// * 新增警情接警记录
// *
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @PostMapping(value = "/save")
// @ApiOperation(httpMethod = "POST", value = "新增警情接警记录", notes = "新增警情接警记录")
// @Transactional
// public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request,
// @RequestBody AlertCalledVo alertCalledVo) throws Exception{
//
// if (ValidationUtil.isEmpty(alertCalledVo)
// || ValidationUtil.isEmpty(alertCalledVo.getAlertCalled()))
// throw new BadRequest("参数校验失败.");
//
// return ResponseHelper.buildResponse(iAlertCalledService.createAlertCalled(alertCalledVo));
// }
//
// /**
// * 根据id删除
// *
// * @param id
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
// @ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
// public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
// return iAlertCalledService.removeById(id);
// }
//
// /**
// * 修改警情接警记录
// *
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/updateById", method = RequestMethod.PUT)
// @ApiOperation(httpMethod = "PUT", value = "修改警情接警记录", notes = "修改警情接警记录")
// public boolean updateByIdAlertCalled(HttpServletRequest request, @RequestBody AlertCalled alertCalled) {
// return iAlertCalledService.updateById(alertCalled);
// }
//
// /**
// * 根据id查询
// *
// * @param id
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/{id}", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
// public ResponseModel<Object> selectById(HttpServletRequest request, @PathVariable Long id) {
//
// if(redisUtils.hasKey(RedisKey.ALERTCALLED_ID+id)){
// Object obj= redisUtils.get(RedisKey.ALERTCALLED_ID+id);
// return ResponseHelper.buildResponse(obj);
// }else{
// // 警情基本信息
// AlertCalled alertCalled = iAlertCalledService.getById(id);
// QueryWrapper<AlertFormValue> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("alert_called_id", id);
// // 警情动态表单数据
// List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
// List<FormValue> formValue = new ArrayList<FormValue>();
// if(list!=null&&list.size()>0) {
// for (AlertFormValue alertFormValue : list) {
// FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
// formValue.add(value);
// }
// }
// AlertCalledFormVo alertCalledFormVo = new AlertCalledFormVo(alertCalled, formValue);
//
// redisUtils.set(RedisKey.ALERTCALLED_ID+id,JSON.toJSON(alertCalledFormVo),time);
// return ResponseHelper.buildResponse(alertCalledFormVo);
// }
// }
//
// /**
// * 列表分页查询
// *
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/list", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
// public ResponseModel<IPage<AlertCalled>> listPage(String pageNum, String pageSize,String sort, AlertCalled alertCalled) {
// Page<AlertCalled> pageBean;
// IPage<AlertCalled> page;
// QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
//
// setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort);
//
// if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
// pageBean = new Page<>(0, Long.MAX_VALUE);
// } else {
// pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
// }
// page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
// return ResponseHelper.buildResponse(page);
// }
//
// /**
// *
// * <pre>
// * 相似警情分页查询
// * </pre>
// *
// * @param alertCalled
// * @param current
// * @param size
// * @return
// * @throws Exception
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @ApiOperation(value = "相似警情分页查询")
// @RequestMapping(value = "/page/similar", method = RequestMethod.POST)
// public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar(
// @RequestBody ESAlertCalledRequestDto alertCalledVo,
// @RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size) throws Exception {
// return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size));
// }
//
// /**
// *
// * <pre>
// * 初始化ES
// * </pre>
// *
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @ApiOperation(value = "初始化ES")
// @RequestMapping(value = "/es/init", method = RequestMethod.PUT)
// public ResponseModel<Boolean> initEs() throws Exception {
// return ResponseHelper.buildResponse(eSAlertCalledService.initEs());
// }
//
// /**
// * 列表无分页查询
// *
// * @return
// */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/getList", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "列表无分页查询", notes = "列表无分页查询")
// public ResponseModel<List<AlertCalled>> list(AlertCalled alertCalled) {
// QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
// setQueryWrapper(alertCalledQueryWrapper, alertCalled,null);
// List<AlertCalled> list = iAlertCalledService.list(alertCalledQueryWrapper);
// return ResponseHelper.buildResponse(list);
// }
//
// private QueryWrapper<AlertCalled> setQueryWrapper(QueryWrapper<AlertCalled> queryWrapper, AlertCalled alertCalled,String sort){
// Class<? extends AlertCalled> aClass = alertCalled.getClass();
// queryWrapper.eq("is_delete", 0);
//
// if(sort!=null) {
// String[] date= sort.split(",");
// if(date[1].equals("ascend")) {
// queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
// }else {
// queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
// }
// }else {
// queryWrapper.orderByDesc("call_time");
// }
//
// if (alertCalled.getCallTimeStart() != null && alertCalled.getCallTimeEnd() != null) {
// queryWrapper.between("call_time", alertCalled.getCallTimeStart(), alertCalled.getCallTimeEnd());
// }
// if (alertCalled.getIsFatherAlert()) { // 0:接警;1:处警
// queryWrapper.isNull("father_alert");
// }
// if (!ValidationUtil.isEmpty(alertCalled.getAlertSourceCodeStr())){
// String[] arr = alertCalled.getAlertSourceCodeStr().split(",");
// List<String> collect = Arrays.stream(arr).collect(Collectors.toList());
// queryWrapper.in("alert_source_code", collect);
// }
// Stream<Field> fieldStream = Arrays.stream(aClass.getDeclaredFields()).filter(field -> {
// String name = NameUtils.camel2Underline(field.getName());
// return !("IS_FATHER_ALERT".equals(name) || "ALERT_SOURCE_CODE_STR".equals(name));
// });
// fieldStream.forEach(field -> {
// try {
// field.setAccessible(true);
// Object o = field.get(alertCalled);
// if (o != null) {
// Class<?> type = field.getType();
// String name = NameUtils.camel2Underline(field.getName());
// if (type.equals(Integer.class)) {
// Integer fileValue = (Integer) field.get(alertCalled);
// queryWrapper.eq(name, fileValue);
// } else if (type.equals(String.class)) {
// String fileValue = (String) field.get(alertCalled);
// queryWrapper.eq(name, fileValue);
// } else if (type.equals(Boolean.class)) {
// Boolean fileValue = (Boolean) field.get(alertCalled);
// queryWrapper.eq(name, fileValue);
// }else if (type.equals(Long.class)) {
// Long fileValue = (Long) field.get(alertCalled);
// queryWrapper.eq(name, fileValue);
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException("系统异常");
// }
// });
// return queryWrapper;
// }
//}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -180,7 +181,7 @@ public class PowerTransferController extends BaseController {
@GetMapping(value = "/power/tree")
@ApiOperation(value = "力量调派资源树", notes = "力量调派资源树")
public ResponseModel<Object> getPowerTree() {
iPowerTransferService.getPowerTree();
powerTransferService.getPowerTree();
return ResponseHelper.buildResponse("");
}
}
......
......@@ -33,8 +33,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Autowired
private AlertFormValueServiceImpl iAlertFormValueService;
@Autowired
private ESAlertCalledService eSAlertCalledService;
// @Autowired
// private ESAlertCalledService eSAlertCalledService;
/**
*
......@@ -71,7 +71,7 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
/**
* 同步保存ES
*/
eSAlertCalledService.saveAlertCalledToES(alertCalled);
// eSAlertCalledService.saveAlertCalledToES(alertCalled);
return alertCalledVo;
}
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository;
/**
*
* <pre>
* 警情信息ES检索服务
* </pre>
*
* @author gwb
* @version $Id: ESAlertCalledService.java, v 0.1 2021年6月19日 下午5:12:01 gwb Exp $
*/
@Service
public class ESAlertCalledService {
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired
private ESAlertCalledRepository esAlertCalledRepository;
@Autowired
private AlertCalledServiceImpl alertCalledService;
@PostConstruct
public void init() throws Exception
{
//初始化ES,重建索引
initEs();
}
/**
* 重建索引
*/
public Boolean initEs() throws Exception {
esAlertCalledRepository.deleteAll();
/**
* 同步历史48小时以内的警情处置记录
*/
QueryWrapper<AlertCalled> wrapper = new QueryWrapper<>();
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 480*60*60*1000;
Date date=new Date(currentTime);
wrapper.ge("call_time", date);
List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
if (!ValidationUtil.isEmpty(alertCalleds))
{
for (AlertCalled alertCalled : alertCalleds)
{
saveAlertCalledToES(alertCalled);
}
}
return true;
}
/**
*
* <pre>
* 批量保存
* </pre>
*
* @param list 警情信息列表
*/
public void saveAll(List<AlertCalled> alertCalleds) throws Exception{
if (!ValidationUtil.isEmpty(alertCalleds))
{
for (AlertCalled alertCalled : alertCalleds)
{
this.saveAlertCalledToES(alertCalled);
}
}
}
/**
*
* <pre>
* 根据警情记录批量保存
* </pre>
*
* @param alertCalleds 警情信息列表
*/
public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception
{
ESAlertCalled esAlertCalled = new ESAlertCalled();
esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
esAlertCalled.setAlertType(alertCalled.getAlertType());
esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
esAlertCalled.setCallTime(alertCalled.getCallTime());
esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime());
esAlertCalled.setContactUser(alertCalled.getContactUser());
esAlertCalled.setContactPhone(alertCalled.getContactPhone());
esAlertCalled.setAddress(alertCalled.getAddress());
esAlertCalled.setAlertStage(alertCalled.getAlertStage());
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
if (alertCalled.getAlertStatus())
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
esAlertCalled.setCoordinateY(alertCalled.getCoordinateY());
esAlertCalledRepository.save(esAlertCalled);
return esAlertCalled;
}
/**
*
* <pre>
* 从ES库批量删除
* </pre>
*
* @param ids
* @return
* @throws Exception
*/
public Boolean deleteById(List<Long> ids) throws Exception{
if (!ValidationUtil.isEmpty(ids)) {
for (Long sequenceNbr : ids) {
if (esAlertCalledRepository.existsById(sequenceNbr)) {
esAlertCalledRepository.deleteById(sequenceNbr);
}
}
}
return true;
}
/**
* 根据id查询ES存储对象
*
* @param sequenceNbr id
* @return ES实例
*/
public ESAlertCalled queryById(Long sequenceNbr) {
return esAlertCalledRepository.findById(sequenceNbr).orElse(null);
}
/**
* 根据关键字查询文档,关键字不为空时按相关性从大到小排序
*
* @param queryStr 关键字
* @param current 当前页码
* @param size 页面大小
* @return
*/
@SuppressWarnings({ "rawtypes" })
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
{
Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
String[] alertStatus = alertCalledVo.getAlertStatus();
if (ValidationUtil.isEmpty(alertStatus))
{
return result;
}
AlertCalled alertCalled = alertCalledVo.getAlertCalled();
if (ValidationUtil.isEmpty(alertCalled))
{
return result;
}
/**
* 通用匹配规则,条件构建
*/
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
for (String status : alertStatus)
{
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
{
qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getName()));
}
}
boolMust.must(qb0);
//接警时间,距离当前时间不超过半小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 30*60*1000;
BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
.must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
boolMust.should(qb1);
//报警人及报警电话一致
if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
{
BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser()))
.must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
boolMust.should(qb2);
}
//事发地点一致,或相距不超过200米的
if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
{
BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
boolMust.should(qb3);
}
//警情类型一致
BoolQueryBuilder qb4 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode()));
boolMust.should(qb4);
//事发单位名称一致
if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved()))
{
BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved()));
boolMust.should(qb5);
}
/**
* 一般火灾,条件构造
*/
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页
.withPageable(PageRequest.of(current, size))
// 排序
// .withSort(SortBuilders.fieldSort("callTime").order(SortOrder.DESC))
//过滤条件
.withQuery(boolMust);
// 对高亮词条进行操作
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
List<ESAlertCalledDto> list = new LinkedList<>();
for (SearchHit searchHit : searchHits.getSearchHits())
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
list.add(eSAlertCalled);
}
result.setRecords(list);
result.setTotal(searchHits.getTotalHits());
return result;
}
}
//package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
//
//import java.util.Date;
//import java.util.LinkedList;
//import java.util.List;
//
//import javax.annotation.PostConstruct;
//
//import org.elasticsearch.index.query.BoolQueryBuilder;
//import org.elasticsearch.index.query.QueryBuilders;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
//import org.springframework.data.elasticsearch.core.SearchHit;
//import org.springframework.data.elasticsearch.core.SearchHits;
//import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
//import org.springframework.stereotype.Service;
//import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
//
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
//import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository;
//
///**
// *
// * <pre>
// * 警情信息ES检索服务
// * </pre>
// *
// * @author gwb
// * @version $Id: ESAlertCalledService.java, v 0.1 2021年6月19日 下午5:12:01 gwb Exp $
// */
//@Service
//public class ESAlertCalledService {
//
// @Autowired
// private ElasticsearchRestTemplate elasticsearchTemplate;
//
// @Autowired
// private ESAlertCalledRepository esAlertCalledRepository;
//
// @Autowired
// private AlertCalledServiceImpl alertCalledService;
//
//
//
// @PostConstruct
// public void init() throws Exception
// {
// //初始化ES,重建索引
// initEs();
// }
//
// /**
// * 重建索引
// */
// public Boolean initEs() throws Exception {
// esAlertCalledRepository.deleteAll();
// /**
// * 同步历史48小时以内的警情处置记录
// */
// QueryWrapper<AlertCalled> wrapper = new QueryWrapper<>();
//
// long currentTime = System.currentTimeMillis() ;
// currentTime = currentTime - 480*60*60*1000;
// Date date=new Date(currentTime);
//
// wrapper.ge("call_time", date);
//
// List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
// if (!ValidationUtil.isEmpty(alertCalleds))
// {
// for (AlertCalled alertCalled : alertCalleds)
// {
// saveAlertCalledToES(alertCalled);
// }
// }
// return true;
// }
//
// /**
// *
// * <pre>
// * 批量保存
// * </pre>
// *
// * @param list 警情信息列表
// */
// public void saveAll(List<AlertCalled> alertCalleds) throws Exception{
//
// if (!ValidationUtil.isEmpty(alertCalleds))
// {
// for (AlertCalled alertCalled : alertCalleds)
// {
// this.saveAlertCalledToES(alertCalled);
// }
// }
// }
//
// /**
// *
// * <pre>
// * 根据警情记录批量保存
// * </pre>
// *
// * @param alertCalleds 警情信息列表
// */
// public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception
// {
// ESAlertCalled esAlertCalled = new ESAlertCalled();
// esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
// esAlertCalled.setAlertType(alertCalled.getAlertType());
// esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
// esAlertCalled.setCallTime(alertCalled.getCallTime());
// esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime());
// esAlertCalled.setContactUser(alertCalled.getContactUser());
// esAlertCalled.setContactPhone(alertCalled.getContactPhone());
// esAlertCalled.setAddress(alertCalled.getAddress());
// esAlertCalled.setAlertStage(alertCalled.getAlertStage());
// esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
// if (alertCalled.getAlertStatus())
// {
// esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
// }else
// {
// esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
// }
// esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
// esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
// esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
// esAlertCalled.setCoordinateY(alertCalled.getCoordinateY());
//
// esAlertCalledRepository.save(esAlertCalled);
//
// return esAlertCalled;
// }
//
// /**
// *
// * <pre>
// * 从ES库批量删除
// * </pre>
// *
// * @param ids
// * @return
// * @throws Exception
// */
// public Boolean deleteById(List<Long> ids) throws Exception{
// if (!ValidationUtil.isEmpty(ids)) {
// for (Long sequenceNbr : ids) {
// if (esAlertCalledRepository.existsById(sequenceNbr)) {
// esAlertCalledRepository.deleteById(sequenceNbr);
// }
// }
// }
//
// return true;
// }
//
// /**
// * 根据id查询ES存储对象
// *
// * @param sequenceNbr id
// * @return ES实例
// */
// public ESAlertCalled queryById(Long sequenceNbr) {
// return esAlertCalledRepository.findById(sequenceNbr).orElse(null);
// }
//
// /**
// * 根据关键字查询文档,关键字不为空时按相关性从大到小排序
// *
// * @param queryStr 关键字
// * @param current 当前页码
// * @param size 页面大小
// * @return
// */
// @SuppressWarnings({ "rawtypes" })
// public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
// {
// Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
//
// String[] alertStatus = alertCalledVo.getAlertStatus();
// if (ValidationUtil.isEmpty(alertStatus))
// {
// return result;
// }
//
// AlertCalled alertCalled = alertCalledVo.getAlertCalled();
// if (ValidationUtil.isEmpty(alertCalled))
// {
// return result;
// }
// /**
// * 通用匹配规则,条件构建
// */
// BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// //警情状态
// BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
// for (String status : alertStatus)
// {
// AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
// if (!ValidationUtil.isEmpty(alertStatusEnum))
// {
// qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getName()));
// }
// }
// boolMust.must(qb0);
// //接警时间,距离当前时间不超过半小时的
// long currentTime = System.currentTimeMillis() ;
// currentTime = currentTime - 30*60*1000;
// BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
// .must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
// boolMust.should(qb1);
// //报警人及报警电话一致
// if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
// {
// BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
// .must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser()))
// .must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
// boolMust.should(qb2);
// }
// //事发地点一致,或相距不超过200米的
// if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
// {
// BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
// .should(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
// boolMust.should(qb3);
// }
// //警情类型一致
// BoolQueryBuilder qb4 = QueryBuilders.boolQuery()
// .must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode()));
// boolMust.should(qb4);
// //事发单位名称一致
// if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved()))
// {
// BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
// .must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved()));
// boolMust.should(qb5);
// }
//
// /**
// * 一般火灾,条件构造
// */
//
//
//
// // 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// // 分页
// .withPageable(PageRequest.of(current, size))
// // 排序
//// .withSort(SortBuilders.fieldSort("callTime").order(SortOrder.DESC))
// //过滤条件
// .withQuery(boolMust);
//
//// 对高亮词条进行操作
// SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
//
// List<ESAlertCalledDto> list = new LinkedList<>();
// for (SearchHit searchHit : searchHits.getSearchHits())
// {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
// list.add(eSAlertCalled);
// }
// result.setRecords(list);
// result.setTotal(searchHits.getTotalHits());
//
// return result;
// }
//
//}
......@@ -2,7 +2,9 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireCarDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
......@@ -13,15 +15,11 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompany;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireCarStatusEnum;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.EquipFeignService;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertCalledService;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertFormValueService;
import com.yeejoin.amos.boot.module.jcs.api.service.IPowerTransferCompanyResourcesService;
import com.yeejoin.amos.boot.module.jcs.api.service.IPowerTransferCompanyService;
import com.yeejoin.amos.boot.module.jcs.api.service.IPowerTransferService;
import com.yeejoin.amos.boot.module.jcs.api.service.ITemplateService;
import com.yeejoin.amos.boot.module.jcs.api.vo.PowerTransferCompanyResourcesVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.PowerTransferCompanyVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.PowerTransferVo;
......@@ -31,6 +29,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -66,11 +65,12 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
AlertFormValueServiceImpl alertFormValueService;
@Autowired
EquipFeignService equipFeignService;
EquipFeignClient equipFeignService;
@Autowired
FireTeamServiceImpl fireTeamService;
@Override
public PowerTransferVo getPowerTransferList(Long alertCalledId) {
List<PowerTransferCompanyResourcesVo> powerTransferList =
this.baseMapper.getPowerTransferList(alertCalledId);
......@@ -132,7 +132,29 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
});
}
// 2.查询消防队伍列表
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code", ""));
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code",
FireBrigadeTypeEnum.专职消防队.getCode()));
List<FireTeam> monitorFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code",
FireBrigadeTypeEnum.监控大队.getCode()));
// 3.组装专职消防队伍车辆
// List<FireTeamDto> fireTeamDtoList = Lists.newArrayList();
// if (!CollectionUtils.isEmpty(fullTimeFireBrigadeList)) {
// fullTimeFireBrigadeList.forEach(brigade -> {
// FireTeamDto teamDto = new FireTeamDto();
// BeanUtils.copyProperties(brigade, teamDto);
// teamDto.setType(FireBrigadeTypeEnum.专职消防队.getKey());
//
//// teamDto.setChildren();
// });
// }
fireCarDtoList.stream().collect(Collectors.groupingBy(FireCarDto::getTeamId));
try {
TreeParser.getTree(null, monitorFireBrigadeList, FireTeam.class.getName(), "getSequenceNbr", 2, "getName",
"getParent");
} catch (Exception e) {
e.printStackTrace();
}
}
private List<PowerTransferCompanyResources> DtoEntityBatchConvert(List<PowerTransferCompanyResourcesDto> powerTransferCompanyResourcesDtoList, Long powerTransferCompanySequenceNbr) {
......@@ -207,6 +229,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
}
}
@Override
public List<PowerTransferCompanyVo> getLastPowerTransferCompany(Long alertCalledId) {
return this.baseMapper.getLastPowerTransferCompany(alertCalledId);
}
......
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