mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -103,5 +103,5 @@ rabbitmqctl set_permissions --vhost /coal/test datacollector '' 'sysExchange' 'p
|
||||
|
||||
```
|
||||
|
||||
gost-windows-amd64.exe -L=tcp://:5672/192.168.59.128:5672
|
||||
D:\dev\gost-windows-amd64.exe -L=tcp://:5672/192.168.59.128:5672
|
||||
```
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lihongjie.coal.pdcDevice.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.dataCollector.entity.DataCollectorEntity;
|
||||
import cn.lihongjie.coal.pdcDevice.entity.PdcDeviceEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -13,4 +14,10 @@ public interface PdcDeviceRepository extends BaseRepository<PdcDeviceEntity> {
|
||||
|
||||
@Query("select distinct deviceGroup from PdcDeviceEntity where organizationId = ?1")
|
||||
List<String> deviceGroups(String organizationId);
|
||||
|
||||
@Query("select count(p) from PdcDeviceEntity p where p.dataCollector = ?1 and p.deviceGroup != ?2")
|
||||
long countByDataCollectorAndDeviceGroup(DataCollectorEntity dataCollector, String deviceGroup);
|
||||
|
||||
@Query("select exists(select 1 from PdcDeviceDataEntity where id in ?1)")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,14 @@ public class PdcDeviceService extends BaseService<PdcDeviceEntity, PdcDeviceRepo
|
||||
throw new BizException("同一个数据采集器下MODBUS地址不能重复");
|
||||
}
|
||||
|
||||
|
||||
long count2 = repository.countByDataCollectorAndDeviceGroup(entity.getDataCollector(), entity.getDeviceGroup());
|
||||
|
||||
if (count2 > 0) {
|
||||
throw new BizException("同一个数据采集器只能绑定到同一个分组");
|
||||
}
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
@@ -105,6 +113,12 @@ public class PdcDeviceService extends BaseService<PdcDeviceEntity, PdcDeviceRepo
|
||||
throw new BizException("同一个数据采集器下MODBUS地址不能重复");
|
||||
}
|
||||
|
||||
long count2 = repository.countByDataCollectorAndDeviceGroup(entity.getDataCollector(), entity.getDeviceGroup());
|
||||
|
||||
if (count2 > 0) {
|
||||
throw new BizException("同一个数据采集器只能绑定到同一个分组");
|
||||
}
|
||||
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
@@ -121,6 +135,13 @@ public class PdcDeviceService extends BaseService<PdcDeviceEntity, PdcDeviceRepo
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据 " + "已归档,无法删除");
|
||||
});
|
||||
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("设备已经绑定数据,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lihongjie.coal.pdcDeviceData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.pdcDevice.dto.PdcDeviceDto;
|
||||
import cn.lihongjie.coal.base.dto.SimpleDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
public class PdcDeviceDataDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private PdcDeviceDto device;
|
||||
private SimpleDto device;
|
||||
|
||||
private LocalDateTime time;
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class PdcDeviceRealTimeDataService
|
||||
|
||||
|
||||
|
||||
select a.*, round(cast(coalesce(b.time_total, (a.time_total / (b.time_total * 100.0)), 0 ) as numeric),3)as time_percent from tmp2 a left join tmp2 b on b.coal_type = '2'
|
||||
select a.*, round(cast(case when b.time_total is null or b.time_total = 0 then 0 else ((a.time_total / b.time_total) * 100.0) end as numeric),3)as time_percent, b.time_total as bt from tmp2 a left join tmp2 b on b.coal_type = '2'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,13 @@ package cn.lihongjie.coal.pdcDeviceSupplier.repository;
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.pdcDeviceSupplier.entity.PdcDeviceSupplierEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface PdcDeviceSupplierRepository extends BaseRepository<PdcDeviceSupplierEntity> {}
|
||||
public interface PdcDeviceSupplierRepository extends BaseRepository<PdcDeviceSupplierEntity> {
|
||||
@Query("select exists (select 1 from PdcDeviceEntity where supplier.id in ?1)")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,11 @@ public class PdcDeviceSupplierService
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据 " + "已归档,无法删除");
|
||||
});
|
||||
|
||||
if (this.repository.isLinked(request.getIds())){
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user