Commit c1ad9392 authored by zhangsen's avatar zhangsen

大屏API

parent 535ff6ab
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
......@@ -11,16 +14,16 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@Api(tags = "组态需求 -- API")
......@@ -37,6 +40,9 @@ public class ConfigureController extends AbstractBaseController {
@Autowired
private IFireFightingSystemService iFireFightingSystemService;
@Autowired
private IotFeign iotFeign;
@RequestMapping(value = "/alarmLogPage", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", produces = "application/json;charset=UTF-8", notes = "列表分页查询")
......@@ -161,23 +167,90 @@ public class ConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(null);
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(fireFightingSystemMapper.getFireCarInfoByWL(page, "LSHLZ1bZAJU645Pgl7dMndrF"));
return CommonResponseUtil.success(fireFightingSystemMapper.getFireCarInfoByWL(page, bizOrgCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览水源信息")
@GetMapping("/getWaterInfo")
public ResponseModel getWaterInfo() {
public ResponseModel getWaterInfo(CommonPageable commonPageable) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
return CommonResponseUtil.success(fireFightingSystemMapper.getWaterInfo(bizOrgCode, null));
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(fireFightingSystemMapper.getWaterInfo(page, bizOrgCode, null));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览稳压泵信息")
@GetMapping("/getPressurePumpInfo")
public ResponseModel getPressurePumpInfo(CommonPageable commonPageable) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
if (StringUtils.isEmpty(bizOrgCode)) {
return CommonResponseUtil.success(null);
}
Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
pressurePumpInfo.getRecords().stream().map(item -> {
item.put("startAndStopNum", 0);
item.put("update_time", "未知");
item.put("equipment_index_name", "未知");
String prefix = null;
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
String nowStrLong = DateUtils.getNowStrLong();
Date startDate = DateUtils.dateAddMinutes(null, -4);
String startDateStr = DateUtils.convertDateToString(startDate, DateUtils.DATE_TIME_PATTERN);
ResponseModel entity1 = null;
ResponseModel entity2 = null;
try {
entity1 = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startDateStr, nowStrLong, prefix, suffix, "FHS_PressurePump_Start");
entity2 = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startDateStr, nowStrLong, prefix, suffix, "FHS_PressurePump_Stop");
} catch (Exception e) {
e.printStackTrace();
}
if (200 == entity1.getStatus() && !ObjectUtils.isEmpty(entity1.getResult()) &&
200 == entity2.getStatus() && !ObjectUtils.isEmpty(entity2.getResult())) {
String json1 = JSON.toJSONString(entity1.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
String json2 = JSON.toJSONString(entity1.getResult());
List<Map<String, String>> listObject2 = (List<Map<String, String>>) JSONArray.parse(json2);
int num = listObject1.size() + listObject2.size();
item.put("startAndStopNum", num);
}
item.put("stateDesc", (Integer) item.get("startAndStopNum") <= 1 ? "正常" : "异常");
item.put("normalNum", (Integer) item.get("startAndStopNum") <= 1 ? 1 : 0);
item.put("unNormalNum", (Integer) item.get("startAndStopNum") <= 1 ? 0 : 1);
Map<String, String> stateMap = fireFightingSystemMapper.queryPressureNowStateBySpecificId((Long) item.get("id"));
if (!ObjectUtils.isEmpty(stateMap) && stateMap.containsKey("update_date") && stateMap.containsKey("equipment_index_name")) {
item.put("update_time", stateMap.get("update"));
item.put("equipment_index_name", stateMap.get("equipment_index_name"));
}
return item;
}).collect(Collectors.toList());
return CommonResponseUtil.success(pressurePumpInfo);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "3小水源信息")
@GetMapping("/getSmallWaterInfo")
public ResponseModel getSmallWaterInfo(@RequestParam(required = false) String systemCode) {
public ResponseModel getSmallWaterInfo(@RequestParam(required = false) String systemCode, CommonPageable commonPageable) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
HashMap<String, Object> hashMap = new HashMap<>();
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
......@@ -194,7 +267,8 @@ public class ConfigureController extends AbstractBaseController {
hashMap.put("systemCode", systemCode);
}
return CommonResponseUtil.success(iFireFightingSystemService.getSmallWaterInfo(hashMap));
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(iFireFightingSystemService.getSmallWaterInfo(page, hashMap));
}
......
......@@ -292,7 +292,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @param bizOrgCode
* @return
*/
List<Map<String, Object>> getWaterInfo(@Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode);
Page<Map<String, Object>> getWaterInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode);
/**
* 获取系统名称及该系统工作状态
......@@ -325,4 +325,21 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @return
*/
Page<Map<String, Object>> equipmentState(Page page, String id);
/**
* 稳压泵信息
*
* @param page
* @param bizOrgCode
* @param systemCode
* @return
*/
Page<Map<String, Object>> getPressurePumpInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode);
/**
* 根据装备ID查指标信息
* @param id
* @return
*/
Map<String, String> queryPressureNowStateBySpecificId(@Param("id") Long id);
}
......@@ -242,7 +242,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Map<String, Object> equipAlarmTOP(HashMap<String, Object> hashMap);
List<Map<String, Object>> getSmallWaterInfo(HashMap<String, Object> hashMap);
Page<Map<String, Object>> getSmallWaterInfo(Page page, HashMap<String, Object> hashMap);
Page<Map<String, Object>> equipmentState(Page result, HashMap<String, Object> hashMap);
......
......@@ -1322,10 +1322,10 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
@Override
public List<Map<String, Object>> getSmallWaterInfo(HashMap<String, Object> hashMap) {
public Page<Map<String, Object>> getSmallWaterInfo(Page page, HashMap<String, Object> hashMap) {
String bizOrgCode = hashMap.get("bizOrgCode").toString();
String systemCode = hashMap.get("systemCode").toString();
return fireFightingSystemMapper.getWaterInfo(bizOrgCode, systemCode);
return fireFightingSystemMapper.getWaterInfo(page, bizOrgCode, systemCode);
}
}
......@@ -2702,4 +2702,33 @@
a.equipmentId
) b
</select>
<select id="getPressurePumpInfo" resultType="java.util.Map">
SELECT
ed.`name`,
ed.area,
es.iot_code,
es.id
FROM
wl_equipment_detail ed
LEFT JOIN wl_equipment_specific es ON es.equipment_detail_id = ed.id
WHERE
ed.`code` LIKE '92010800%'
AND biz_org_code = #{bizOrgCode}
</select>
<select id="queryPressureNowStateBySpecificId" resultType="java.util.Map">
SELECT
i.update_date,
i.equipment_index_name
FROM
wl_equipment_specific_index i
WHERE
i.equipment_index_key IN ( 'FHS_PressurePump_Start', 'FHS_PressurePump_Stop' )
AND i.equipment_specific_id = #{id,jdbcType=VARCHAR}
and i.`value` = 'true'
ORDER BY
i.update_date DESC
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