Commit 09e6a1e3 authored by lisong's avatar lisong

添加一张大屏数据源接口

parent 37d1a3c7
package com.yeejoin.equipmanage.controller; 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.CommonPageable;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil; import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.BigScreenVo; import com.yeejoin.equipmanage.common.vo.BigScreenVo;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IFireFightingSystemService; import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; 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.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController @RestController
@Api(tags = "一张图大屏API") @Api(tags = "一张图大屏API")
@RequestMapping(value = "/bigScreen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/bigScreen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class BigScreenController { public class BigScreenController extends AbstractBaseController {
@Autowired @Autowired
private IFireFightingSystemService iFireFightingSystemService; private IFireFightingSystemService iFireFightingSystemService;
@Autowired
private FireFightingSystemMapper fireFightingSystemMapper;
@Autowired
private IotFeign iotFeign;
@GetMapping(value = "/list") @GetMapping(value = "/list")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "系统、消防水池、工业水池、水源总容积、消防车辆(接口弃用)", notes = "系统、消防水池、工业水池、水源总容积、消防车辆") @ApiOperation(httpMethod = "GET", value = "系统、消防水池、工业水池、水源总容积、消防车辆(接口弃用)", notes = "系统、消防水池、工业水池、水源总容积、消防车辆")
...@@ -36,4 +61,91 @@ public class BigScreenController { ...@@ -36,4 +61,91 @@ public class BigScreenController {
public ResponseModel<BigScreenVo> getCarInfo(@RequestParam(required = false, value = "companyCode") String companyCode) { public ResponseModel<BigScreenVo> getCarInfo(@RequestParam(required = false, value = "companyCode") String companyCode) {
return CommonResponseUtil.success(iFireFightingSystemService.getCarInfo(companyCode)); return CommonResponseUtil.success(iFireFightingSystemService.getCarInfo(companyCode));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "水源信息列表")
@GetMapping("/getWaterInfo")
public ResponseModel getWaterInfo(CommonPageable commonPageable, @RequestParam(value = "companyCode",required = false)String companyCode) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(iFireFightingSystemService.getWaterInfo(page, companyCode, null));
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "稳压泵列表信息")
@GetMapping("/getPressurePumpInfo")
public ResponseModel getPressurePumpInfo(CommonPageable commonPageable,@RequestParam(required = false, value = "companyCode")String companyCode) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
String bizOrgCode = null;
if (StringUtil.isNotEmpty(companyCode)) {
bizOrgCode = fireFightingSystemMapper.queryByCompanyCode(companyCode);
}
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", String.valueOf(stateMap.get("update_date")).replaceAll("T", " "));
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 = "系统今日告警信息列表")
@GetMapping("/getSystemInfo")
public ResponseModel getSystemInfo(CommonPageable commonPageable, @RequestParam(value = "companyCode",required = false)String companyCode) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(iFireFightingSystemService.getSystemInfo(page, companyCode, null));
}
} }
...@@ -306,6 +306,13 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -306,6 +306,13 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @return * @return
*/ */
Page<Map<String, Object>> getWaterInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode); Page<Map<String, Object>> getWaterInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode);
/**
* 获取系统今日告警信息
*
* @param bizOrgCode
* @return
*/
Page<Map<String, Object>> getSystemInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode);
/** /**
* 获取系统名称及该系统工作状态 * 获取系统名称及该系统工作状态
......
...@@ -280,5 +280,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -280,5 +280,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
String iotDayReport(String bizOrgCode, String startDate, String endDate); String iotDayReport(String bizOrgCode, String startDate, String endDate);
Page<Map<String, Object>> getWaterInfo(Page page, String companyCode, String systemCode);
Page<Map<String, Object>> getSystemInfo(Page page, String companyCode, String systemCode);
} }
...@@ -1963,4 +1963,22 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1963,4 +1963,22 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
} }
return pdfUrlString; return pdfUrlString;
} }
@Override
public Page<Map<String, Object>> getWaterInfo(Page page, String companyCode, String systemCode) {
String bizOrgCode = null;
if (StringUtil.isNotEmpty(companyCode)) {
bizOrgCode = fireFightingSystemMapper.queryByCompanyCode(companyCode);
}
return fireFightingSystemMapper.getWaterInfo(page, bizOrgCode, null);
}
@Override
public Page<Map<String, Object>> getSystemInfo(Page page, String companyCode, String systemCode) {
String bizOrgCode = null;
if (StringUtil.isNotEmpty(companyCode)) {
bizOrgCode = fireFightingSystemMapper.queryByCompanyCode(companyCode);
}
return fireFightingSystemMapper.getSystemInfo(page, bizOrgCode, null);
}
} }
...@@ -2606,7 +2606,9 @@ ...@@ -2606,7 +2606,9 @@
LEFT JOIN wl_warehouse_structure ws ON ws.id = es.warehouse_structure_id LEFT JOIN wl_warehouse_structure ws ON ws.id = es.warehouse_structure_id
WHERE WHERE
ed.`code` LIKE '92010800%' ed.`code` LIKE '92010800%'
AND es.biz_org_code like concat(#{bizOrgCode}, '%') <if test="bizOrgCode != null and bizOrgCode != ''" >
AND es.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</select> </select>
<select id="queryPressureNowStateBySpecificId" resultType="java.util.Map"> <select id="queryPressureNowStateBySpecificId" resultType="java.util.Map">
...@@ -4271,4 +4273,28 @@ ...@@ -4271,4 +4273,28 @@
) )
</select> </select>
<select id="getSystemInfo" resultType="java.util.Map">
SELECT
temp.*,
CASE
WHEN temp.notReturnd > 0 THEN
'异常' ELSE '正常'
END AS STATUS
FROM
(
SELECT
fs.id,
fs.NAME,
fs.CODE,
( SELECT COUNT( DISTINCT(wesa.iot_code) ) FROM wl_equipment_specific_alarm wesa WHERE FIND_IN_SET( fs.id, wesa.system_ids ) AND wesa.create_date like concat(DATE_FORMAT(NOW(),'%Y-%m-%d')) ) AS total,
( SELECT COUNT( DISTINCT(wesa.iot_code) ) FROM wl_equipment_specific_alarm wesa WHERE FIND_IN_SET( fs.id, wesa.system_ids ) AND wesa.equipment_specific_index_value = 'true' AND wesa.create_date like concat(DATE_FORMAT(NOW(),'%Y-%m-%d'))) AS notReturnd
FROM
f_fire_fighting_system fs
) temp
ORDER BY
temp.notReturnd DESC
</select>
</mapper> </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