feat(record): 修改母排报警记录统计方法

- 将 RecordBusbarAlarmMapper 接口中的 recordBusbarAlarmCount 方法返回类型改为 List<RecordBusbarAlarmCountResult>
- 更新 RecordBusbarAlarmServiceImpl 中的 recordBusbarAlarmCount 方法实现
- 修改数据库映射文件 RecordBusbarAlarmMapper.xml 中的 SQL 语句
IOT
zch 1 month ago
parent cbc287cc6a
commit 9b807f0b02

@ -206,6 +206,7 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
* @param energyType * @param energyType
* @return * @return
*/ */
@Override
public int getEnergyTypeCount(String energyType){ public int getEnergyTypeCount(String energyType){
return emsBaseMonitorInfoMapper.getEnergyTypeCount(energyType); return emsBaseMonitorInfoMapper.getEnergyTypeCount(energyType);
} }

@ -120,6 +120,7 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
* @param tWTempertureData * @param tWTempertureData
* @return * @return
*/ */
@Override
public List<TWTempertureData> selectLastTWTempertureDataList(TWTempertureData tWTempertureData) { public List<TWTempertureData> selectLastTWTempertureDataList(TWTempertureData tWTempertureData) {
// 按monitorName分组并获取每个分组的最新记录 // 按monitorName分组并获取每个分组的最新记录
return tWTempertureDataMapper.selectLastTWTempertureDataList(tWTempertureData); return tWTempertureDataMapper.selectLastTWTempertureDataList(tWTempertureData);
@ -130,6 +131,7 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
* @param tWTempertureData * @param tWTempertureData
* @return * @return
*/ */
@Override
public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData) { public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData) {
try { try {
// 从数据库中查询温度数据列表 // 从数据库中查询温度数据列表
@ -168,14 +170,14 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
} }
/** /**
* *
* *
* @param source * @param source
* @param target * @param target
* @param fieldName * @param fieldName
*/ */
private void setIfNotNull(TWTempertureData source, TWTempertureData target, String fieldName) { private void setIfNotNull(TWTempertureData source, TWTempertureData target, String fieldName) {
try { try {
// 获取源对象中指定字段的getter方法 // 获取源对象中指定字段的getter方法
Method getMethod = TWTempertureData.class.getMethod("get" + capitalize(fieldName)); Method getMethod = TWTempertureData.class.getMethod("get" + capitalize(fieldName));
@ -191,14 +193,14 @@ private void setIfNotNull(TWTempertureData source, TWTempertureData target, Stri
// 捕获并打印异常信息 // 捕获并打印异常信息
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* PM * PM
* @param source TWTempertureDataPM * @param source TWTempertureDataPM
* @param target TWTempertureDataPM * @param target TWTempertureDataPM
*/ */
private void setPmValues(TWTempertureData source, TWTempertureData target) { private void setPmValues(TWTempertureData source, TWTempertureData target) {
setIfNotNull(source, target, "pm1"); setIfNotNull(source, target, "pm1");
if (target.getPm1() == null) { if (target.getPm1() == null) {
setIfNotNull(source, target, "pm2"); setIfNotNull(source, target, "pm2");
@ -206,21 +208,21 @@ private void setPmValues(TWTempertureData source, TWTempertureData target) {
if (target.getPm2() == null) { if (target.getPm2() == null) {
setIfNotNull(source, target, "pm10"); setIfNotNull(source, target, "pm10");
} }
} }
/** /**
* *
* *
* @param str * @param str
* @return 0 * @return 0
*/ */
private String capitalize(String str) { private String capitalize(String str) {
// 如果字符串为null或者长度为0直接返回原字符串 // 如果字符串为null或者长度为0直接返回原字符串
if (str == null || str.length() == 0) { if (str == null || str.length() == 0) {
return str; return str;
} }
// 将字符串的第一个字符转换为大写,并与剩余部分拼接后返回 // 将字符串的第一个字符转换为大写,并与剩余部分拼接后返回
return str.substring(0, 1).toUpperCase() + str.substring(1); return str.substring(0, 1).toUpperCase() + str.substring(1);
} }
} }

@ -101,4 +101,13 @@ public class BaseBusbarInfoController extends BaseController
{ {
return toAjax(baseBusbarInfoService.deleteBaseBusbarInfoByObjIds(objIds)); return toAjax(baseBusbarInfoService.deleteBaseBusbarInfoByObjIds(objIds));
} }
/**
*
*/
@PostMapping("/countCabinet")
public AjaxResult countCabinet() {
return success(baseBusbarInfoService.countBaseBusbarInfo());
}
} }

@ -127,4 +127,13 @@ public class BaseCabinetInfoController extends BaseController
return success(list); return success(list);
} }
/**
*
* */
@PostMapping("/countCabinet")
public int countCabinet() {
return baseCabinetInfoService.countBaseCabinetInfo();
}
} }

@ -58,4 +58,6 @@ public interface BaseBusbarInfoMapper
* @return * @return
*/ */
public int deleteBaseBusbarInfoByObjIds(Long[] objIds); public int deleteBaseBusbarInfoByObjIds(Long[] objIds);
public int countBaseBusbarInfo();
} }

@ -58,4 +58,6 @@ public interface BaseCabinetInfoMapper
* @return * @return
*/ */
public int deleteBaseCabinetInfoByObjIds(Long[] objIds); public int deleteBaseCabinetInfoByObjIds(Long[] objIds);
public int countBaseCabinetInfo();
} }

@ -58,4 +58,6 @@ public interface IBaseBusbarInfoService
* @return * @return
*/ */
public int deleteBaseBusbarInfoByObjId(Long objId); public int deleteBaseBusbarInfoByObjId(Long objId);
public int countBaseBusbarInfo();
} }

