Commit 97338dff authored by 张森's avatar 张森

自动化需求开发

parent 4ff80285
......@@ -17,6 +17,7 @@ import com.yeejoin.equipmanage.common.entity.vo.EquiplistSpecificBySystemVO;
import com.yeejoin.equipmanage.common.entity.vo.IotIndexInfoVo;
import com.yeejoin.equipmanage.common.entity.vo.SourceNameByEquipSpeIdVO;
import com.yeejoin.equipmanage.common.enums.EquipQrcodeColorEnum;
import com.yeejoin.equipmanage.common.utils.CommonPageable;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.EquipmentOnCarVo;
......@@ -30,6 +31,7 @@ import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import com.yeejoin.equipmanage.service.impl.FireFightingSystemServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -601,4 +603,42 @@ public class EquipmentSpecificController extends AbstractBaseController {
return list;
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询消防设备历史数据", notes = "查询消防设备历史数据")
@RequestMapping(value = "/data/history-for-studio", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel queryForFireEquipmentHistoryForStudio(
@ApiParam(value = "设备名称", required = false) @RequestParam(required = false) String fireEquipmentName,
@ApiParam(value = "按保护对象名称", required = false) @RequestParam(required = false) String equipmentName,
@ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startTime,
@ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String endTime,
@ApiParam(value = "当前页码", required = false) @RequestParam(required = true) int pageNumber,
@ApiParam(value = "每页大小", required = false) @RequestParam(required = true) int pageSize,
@ApiParam(value = "装备定义code", required = false) @RequestParam(required = false) String equipmentCode) {
if (pageNumber >= 1) {
--pageNumber;
}
org.springframework.data.domain.Page page;
try {
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
page = equipmentSpecificSerivce.queryForFireEquipmentHistory(
StringUtils.trimToNull(fireEquipmentName), StringUtils.trimToNull(equipmentName),
StringUtils.trimToNull(startTime), StringUtils.trimToNull(endTime), commonPageable, equipmentCode);
} catch (Exception e) {
return CommonResponseUtil.failure(e.getMessage());
}
com.baomidou.mybatisplus.extension.plugins.pagination.Page<Object> objectPage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>();
objectPage.setCurrent(page.getNumber());
objectPage.setRecords(page.getContent());
objectPage.setTotal(page.getTotalElements());
objectPage.setPages(page.getTotalPages());
return CommonResponseUtil.success(objectPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "稳压泵/消防泵运行监视", notes = "稳压泵/消防泵运行监视")
@RequestMapping(value = "/queryOperationMonitoring", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel queryOperationMonitoring() {
return CommonResponseUtil.success(equipmentSpecificSerivce.queryOperationMonitoring());
}
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.equipmanage.dto;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* <pre>
* 分页数据
* </pre>
*
* @author as-youjun
* @version $Id: CompanyPage.java, v 0.1 2017年4月13日 上午11:35:25 as-youjun Exp $
*/
public final class CommonPage<T> extends PageImpl<T> {
/**
* <pre>
* uid
* </pre>
*/
private static final long serialVersionUID = -5533124806408380886L;
/**
*
*/
private String message;
/**
* 返回结果状态
*/
private String result;
public CommonPage(List<T> content, Pageable pageable, long total) {
super(content, pageable, total);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult()
{
return result;
}
public void setResult(String result)
{
this.result = result;
}
}
......@@ -330,4 +330,26 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<Map<String, Object>> selectZJEquipmentSpecificWWXByIds(String bussIds);
long queryForFireEquipmentHistoryCount(@Param("fireEquipmentName") String fireEquipmentName,
@Param("equipmentName") String equipmentName,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("equipmentCode") String equipmentCode);
//查询 消防设备历史数据
List<Map> queryForFireEquipmentHistory(
@Param("fireEquipmentName") String fireEquipmentName,
@Param("equipmentName") String equipmentName,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("start") long start,
@Param("length") int length,
@Param("equipmentCode") String equipmentCode
);
List<Map<String, Object>> getPumpInfoList();
List<Map<String, Object>> getFireInfoList();
List<Map<String, Object>> getConInfoList();
}
......@@ -15,6 +15,7 @@ import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.dto.EquipmentSpecificDTO;
import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.utils.CommonPageable;
import com.yeejoin.equipmanage.common.vo.*;
import org.apache.ibatis.annotations.Param;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -325,5 +326,12 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
List<Map<String, Object>> getZJScrapStatics(String bizOrgCode);
org.springframework.data.domain.Page queryForFireEquipmentHistory(String fireEquipmentName,
String equipmentName,
String startTime,
String endTime,
CommonPageable commonPageable,
String equipmentCode);
List<Map<String, Object>> queryOperationMonitoring();
}
package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -27,10 +28,12 @@ import com.yeejoin.equipmanage.common.entity.dto.EquipmentSpecificDTO;
import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.enums.*;
import com.yeejoin.equipmanage.common.exception.BaseException;
import com.yeejoin.equipmanage.common.utils.CommonPageable;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.QRCodeUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.dto.CommonPage;
import com.yeejoin.equipmanage.fegin.IdxFeign;
import com.yeejoin.equipmanage.fegin.SystemctlFeign;
import com.yeejoin.equipmanage.mapper.*;
......@@ -2224,5 +2227,88 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
return equipmentSpecificMapper.getZJScrapStatics(bizOrgCode);
}
//查询 消防设备历史数据
public org.springframework.data.domain.Page queryForFireEquipmentHistory(String fireEquipmentName,
String equipmentName,
String startTime,
String endTime,
CommonPageable commonPageable,
String equipmentCode) {
long total = equipmentSpecificMapper.queryForFireEquipmentHistoryCount(fireEquipmentName, equipmentName,
startTime,
endTime,
equipmentCode);
List<Map> content = equipmentSpecificMapper.queryForFireEquipmentHistory(fireEquipmentName,
equipmentName,
startTime,
endTime,
commonPageable.getOffset(),
commonPageable.getPageSize(),
equipmentCode);
org.springframework.data.domain.Page result = new CommonPage(content, commonPageable, total);
return result;
}
@Override
public List<Map<String, Object>> queryOperationMonitoring() {
ArrayList<Map<String, Object>> resultList = new ArrayList<>();
// 稳压泵信息
List<Map<String, Object>> pumpInfoList = equipmentSpecificMapper.getPumpInfoList();
if (CollUtil.isNotEmpty(pumpInfoList)) {
pumpInfoList.forEach(item -> {
String equipmentIndexKey = item.getOrDefault("equipmentIndexKey", "").toString();
item.put("indexValueName", "停止");
if (!ObjectUtils.isEmpty(equipmentIndexKey)) {
if (equipmentIndexKey.equals("FHS_PressurePump_Start")) {
item.put("indexValueName", "启动");
}
if (equipmentIndexKey.equals("FHS_PressurePump_Stop")) {
item.put("indexValueName", "停止");
}
if (equipmentIndexKey.equals("FHS_PressurePump_ManualAutomaticSignal") &&
item.getOrDefault("indexValue", "").toString().equals("true")) {
item.put("indexValueName", "手动状态");
} else {
item.put("indexValueName", "自动状态");
}
}
});
resultList.addAll(pumpInfoList);
}
// 消防泵信息
List<Map<String, Object>> fireInfoList = equipmentSpecificMapper.getFireInfoList();
if (CollUtil.isNotEmpty(fireInfoList)) {
fireInfoList.forEach(item -> {
String equipmentIndexKey = item.getOrDefault("equipmentIndexKey", "").toString();
item.put("indexValueName", "停止");
if (!ObjectUtils.isEmpty(equipmentIndexKey)) {
if (equipmentIndexKey.equals("FHS_FirePump_Start")) {
item.put("indexValueName", "启动");
}
if (equipmentIndexKey.equals("FHS_FirePump_Stop")) {
item.put("indexValueName", "停止");
}
}
});
resultList.addAll(fireInfoList);
}
// 控制柜信息
List<Map<String, Object>> conInfoList = equipmentSpecificMapper.getConInfoList();
if (CollUtil.isNotEmpty(conInfoList)) {
conInfoList.forEach(item -> {
String equipmentIndexKey = item.getOrDefault("equipmentIndexKey", "").toString();
item.put("indexValueName", "自动状态");
if (!ObjectUtils.isEmpty(equipmentIndexKey)) {
if (item.getOrDefault("indexValue", "").toString().equals("true")) {
item.put("indexValueName", "手动状态");
}
}
});
resultList.addAll(conInfoList);
}
return resultList;
}
}
......@@ -2874,6 +2874,215 @@
</if>
</select>
<select id="queryForFireEquipmentHistoryCount" resultType="long">
SELECT
COUNT(1)
FROM
(
SELECT
det.`name` as fireEquipmentName,
spe.`code` as fireEquipmentCode,
(
SELECT
group_concat(DISTINCT f.`name`)
FROM
f_equipment_fire_equipment efe
JOIN f_equipment f ON efe.equipment_id = f.id
WHERE
efe.fire_equipment_id = ind.equipment_specific_id
) equipmentName,
ind.update_date
FROM
wl_equipment_specific_index as ind
left join wl_equipment_specific as spe on spe.id = ind.equipment_specific_id
left join wl_equipment_detail as det on spe.equipment_detail_id = det.id
WHERE ind.`value` IS NOT NULL AND ind.`value` != ''
<if test="equipmentCode != null and equipmentCode != ''">
AND det.code LIKE concat(#{equipmentCode}, '%')
</if>
) d
<where>
<if test="fireEquipmentName!=null">
AND d.fireEquipmentName LIKE '%${fireEquipmentName}%'
</if>
<if test="equipmentName!=null">
AND d.equipmentName LIKE '%${equipmentName}%'
</if>
<if test="startTime != null and startTime != ''">
AND d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND d.update_date &lt;= #{endTime}
</if>
</where>
</select>
<select id="queryForFireEquipmentHistory" resultType="map">
SELECT
d.*
FROM
(
SELECT
det.`name` as fireEquipmentName,
spe.`code` as fireEquipmentCode,
ein.name as eq_point_name,
CASE ind.value WHEN 'true' THEN '是'
WHEN 'false' THEN '否'
ELSE FORMAT(IFNULL(ind.value, 0), 2) END 'e_value',
ein.unit as eq_point_unit,
CONCAT(IFNULL(str.full_name,''),' ',IFNULL(sto.description,'')) as source_name,
(
SELECT
group_concat(DISTINCT f.`name`)
FROM
f_equipment_fire_equipment efe
JOIN f_equipment f ON efe.equipment_id = f.id
WHERE
efe.fire_equipment_id = ind.equipment_specific_id
) equipmentName,
ind.update_date as create_date,
( SELECT
IFNULL(GROUP_CONCAT( temp.name SEPARATOR ','),'') AS systemName
FROM
( SELECT NAME FROM f_fire_fighting_system fs WHERE FIND_IN_SET( fs.id, spe.system_id ) ) temp
) AS systemName
FROM
wl_equipment_specific_index as ind
left join wl_equipment_specific as spe on spe.id = ind.equipment_specific_id
left join wl_equipment_detail as det on spe.equipment_detail_id = det.id
left join wl_equipment_index as ein on ind.equipment_index_id = ein.id
left join wl_stock_detail as sto on sto.equipment_specific_id = spe.id
left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id
WHERE ind.`value` IS NOT NULL AND ind.`value` != '' AND ein.is_iot = 1
<if test="equipmentCode != null and equipmentCode != ''">
AND det.code LIKE concat(#{equipmentCode}, '%')
</if>
) d
<where>
<if test="fireEquipmentName!=null">
AND d.fireEquipmentName LIKE '%${fireEquipmentName}%'
</if>
<if test="equipmentName!=null">
AND d.equipmentName LIKE '%${equipmentName}%'
</if>
<if test="startTime != null and startTime != ''">
AND d.create_date &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND d.create_date &lt;= #{endTime}
</if>
</where>
ORDER BY d.create_date desc
LIMIT ${start},${length}
</select>
<select id="getPumpInfoList" resultType="java.util.Map">
SELECT COALESCE
( a.id, '' ) AS id,
COALESCE ( a.iot_code, '' ) AS iotCode,
COALESCE ( a.code, '' ) AS code,
COALESCE ( a.name, '' ) AS name,
COALESCE ( a.warehouse_structure_id, '' ) AS buildId,
COALESCE ( b.name, '' ) AS buildName,
esi.equipment_index_key as equipmentIndexKey,
esi.`value` as indexValue
FROM
wl_equipment_specific a
LEFT JOIN wl_warehouse_structure b ON a.warehouse_structure_id = b.id
LEFT JOIN (
SELECT
equipment_specific_id,
equipment_index_key,
`value`,
update_date
FROM
(
SELECT
*,
ROW_NUMBER() OVER ( PARTITION BY equipment_specific_id ORDER BY update_date DESC ) AS rn
FROM
wl_equipment_specific_index
WHERE
( equipment_index_key IN ( 'FHS_PressurePump_Start', 'FHS_PressurePump_Stop' ) AND `value` = 'true' )
OR ( equipment_index_key = 'FHS_PressurePump_ManualAutomaticSignal' AND `value` IS NOT NULL AND `value` != '' )
) esi_with_rn
WHERE
esi_with_rn.rn = 1
) esi ON a.id = esi.equipment_specific_id
WHERE
a.equipment_code LIKE '92010800%'
</select>
<select id="getFireInfoList" resultType="java.util.Map">
SELECT COALESCE
( a.id, '' ) AS id,
COALESCE ( a.iot_code, '' ) AS iotCode,
COALESCE ( a.CODE, '' ) AS code,
COALESCE ( a.NAME, '' ) AS name,
COALESCE ( a.warehouse_structure_id, '' ) AS buildId,
COALESCE ( b.NAME, '' ) AS buildName,
ifnull( esi.equipment_index_key, 'FHS_FirePump_Stop' ) AS equipmentIndexKey,
'true' AS indexValue
FROM
wl_equipment_specific a
LEFT JOIN wl_warehouse_structure b ON a.warehouse_structure_id = b.id
LEFT JOIN (
SELECT
equipment_specific_id,
equipment_index_key,
`value`,
update_date
FROM
(
SELECT
*,
ROW_NUMBER() OVER ( PARTITION BY equipment_specific_id ORDER BY update_date DESC ) AS rn
FROM
wl_equipment_specific_index
WHERE
( equipment_index_key IN ( 'FHS_FirePump_Start', 'FHS_FirePump_Stop' ) AND `value` = 'true' )
) esi_with_rn
WHERE
esi_with_rn.rn = 1
) esi ON a.id = esi.equipment_specific_id
WHERE
a.equipment_code LIKE '920106007%'
</select>
<select id="getConInfoList" resultType="java.util.Map">
SELECT COALESCE
( a.id, '' ) AS id,
COALESCE ( a.iot_code, '' ) AS iotCode,
COALESCE ( a.code, '' ) AS code,
COALESCE ( a.name, '' ) AS name,
COALESCE ( a.warehouse_structure_id, '' ) AS buildId,
COALESCE ( b.name, '' ) AS buildName,
esi.equipment_index_key as equipmentIndexKey,
esi.`value` as indexValue
FROM
wl_equipment_specific a
LEFT JOIN wl_warehouse_structure b ON a.warehouse_structure_id = b.id
LEFT JOIN (
SELECT
equipment_specific_id,
equipment_index_key,
`value`,
update_date
FROM
(
SELECT
*,
ROW_NUMBER() OVER ( PARTITION BY equipment_specific_id ORDER BY update_date DESC ) AS rn
FROM
wl_equipment_specific_index
WHERE
equipment_index_key = 'FHS_PressurePump_ManualAutomaticSignal' AND `value` IS NOT NULL AND `value` != ''
) esi_with_rn
WHERE
esi_with_rn.rn = 1
) esi ON a.id = esi.equipment_specific_id
WHERE
a.equipment_code LIKE '92010500%'
</select>
</mapper>
\ No newline at end of file
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