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