Browse Source

1、设备监控修复。

dev
mh 1 month ago
parent
commit
ad75b5ae36
  1. 2
      mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java
  2. 13
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java
  3. 3
      mh-common/src/main/java/com/mh/common/core/domain/vo/DeviceOperateMonitorVO.java
  4. 7
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  5. 8
      mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java
  6. 6
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  7. 2
      mh-system/src/main/resources/mapper/system/SysParamsMapper.xml

2
mh-admin/src/main/java/com/mh/web/controller/comprehensive/ProOverviewController.java

@ -47,7 +47,7 @@ public class ProOverviewController extends BaseController {
* 头像上传 * 头像上传
*/ */
@Log(title = "项目图标", businessType = BusinessType.UPDATE) @Log(title = "项目图标", businessType = BusinessType.UPDATE)
@PutMapping("/logo") @PostMapping("/logo")
public AjaxResult avatar(@RequestParam("logo") MultipartFile file, @RequestParam("proId") String proId) throws Exception public AjaxResult avatar(@RequestParam("logo") MultipartFile file, @RequestParam("proId") String proId) throws Exception
{ {
if (!file.isEmpty()) if (!file.isEmpty())

13
mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java

@ -34,6 +34,16 @@ public class CollectionParamsManageVO {
private String paramType; private String paramType;
/**
* 台账排序
*/
private int dlOrderNum;
/**
* 采集参数排序
*/
private int cmpOrderNum;
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this) return new ToStringBuilder(this)
@ -45,7 +55,8 @@ public class CollectionParamsManageVO {
.append("curValue", curValue) .append("curValue", curValue)
.append("curTime", curTime) .append("curTime", curTime)
.append("paramType", paramType) .append("paramType", paramType)
.append("dlOrderNum", dlOrderNum)
.append("cmpOrderNum", cmpOrderNum)
.toString(); .toString();
} }
} }

3
mh-common/src/main/java/com/mh/common/core/domain/vo/DeviceOperateMonitorVO.java

@ -43,6 +43,8 @@ public class DeviceOperateMonitorVO {
private String paramType; private String paramType;
private int orderNum;
private List<DeviceOperateMonitorVO> children; private List<DeviceOperateMonitorVO> children;
@Override @Override
@ -53,6 +55,7 @@ public class DeviceOperateMonitorVO {
.append("value", value) .append("value", value)
.append("time", time) .append("time", time)
.append("paramType", paramType) .append("paramType", paramType)
.append("orderNum", orderNum)
.append("children", children) .append("children", children)
.toString(); .toString();
} }

7
mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java

