Commit 408734f5 authored by KeYong's avatar KeYong

修改消防器材接口排序问题

parent 76cf9c14
......@@ -243,6 +243,19 @@ public class DataDictionaryController extends BaseController {
}
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionaryIdFillMenuHasSort", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典,id为SequenceNbr", notes = "根据字典类型查询字典,id为SequenceNbr")
public ResponseModel<Object> getDictionaryWithTreeFillIdHasSort(@RequestParam String type) throws Exception {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getSortTree(null, list, DataDictionary.class.getName(), "getSequenceNbr", 2, "getName",
"getParent", "getSortNum", null,"getCode");
return ResponseHelper.buildResponse(menus);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionary", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典2", notes = "根据字典类型查询字典2")
......
......@@ -17,13 +17,21 @@ public class Menu {
public Boolean isRoot;
public List<Menu> children;
public String treeCode;
public int num;
public Integer sortNum;
public int num;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public Menu(Long id, String name, Long parentId2,int num) {
super();
this.id = id;
......@@ -31,6 +39,16 @@ public class Menu {
this.parentId = parentId2;
this.num = num;
}
public Menu(Long id, String name, Long parentId2,int num, Integer sortNum) {
super();
this.id = id;
this.name = name;
this.parentId = parentId2;
this.num = num;
this.sortNum = sortNum;
}
public Menu(Long id, String name, Long parentId2,int num,String treeCode) {
super();
this.id = id;
......@@ -39,6 +57,16 @@ public class Menu {
this.num = num;
this.treeCode = treeCode;
}
public Menu(Long id, String name, Long parentId2,int num,String treeCode, Integer sortNum) {
super();
this.id = id;
this.name = name;
this.parentId = parentId2;
this.num = num;
this.treeCode = treeCode;
this.sortNum = sortNum;
}
public Menu(Long id, String name, Long parentId, List<Menu> children,int num) {
super();
this.id = id;
......@@ -56,7 +84,6 @@ public class Menu {
this.children = children;
this.num = num;
}
public Long getId() {
return id;
}
......
......@@ -104,6 +104,75 @@ public class TreeParser {
return resultList;
}
@SuppressWarnings("unchecked")
public static List<Menu> getSortTree(Long topId, @SuppressWarnings("rawtypes") Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, String SORTMethodName, List<FirefightersTreeDto> list, String treeCode) throws Exception {
List<Menu> resultList = new ArrayList<>();
@SuppressWarnings("rawtypes")
Class clazz = Class.forName(packageURL);
Method IDMethodNameme = null;
switch (IDHierarchy) {
case 1:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
case 2:
IDMethodNameme = clazz.getSuperclass().getDeclaredMethod(IDMethodName);
break;
case 3:
IDMethodNameme = clazz.getSuperclass().getSuperclass().getDeclaredMethod(IDMethodName);
break;
default:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
}
Method NAMEMethodNameme = clazz.getDeclaredMethod(NAMEMethodName);
Method SORTMethodNamee = clazz.getDeclaredMethod(SORTMethodName);
Method PARENTIDMethodNameme = clazz.getDeclaredMethod(PARENTIDMethodName);
Method treeCodeName =null;
if(treeCode!=null){
treeCodeName = clazz.getDeclaredMethod(treeCode);
}
//获取顶层元素集合
Long parentId;
for (Object ob : entityList) {
Object entity = clazz.cast(ob);
parentId = PARENTIDMethodNameme.invoke(entity) != null ? Long.valueOf(String.valueOf(PARENTIDMethodNameme.invoke(entity))) : null;
if (parentId == null || parentId.equals(topId) ) {//陈浩2021-12-01修改 topId == parentId 的判断
String codeString = String.valueOf(IDMethodNameme.invoke(entity));
Integer num = 0;
if (list != null && list.size() > 0) {
for (FirefightersTreeDto map : list) {
if (null != map.getJobTitleCode() && map.getJobTitleCode().equals(codeString)) {
num = Integer.valueOf((String) map.getNum());
break;
}
}
;
}
Menu menu = null;
if(treeCodeName!=null){
String treeCodeNamedat = String.valueOf(treeCodeName.invoke(entity));
menu = new Menu(Long.valueOf(codeString), String.valueOf(NAMEMethodNameme.invoke(entity)), parentId, num,treeCodeNamedat, Integer.valueOf(String.valueOf(SORTMethodNamee.invoke(entity))));
}else{
menu = new Menu(Long.valueOf(codeString), String.valueOf(NAMEMethodNameme.invoke(entity)), parentId, num, Integer.valueOf(String.valueOf(SORTMethodNamee.invoke(entity))));
}
resultList.add(menu);
}
}
//获取每个顶层元素的子数据集合
for (Menu entity : resultList) {
entity.setChildren(getSub(entity.getId(), entityList, packageURL, IDMethodName, IDHierarchy, NAMEMethodName, PARENTIDMethodName, list,treeCode));
}
return resultList;
}
public static List<Menu> getTreeTeam(Long topId, @SuppressWarnings("rawtypes") Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, List<FirefightersTreeDto> list,String treeCode) throws Exception {
List<Menu> resultList = new ArrayList<>();
@SuppressWarnings("rawtypes")
......
......@@ -20,6 +20,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -84,7 +85,7 @@ public class FireResourceSupervisionController extends BaseController {
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtils.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
}
List<Map<String, Object>> fireEquipStats = iFireResourceSupervisionService.getFireEquipStatistic(type, bizOrgCode);
List<LinkedHashMap<String, Object>> fireEquipStats = iFireResourceSupervisionService.getFireEquipStatistic(type, bizOrgCode);
return ResponseHelper.buildResponse(fireEquipStats);
}
}
......@@ -206,7 +206,7 @@ public interface JcsFeign {
@GetMapping(value = "/org-usr/getCompany")
FeignClientResult getCompany( @RequestParam(value = "bizOrgCode") String bizOrgCode);
@GetMapping(value = "/data-dictionary/dataDictionaryIdFillMenu")
@GetMapping(value = "/data-dictionary/dataDictionaryIdFillMenuHasSort")
FeignClientResult<List<DataDictionary>> dataDictionaryIdFillMenu(@RequestParam(value = "type") String type);
@GetMapping(value = "/data-dictionary/getDictListByType")
......
......@@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -743,7 +744,9 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Page<Map<String, Object>> getEquipmentRunLogBySysInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode,
@Param("fireEquipmentName") String fireEquipmentName, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<Map<String, Object>> getFireEquipStatistic(@Param("collect") List<String> collect, @Param("bizOrgCode")String bizOrgCode);
List<LinkedHashMap<String, Object>> getFireEquipStatistic(@Param("collect") List<String> collect, @Param("bizOrgCode")String bizOrgCode);
List<LinkedHashMap<String, Object>> getOtherFireEquipStatistic(@Param("collect") List<String> collect, @Param("bizOrgCode")String bizOrgCode);
List<EquipCountBySystemVO> getFireEquipConfigInfo(@Param("codes") List<String> codes, @Param("bizOrgCode")String bizOrgCode);
}
......
......@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.entity.dto.FireResourceStatsDTO;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -29,5 +30,5 @@ public interface IFireResourceSupervisionService {
FireResourceStatsDTO getFireEquipStats(String bizOrgCode);
List<Map<String, Object>> getFireEquipStatistic(String type, String bizOrgCode);
List<LinkedHashMap<String, Object>> getFireEquipStatistic(String type, String bizOrgCode);
}
......@@ -7,6 +7,7 @@ import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IFireResourceSupervisionService;
import liquibase.pro.packaged.X;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,10 +16,7 @@ import org.springframework.util.StringUtils;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@Service
......@@ -75,16 +73,35 @@ public class IFireResourceSupervisionServiceImpl implements IFireResourceSupervi
}
@Override
public List<Map<String, Object>> getFireEquipStatistic(String type, String bizOrgCode) {
public List<LinkedHashMap<String, Object>> getFireEquipStatistic(String type, String bizOrgCode) {
List<DataDictionary> dictionaryList = jcsFeignClient.dataDictionaryIdFillMenu(StringUtil.isNotEmpty(type) ? type : "ZYGL_XFQC").getResult();
List<String> list = new ArrayList<>();
Map<Integer, String> sortMap = new TreeMap<>(new Comparator<Integer>(){
@Override
public int compare(Integer o1, Integer o2) {
return o1-o2; //按照key顺序排列,o2-o1是逆序, o1-o2是正序
}
});
if (!CollectionUtils.isEmpty(dictionaryList)) {
dictionaryList.forEach(x -> {
list.add(x.getTreeCode());
sortMap.put(x.getSortNum(), x.getTreeCode());
});
}
List<Map<String, Object>> resultMap = fireFightingSystemMapper.getFireEquipStatistic(list, bizOrgCode);
return resultMap;
List<LinkedHashMap<String, Object>> resultMap = fireFightingSystemMapper.getFireEquipStatistic(list, bizOrgCode);
List<LinkedHashMap<String, Object>> resp = new ArrayList<>();
if (!sortMap.isEmpty()) {
sortMap.entrySet().forEach(x -> {
resultMap.forEach(y -> {
if (x.getValue().equalsIgnoreCase(String.valueOf(y.get("code")))) {
resp.add(y);
}
});
});
}
List<LinkedHashMap<String, Object>> otherMapData = fireFightingSystemMapper.getOtherFireEquipStatistic(list, bizOrgCode);
resp.addAll(otherMapData);
return resp;
}
private FireResourceStatsDTO buildFireResourceStatsDTO(Map<String, Object> resultMap) {
......
......@@ -6781,7 +6781,7 @@
ORDER BY d.create_date desc
</select>
<select id="getFireEquipStatistic" resultType="Map">
<select id="getFireEquipStatistic" resultType="java.util.LinkedHashMap">
SELECT
a.`name` AS `name`,
wes.equipment_code AS `code`,
......@@ -6815,8 +6815,10 @@
AND wes.biz_org_code like concat (#{bizOrgCode},'%')
</if>
GROUP BY
wes.equipment_code
UNION ALL
wes.equipment_code
</select>
<select id="getOtherFireEquipStatistic" resultType="java.util.LinkedHashMap">
SELECT
'其他' AS `name`,
'' AS `code`,
......@@ -6845,10 +6847,10 @@
</where>
) a ON a.`code` = wes.equipment_code
WHERE
a.`name` IS NOT NULL AND wes.system_id IS NOT NULL
a.`name` IS NOT NULL AND wes.system_id IS NOT NULL
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wes.biz_org_code like concat (#{bizOrgCode},'%')
</if>
AND wes.biz_org_code like concat (#{bizOrgCode},'%')
</if>
</select>
<select id="getFireEquipConfigInfo" resultMap="EquipCountBySystemId">
......
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