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
* @return
*/
@Override
public int getEnergyTypeCount(String energyType){
return emsBaseMonitorInfoMapper.getEnergyTypeCount(energyType);
}

@ -120,6 +120,7 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
* @param tWTempertureData
* @return
*/
@Override
public List<TWTempertureData> selectLastTWTempertureDataList(TWTempertureData tWTempertureData) {
// 按monitorName分组并获取每个分组的最新记录
return tWTempertureDataMapper.selectLastTWTempertureDataList(tWTempertureData);
@ -130,6 +131,7 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
* @param tWTempertureData
* @return
*/
@Override
public List<TWTempertureData> selectLastTWTempertureData(TWTempertureData tWTempertureData) {
try {
// 从数据库中查询温度数据列表
@ -168,59 +170,59 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
}
/**
*
*
* @param source
* @param target
* @param fieldName
*/
private void setIfNotNull(TWTempertureData source, TWTempertureData target, String fieldName) {
try {
// 获取源对象中指定字段的getter方法
Method getMethod = TWTempertureData.class.getMethod("get" + capitalize(fieldName));
// 获取目标对象中指定字段的setter方法参数类型与getter方法返回类型一致
Method setMethod = TWTempertureData.class.getMethod("set" + capitalize(fieldName), getMethod.getReturnType());
// 调用getter方法获取源对象中的字段值
Object value = getMethod.invoke(source);
// 如果字段值不为空且目标对象中的对应字段值为空则调用setter方法将值设置到目标对象中
if (value != null && getMethod.invoke(target) == null) {
setMethod.invoke(target, value);
/**
*
*
* @param source
* @param target
* @param fieldName
*/
private void setIfNotNull(TWTempertureData source, TWTempertureData target, String fieldName) {
try {
// 获取源对象中指定字段的getter方法
Method getMethod = TWTempertureData.class.getMethod("get" + capitalize(fieldName));
// 获取目标对象中指定字段的setter方法参数类型与getter方法返回类型一致
Method setMethod = TWTempertureData.class.getMethod("set" + capitalize(fieldName), getMethod.getReturnType());
// 调用getter方法获取源对象中的字段值
Object value = getMethod.invoke(source);
// 如果字段值不为空且目标对象中的对应字段值为空则调用setter方法将值设置到目标对象中
if (value != null && getMethod.invoke(target) == null) {
setMethod.invoke(target, value);
}
} catch (Exception e) {
// 捕获并打印异常信息
e.printStackTrace();
}
} catch (Exception e) {
// 捕获并打印异常信息
e.printStackTrace();
}
}
/**
* PM
* @param source TWTempertureDataPM
* @param target TWTempertureDataPM
*/
private void setPmValues(TWTempertureData source, TWTempertureData target) {
setIfNotNull(source, target, "pm1");
if (target.getPm1() == null) {
setIfNotNull(source, target, "pm2");
}
if (target.getPm2() == null) {
setIfNotNull(source, target, "pm10");
/**
* PM
* @param source TWTempertureDataPM
* @param target TWTempertureDataPM
*/
private void setPmValues(TWTempertureData source, TWTempertureData target) {
setIfNotNull(source, target, "pm1");
if (target.getPm1() == null) {
setIfNotNull(source, target, "pm2");
}
if (target.getPm2() == null) {
setIfNotNull(source, target, "pm10");
}
}
}
/**
*
*
* @param str
* @return 0
*/
private String capitalize(String str) {
// 如果字符串为null或者长度为0直接返回原字符串
if (str == null || str.length() == 0) {
return str;
/**
*
*
* @param str
* @return 0
*/
private String capitalize(String str) {
// 如果字符串为null或者长度为0直接返回原字符串
if (str == null || str.length() == 0) {
return str;
}
// 将字符串的第一个字符转换为大写,并与剩余部分拼接后返回
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
// 将字符串的第一个字符转换为大写,并与剩余部分拼接后返回
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
}

@ -23,7 +23,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
*
* @author zangch
* @date 2024-10-31
*/
@ -101,4 +101,13 @@ public class BaseBusbarInfoController extends BaseController
{
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);
}
/**
*
* */
@PostMapping("/countCabinet")
public int countCabinet() {
return baseCabinetInfoService.countBaseCabinetInfo();
}
}

@ -5,15 +5,15 @@ import com.ruoyi.base.domain.BaseBusbarInfo;
/**
* Mapper
*
*
* @author zangch
* @date 2024-10-31
*/
public interface BaseBusbarInfoMapper
public interface BaseBusbarInfoMapper
{
/**
*
*
*
* @param objId
* @return
*/
@ -21,7 +21,7 @@ public interface BaseBusbarInfoMapper
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -29,7 +29,7 @@ public interface BaseBusbarInfoMapper
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -37,7 +37,7 @@ public interface BaseBusbarInfoMapper
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -45,7 +45,7 @@ public interface BaseBusbarInfoMapper
/**
*
*
*
* @param objId
* @return
*/
@ -53,9 +53,11 @@ public interface BaseBusbarInfoMapper
/**
*
*
*
* @param objIds
* @return
*/
public int deleteBaseBusbarInfoByObjIds(Long[] objIds);
public int countBaseBusbarInfo();
}

@ -5,15 +5,15 @@ import com.ruoyi.base.domain.BaseCabinetInfo;
/**
* Mapper
*
*
* @author ruoyi
* @date 2024-10-31
*/
public interface BaseCabinetInfoMapper
public interface BaseCabinetInfoMapper
{
/**
*
*
*
* @param objId
* @return
*/
@ -21,7 +21,7 @@ public interface BaseCabinetInfoMapper
/**
*
*
*
* @param baseCabinetInfo
* @return
*/
@ -29,7 +29,7 @@ public interface BaseCabinetInfoMapper
/**
*
*
*
* @param baseCabinetInfo
* @return
*/
@ -37,7 +37,7 @@ public interface BaseCabinetInfoMapper
/**
*
*
*
* @param baseCabinetInfo
* @return
*/
@ -45,7 +45,7 @@ public interface BaseCabinetInfoMapper
/**
*
*
*
* @param objId
* @return
*/
@ -53,9 +53,11 @@ public interface BaseCabinetInfoMapper
/**
*
*
*
* @param objIds
* @return
*/
public int deleteBaseCabinetInfoByObjIds(Long[] objIds);
public int countBaseCabinetInfo();
}

@ -5,15 +5,15 @@ import com.ruoyi.base.domain.BaseBusbarInfo;
/**
* Service
*
*
* @author zangch
* @date 2024-10-31
*/
public interface IBaseBusbarInfoService
public interface IBaseBusbarInfoService
{
/**
*
*
*
* @param objId
* @return
*/
@ -21,7 +21,7 @@ public interface IBaseBusbarInfoService
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -29,7 +29,7 @@ public interface IBaseBusbarInfoService
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -37,7 +37,7 @@ public interface IBaseBusbarInfoService
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -45,7 +45,7 @@ public interface IBaseBusbarInfoService
/**
*
*
*
* @param objIds
* @return
*/
@ -53,9 +53,11 @@ public interface IBaseBusbarInfoService
/**
*
*
*
* @param objId
* @return
*/
public int deleteBaseBusbarInfoByObjId(Long objId);
public int countBaseBusbarInfo();
}

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

@ -13,12 +13,12 @@ import com.ruoyi.base.service.IBaseBusbarInfoService;
/**
* Service
*
*
* @author zangch
* @date 2024-10-31
*/
@Service
public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
{
@Autowired
private BaseBusbarInfoMapper baseBusbarInfoMapper;
@ -28,7 +28,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/**
*
*
*
* @param objId
* @return
*/
@ -40,7 +40,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -52,7 +52,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -75,9 +75,9 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
if (baseCabinetInfoList.isEmpty()) {
throw new ServiceException("未找到该电柜信息,请先新增电柜");
}
// 获取母排信息中的母排编码
Long busbarCode = baseBusbarInfo.getBusbarCode();
Long busbarCode = baseBusbarInfo.getBusbarCode();
// 创建一个新的母排信息对象并设置母排编码
BaseBusbarInfo searchBusbar = new BaseBusbarInfo();
searchBusbar.setBusbarCode(busbarCode);
@ -87,14 +87,14 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
if (!baseBusbarInfoList.isEmpty()) {
throw new ServiceException("该母排编号已存在,请重新输入");
}
// 插入母排信息到数据库中,并返回插入操作的结果
return baseBusbarInfoMapper.insertBaseBusbarInfo(baseBusbarInfo);
}
/**
*
*
*
* @param baseBusbarInfo
* @return
*/
@ -133,7 +133,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/**
*
*
*
* @param objIds
* @return
*/
@ -145,7 +145,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/**
*
*
*
* @param objId
* @return
*/
@ -154,4 +154,9 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
{
return baseBusbarInfoMapper.deleteBaseBusbarInfoByObjId(objId);
}
@Override
public int countBaseBusbarInfo(){
return baseBusbarInfoMapper.countBaseBusbarInfo();
}
}

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

@ -2,18 +2,19 @@ package com.ruoyi.record.mapper;
import java.util.List;
import com.ruoyi.record.domain.RecordBusbarAlarm;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
/**
* Mapper
*
*
* @author zangch
* @date 2024-12-03
*/
public interface RecordBusbarAlarmMapper
public interface RecordBusbarAlarmMapper
{
/**
*
*
*
* @param objId
* @return
*/
@ -21,7 +22,7 @@ public interface RecordBusbarAlarmMapper
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -29,7 +30,7 @@ public interface RecordBusbarAlarmMapper
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -37,7 +38,7 @@ public interface RecordBusbarAlarmMapper
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -45,7 +46,7 @@ public interface RecordBusbarAlarmMapper
/**
*
*
*
* @param objId
* @return
*/
@ -53,9 +54,11 @@ public interface RecordBusbarAlarmMapper
/**
*
*
*
* @param objIds
* @return
*/
public int deleteRecordBusbarAlarmByObjIds(Long[] objIds);
public List<RecordBusbarAlarmCountResult> recordBusbarAlarmCount(RecordBusbarAlarm recordBusbarAlarm);
}

@ -2,18 +2,19 @@ package com.ruoyi.record.service;
import java.util.List;
import com.ruoyi.record.domain.RecordBusbarAlarm;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
/**
* Service
*
*
* @author zangch
* @date 2024-12-03
*/
public interface IRecordBusbarAlarmService
public interface IRecordBusbarAlarmService
{
/**
*
*
*
* @param objId
* @return
*/
@ -21,7 +22,7 @@ public interface IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -29,7 +30,7 @@ public interface IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -37,7 +38,7 @@ public interface IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -45,7 +46,7 @@ public interface IRecordBusbarAlarmService
/**
*
*
*
* @param objIds
* @return
*/
@ -53,11 +54,11 @@ public interface IRecordBusbarAlarmService
/**
*
*
*
* @param objId
* @return
*/
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;
import java.util.List;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.record.mapper.RecordBusbarAlarmMapper;
@ -9,19 +11,19 @@ import com.ruoyi.record.service.IRecordBusbarAlarmService;
/**
* Service
*
*
* @author zangch
* @date 2024-12-03
*/
@Service
public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
{
@Autowired
private RecordBusbarAlarmMapper recordBusbarAlarmMapper;
/**
*
*
*
* @param objId
* @return
*/
@ -33,7 +35,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -45,7 +47,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -57,7 +59,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/**
*
*
*
* @param recordBusbarAlarm
* @return
*/
@ -69,7 +71,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/**
*
*
*
* @param objIds
* @return
*/
@ -81,7 +83,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/**
*
*
*
* @param objId
* @return
*/
@ -90,4 +92,10 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
{
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}
</foreach>
</delete>
<select id="recordBusbarAlarmCount" resultType="java.lang.Integer">
select count(*) from base_busbar_info
</select>
</mapper>

@ -117,4 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{objId}
</foreach>
</delete>
<select id="countBaseCabinetInfo" resultType="Integer">
select count(1) from base_cabinet_info
</select>
</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
DATE(record_time) AS record_date,
COUNT(*) AS alarm_count
@ -125,4 +125,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY
DATE(record_time)
</select>
</mapper>

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

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

Loading…
Cancel
Save