Commit 1bf2a96d authored by 李秀明's avatar 李秀明

统一消防资源-消防器材设备统计逻辑

parent 4fc4df38
......@@ -130,8 +130,15 @@ public class FireFightingSystemController extends AbstractBaseController {
@RequestMapping(value = "/getEquipcountBySystemId", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("根据系统id查询分组设备数量")
public List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId) {
return fireFightingSystemService.getEquipCountBySystemId(systemId);
public List<EquipCountBySystemVO> getEquipCountBySystemId(
@RequestParam(value = "systemId", required = false) Long systemId,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode
) {
if (org.apache.commons.lang3.StringUtils.isBlank(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && org.apache.commons.lang3.StringUtils.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
}
return fireFightingSystemService.getEquipCountBySystemId(systemId, bizOrgCode);
}
@RequestMapping(value = "/getEquipCountPageBySystemId", method = RequestMethod.GET)
......@@ -947,8 +954,14 @@ public class FireFightingSystemController extends AbstractBaseController {
@ApiOperation(value = "按照组态格式获取设备详情", notes = "按照组态格式获取设备详情")
@GetMapping(value = "/getSystemById")
public Map<String, Object> getSystemById(Long id) {
String bizOrgCode = "";
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
}
FireFightingSystemEntity fireFightingSystem = fireFightingSystemService.getById(id);
List<AlarmDataVO> list1 = fireFightingSystemService.getSystemById(id);
List<AlarmDataVO> list1 = fireFightingSystemService.getSystemById(id, bizOrgCode);
Map<String, Object> res = new LinkedHashMap<>();
Boolean status = Boolean.TRUE;
List<Object> ite = new ArrayList<>();
......
......@@ -30,6 +30,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
int getEquipmentSpeCount(Map<String, Object> map);
List<Map<String, Object>> getEquipmentCount(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Long>> getEquipmentCountBySystemId(@Param("bizOrgCode") String bizOrgCode, @Param("systemIds") List<Long> systemIds);
IPage<ComplementCodeVO> selectEquipmentSpecific(Page page, EquipmentSpecificDTO equipmentSpecificDTO);
......
......@@ -51,7 +51,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @param systemId
* @return
*/
List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId);
List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId, String bizOrgCode);
Page<EquipCountBySystemVO> getEquipCountPageBySystemId(@Param("page") Page<Object> page, @Param("systemId") Long systemId, @Param("bizOrgCode") String bizOrgCode);
......
......@@ -57,7 +57,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
* @param systemId
* @return
*/
List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId);
List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId, String bizOrgCode);
/**
* 根据系统id查询分组设备数量
......@@ -128,7 +128,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
* @param id
* @return
*/
List<AlarmDataVO> getSystemById(Long id);
List<AlarmDataVO> getSystemById(Long id, String bizOrgCode);
IPage<EquipmentAlarmBySystemIdOrSourceIdVO> getEquipmentAlarmBySystemIdOrSourceIdVO(IPage<EquipmentAlarmBySystemIdOrSourceIdVO> page,Long sourceId,Long systemId,Integer confirmType,String createDate,String type, String equipmentId);
......
......@@ -256,11 +256,13 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
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()));
long count = Long.parseLong(map.getOrDefault("count", "0").toString()) + Long.parseLong(objectMap.getOrDefault("count", 0).toString());
objectMap.put("count", count);
}
equipmentCountMap.put(uniqueKey, map);
}
}
List<Map<String, Long>> systemEquipCountMaps = equipmentSpecificMapper.getEquipmentCountBySystemId(bizOrgCode, systemIds);
// 构建分组对象
JSONArray groups = new JSONArray();
......@@ -309,6 +311,11 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
}
}
system.put("equipments", equipments);
systemEquipCountMaps.forEach(map -> {
if (String.valueOf(map.get("systemId")).equals(systemId.toString())) {
system.put("equipmentCount", map.getOrDefault("count", 0L));
}
});
systems.add(system);
}
groups.add(group);
......
......@@ -196,8 +196,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
private StockDetailMapper stockDetailMapper;
@Override
public List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId) {
return this.baseMapper.getEquipCountBySystemId(systemId);
public List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId, String bizOrgCode) {
return this.baseMapper.getEquipCountBySystemId(systemId, bizOrgCode);
}
@Override
......@@ -1221,13 +1221,15 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
@Override
public List<AlarmDataVO> getSystemById(Long id) {
public List<AlarmDataVO> getSystemById(Long id, String bizOrgCode) {
List<AlarmDataVO> list = this.baseMapper.getSystemById(id);
// 部件总数
Integer equipmentCount = equipmentSpecificMapper.selectCount(
Wrappers.<EquipmentSpecific>lambdaQuery()
.eq(EquipmentSpecific::getSystemId, id)
.isNotNull(EquipmentSpecific::getEquipmentCode)
.eq(EquipmentSpecific::getSingle, true)
.likeRight(StringUtils.hasText(bizOrgCode), EquipmentSpecific::getBizOrgCode, bizOrgCode)
);
// 未复归设备
List<EquipmentSpecificAlarm> equipSpecIds = equipmentSpecificAlarmMapper.selectList(
......@@ -1235,6 +1237,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
.select(EquipmentSpecificAlarm::getEquipmentSpecificId)
.like(EquipmentSpecificAlarm::getSystemIds, id)
.eq(EquipmentSpecificAlarm::getStatus, "1")
.likeRight(StringUtils.hasText(bizOrgCode), EquipmentSpecificAlarm::getBizOrgCode, bizOrgCode)
);
int count = (int) equipSpecIds.stream().map(EquipmentSpecificAlarm::getEquipmentSpecificId).distinct().count();
list.add(new AlarmDataVO("部件总数", equipmentCount + " 个", false));
......
......@@ -118,17 +118,37 @@
u.name AS unit
FROM
wl_equipment_specific wesp
LEFT JOIN wl_equipment_detail wsd ON wesp.equipment_detail_id = wsd.id
LEFT JOIN wl_equipment we ON wsd.equipment_id = we.id
LEFT JOIN wl_equipment we ON we.code = wesp.equipment_code
LEFT JOIN wl_unit u on u.id = we.unit_id
<where>
we.id IS NOT NULL AND wesp.system_id IS NOT NULL
we.id IS NOT NULL AND wesp.system_id IS NOT NULL AND wesp.single = true
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wesp.biz_org_code like concat(#{bizOrgCode},'%')
</if>
</where>
GROUP BY
we.code, wesp.system_id
GROUP BY we.code
</select>
<select id="getEquipmentCountBySystemId" resultType="Map">
SELECT
wesp.system_id AS systemId,
count(1) AS count
FROM
wl_equipment_specific wesp
LEFT JOIN wl_equipment we ON we.code = wesp.equipment_code
<where>
we.id IS NOT NULL AND wesp.system_id IS NOT NULL AND wesp.single = true
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wesp.biz_org_code like concat(#{bizOrgCode},'%')
</if>
<if test="systemIds != null and systemIds.size() > 0">
AND (
<foreach collection="systemIds" item="systemId" separator="OR">
find_in_set(wesp.system_id, #{systemId})
</foreach>
)
</if>
</where>
GROUP BY wesp.system_id
</select>
<select id="selectEquipmentSpecific" resultMap="ComplementCode">
SELECT
......
......@@ -104,13 +104,17 @@
cate.NAME AS equipmentCateGoryName
FROM
wl_equipment_specific AS spe
LEFT JOIN wl_equipment_detail AS det ON spe.equipment_detail_id = det.id
LEFT JOIN wl_equipment AS wle ON wle.id = det.equipment_id
LEFT JOIN wl_equipment AS wle ON wle.code = spe.equipment_code
LEFT JOIN wl_equipment_category cate ON cate.id = wle.category_id
LEFT JOIN wl_unit as unit ON wle.unit_id = unit.id
where
find_in_set(#{systemId},spe.system_id) and spe.single = true
group by wle.id
<where>
wle.id is not null
and find_in_set(#{systemId},spe.system_id) and spe.single = true
<if test="bizOrgCode != null and bizOrgCode != ''">
AND spe.biz_org_code like concat (#{bizOrgCode},'%')
</if>
</where>
group by wle.code
</select>
<select id="getEquipCountPageBySystemId" resultMap="EquipCountBySystemId">
SELECT
......@@ -128,14 +132,15 @@
LEFT JOIN wl_equipment_category cate ON cate.id = wle.category_id
LEFT JOIN wl_unit as unit ON wle.unit_id = unit.id
<where>
wle.id is not null and spe.single = true and spe.system_id is not null
<if test="systemId != null and systemId != ''">
find_in_set(#{systemId},spe.system_id) and spe.single = true
AND find_in_set(#{systemId},spe.system_id)
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND spe.biz_org_code like concat (#{bizOrgCode},'%')
</if>
</where>
wle.`code`
group by wle.code
</select>
<insert id="save">
INSERT INTO
......
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