Commit 8f551dc2 authored by tianbo's avatar tianbo

app-力量调派接口

parent 3e2c833d
......@@ -6,8 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 调派资源dto
*
......
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 调派资源统计dto
*
* @author tb
* @date 2021-08-20
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@ApiModel(value="ResourceStatisticsDto", description="调派资源统计dto")
public class ResourceStatisticsDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "全部")
private Integer allCount = 0;
@ApiModelProperty(value = "到场")
private Integer arrived = 0;
@ApiModelProperty(value = "途中")
private Integer underway = 0;
public ResourceStatisticsDto(String type, Integer allCount) {
this.type = type;
this.allCount = allCount;
this.arrived = 0;
this.underway = 0;
}
}
......@@ -10,6 +10,7 @@ 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;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import org.apache.ibatis.annotations.Param;
......@@ -96,6 +97,15 @@ public interface PowerTransferMapper extends BaseMapper<PowerTransfer> {
@Param("alertCalledId") Long alertCalledId);
/**
* 根据类型查询力量调派统计
*
* @param alertCalledId
* @param type
* @return
*/
List<ResourceStatisticsDto> getPowerTransferTeamResourceCount(Long alertCalledId, String type);
/**
* 根据参数获取警情当前已调派车辆资源列表信息
*
* @param alertCalledId 警情id
......
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
......@@ -43,4 +44,13 @@ public interface IPowerTransferService extends IService<PowerTransfer> {
* @return
*/
IPage<PowerTransferResourceDto> getPowerTransferPageByParam(Long alertCalledId, String type, Page<PowerTransferResourceDto> page);
/**
* 根据参数查询力量调派资源统计信息
*
* @param alertCalledId 警情id
* @param type 查询类型
* @return
*/
List<ResourceStatisticsDto> getPowerTransferStatistics(Long alertCalledId, String type);
}
......@@ -210,6 +210,32 @@
transfer.alert_called_id = #{alertCalledId}
AND is_distribution_agencies = 0
</select>
<select id="getPowerTransferTeamResourceCount"
resultType="com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto">
SELECT
"team" type,
count( DISTINCT company.company_id ) allCount
FROM
jc_power_transfer_company company
LEFT JOIN jc_power_transfer transfer ON transfer.sequence_nbr = company.power_transfer_id
WHERE
transfer.alert_called_id = #{alertCalledId}
AND is_distribution_agencies = 0 UNION ALL
SELECT
"car" type,
count( DISTINCT car.resources_id ) allCount
FROM
jc_power_transfer_company_resources car
LEFT JOIN jc_power_transfer_company company ON company.sequence_nbr = car.power_transfer_company_id
LEFT JOIN jc_power_transfer transfer ON transfer.sequence_nbr = company.power_transfer_id
WHERE
transfer.alert_called_id = #{alertCalledId}
AND is_distribution_agencies = 0
UNION ALL
SELECT
"person" type,
0 allCount
</select>
<select id="getPowerTransferCarResource"
resultType="com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto">
SELECT DISTINCT
......
......@@ -947,7 +947,7 @@ public class CommandController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "app-根据警情id查询力量调派列表", notes = "app-根据警情id查询力量调派列表")
@GetMapping(value = "/app/transferList")
public ResponseModel getPowerTransferList(@RequestParam String alertId,
@RequestParam(defaultValue = "company") String type,
@RequestParam(defaultValue = "team") String type,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page page = new Page();
......@@ -955,4 +955,12 @@ public class CommandController extends BaseController {
page.setCurrent(current);
return ResponseHelper.buildResponse(powerTransferService.getPowerTransferPageByParam(Long.valueOf(alertId), type, page));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "app-根据警情id查询力量调派资源统计", notes = "app-根据警情id查询力量调派资源统计")
@GetMapping(value = "/app/transfer/statistics")
public ResponseModel getPowerTransferStatistics(@RequestParam String alertId,
@RequestParam(defaultValue = "team") String type) {
return ResponseHelper.buildResponse(powerTransferService.getPowerTransferStatistics(Long.valueOf(alertId), type));
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
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.entity.PowerTransfer;
......@@ -372,8 +373,8 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
}
IPage<PowerTransferResourceDto> resultPage = null;
switch (type) {
case "company":
resultPage = powerTransferMapper.getPowerTransferTeamResource(page, alertCalledId);
case "team":
resultPage = getPowerTransferTeamResource(page, alertCalledId);
break;
case "car":
resultPage = getPowerTransferCarResource(page, alertCalledId);
......@@ -388,7 +389,28 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
return resultPage;
}
private IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page, Long alertCalledId) {
@Override
public List<ResourceStatisticsDto> getPowerTransferStatistics(Long alertCalledId, String type) {
List<ResourceStatisticsDto> result;
result = powerTransferMapper.getPowerTransferTeamResourceCount(alertCalledId, type);
if (ValidationUtil.isEmpty(result)) {
ResourceStatisticsDto team = new ResourceStatisticsDto("team", 0, 0, 0);
ResourceStatisticsDto car = new ResourceStatisticsDto("car", 0, 0, 0);
ResourceStatisticsDto person = new ResourceStatisticsDto("person", 0, 0, 0);
result.add(team);
result.add(car);
result.add(person);
}
return result;
}
public IPage<PowerTransferResourceDto> getPowerTransferTeamResource(Page<PowerTransferResourceDto> page,
Long alertCalledId) {
return powerTransferMapper.getPowerTransferTeamResource(page, alertCalledId);
}
private IPage<PowerTransferResourceDto> getPowerTransferCarResource(Page<PowerTransferResourceDto> page,
Long alertCalledId) {
ResponseModel<Object> result = equipFeignClient.getFireCarListAll();
Map<String, List<Map<String, Object>>> carInfoMap = Maps.newConcurrentMap();
if (!ValidationUtil.isEmpty(result)) {
......@@ -405,7 +427,6 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
String seq = car.getSequenceNbr().toString();
car.setName((String) finalCarInfoMap.get(seq).get(0).get("name"));
String carStateCode = (String) finalCarInfoMap.get(seq).get(0).get("carState");
FireCarStatusEnum.getEnum(carStateCode);
car.setCarState(!ValidationUtil.isEmpty(FireCarStatusEnum.getEnum(carStateCode)) ?
FireCarStatusEnum.getEnum(carStateCode).getName() : "");
List<String> images = (List<String>) finalCarInfoMap.get(seq).get(0).get("image");
......
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