Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
82c2246e2f
@ -196,7 +196,7 @@ public class SysIotModelController {
|
||||
return R.success(sysIotModelService.updateSysIotModelService(sysIotModelServiceDto));
|
||||
}
|
||||
|
||||
/** 物模型属性删除 */
|
||||
/** 物模型属性动作删除 */
|
||||
@PostMapping("/service/delete")
|
||||
public R<Void> deleteSysIotModelService(@RequestBody SysIotModelServiceDto sysIotModelServiceDto) {
|
||||
|
||||
|
@ -142,12 +142,12 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
List<SysEquipmentExcel> sysEquipmentList = sysEquipmentMapper.queryInfoById(sysEquipmentDto);
|
||||
//自定义别名 别名的key和实体类中的名称要对应上!!
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||
map.put("tag", "标识");
|
||||
map.put("objectType", "设备类型编码(10001:风电场,10002:机组)");
|
||||
map.put("iotModelName", "所属物模型名称");
|
||||
map.put("tag", "*标识(I:新增,U:修改,D:删除)");
|
||||
map.put("objectType", "*设备类型编码(10001:风电场,10002:机组)");
|
||||
map.put("iotModelCode", "所属物模型编码");
|
||||
map.put("code", "设备编码");
|
||||
map.put("name", "设备名称");
|
||||
map.put("iotModelName", "所属物模型名称");
|
||||
map.put("code", "*设备编码");
|
||||
map.put("name", "*设备名称");
|
||||
map.put("madeinFactory", "制造商");
|
||||
map.put("model", "型号规格");
|
||||
map.put("location", "安装位置");
|
||||
@ -155,13 +155,13 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
map.put("latitude", "纬度");
|
||||
map.put("installDate", "安装时间");
|
||||
map.put("remarks", "备注");
|
||||
map.put("mrid", "机构编码");
|
||||
map.put("orgName", "机构名称");
|
||||
map.put("parentEquipmentCode", "上级设备编码");
|
||||
map.put("parentEquipmentName", "上级设备名称");
|
||||
map.put("belongLine", "所属线路");
|
||||
map.put("standard", "是否为标杆机组(0:否,1:是)");
|
||||
map.put("nominalCapacity", "额定容量MW");
|
||||
map.put("mrid", "机构编码");
|
||||
map.put("parentEquipmentCode", "上级设备编码");
|
||||
|
||||
ExcelWriter writer = new ExcelWriter();
|
||||
writer.setHeaderAlias(map);
|
||||
@ -203,14 +203,13 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
// 遍历
|
||||
for (List<Object> row : list) {
|
||||
SysEquipment field = new SysEquipment();
|
||||
|
||||
// 根据编码获取物模型id
|
||||
if (StringUtils.hasText(row.get(3).toString())) {
|
||||
if (StringUtils.hasText(row.get(2).toString())) {
|
||||
Long iotModelId = sysIotModelMapper.queryIotModelIdByName(row.get(3).toString());
|
||||
field.setIotModelId(iotModelId);
|
||||
}
|
||||
if (StringUtils.hasText(row.get(18).toString())) {
|
||||
Long orgId = sysOrgMapper.queryOrgIdByName(row.get(18).toString());
|
||||
if (StringUtils.hasText(row.get(13).toString())) {
|
||||
Long orgId = sysOrgMapper.queryOrgIdByName(row.get(13).toString());
|
||||
field.setOrgId(orgId);
|
||||
}
|
||||
// 转换成字符串
|
||||
@ -231,10 +230,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
field.setInstallDate(sf.parse(row.get(11).toString()));
|
||||
}
|
||||
field.setRemarks(row.get(12).toString());
|
||||
field.setBelongLine(row.get(15).toString());
|
||||
field.setStandard(Integer.valueOf(row.get(16).toString()));
|
||||
if (StringUtils.hasText(row.get(17).toString())) {
|
||||
field.setNominalCapacity(Double.valueOf(row.get(17).toString()));
|
||||
field.setBelongLine(row.get(17).toString());
|
||||
field.setStandard(Integer.valueOf(row.get(18).toString()));
|
||||
if (StringUtils.hasText(row.get(19).toString())) {
|
||||
field.setNominalCapacity(Double.valueOf(row.get(19).toString()));
|
||||
}
|
||||
field.setParentEquipmentId(Long.valueOf(parentEquipmentId));
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
sysIotModelField.setRevision(1);
|
||||
|
||||
if (sysIotModelFieldDto.getAttributeType() == 140) {
|
||||
sysIotModelField.setDataType("int4");
|
||||
sysIotModelField.setDataType("tinyint");
|
||||
}
|
||||
|
||||
sysIotModelFieldMapper.insert(sysIotModelField);
|
||||
@ -178,7 +178,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
sysIotModelField.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysIotModelField.setAttributeCode(sysIotModelFieldDto.getAttributeCode().toLowerCase());
|
||||
if (sysIotModelFieldDto.getAttributeType() == 140) {
|
||||
sysIotModelField.setDataType("int4");
|
||||
sysIotModelField.setDataType("tinyint");
|
||||
}
|
||||
SysIotModelFieldVo sysIotModelFieldQuery = sysIotModelFieldMapper.selectByAttributeCode(sysIotModelFieldDto.getIotModelId(), sysIotModelFieldDto.getAttributeCode());
|
||||
if (!(sysIotModelFieldQuery == null)) {
|
||||
@ -264,16 +264,16 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||
SheetInfoBean sheetDTO = new SheetInfoBean();
|
||||
map.put("tag", "标识");
|
||||
map.put("iotModelName", "所属物模型名称");
|
||||
map.put("iotModelCode", "所属物模型编码");
|
||||
map.put("attributeCode", "物模型属性编码");
|
||||
map.put("attributeName", "物模型属性名称");
|
||||
map.put("attributeType", "属性类型(138:模拟量,139:累积量,140:离散量)");
|
||||
map.put("porder", "测点序号");
|
||||
map.put("iotModelName", "所属物模型名称");
|
||||
map.put("attributeCode", "*物模型属性编码");
|
||||
map.put("attributeName", "*物模型属性名称");
|
||||
map.put("attributeType", "*属性类型(138:模拟量,139:累积量,140:离散量)");
|
||||
map.put("porder", "*测点序号");
|
||||
map.put("subSystem", "子系統");
|
||||
map.put("dataType", "数据类型");
|
||||
map.put("visible", "是否可见(0:不可见,1:可见)");
|
||||
map.put("highSpeed", "属性频度:0低频属性,1高频属性");
|
||||
map.put("highSpeed", "属性频度(0低频属性,1高频属性)");
|
||||
sheetDTO.setSheetName("物模型属性");
|
||||
sheetDTO.setFieldAndAlias(map);
|
||||
sheetDTO.setCollection(sysIotModelFieldVoList);
|
||||
@ -283,12 +283,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
LinkedHashMap<String, String> map1= new LinkedHashMap<>();
|
||||
SheetInfoBean sheetDTO1 = new SheetInfoBean();
|
||||
map1.put("tag", "标识");
|
||||
map1.put("iotModelName", "所属物模型名称");
|
||||
map1.put("iotModelCode", "所属物模型编码");
|
||||
map1.put("serviceCode", "物模型动作编码");
|
||||
map1.put("serviceName", "物模型动作名称");
|
||||
map1.put("serviceType", "动作类型(146:遥控,147:遥调)");
|
||||
map1.put("porder", "测点序号");
|
||||
map1.put("iotModelName", "所属物模型名称");
|
||||
map1.put("serviceCode", "*物模型动作编码");
|
||||
map1.put("serviceName", "*物模型动作名称");
|
||||
map1.put("serviceType", "*动作类型(146:遥控,147:遥调)");
|
||||
map1.put("porder", "*测点序号");
|
||||
sheetDTO1.setSheetName("物模型动作");
|
||||
sheetDTO1.setFieldAndAlias(map1);
|
||||
sheetDTO1.setCollection(sysIotModelServiceVoList);
|
||||
|
@ -58,21 +58,131 @@ public class TDEngineService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建超级表
|
||||
*/
|
||||
public void createStable(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) {
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
Set<String> keySet = fieldNameTypeMap.keySet();
|
||||
if (keySet.size() != 0) {
|
||||
sb.append("CREATE STABLE IF NOT EXISTS ");
|
||||
sb.append(stableType).append(iotModelCode);
|
||||
sb.append(" (`updatetime` TIMESTAMP");
|
||||
|
||||
// 使用增强的 for 循环遍历键
|
||||
for (String key : keySet) {
|
||||
sb.append(", ");
|
||||
sb.append(key);
|
||||
sb.append(" " + fieldNameTypeMap.get(key));
|
||||
}
|
||||
sb.append(") TAGS (`deviceid` BIGINT);");
|
||||
try {
|
||||
System.out.println(sb.toString());
|
||||
pstmt.executeUpdate(sb.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("创建超级表失败,失败原因{}", e);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增超级表列
|
||||
*/
|
||||
public void addStableColumn(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) {
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
Set<String> keySet = fieldNameTypeMap.keySet();
|
||||
if (keySet.size() != 0) {
|
||||
for (String key : keySet) {
|
||||
sb.append("ALTER STABLE ");
|
||||
sb.append(stableType).append(iotModelCode);
|
||||
sb.append(" ADD COLUMN ");
|
||||
sb.append(key);
|
||||
sb.append(" " + fieldNameTypeMap.get(key));
|
||||
sb.append(";");
|
||||
try {
|
||||
pstmt.executeUpdate(sb.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("新增超级表列失败:{},失败原因{}", sb.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除超级表列
|
||||
*/
|
||||
public void deleteColumn(String stableName, String fieldCode) {
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
sb.append("ALTER STABLE ");
|
||||
sb.append(stableName);
|
||||
sb.append(" DROP COLUMN");;
|
||||
sb.append(fieldCode);
|
||||
sb.append(";");
|
||||
try {
|
||||
pstmt.executeUpdate(sb.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("删除超级表列失败:{},失败原因{}", sb.toString(), e);
|
||||
}
|
||||
|
||||
}catch (Exception ignored){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除超级表
|
||||
*/
|
||||
public void deleteStable(String stableName){
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
sb.append("DROP STABLE ");
|
||||
sb.append(stableName);
|
||||
sb.append(";");
|
||||
try {
|
||||
pstmt.executeUpdate(sb.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("删除超级表失败:{},失败原因{}", sb.toString(), e);
|
||||
}
|
||||
|
||||
}catch (Exception ignored){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 遍历所有的物模型存入内存中
|
||||
public void initIotModel(List<IotModelFieldVo> allIotModel, ConcurrentHashMap<String,Map<String, Object>> highIotFieldMap,ConcurrentHashMap<String,Map<String, Object>> lowIotFieldMap) {
|
||||
public void initIotModel(List<IotModelFieldVo> allIotModel, ConcurrentHashMap<String, Map<String, Object>> highIotFieldMap, ConcurrentHashMap<String, Map<String, Object>> lowIotFieldMap) {
|
||||
// 创建物模型超级表
|
||||
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
|
||||
ListUtil.page(allIotModel, batchSize, list ->{
|
||||
ListUtil.page(allIotModel, batchSize, list -> {
|
||||
|
||||
for (IotModelFieldVo info : list) {
|
||||
StringBuilder sb = new StringBuilder(1024*1024);
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
Map<String, Object> map = highIotFieldMap.get(info.getIotModelCode());
|
||||
Set<String> keySet = map.keySet();
|
||||
if (keySet.size() != 0){
|
||||
if (keySet.size() != 0) {
|
||||
sb.append("CREATE STABLE IF NOT EXISTS ");
|
||||
sb.append("h_").append(info.getIotModelCode());
|
||||
sb.append(" (`updatetime` TIMESTAMP");
|
||||
@ -81,7 +191,7 @@ public class TDEngineService {
|
||||
for (String key : map.keySet()) {
|
||||
sb.append(", ");
|
||||
sb.append(key);
|
||||
sb.append(" float");
|
||||
sb.append(" "+map.get(key));
|
||||
}
|
||||
sb.append(") TAGS (`deviceid` BIGINT);");
|
||||
try {
|
||||
@ -94,10 +204,10 @@ public class TDEngineService {
|
||||
|
||||
}
|
||||
for (IotModelFieldVo info : list) {
|
||||
StringBuilder sb = new StringBuilder(1024*1024);
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
sb.setLength(0);
|
||||
Map<String, Object> map = lowIotFieldMap.get(info.getIotModelCode());
|
||||
if (map.keySet().size() != 0){
|
||||
if (map.keySet().size() != 0) {
|
||||
sb.append("CREATE STABLE IF NOT EXISTS ");
|
||||
sb.append("l_").append(info.getIotModelCode());
|
||||
sb.append(" (`updatetime` TIMESTAMP");
|
||||
@ -105,7 +215,7 @@ public class TDEngineService {
|
||||
for (String key : map.keySet()) {
|
||||
sb.append(", ");
|
||||
sb.append(key);
|
||||
sb.append(" float");
|
||||
sb.append(" "+map.get(key));
|
||||
}
|
||||
sb.append(") TAGS (`deviceid` BIGINT);");
|
||||
try {
|
||||
@ -125,20 +235,20 @@ public class TDEngineService {
|
||||
|
||||
@Async
|
||||
public void updateYCHighValues(List<RTData> values, String iotModelCode) {
|
||||
StringBuilder sb = new StringBuilder(1024*1024);
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
ListUtil.page(values, batchSize, (list)->{
|
||||
ListUtil.page(values, batchSize, (list) -> {
|
||||
sb.setLength(0);
|
||||
sb.append("insert into ");
|
||||
for (RTData dv : list) {
|
||||
sb.append("h");
|
||||
sb.append(dv.getDeviceId());
|
||||
sb.append(" using h_" );
|
||||
sb.append(" using h_");
|
||||
sb.append(iotModelCode);
|
||||
sb.append(" tags (");
|
||||
sb.append(dv.getDeviceId());
|
||||
sb.append(") (");
|
||||
sb.append(") (updatetime");
|
||||
dv.getValues().forEach((key, value) ->
|
||||
sb.append(",").append(key)
|
||||
);
|
||||
@ -163,20 +273,20 @@ public class TDEngineService {
|
||||
|
||||
@Async
|
||||
public void updateYCLowValues(List<RTData> values, String iotModelCode) {
|
||||
StringBuilder sb = new StringBuilder(1024*1024);
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
ListUtil.page(values, batchSize, (list)->{
|
||||
ListUtil.page(values, batchSize, (list) -> {
|
||||
sb.setLength(0);
|
||||
sb.append("insert into ");
|
||||
for (RTData dv : list) {
|
||||
sb.append("l");
|
||||
sb.append(dv.getDeviceId());
|
||||
sb.append(" using l_" );
|
||||
sb.append(" using l_");
|
||||
sb.append(iotModelCode);
|
||||
sb.append(" tags (");
|
||||
sb.append(dv.getDeviceId());
|
||||
sb.append(") (");
|
||||
sb.append(") (updatetime");
|
||||
dv.getValues().forEach((key, value) ->
|
||||
sb.append(",").append(key)
|
||||
);
|
||||
@ -201,16 +311,16 @@ public class TDEngineService {
|
||||
|
||||
@Async
|
||||
public void updateStataValues(List<RTData> values, String iotModelCode) {
|
||||
StringBuilder sb = new StringBuilder(1024*1024);
|
||||
StringBuilder sb = new StringBuilder(1024 * 1024);
|
||||
try (Connection conn = hikariDataSource.getConnection();
|
||||
Statement pstmt = conn.createStatement()) {
|
||||
ListUtil.page(values, batchSize, (list)->{
|
||||
ListUtil.page(values, batchSize, (list) -> {
|
||||
sb.setLength(0);
|
||||
sb.append("insert into ");
|
||||
for (RTData dv : list) {
|
||||
sb.append("d");
|
||||
sb.append(dv.getDeviceId());
|
||||
sb.append(" using " );
|
||||
sb.append(" using ");
|
||||
sb.append(iotModelCode);
|
||||
sb.append(" tags (");
|
||||
sb.append(dv.getDeviceId());
|
||||
|
@ -218,16 +218,16 @@ public class DataServiceImpl implements DataService {
|
||||
String key = String.valueOf(item.getId());
|
||||
iotModelMap.put(key, item.getIotModelCode());
|
||||
List<SysIotModelField> allIotModelField = sysIotModelMapper.getAllIotModelField(item.getId());
|
||||
List<String> LowModelFieldList = allIotModelField.stream().filter(field -> field.getHighSpeed() == 0).map(SysIotModelField::getAttributeCode).collect(Collectors.toList());
|
||||
List<String> HighModelFieldList = allIotModelField.stream().filter(field -> field.getHighSpeed() == 1).map(SysIotModelField::getAttributeCode).collect(Collectors.toList());
|
||||
Map<String,String> LowModelFieldList = allIotModelField.stream().filter(field -> field.getHighSpeed() == 0).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
|
||||
Map<String,String> HighModelFieldList = allIotModelField.stream().filter(field -> field.getHighSpeed() == 1).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (String field : HighModelFieldList) {
|
||||
map.put(field, null);
|
||||
for (String field : HighModelFieldList.keySet()) {
|
||||
map.put(field, HighModelFieldList.get(field));
|
||||
}
|
||||
highIotFieldMap.put(item.getIotModelCode(), map);
|
||||
Map<String, Object> lowMap = new HashMap<>();
|
||||
for (String field : LowModelFieldList) {
|
||||
lowMap.put(field, null);
|
||||
for (String field : LowModelFieldList.keySet()) {
|
||||
lowMap.put(field, LowModelFieldList.get(field));
|
||||
}
|
||||
lowIotFieldMap.put(item.getIotModelCode(), lowMap);
|
||||
}
|
||||
|
@ -61,8 +61,8 @@
|
||||
<select id="getIotModelFieldByEquipmentId" resultType="com.das.modules.node.domain.vo.IotModelVo">
|
||||
select simf.attribute_type as attributeType,sims.service_type as serviceType, se.iot_addr as iotAddr,si.equipment_attribute as equipmentAttribute,si.equipment_service as equipmentService, si.params, simf.highspeed as highSpeed from sys_imptabmapping si
|
||||
left join sys_equipment se on si.equipment_id = se.id
|
||||
left join sys_iot_model_field simf on si.equipment_attribute = simf.attribute_code
|
||||
left join sys_iot_model_service sims on si.equipment_service = sims.service_code
|
||||
left join sys_iot_model_field simf on si.equipment_attribute = simf.attribute_code and se.iot_model_id = simf.iot_model_id
|
||||
left join sys_iot_model_service sims on si.equipment_service = sims.service_code and se.iot_model_id = sims.iot_model_id
|
||||
where si.equipment_id = #{equipmentId}
|
||||
</select>
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
||||
where se.id = #{id}
|
||||
</select>
|
||||
<select id="getAllIotModelField" resultType="com.das.modules.equipment.entity.SysIotModelField">
|
||||
select simf.attribute_code as attributeCode,simf.highspeed as highSpeed from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
|
||||
select simf.attribute_code as attributeCode,simf.highspeed as highSpeed,simf.datatype as dataType from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
|
||||
</select>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user