Commit c90d00b6 authored by tianbo's avatar tianbo

aop 修改,指挥app接口添加

parent 2bded5cc
...@@ -27,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -27,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.auth.exception.AuthException; import org.typroject.tyboot.core.auth.exception.AuthException;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Arrays; import java.util.Arrays;
...@@ -62,6 +63,9 @@ public class ControllerAop { ...@@ -62,6 +63,9 @@ public class ControllerAop {
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
//TODO tyboot 框架拦截器已缓存数据 //TODO tyboot 框架拦截器已缓存数据
String token = RequestContext.getToken(); String token = RequestContext.getToken();
if (ValidationUtil.isEmpty(token)) {
token = request.getHeader("X-Access-Token");
}
// 不需要添加请求头的接口 // 不需要添加请求头的接口
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany", "/jcs/command/lookHtmlText"}; String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany", "/jcs/command/lookHtmlText"};
// 获取请求路径 // 获取请求路径
......
...@@ -114,4 +114,5 @@ public interface PowerTransferMapper extends BaseMapper<PowerTransfer> { ...@@ -114,4 +114,5 @@ public interface PowerTransferMapper extends BaseMapper<PowerTransfer> {
*/ */
IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page, IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page,
@Param("alertCalledId") Long alertCalledId); @Param("alertCalledId") Long alertCalledId);
} }
package com.yeejoin.amos.boot.module.jcs.api.service; package com.yeejoin.amos.boot.module.jcs.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
...@@ -53,4 +54,13 @@ public interface IPowerTransferService extends IService<PowerTransfer> { ...@@ -53,4 +54,13 @@ public interface IPowerTransferService extends IService<PowerTransfer> {
* @return * @return
*/ */
List<ResourceStatisticsDto> getPowerTransferStatistics(Long alertCalledId, String type); List<ResourceStatisticsDto> getPowerTransferStatistics(Long alertCalledId, String type);
/**
* 根据警情id获取警情调派的资源(车辆、人员、装备、车载水量、车载药剂)统计
*
* @param alertCalledId
* @return
*/
JSONObject getPowerTransferCarResourceStatistics(Long alertCalledId);
} }
...@@ -251,5 +251,4 @@ ...@@ -251,5 +251,4 @@
AND is_distribution_agencies = 0 AND is_distribution_agencies = 0
</select> </select>
</mapper> </mapper>
...@@ -1028,4 +1028,14 @@ public class CommandController extends BaseController { ...@@ -1028,4 +1028,14 @@ public class CommandController extends BaseController {
public ResponseModel<Object> selectByAlertCalledId(@PathVariable Long id) { public ResponseModel<Object> selectByAlertCalledId(@PathVariable Long id) {
return ResponseHelper.buildResponse(iAlertCalledService.queryAlertCalledById(id)); return ResponseHelper.buildResponse(iAlertCalledService.queryAlertCalledById(id));
} }
/**
* app-根据id查询警情力量统计
**/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "alertCalled/statistics/{alertId}")
@ApiOperation(httpMethod = "GET", value = "app-根据id查询警情力量统计", notes = "app-根据id查询警情力量统计")
public ResponseModel<Object> statisticsByAlertCalledId(@PathVariable Long alertId) {
return ResponseHelper.buildResponse(powerTransferService.getPowerTransferCarResourceStatistics(alertId));
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto;
import com.yeejoin.amos.boot.module.common.api.dto.FireBrigadeResourceDto; import com.yeejoin.amos.boot.module.common.api.dto.FireBrigadeResourceDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyShiftServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto; import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCarCountDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCarCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
...@@ -39,6 +42,7 @@ import org.springframework.stereotype.Service; ...@@ -39,6 +42,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -93,6 +97,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -93,6 +97,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
@Value("${mqtt.topic.command.power.deployment}") @Value("${mqtt.topic.command.power.deployment}")
private String topic; private String topic;
@Autowired
private DutyShiftServiceImpl dutyShiftServiceImpl;
@Override @Override
public PowerTransferSimpleDto getPowerTransferList(Long alertCalledId) { public PowerTransferSimpleDto getPowerTransferList(Long alertCalledId) {
List<PowerTransferCompanyResourcesDto> powerTransferList = List<PowerTransferCompanyResourcesDto> powerTransferList =
...@@ -411,15 +418,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -411,15 +418,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
private IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page, private IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page,
Long alertCalledId) { Long alertCalledId) {
ResponseModel<Object> result = equipFeignClient.getFireCarListAll(); Map<String, List<Map<String, Object>>> carInfoMap = getCarListMap();
Map<String, List<Map<String, Object>>> carInfoMap = Maps.newConcurrentMap();
if (!ValidationUtil.isEmpty(result)) {
List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
if (!ValidationUtil.isEmpty(fireCarListMapList)) {
carInfoMap =
fireCarListMapList.stream().collect(Collectors.groupingBy(car -> car.get("id").toString()));
}
}
IPage<PowerTransferResourceDto> carResourcePage = powerTransferMapper.getPowerTransferCarResource(page, alertCalledId); IPage<PowerTransferResourceDto> carResourcePage = powerTransferMapper.getPowerTransferCarResource(page, alertCalledId);
Map<String, List<Map<String, Object>>> finalCarInfoMap = carInfoMap; Map<String, List<Map<String, Object>>> finalCarInfoMap = carInfoMap;
...@@ -434,4 +433,82 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -434,4 +433,82 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
}); });
return carResourcePage; return carResourcePage;
} }
private Map<String, List<Map<String, Object>>> getCarListMap() {
ResponseModel<Object> result = equipFeignClient.getFireCarListAll();
Map<String, List<Map<String, Object>>> carInfoMap = Maps.newConcurrentMap();
if (!ValidationUtil.isEmpty(result)) {
List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
if (!ValidationUtil.isEmpty(fireCarListMapList)) {
carInfoMap =
fireCarListMapList.stream().collect(Collectors.groupingBy(car -> car.get("id").toString()));
}
}
return carInfoMap;
}
private List<Map<String, Object>> getCarList() {
ResponseModel<Object> result = equipFeignClient.getFireCarListAll();
List<Map<String, Object>> fireCarListMapList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(result)) {
fireCarListMapList = (List<Map<String, Object>>) result.getResult();
}
return fireCarListMapList;
}
@Override
public JSONObject getPowerTransferCarResourceStatistics(Long alertCalledId) {
// 所有车辆
List<Map<String, Object>> carList = getCarList();
IPage<PowerTransferResourceDto> carResourcePage =
powerTransferMapper.getPowerTransferCarResource(new Page<>(1L, Long.MAX_VALUE),
alertCalledId);
// 调派的车辆id
List<Long> carIdList = Lists.transform(carResourcePage.getRecords(), PowerTransferResourceDto::getSequenceNbr);
// 调派的车辆信息列表
List<Map<String, Object>> totalCarList =
carList.stream().filter(c -> carIdList.contains(c.get("id"))).collect(Collectors.toList());
// TODO 车辆枚举后期修改为已到达状态
List<Map<String, Object>> arrivedCarList =
carList.stream().filter(c -> carIdList.contains(c.get("id")) && FireCarStatusEnum.出动.getCode().equals(c.get(
"carState"))).collect(Collectors.toList());
// 车辆统计
Long carTotal = carResourcePage.getTotal();
JSONObject resourceStatistics = new JSONObject();
JSONObject car = new JSONObject();
car.put("total", carTotal);
car.put("count", arrivedCarList.size());
car.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("car", car);
// 车辆人员统计
// 当前时间所在班次
List<DutyShiftDto> dutyList = dutyShiftServiceImpl.queryForDutyShiftList(RequestContext.getAppKey(), false);
// 车辆值班
JSONObject person = new JSONObject();
person.put("total", carTotal);
person.put("count", arrivedCarList.size());
person.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("person", person);
// TODO 车载器材统计
JSONObject equip = new JSONObject();
equip.put("total", carTotal);
equip.put("count", arrivedCarList.size());
equip.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("equip", equip);
// TODO 车载水量统计
JSONObject water = new JSONObject();
water.put("total", carTotal);
water.put("count", arrivedCarList.size());
water.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("water", water);
// TODO 车载药剂统计
JSONObject medicament = new JSONObject();
medicament.put("total", carTotal);
medicament.put("count", arrivedCarList.size());
medicament.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("medicament", medicament);
return resourceStatistics;
}
} }
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