@ -171,7 +171,9 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" cpm.other_name, " + " cpm.other_name, " +
" cpm.cur_value, " + " cpm.cur_value, " +
" cpm.cur_time, " + " cpm.cur_time, " +
" cpm.param_type " + " cpm.param_type," +
" dl.order_num as dl_order_num," +
" cpm.order_num as cpm_order_num " +
"from " + "from " +
" collection_params_manage cpm " + " collection_params_manage cpm " +
"left join " + "left join " +
@ -179,7 +181,8 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" cpm.device_ledger_id = dl.id " + " cpm.device_ledger_id = dl.id " +
" where cpm.system_type = #{systemType} " + " where cpm.system_type = #{systemType} " +
" and cpm.param_type != '0' " + " and cpm.param_type != '0' " +
" order by dl.device_type, cpm.param_type ") " and cpm.param_type != '16' " +
" order by dl.device_type ,dl.order_num ,cpm.order_num ")
List<CollectionParamsManageVO> selectBySystemType(@Param("systemType") String systemType); List<CollectionParamsManageVO> selectBySystemType(@Param("systemType") String systemType);
@Select("select " + @Select("select " +

8
mh-system/src/main/java/com/mh/system/mapper/device/DataProcessMapper.java

@ -132,19 +132,19 @@ public interface DataProcessMapper {
void insertTable(@Param("data") DeviceReport data, @Param("tableName") String tableName); void insertTable(@Param("data") DeviceReport data, @Param("tableName") String tableName);
@Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " + @Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(MONTH FROM AGE(cur_time, #{curTime})) = 0 ") "where device_num = #{data.deviceNum} and EXTRACT(MONTH FROM AGE(cur_time, #{data.curTime})) = 0 ")
void updateTableMM(@Param("data") DeviceReport data, @Param("tableName") String tableName); void updateTableMM(@Param("data") DeviceReport data, @Param("tableName") String tableName);
@Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " + @Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(YEAR FROM AGE(cur_time, #{curTime})) = 0 ") "where device_num = #{data.deviceNum} and EXTRACT(YEAR FROM AGE(cur_time, #{data.curTime})) = 0 ")
void updateTableYY(@Param("data") DeviceReport data, @Param("tableName") String tableName); void updateTableYY(@Param("data") DeviceReport data, @Param("tableName") String tableName);
@Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " + @Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(DAY FROM AGE(cur_time, #{curTime})) = 0 ") "where device_num = #{data.deviceNum} and EXTRACT(DAY FROM AGE(cur_time, #{data.curTime})) = 0 ")
void updateTableDD(@Param("data") DeviceReport data, @Param("tableName") String tableName); void updateTableDD(@Param("data") DeviceReport data, @Param("tableName") String tableName);
@Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " + @Update("update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue},calc_value = (#{data.curValue} - last_value)*ratio,used_value = #{data.curValue} - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(HOUR FROM AGE(cur_time, #{curTime})) = 0 ") "where device_num = #{data.deviceNum} and EXTRACT(HOUR FROM AGE(cur_time, #{data.curTime})) = 0 ")
void updateTableHH(@Param("data") DeviceReport data, @Param("tableName") String tableName); void updateTableHH(@Param("data") DeviceReport data, @Param("tableName") String tableName);
/** /**

6
mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

@ -264,6 +264,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 根据deviceLedgerId进行分组,然后得出deviceLedgerId,deviceName赋值给DeviceOperateMonitorVO的id和name // 根据deviceLedgerId进行分组,然后得出deviceLedgerId,deviceName赋值给DeviceOperateMonitorVO的id和name
// 按设备台账ID分组 // 按设备台账ID分组
Map<String, List<CollectionParamsManageVO>> groupedByDevice = collectionParamsManages.stream() Map<String, List<CollectionParamsManageVO>> groupedByDevice = collectionParamsManages.stream()
.sorted(Comparator.comparing(CollectionParamsManageVO::getDlOrderNum))
.collect(Collectors.groupingBy(CollectionParamsManageVO::getDeviceLedgerId)); .collect(Collectors.groupingBy(CollectionParamsManageVO::getDeviceLedgerId));
// 转换分组结果为监控VO列表 // 转换分组结果为监控VO列表
@ -275,12 +276,13 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
DeviceOperateMonitorVO vo = new DeviceOperateMonitorVO(); DeviceOperateMonitorVO vo = new DeviceOperateMonitorVO();
vo.setId(firstItem.getDeviceLedgerId()); vo.setId(firstItem.getDeviceLedgerId());
vo.setName(firstItem.getDeviceName()); vo.setName(firstItem.getDeviceName());
vo.setOrderNum(firstItem.getDlOrderNum());
// 可补充其他需要聚合的字段 // 可补充其他需要聚合的字段
// vo.setStatus(calculateStatus(group)); // vo.setStatus(calculateStatus(group));
return vo; return vo;
}) })
.sorted(Comparator.comparing(DeviceOperateMonitorVO::getOrderNum))
.toList(); .toList();
// 在遍历monitorData,根据deviceLedgerId查询出collectionParamsManages集合对应的设备id,otherName对应name,curValue对应value,curTime对应time,paramType对应paramType,然后拼接到monitorData中children中 // 在遍历monitorData,根据deviceLedgerId查询出collectionParamsManages集合对应的设备id,otherName对应name,curValue对应value,curTime对应time,paramType对应paramType,然后拼接到monitorData中children中
// 处理子节点数据 // 处理子节点数据
@ -295,8 +297,10 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
child.setValue(String.valueOf(param.getCurValue())); child.setValue(String.valueOf(param.getCurValue()));
child.setTime(param.getCurTime()); child.setTime(param.getCurTime());
child.setParamType(param.getParamType()); child.setParamType(param.getParamType());
child.setOrderNum(param.getCmpOrderNum());
return child; return child;
}) })
.sorted(Comparator.comparing(DeviceOperateMonitorVO::getOrderNum))
.collect(Collectors.toList()); .collect(Collectors.toList());
mainVO.setChildren(children); mainVO.setChildren(children);
}); });

2
mh-system/src/main/resources/mapper/system/SysParamsMapper.xml

@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<update id="updateLogo"> <update id="updateLogo">
update sys_params set logo=#{logo}, updateBy = #{userName}, updateTime = current_timestamp where id=#{proId} update sys_params set logo=#{logo}, update_by = #{userName}, update_time = current_timestamp where id=#{proId}
</update> </update>

Loading…
Cancel
Save