Browse Source

1、策略管理、设备操作优化;

dev
mh 4 weeks ago
parent
commit
be1daddc9a
  1. 1
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  2. 8
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  3. 7
      mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java
  4. 8
      mh-system/src/main/java/com/mh/system/service/policy/impl/PolicyManageServiceImpl.java

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

@ -182,6 +182,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" where cpm.system_type = #{systemType} " +
" and cpm.param_type != '0' " +
" and cpm.param_type != '16' " +
" and cpm.is_use = 0 " +
" order by dl.device_type ,dl.order_num ,cpm.order_num ")
List<CollectionParamsManageVO> selectBySystemType(@Param("systemType") String systemType);

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

@ -154,13 +154,17 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 批量更新
chillersEntities.forEach(chillerEntity -> {
log.info("chillerEntity: {}", chillerEntity.toString());
collectionParamsManageMapper.updateById(chillerEntity);
if (chillerEntity.getId()!= null && !StringUtils.isEmpty(chillerEntity.getId())) {
collectionParamsManageMapper.updateById(chillerEntity);
}
});
// 根据台账id更新台账在线情况
// 根据chillerEntity使用stream流获取台账id分组数据
chillersEntities.stream().map(CollectionParamsManage::getDeviceLedgerId).distinct().forEach(deviceLedgerId -> {
// 根据台账id 更新 device_ledger 在线情况,0:在线,1:离线
deviceLedgerMapper.updateOnlineStatus(deviceLedgerId);
if (!StringUtils.isEmpty(deviceLedgerId)) {
deviceLedgerMapper.updateOnlineStatus(deviceLedgerId);
}
});
// 根据网关id更新网关在线情况
chillersEntities.stream().map(CollectionParamsManage::getGatewayId).distinct().forEach(gatewayId -> {

7
mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java

@ -14,6 +14,7 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -56,6 +57,12 @@ public class OperationDeviceServiceImpl implements IOperationDeviceService {
String message = changeValue.getParam();
// 获取报文类型
Integer type = changeValue.getType();
if (type != null) {
if (type == 1) {
// 设置延时开关时间,参数需要*1000
message = new BigDecimal(message).multiply(new BigDecimal("1000")).toString();
}
}
// 获取报文其他信息
String otherName = changeValue.getOtherName();
if (StringUtils.isEmpty(otherName)) {

8
mh-system/src/main/java/com/mh/system/service/policy/impl/PolicyManageServiceImpl.java

@ -7,6 +7,7 @@ import com.mh.system.mapper.policy.PolicyManageMapper;
import com.mh.system.service.policy.IPolicyManageService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@ -40,6 +41,13 @@ public class PolicyManageServiceImpl implements IPolicyManageService {
Map<String, List<PolicyManage>> listMap = policyManages.stream()
// 先按PolicyType排序
.sorted(Comparator.comparing(PolicyManage::getPolicyType))
// 处理每个PolicyManage对象的curValue字段
.peek(policy -> {
if (funPolicyType.equals("2")) {
policy.setCurValue(BigDecimal.valueOf(policy.getCurValue()
.divide(new BigDecimal(1000)).intValue())); // 除以1000并保留整数
}
})
// 再按PolicyName分组
.collect(Collectors.groupingBy(PolicyManage::getPolicyName, Collectors.toList()));
// 在遍历赋值给DeviceMonitorDTO,key给name,value给list

Loading…
Cancel
Save