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

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

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