Commit de0c8893 authored by 李秀明's avatar 李秀明

feat: 设备告警接口新增参数与逻辑修改

parent 8c08ee7e
......@@ -17,6 +17,8 @@ public class EquipmentAlarmLogDto {
private String time;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "设备位置")
private String location;
@ApiModelProperty(value = "事件内容")
private String content;
......
......@@ -155,8 +155,12 @@ public class BigScreenController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "卡片BigSystem报警处理情况统计")
@GetMapping("/statistic/alarm")
public ResponseModel getSystemAlarmStatistic(@RequestParam(value = "systemCode", required = false)String systemCode) {
return CommonResponseUtil.success(iFireFightingSystemService.getSystemAlarmStatistic(systemCode));
public ResponseModel getSystemAlarmStatistic(
@RequestParam(value = "systemCode", required = false) String systemCode,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate
) {
return CommonResponseUtil.success(iFireFightingSystemService.getSystemAlarmStatistic(systemCode, startDate, endDate));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -708,7 +708,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Page<Map<String, Object>> getWaterInfoPage(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("type") String type, @Param("status") String status);
Map<String, String> getSystemAlarmStatistic(@Param("systemCode") String systemCode);
Map<String, String> getSystemAlarmStatistic(@Param("systemCode") String systemCode, @Param("startDate") String startDate, @Param("endDate") String endDate);
List<Map<String, Object>> getSystemAlarmTrend(@Param("systemCode") String systemCode, @Param("updateTime") String updateTime);
......
......@@ -10,5 +10,5 @@ import com.yeejoin.equipmanage.common.entity.WarehouseStructure;
* @date 2020-07-07
*/
public interface WarehouseStructureMapper extends BaseMapper<WarehouseStructure> {
WarehouseStructure selectByEquipmentId(Long equipmentId);
}
......@@ -338,7 +338,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Page<Map<String, Object>> getWaterInfoPage(Page<Map<String, Object>> page, String bizOrgCode, String type, String status);
List<Map<String, String>> getSystemAlarmStatistic(String systemCode);
List<Map<String, String>> getSystemAlarmStatistic(String systemCode, String startDate, String endDate);
Map<String, Object> getSystemAlarmTrend(String systemCode, String updateTime);
......
......@@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.dto.EquiplistSpecificBySystemESVO;
import com.yeejoin.equipmanage.common.entity.EquipmentIndex;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.common.entity.WarehouseStructure;
import com.yeejoin.equipmanage.common.entity.dto.EquipmentAlarmLogDto;
import com.yeejoin.equipmanage.common.exception.BaseException;
import com.yeejoin.equipmanage.dao.ESequiplistSpecificBySystemRepository;
import com.yeejoin.equipmanage.mapper.EquipmentIndexMapper;
import com.yeejoin.equipmanage.mapper.WarehouseStructureMapper;
import com.yeejoin.equipmanage.service.IESeqService;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -30,6 +32,7 @@ import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.SimpleDateFormat;
......@@ -51,6 +54,8 @@ public class ESeqServiceImpl implements IESeqService {
@Autowired
private EquipmentIndexMapper equipmentIndexMapper;
@Autowired
private WarehouseStructureMapper warehouseStructureMapper;
@Value("${es.ESEquiplistSpecific.flag}")
private Boolean flag;
......@@ -89,38 +94,36 @@ public class ESeqServiceImpl implements IESeqService {
)
.withPageable(PageRequest.of(current-1, pageSize))
.withSort(SortBuilders.fieldSort("time").order(SortOrder.DESC));
List<EquipmentAlarmLogDto> list = new LinkedList<EquipmentAlarmLogDto>();
try
{
SearchHits<EquiplistSpecificBySystemESVO> searchHits =elasticsearchTemplate.search(queryBuilder.build(), EquiplistSpecificBySystemESVO.class);
List<EquipmentAlarmLogDto> list = new LinkedList<>();
try {
SearchHits<EquiplistSpecificBySystemESVO> searchHits = elasticsearchTemplate.search(queryBuilder.build(), EquiplistSpecificBySystemESVO.class);
for (SearchHit<EquiplistSpecificBySystemESVO> searchHit : searchHits.getSearchHits())
{
for (SearchHit<EquiplistSpecificBySystemESVO> searchHit : searchHits.getSearchHits()) {
JSONObject jsonObject = (JSONObject) JSON.toJSON(searchHit.getContent());
EquiplistSpecificBySystemESVO equiplistSpecificBySystemESVO = JSON.toJavaObject(jsonObject, EquiplistSpecificBySystemESVO.class);
EquipmentAlarmLogDto da=new EquipmentAlarmLogDto();
da.setId(UUID.randomUUID().toString());
da.setName(equiplistSpecificBySystemESVO.getEquipmentSpecificName());
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date daf =new Date(equiplistSpecificBySystemESVO.getTime());
String time=ft.format(daf);
da.setTime(time);
// String value=equiplistSpecificBySystemESVO.getValue();
// value= getReadableStatus(value );
// da.setContent(equiplistSpecificBySystemESVO.getEquipmentIndexName()+":"+value);
QueryWrapper<EquipmentIndex> wrapper = new QueryWrapper<>();
wrapper.eq("name_key", equiplistSpecificBySystemESVO.getEquipmentIndexKey());
wrapper.last("limit 1");
EquipmentIndex index = equipmentIndexMapper.selectOne(wrapper);
da.setContent(index.getTypeName());
list.add(da);
EquipmentAlarmLogDto da = new EquipmentAlarmLogDto();
da.setId(String.valueOf(equiplistSpecificBySystemESVO.getEquipmentSpecificId()));
da.setName(equiplistSpecificBySystemESVO.getEquipmentSpecificName());
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date daf = new Date(equiplistSpecificBySystemESVO.getTime());
String time = ft.format(daf);
da.setTime(time);
QueryWrapper<EquipmentIndex> wrapper = new QueryWrapper<>();
wrapper.eq("name_key", equiplistSpecificBySystemESVO.getEquipmentIndexKey());
wrapper.last("limit 1");
EquipmentIndex index = equipmentIndexMapper.selectOne(wrapper);
da.setContent(index.getTypeName());
WarehouseStructure warehouseStructure = warehouseStructureMapper.selectByEquipmentId(equiplistSpecificBySystemESVO.getEquipmentSpecificId());
if (warehouseStructure != null) {
da.setLocation(StringUtils.hasText(warehouseStructure.getFullName()) ? warehouseStructure.getFullName() : "");
}
list.add(da);
}
pageBean.setRecords(list);
pageBean.setTotal(searchHits.getTotalHits());
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest("系统异常");
throw new BadRequest("系统异常");
}
return pageBean;
}
......
......@@ -2533,8 +2533,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
return fireFightingSystemMapper.getWaterInfoPage(page, bizOrgCode, type, status);
}
@Override
public List<Map<String, String>> getSystemAlarmStatistic(String systemCode) {
Map<String, String> map = fireFightingSystemMapper.getSystemAlarmStatistic(systemCode);
public List<Map<String, String>> getSystemAlarmStatistic(String systemCode, String startDate, String endDate) {
Map<String, String> map = fireFightingSystemMapper.getSystemAlarmStatistic(systemCode, startDate, endDate);
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> entryMap = new HashMap<>();
entryMap.put("key", "1");
......@@ -2546,7 +2546,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
Map<String, String> entryMap1 = new HashMap<>();
entryMap1.put("key", "2");
entryMap1.put("type", "handled");
entryMap1.put("name", "已处理");
entryMap1.put("name", "已消除");
entryMap1.put("value", map.get("handledNum"));
entryMap1.put("unit", "");
list.add(entryMap1);
......@@ -2561,7 +2561,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
entryMap3.put("key", "4");
entryMap3.put("type", "faultEquip");
entryMap3.put("name", "故障设备");
entryMap3.put("value", map.get("alarmEquipNum"));
entryMap3.put("value", map.get("faultEquipNum"));
entryMap3.put("unit", "");
list.add(entryMap3);
return list;
......
......@@ -6179,8 +6179,26 @@
<select id="getSystemAlarmStatistic" resultType="Map">
SELECT
COUNT(wlesal.id) AS totalNum,
IFNULL((select COUNT(DISTINCT wl.equipment_specific_id) from wl_equipment_specific_alarm_log wl where
wl.`status` = 1 AND system_codes LIKE CONCAT('%', #{systemCode}, '%')), 0) AS alarmEquipNum,
IFNULL(
(
SELECT
COUNT(DISTINCT wl.equipment_specific_id)
FROM
wl_equipment_specific_alarm_log wl
<where>
wl.type = 'BREAKDOWN'
<if test="systemCode != null and systemCode != ''">
AND wl.system_codes LIKE CONCAT('%', #{systemCode}, '%')
</if>
<if test="startDate != null and startDate != ''">
AND wl.create_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND wl.create_date &lt;= #{endDate}
</if>
</where>
)
, 0) AS faultEquipNum,
IFNULL(SUM(IF(wlesal.clean_time IS NULL,1,0)), 0) AS unClearNum,
IFNULL(SUM(IF(wlesal.confirm_type IS NOT NULL,1,0)), 0) AS handledNum
FROM
......@@ -6188,7 +6206,13 @@
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wlesal.system_ids )
<where>
<if test="systemCode != null and systemCode != ''">
fs.code = #{systemCode}
AND fs.code = #{systemCode}
</if>
<if test="startDate != null and startDate != ''">
AND wlesal.create_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND wlesal.create_date &lt;= #{endDate}
</if>
</where>
</select>
......
......@@ -2,4 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.WarehouseStructureMapper">
<select id="selectByEquipmentId" resultType="com.yeejoin.equipmanage.common.entity.WarehouseStructure">
SELECT
ws.*
FROM
wl_equipment_specific es
LEFT JOIN wl_warehouse_structure ws ON es.warehouse_structure_id = ws.id
WHERE
es.id = #{equipmentSpecificId}
LIMIT 1
</select>
</mapper>
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