Commit 19470ed7 authored by KeYong's avatar KeYong

Merge branch 'develop_dl' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_dl

parents e6f6c5f7 346bfd7a
...@@ -41,9 +41,9 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -41,9 +41,9 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
private IFireFightingSystemService fireFightingSystemService; private IFireFightingSystemService fireFightingSystemService;
/** /**
* 获取未绑定分组的系统列表 * 获取消防系统列表
* *
* @param bizOrgCode * @param bizOrgCode bizOrgCode
*/ */
@Override @Override
public JSONArray selectUnboundSystems(String bizOrgCode) { public JSONArray selectUnboundSystems(String bizOrgCode) {
...@@ -65,6 +65,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -65,6 +65,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
jsonObject.put("id", system.getId()); jsonObject.put("id", system.getId());
jsonObject.put("name", system.getName()); jsonObject.put("name", system.getName());
if (!systemIds.contains(system.getId())) { if (!systemIds.contains(system.getId())) {
// isBound: 是否已绑定分组
jsonObject.put("isBound", true); jsonObject.put("isBound", true);
} else { } else {
jsonObject.put("isBound", false); jsonObject.put("isBound", false);
...@@ -133,7 +134,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -133,7 +134,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
// 分组信息入库 // 分组信息入库
FireFightingSystemGroupEntity fireFightingSystemGroupEntity = FireFightingSystemGroupEntity.builder() FireFightingSystemGroupEntity fireFightingSystemGroupEntity = FireFightingSystemGroupEntity.builder()
.groupName(fireFightingSystemGroupModalDto.getGroupName()) .groupName(fireFightingSystemGroupModalDto.getGroupName())
.groupCode(System.currentTimeMillis() + "") // TODO .groupCode(new StringBuilder(String.valueOf(System.currentTimeMillis())).reverse().toString())
.displayType(fireFightingSystemGroupModalDto.getDisplayType()) .displayType(fireFightingSystemGroupModalDto.getDisplayType())
.systemIds(String.join(",", sortedSystemIds)) .systemIds(String.join(",", sortedSystemIds))
.remarks("") .remarks("")
...@@ -193,6 +194,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -193,6 +194,7 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
* @return 分组列表 * @return 分组列表
*/ */
@Override @Override
@SuppressWarnings("unchecked")
public JSONArray listGroup(String bizOrgCode) { public JSONArray listGroup(String bizOrgCode) {
List<FireFightingSystemGroupEntity> groupEntities = fireFightingSystemGroupMapper.selectList( List<FireFightingSystemGroupEntity> groupEntities = fireFightingSystemGroupMapper.selectList(
Wrappers.<FireFightingSystemGroupEntity>lambdaQuery() Wrappers.<FireFightingSystemGroupEntity>lambdaQuery()
...@@ -228,12 +230,24 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -228,12 +230,24 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
} }
} }
// List to Map -> key: equipmentId, value: 装备定义数量 // List to Map -> key: systemId@equipmentId, value: 装备定义数量Map
List<Map<String, Object>> equipmentCountList = equipmentSpecificMapper.getEquipmentCount(bizOrgCode); List<Map<String, Object>> equipmentCountList = equipmentSpecificMapper.getEquipmentCount(bizOrgCode);
Map<Long, Map<String, Object>> equipmentCountMap = equipmentCountList.stream().map(map -> new HashMap<Long, Map<String, Object>>() {{ Map<String, Map<String, Object>> equipmentCountMap = new HashMap<>();
put(Long.valueOf(map.get("equipmentId").toString()), map); for (Map<String, Object> map : equipmentCountList) {
}}).collect(Collectors.toMap(map -> map.keySet().iterator().next(), map -> map.values().iterator().next())); String equipmentId = map.getOrDefault("equipmentId", "").toString();
String systemId = map.getOrDefault("systemId", "").toString();
String[] ids = systemId.split(",");
for (String id : ids) {
String uniqueKey = id + "@" + equipmentId;
if (equipmentCountMap.containsKey(uniqueKey)) {
Map<String, Object> objectMap = equipmentCountMap.get(uniqueKey);
objectMap.put("count", Long.parseLong(map.getOrDefault("count", "0").toString()) + Long.parseLong(objectMap.getOrDefault("count", 0).toString()));
}
equipmentCountMap.put(uniqueKey, map);
}
}
// 构建分组对象
JSONArray groups = new JSONArray(); JSONArray groups = new JSONArray();
for (FireFightingSystemGroupEntity groupEntity : groupEntities) { for (FireFightingSystemGroupEntity groupEntity : groupEntities) {
JSONObject group = new JSONObject(); JSONObject group = new JSONObject();
...@@ -263,8 +277,8 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -263,8 +277,8 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
List<Map<String, Object>> equipments = new ArrayList<>(); List<Map<String, Object>> equipments = new ArrayList<>();
for (SystemEquipmentRelationEntity relationEntity : relationEntities) { for (SystemEquipmentRelationEntity relationEntity : relationEntities) {
Long equipmentId = relationEntity.getEquipmentId(); Long equipmentId = relationEntity.getEquipmentId();
if (equipmentCountMap.containsKey(equipmentId)) { if (equipmentCountMap.containsKey(systemId + "@" + equipmentId)) {
Map<String, Object> equipmentMap = equipmentCountMap.get(equipmentId); Map<String, Object> equipmentMap = equipmentCountMap.get(systemId + "@" + equipmentId);
Map<String, Object> equipment = new HashMap<>(); Map<String, Object> equipment = new HashMap<>();
equipment.put("id", equipmentMap.get("equipmentId")); equipment.put("id", equipmentMap.get("equipmentId"));
equipment.put("name", equipmentMap.get("equipmentName")); equipment.put("name", equipmentMap.get("equipmentName"));
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
SELECT SELECT
we.id AS equipmentId, we.id AS equipmentId,
we.name AS equipmentName, we.name AS equipmentName,
wesp.system_id AS systemId,
count(1) AS count, count(1) AS count,
u.name AS unit u.name AS unit
FROM FROM
...@@ -121,13 +122,13 @@ ...@@ -121,13 +122,13 @@
LEFT JOIN wl_equipment we ON wsd.equipment_id = we.id LEFT JOIN wl_equipment we ON wsd.equipment_id = we.id
LEFT JOIN wl_unit u on u.id = we.unit_id LEFT JOIN wl_unit u on u.id = we.unit_id
<where> <where>
we.id IS NOT NULL we.id IS NOT NULL AND wesp.system_id IS NOT NULL
<if test="bizOrgCode != null and bizOrgCode != ''"> <if test="bizOrgCode != null and bizOrgCode != ''">
AND wesp.biz_org_code like concat(#{bizOrgCode},'%') AND wesp.biz_org_code like concat(#{bizOrgCode},'%')
</if> </if>
</where> </where>
GROUP BY GROUP BY
we.code we.code, wesp.system_id
</select> </select>
<select id="selectEquipmentSpecific" resultMap="ComplementCode"> <select id="selectEquipmentSpecific" resultMap="ComplementCode">
SELECT SELECT
......
...@@ -96,10 +96,10 @@ ...@@ -96,10 +96,10 @@
<select id="getEquipCountBySystemId" resultMap="EquipCountBySystemId"> <select id="getEquipCountBySystemId" resultMap="EquipCountBySystemId">
SELECT SELECT
wle.id equipment_id, wle.id equipment_id,
det.NAME equipment_name, wle.NAME equipment_name,
count(spe.id) num, count(spe.id) num,
unit.name unit_name, unit.name unit_name,
wle.img, wle.shbz_img img,
cate.NAME AS equipmentCateGoryName cate.NAME AS equipmentCateGoryName
FROM FROM
wl_equipment_specific AS spe wl_equipment_specific AS spe
...@@ -114,10 +114,10 @@ ...@@ -114,10 +114,10 @@
<select id="getEquipCountPageBySystemId" resultMap="EquipCountBySystemId"> <select id="getEquipCountPageBySystemId" resultMap="EquipCountBySystemId">
SELECT SELECT
wle.id equipment_id, wle.id equipment_id,
det.NAME equipment_name, wle.NAME equipment_name,
count(spe.id) num, count(spe.id) num,
unit.name unit_name, unit.name unit_name,
wle.img, wle.shbz_img img,
cate.NAME AS equipmentCateGoryName cate.NAME AS equipmentCateGoryName
FROM FROM
wl_equipment_specific AS spe wl_equipment_specific AS spe
......
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