Commit 47cee41a authored by taabe's avatar taabe

消防队伍人员、车辆数量统计

parent 953ccdff
package com.yeejoin.amos.boot.module.jcs.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 消防队伍卡片列表dto
*
* @author tb
* @date 2021-06-07
*/
@Data
@ApiModel(value = "FireTeamCardDto", description = "消防队伍卡片列表dto")
public class FireTeamCardDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "消防队伍图片")
private String img;
@ApiModelProperty(value = "队伍名称")
private String name;
@ApiModelProperty(value = "队伍类型")
private String type;
@ApiModelProperty(value = "联系人")
private String contactUser;
@ApiModelProperty(value = "联系电话")
private String contactPhone;
@ApiModelProperty(value = "队伍地址")
private String address;
@ApiModelProperty(value = "队伍id")
private Long sequenceNbr;
@ApiModelProperty(value = "队伍车数量")
private Integer carNum = 0;
@ApiModelProperty(value = "队伍人员数量")
private Integer fighterNum = 0;
@ApiModelProperty(value = "出动数量")
private Integer dispatchNum;
@ApiModelProperty(value = "执勤数量")
private Integer onDutyNum;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* @author DELL
*/
@Data
public class FireTeamListDto {
@ApiModelProperty(value = "单位名称")
private String name;
@ApiModelProperty(value = "机构code")
private String companyCode;
@ApiModelProperty(value = "队伍code")
private String typeCode;
@ApiModelProperty(value = "父级id")
private Long parent;
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireBrigadeResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamCardDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamListVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamVo;
......@@ -41,4 +45,13 @@ public interface FireTeamMapper extends BaseMapper<FireTeam> {
* @return
*/
List<FireBrigadeResourceDto> listMonitorFireBrigade();
/**
* 查询消防队伍卡片分页列表
*
* @param page
* @param par
* @return
*/
IPage<FireTeamCardDto> getFireTeamForPage(Page page, FireTeamListDto par);
}
......@@ -16,4 +16,22 @@
GROUP BY
ft.sequence_nbr
</select>
<select id="getFireTeamForPage" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamCardDto">
SELECT
a.sequence_nbr sequenceNbr,
a.img,
a.NAME,
a.contact_user contactUser,
a.contact_phone contactPhone,
a.address,
( SELECT count( 1 ) FROM cb_firefighters WHERE fire_team_id = a.sequence_nbr AND is_delete = 0 ) fighterNum
FROM
cb_fire_team a
WHERE
a.is_delete = 0
<if test='par.parent!=null'>and a.parent = #{par.parent}</if>
<if test='par.typeCode!=null'>and a.type_code = #{par.typeCode}</if>
<if test='par.companyCode!=null'>and a.company_code = #{par.companyCode}</if>
<if test='par.name!=null'>and a.name like concat('%', #{par.name}, '%')</if>
</select>
</mapper>
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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.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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -28,13 +8,33 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamCardDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamListVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamVo;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireTeamServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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.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.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -120,6 +120,25 @@ public class FireTeamController extends BaseController {
return ResponseHelper.buildResponse(pageBean);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/listByPage", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "卡片列表分页查询", notes = "卡片列表分页查询")
public ResponseModel<IPage<FireTeamCardDto>> getFireTeamByPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
FireTeamListDto fireTeamList) {
//条件分页
if (pageNum == null || pageSize == null) {
pageNum = 1;
pageSize = 10;
}
if (pageSize == -1) {
pageSize = Integer.MAX_VALUE;
}
Page<FireTeamCardDto> pageBean = new Page<>(pageNum, pageSize);
IPage<FireTeamCardDto> page = iFireTeamService.listFireTeamByPage(pageBean, fireTeamList);
return ResponseHelper.buildResponse(page);
}
/**
* 列表分页查询
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireBrigadeResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamCardDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.jcs.api.mapper.FireTeamMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireTeamService;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamListVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.FireTeamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 消防队伍 服务实现类
......@@ -25,6 +34,10 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam,FireT
@Autowired
FireTeamMapper fireTeamMapper;
@Autowired
EquipFeignClient equipFeignClient;
@Override
public List<FireTeamVo> getFireTeam(int pageNum, int pageSize, FireTeamListVo par) {
// TODO Auto-generated method stub
......@@ -46,4 +59,28 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam,FireT
public List<FireBrigadeResourceDto> listMonitorFireBrigade() {
return fireTeamMapper.listMonitorFireBrigade();
}
public IPage<FireTeamCardDto> listFireTeamByPage(Page page, FireTeamListDto team) {
// 获取消防车辆列表
ResponseModel<Object> result = equipFeignClient.getFireCarListAll();
Map<Object, Long> teamCarCountMap = Maps.newConcurrentMap();
if (!ValidationUtil.isEmpty(result)) {
List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
if (!ValidationUtil.isEmpty(fireCarListMapList)) {
teamCarCountMap =
fireCarListMapList.stream().filter(car -> !ValidationUtil.isEmpty(car.get("teamId"))).collect(Collectors.groupingBy(car -> car.get(
"teamId"), Collectors.counting()));
}
}
IPage<FireTeamCardDto> fireTeamListPage = this.baseMapper.getFireTeamForPage(page, team);
List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords();
Map<Object, Long> finalTeamCarCountMap = teamCarCountMap;
fireTeamList.forEach(t -> {
if (!ValidationUtil.isEmpty(finalTeamCarCountMap.get(t.getSequenceNbr().toString()))) {
t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue());
}
});
fireTeamListPage.setRecords(fireTeamList);
return fireTeamListPage;
}
}
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