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,59 +170,59 @@ 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));
// 获取目标对象中指定字段的setter方法参数类型与getter方法返回类型一致 // 获取目标对象中指定字段的setter方法参数类型与getter方法返回类型一致
Method setMethod = TWTempertureData.class.getMethod("set" + capitalize(fieldName), getMethod.getReturnType()); Method setMethod = TWTempertureData.class.getMethod("set" + capitalize(fieldName), getMethod.getReturnType());
// 调用getter方法获取源对象中的字段值 // 调用getter方法获取源对象中的字段值
Object value = getMethod.invoke(source); Object value = getMethod.invoke(source);
// 如果字段值不为空且目标对象中的对应字段值为空则调用setter方法将值设置到目标对象中 // 如果字段值不为空且目标对象中的对应字段值为空则调用setter方法将值设置到目标对象中
if (value != null && getMethod.invoke(target) == null) { if (value != null && getMethod.invoke(target) == null) {
setMethod.invoke(target, value); setMethod.invoke(target, value);
}
} catch (Exception e) {
// 捕获并打印异常信息
e.printStackTrace();
} }
} catch (Exception e) {
// 捕获并打印异常信息
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");
} }
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);
}
} }

@ -23,7 +23,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author zangch * @author zangch
* @date 2024-10-31 * @date 2024-10-31
*/ */
@ -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();
}
} }

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

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

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

@ -13,12 +13,12 @@ import com.ruoyi.base.service.IBaseBusbarInfoService;
/** /**
* Service * Service
* *
* @author zangch * @author zangch
* @date 2024-10-31 * @date 2024-10-31
*/ */
@Service @Service
public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
{ {
@Autowired @Autowired
private BaseBusbarInfoMapper baseBusbarInfoMapper; private BaseBusbarInfoMapper baseBusbarInfoMapper;
@ -28,7 +28,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -40,7 +40,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/** /**
* *
* *
* @param baseBusbarInfo * @param baseBusbarInfo
* @return * @return
*/ */
@ -52,7 +52,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/** /**
* *
* *
* @param baseBusbarInfo * @param baseBusbarInfo
* @return * @return
*/ */
@ -75,9 +75,9 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
if (baseCabinetInfoList.isEmpty()) { if (baseCabinetInfoList.isEmpty()) {
throw new ServiceException("未找到该电柜信息,请先新增电柜"); throw new ServiceException("未找到该电柜信息,请先新增电柜");
} }
// 获取母排信息中的母排编码 // 获取母排信息中的母排编码
Long busbarCode = baseBusbarInfo.getBusbarCode(); Long busbarCode = baseBusbarInfo.getBusbarCode();
// 创建一个新的母排信息对象并设置母排编码 // 创建一个新的母排信息对象并设置母排编码
BaseBusbarInfo searchBusbar = new BaseBusbarInfo(); BaseBusbarInfo searchBusbar = new BaseBusbarInfo();
searchBusbar.setBusbarCode(busbarCode); searchBusbar.setBusbarCode(busbarCode);
@ -87,14 +87,14 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
if (!baseBusbarInfoList.isEmpty()) { if (!baseBusbarInfoList.isEmpty()) {
throw new ServiceException("该母排编号已存在,请重新输入"); throw new ServiceException("该母排编号已存在,请重新输入");
} }
// 插入母排信息到数据库中,并返回插入操作的结果 // 插入母排信息到数据库中,并返回插入操作的结果
return baseBusbarInfoMapper.insertBaseBusbarInfo(baseBusbarInfo); return baseBusbarInfoMapper.insertBaseBusbarInfo(baseBusbarInfo);
} }
/** /**
* *
* *
* @param baseBusbarInfo * @param baseBusbarInfo
* @return * @return
*/ */
@ -133,7 +133,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/** /**
* *
* *
* @param objIds * @param objIds
* @return * @return
*/ */
@ -145,7 +145,7 @@ public class BaseBusbarInfoServiceImpl implements IBaseBusbarInfoService
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -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,18 +2,19 @@ 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
* *
* @author zangch * @author zangch
* @date 2024-12-03 * @date 2024-12-03
*/ */
public interface RecordBusbarAlarmMapper public interface RecordBusbarAlarmMapper
{ {
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -21,7 +22,7 @@ public interface RecordBusbarAlarmMapper
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -29,7 +30,7 @@ public interface RecordBusbarAlarmMapper
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -37,7 +38,7 @@ public interface RecordBusbarAlarmMapper
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -45,7 +46,7 @@ public interface RecordBusbarAlarmMapper
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -53,9 +54,11 @@ public interface RecordBusbarAlarmMapper
/** /**
* *
* *
* @param objIds * @param objIds
* @return * @return
*/ */
public int deleteRecordBusbarAlarmByObjIds(Long[] objIds); 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 java.util.List;
import com.ruoyi.record.domain.RecordBusbarAlarm; import com.ruoyi.record.domain.RecordBusbarAlarm;
import com.ruoyi.record.domain.VO.RecordBusbarAlarmCountResult;
/** /**
* Service * Service
* *
* @author zangch * @author zangch
* @date 2024-12-03 * @date 2024-12-03
*/ */
public interface IRecordBusbarAlarmService public interface IRecordBusbarAlarmService
{ {
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -21,7 +22,7 @@ public interface IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -29,7 +30,7 @@ public interface IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -37,7 +38,7 @@ public interface IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -45,7 +46,7 @@ public interface IRecordBusbarAlarmService
/** /**
* *
* *
* @param objIds * @param objIds
* @return * @return
*/ */
@ -53,11 +54,11 @@ public interface IRecordBusbarAlarmService
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
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;
@ -9,19 +11,19 @@ import com.ruoyi.record.service.IRecordBusbarAlarmService;
/** /**
* Service * Service
* *
* @author zangch * @author zangch
* @date 2024-12-03 * @date 2024-12-03
*/ */
@Service @Service
public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
{ {
@Autowired @Autowired
private RecordBusbarAlarmMapper recordBusbarAlarmMapper; private RecordBusbarAlarmMapper recordBusbarAlarmMapper;
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -33,7 +35,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -45,7 +47,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -57,7 +59,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/** /**
* *
* *
* @param recordBusbarAlarm * @param recordBusbarAlarm
* @return * @return
*/ */
@ -69,7 +71,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/** /**
* *
* *
* @param objIds * @param objIds
* @return * @return
*/ */
@ -81,7 +83,7 @@ public class RecordBusbarAlarmServiceImpl implements IRecordBusbarAlarmService
/** /**
* *
* *
* @param objId * @param objId
* @return * @return
*/ */
@ -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