@ -68,4 +68,6 @@ public interface IBaseCabinetInfoService
* @return * @return
*/ */
public List<baseCabinetInfoTreeSelects> selectCabinetInfoTreeList(BaseCabinetInfo baseCabinetInfo); public List<baseCabinetInfoTreeSelects> selectCabinetInfoTreeList(BaseCabinetInfo baseCabinetInfo);
public int countBaseCabinetInfo();
} }

@ -154,4 +154,9 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
{ {
return baseBusbarInfoMapper.deleteBaseBusbarInfoByObjId(objId); return baseBusbarInfoMapper.deleteBaseBusbarInfoByObjId(objId);
} }
@Override
public int countBaseBusbarInfo(){
return baseBusbarInfoMapper.countBaseBusbarInfo();
}
} }

@ -118,11 +118,17 @@ public class BaseCabinetInfoServiceImpl implements IBaseCabinetInfoService
* *
* @return * @return
*/ */
@Override
public List<baseCabinetInfoTreeSelects> selectCabinetInfoTreeList(BaseCabinetInfo baseCabinetInfo){ public List<baseCabinetInfoTreeSelects> selectCabinetInfoTreeList(BaseCabinetInfo baseCabinetInfo){
List<BaseCabinetInfo> baseCabinetInfos = baseCabinetInfoMapper.selectBaseCabinetInfoList(baseCabinetInfo); List<BaseCabinetInfo> baseCabinetInfos = baseCabinetInfoMapper.selectBaseCabinetInfoList(baseCabinetInfo);
return baseCabinetInfos.stream().map(baseCabinetInfoTreeSelects::new).collect(Collectors.toList()); return baseCabinetInfos.stream().map(baseCabinetInfoTreeSelects::new).collect(Collectors.toList());
} }
@Override
public int countBaseCabinetInfo(){
return baseCabinetInfoMapper.countBaseCabinetInfo();
}
/* /*
*/ */
/** /**

@ -2,6 +2,7 @@ package com.ruoyi.record.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.record.domain.RecordBusbarAlarm; import com.ruoyi.record.domain.RecordBusbarAlarm;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
/** /**
* Mapper * Mapper
@ -58,4 +59,6 @@ public interface RecordBusbarAlarmMapper
* @return * @return
*/ */
public int deleteRecordBusbarAlarmByObjIds(Long[] objIds); public int deleteRecordBusbarAlarmByObjIds(Long[] objIds);
public List<RecordBusbarAlarmCountResult> recordBusbarAlarmCount(RecordBusbarAlarm recordBusbarAlarm);
} }

@ -2,6 +2,7 @@ package com.ruoyi.record.service;
import java.util.List; import java.util.List;
import com.ruoyi.record.domain.RecordBusbarAlarm; import com.ruoyi.record.domain.RecordBusbarAlarm;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
/** /**
* Service * Service
@ -59,5 +60,5 @@ public interface IRecordBusbarAlarmService
*/ */
public int deleteRecordBusbarAlarmByObjId(Long objId); public int deleteRecordBusbarAlarmByObjId(Long objId);
int recordBusbarAlarmCount(RecordBusbarAlarm recordBusbarAlarm); public List<RecordBusbarAlarmCountResult> recordBusbarAlarmCount(RecordBusbarAlarm recordBusbarAlarm);
} }

@ -1,6 +1,8 @@
package com.ruoyi.record.service.impl; package com.ruoyi.record.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.record.mapper.RecordBusbarAlarmMapper; import com.ruoyi.record.mapper.RecordBusbarAlarmMapper;
@ -90,4 +92,10 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
{ {
return recordBusbarAlarmMapper.deleteRecordBusbarAlarmByObjId(objId); return recordBusbarAlarmMapper.deleteRecordBusbarAlarmByObjId(objId);
} }
@Override
public List<RecordBusbarAlarmCountResult> recordBusbarAlarmCount(RecordBusbarAlarm recordBusbarAlarm){
return recordBusbarAlarmMapper.recordBusbarAlarmCount(recordBusbarAlarm);
}
} }

@ -140,4 +140,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="recordBusbarAlarmCount" resultType="java.lang.Integer">
select count(*) from base_busbar_info
</select>
</mapper> </mapper>

@ -117,4 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="countBaseCabinetInfo" resultType="Integer">
select count(1) from base_cabinet_info
</select>
</mapper> </mapper>

@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRecordBusbarAlarmListByDay" parameterType="RecordBusbarAlarm" resultMap="RecordBusbarAlarmCountResult"> <select id="recordBusbarAlarmCount" parameterType="RecordBusbarAlarm" resultMap="RecordBusbarAlarmCountResult">
SELECT SELECT
DATE(record_time) AS record_date, DATE(record_time) AS record_date,
COUNT(*) AS alarm_count COUNT(*) AS alarm_count
@ -125,4 +125,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY GROUP BY
DATE(record_time) DATE(record_time)
</select> </select>
</mapper> </mapper>

@ -42,3 +42,13 @@ export function delBaseBusbarInfo(objId) {
method: 'delete' method: 'delete'
}) })
} }
/**
* 统计母排数量
* */
export function countBusbar() {
return request({
url: '/base/baseBusbarInfo/countBusbar',
method: 'post'
})
}

@ -51,3 +51,13 @@ export function getBaseCabinetInfoTree(data) {
data: data data: data
}) })
} }
/**
* 统计电柜数量
* */
export function countCabinet() {
return request({
url: '/base/baseCabinetInfo/countCabinet',
method: 'post'
})
}

Loading…
Cancel
Save