Commit 1e591417 authored by taabe's avatar taabe

消防队伍树、列表接口修改

parent c7ac7e12
...@@ -6,6 +6,7 @@ import java.lang.reflect.Method; ...@@ -6,6 +6,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random;
/** /**
* 生成树工具类 * 生成树工具类
...@@ -328,5 +329,15 @@ public class TreeParser { ...@@ -328,5 +329,15 @@ public class TreeParser {
return childList; return childList;
} }
public static String genTreeCode() {
int length = 6;
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(62);
sb.append(str.charAt(number));
}
return sb.toString();
}
} }
...@@ -38,4 +38,7 @@ public class FireTeamCardDto { ...@@ -38,4 +38,7 @@ public class FireTeamCardDto {
private Integer dispatchNum; private Integer dispatchNum;
@ApiModelProperty(value = "执勤数量") @ApiModelProperty(value = "执勤数量")
private Integer onDutyNum; private Integer onDutyNum;
@ApiModelProperty(value = "树结构层级code")
private String treeCode;
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* *
* @author DELL * @author DELL
...@@ -27,4 +29,7 @@ public class FireTeamListDto { ...@@ -27,4 +29,7 @@ public class FireTeamListDto {
@ApiModelProperty(value = "树节点id") @ApiModelProperty(value = "树节点id")
private Long nodeId; private Long nodeId;
@ApiModelProperty(value = "树节点子节点id集合")
private List<String> nodeIds;
} }
...@@ -80,4 +80,6 @@ public class FireTeam extends BaseEntity { ...@@ -80,4 +80,6 @@ public class FireTeam extends BaseEntity {
@TableField(fill=FieldFill.INSERT_UPDATE) @TableField(fill=FieldFill.INSERT_UPDATE)
private String recUserName; private String recUserName;
@ApiModelProperty(value = "树结构层级code")
private String treeCode;
} }
...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto; ...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto;
import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto; import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto; import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -58,8 +59,16 @@ public interface FireTeamMapper extends BaseMapper<FireTeam> { ...@@ -58,8 +59,16 @@ public interface FireTeamMapper extends BaseMapper<FireTeam> {
/** /**
* 根据队伍id查询队伍下人员列表 * 根据队伍id查询队伍下人员列表
* *
* @param teamIds
* @return
*/
List<FirefightersDto> queryFighterByTeamId(@Param("teamIds") List<String> teamIds);
/**
* 根据当前队伍id查询该队伍下所有子队伍
*
* @param teamId * @param teamId
* @return * @return
*/ */
List<FirefightersDto> queryFighterByTeamId(Long teamId); List<FireTeam> listFireTeamById(Long teamId);
} }
...@@ -30,4 +30,12 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -30,4 +30,12 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode); List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode);
List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete); List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete);
/**
* 根据id查询当前单位下的所有子单位、部门
*
* @param orgUserId
* @return
*/
List<OrgUsr> listOrgUserById(Long orgUserId);
} }
...@@ -13,6 +13,19 @@ ...@@ -13,6 +13,19 @@
and ft.type_code = 118 and ft.type_code = 118
GROUP BY ft.sequence_nbr GROUP BY ft.sequence_nbr
</select> </select>
<select id="queryFighterByTeamId" resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto">
select *
from cb_firefighters
where is_delete = 0
and fire_team_id in
<if test="teamIds != null">
<foreach collection="teamIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</select>
<select id="getFireTeamForPage" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto"> <select id="getFireTeamForPage" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto">
SELECT SELECT
a.sequence_nbr sequenceNbr, a.sequence_nbr sequenceNbr,
...@@ -30,21 +43,32 @@ ...@@ -30,21 +43,32 @@
<if test='par.typeCode != null'>and a.type_code = #{par.typeCode}</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.companyCode != null'>and a.company_code = #{par.companyCode}</if>
<if test='par.name != null'>and a.name like concat('%', #{par.name}, '%')</if> <if test='par.name != null'>and a.name like concat('%', #{par.name}, '%')</if>
<if test='par.nodeType != null and par.nodeType == "1"'>and a.company = #{par.nodeId}</if> <if test='par.nodeType != null and par.nodeType == "1" and par.nodeIds != null and par.nodeIds.size() > 0'>
<if test='par.nodeType != null and par.nodeType == "0"'>and a.parent = #{par.nodeId} or a.sequence_nbr = and a.company in
#{par.nodeId}</if> <foreach collection="par.nodeIds" separator="," open="(" item="nodeId" close=")">
#{nodeId}
</foreach>
</if>
<if test='par.nodeType != null and par.nodeType == "0" and par.nodeIds != null and par.nodeIds.size() > 0'>
and a.parent in
<foreach collection="par.nodeIds" separator="," open="(" item="nodeId" close=")">
#{nodeId}
</foreach>
or a.sequence_nbr = #{par.nodeId}
</if>
</select> </select>
<select id="listFireTeamDto" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto"> <select id="listFireTeamDto" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto">
select t.*, p.name parentName select t.*, p.name parentName
from cb_fire_team t from cb_fire_team t
left join cb_fire_team p on t.parent = p.sequence_nbr left join cb_fire_team p on t.parent = p.sequence_nbr
where t.is_delete = #{isDelete} where t.is_delete = #{isDelete}
</select> </select>
<select id="queryFighterByTeamId" resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto"> <select id="listFireTeamById" resultType="com.yeejoin.amos.boot.module.common.api.entity.FireTeam">
select * SELECT *
from cb_firefighters FROM cb_fire_team
where is_delete = 0 WHERE is_delete = 0
and fire_team_id = #{teamId} <if test="teamId != null">
AND tree_code LIKE CONCAT((SELECT tree_code FROM cb_fire_team WHERE sequence_nbr = #{teamId}),'%');
</if>
</select> </select>
</mapper> </mapper>
...@@ -201,4 +201,12 @@ ...@@ -201,4 +201,12 @@
on u.sequence_nbr = v.instance_id on u.sequence_nbr = v.instance_id
where u.is_delete = #{isDelete} where u.is_delete = #{isDelete}
</select> </select>
<select id="listOrgUserById" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT *
FROM cb_org_usr
WHERE is_delete = 0
<if test="orgUserId != null">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{orgUserId}),'%');
</if>
</select>
</mapper> </mapper>
...@@ -845,4 +845,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -845,4 +845,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return excelOrgPersonDtoList; return excelOrgPersonDtoList;
} }
/**
* 根据id查询当前单位下的所有子单位、部门
*
* @param orgUserId
* @return
*/
public List<OrgUsr> listOrgUserById(Long orgUserId) {
return this.baseMapper.listOrgUserById(orgUserId);
}
} }
...@@ -8,9 +8,11 @@ import java.util.Map; ...@@ -8,9 +8,11 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto; import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; 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.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -62,8 +65,7 @@ public class FireTeamController extends BaseController { ...@@ -62,8 +65,7 @@ public class FireTeamController extends BaseController {
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍") @ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍")
public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) { public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) {
iFireTeamService.save(fireTeam); return ResponseHelper.buildResponse(iFireTeamService.saveFireTeam(fireTeam));
return ResponseHelper.buildResponse(null);
} }
/** /**
...@@ -89,8 +91,7 @@ public class FireTeamController extends BaseController { ...@@ -89,8 +91,7 @@ public class FireTeamController extends BaseController {
@RequestMapping(value = "/updateById", method = RequestMethod.PUT) @RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改消防队伍", notes = "修改消防队伍") @ApiOperation(httpMethod = "PUT", value = "修改消防队伍", notes = "修改消防队伍")
public ResponseModel<Object> updateByIdFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) { public ResponseModel<Object> updateByIdFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) {
iFireTeamService.updateById(fireTeam); return ResponseHelper.buildResponse(iFireTeamService.saveFireTeam(fireTeam));
return ResponseHelper.buildResponse(null);
} }
/** /**
...@@ -228,10 +229,14 @@ public class FireTeamController extends BaseController { ...@@ -228,10 +229,14 @@ public class FireTeamController extends BaseController {
* @throws Exception * @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{teamId}/fighter", method = RequestMethod.GET) @RequestMapping(value = "/fighter", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查询消防队伍下的人员", notes = "查询消防队伍下的人员") @ApiOperation(httpMethod = "GET", value = "查询消防队伍下的人员", notes = "查询消防队伍下的人员")
public ResponseModel<List<FirefightersDto>> listFighterByTeamId(@PathVariable("teamId") Long teamId) { public ResponseModel<List<FirefightersDto>> listFighterByTeamId(@RequestParam("teamIds") String teamIds) {
List<FirefightersDto> fighters = iFireTeamService.getFighterByTeamId(teamId); List<String> teamIdList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(teamIds)) {
teamIdList = Lists.newArrayList(teamIds.split(","));
}
List<FirefightersDto> fighters = iFireTeamService.getFighterByTeamId(teamIdList);
return ResponseHelper.buildResponse(fighters); return ResponseHelper.buildResponse(fighters);
} }
} }
\ No newline at end of file
...@@ -25,9 +25,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -25,9 +25,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -76,6 +78,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -76,6 +78,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
"teamId"), Collectors.counting())); "teamId"), Collectors.counting()));
} }
} }
// 查询单位
if (Objects.equals("1", team.getNodeType())) {
List<OrgUsr> companyDeptList = orgUsrService.listOrgUserById(team.getNodeId());
team.setNodeIds(companyDeptList.stream().map(e -> e.getSequenceNbr().toString()).collect(Collectors.toList()));
}
// 查询队伍
if (Objects.equals("0", team.getNodeType())) {
List<FireTeam> teamList = listFireTeamById(team.getNodeId());
team.setNodeIds(teamList.stream().map(e -> e.getSequenceNbr().toString()).collect(Collectors.toList()));
}
IPage<FireTeamCardDto> fireTeamListPage = this.baseMapper.getFireTeamForPage(page, team); IPage<FireTeamCardDto> fireTeamListPage = this.baseMapper.getFireTeamForPage(page, team);
List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords(); List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords();
Map<Object, Long> finalTeamCarCountMap = teamCarCountMap; Map<Object, Long> finalTeamCarCountMap = teamCarCountMap;
...@@ -84,14 +98,14 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -84,14 +98,14 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue()); t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue());
} }
}); });
// 如果队伍下没有队伍则将自己加入返回列表
if ("0".equals(team.getNodeType()) && !ValidationUtil.isEmpty(fireTeamList) && fireTeamList.size() > 1) {
fireTeamList = fireTeamList.stream().filter(t -> t.getSequenceNbr().equals(team.getNodeId())).collect(Collectors.toList());
}
fireTeamListPage.setRecords(fireTeamList); fireTeamListPage.setRecords(fireTeamList);
return fireTeamListPage; return fireTeamListPage;
} }
public List<FireTeam> listFireTeamById(Long teamId) {
return this.baseMapper.listFireTeamById(teamId);
}
public List<FireTeamDto> queryFireTeamForList(Boolean isDelete) { public List<FireTeamDto> queryFireTeamForList(Boolean isDelete) {
return fireTeamMapper.listFireTeamDto(isDelete); return fireTeamMapper.listFireTeamDto(isDelete);
} }
...@@ -135,7 +149,7 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -135,7 +149,7 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
team.setParent(team.getCompany()); team.setParent(team.getCompany());
} }
teamMenuList.add(new MenuFrom(team.getSequenceNbr().toString(), team.getName(), teamMenuList.add(new MenuFrom(team.getSequenceNbr().toString(), team.getName(),
team.getParent().toString(), "1")); team.getParent().toString(), "0"));
}); });
companyDeptMenuList.addAll(teamMenuList); companyDeptMenuList.addAll(teamMenuList);
List<MenuFrom> menuList = TreeParser.getTreexin("-1", companyDeptMenuList, MenuFrom.class.getName(), "getKey", List<MenuFrom> menuList = TreeParser.getTreexin("-1", companyDeptMenuList, MenuFrom.class.getName(), "getKey",
...@@ -147,10 +161,26 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -147,10 +161,26 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
/** /**
* 根据队伍id查询队伍下人员列表 * 根据队伍id查询队伍下人员列表
* *
* @param teamId * @param teamIds
* @return * @return
*/ */
public List<FirefightersDto> getFighterByTeamId(Long teamId) { public List<FirefightersDto> getFighterByTeamId(List<String> teamIds) {
return this.baseMapper.queryFighterByTeamId(teamId); return this.baseMapper.queryFighterByTeamId(teamIds);
}
public FireTeam saveFireTeam(FireTeam fireTeam) {
if (ValidationUtil.isEmpty(fireTeam.getParent())) {
fireTeam.setTreeCode(TreeParser.genTreeCode());
} else {
FireTeam parentTeam = getById(fireTeam.getParent());
fireTeam.setTreeCode(parentTeam.getTreeCode() + TreeParser.genTreeCode());
}
if (ValidationUtil.isEmpty(fireTeam.getSequenceNbr())) {
save(fireTeam);
} else {
updateById(fireTeam);
}
return fireTeam;
} }
} }
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