dnc设备参数接口只记录最新数据

master
zpl 3 years ago
parent dc8e624f71
commit bab8da36a2

@ -26,6 +26,7 @@ public interface EdcDataResourceService extends IService<EdcDataResource> {
List<EdcDataResource> selectList(EdcDataResource edcDataResource); List<EdcDataResource> selectList(EdcDataResource edcDataResource);
void removeAll(EdcDataResource edcDataResource);
/** /**
* -DNC * -DNC
* @param text * @param text

@ -42,6 +42,8 @@ public class EdcDataResourceServiceImpl extends ServiceImpl<EdcDataResourceMappe
@Autowired @Autowired
private EdcDataResourceMapper edcDataResourceMapper; private EdcDataResourceMapper edcDataResourceMapper;
@Autowired @Autowired
private EdcDataResourceService edcDataResourceService;
@Autowired
private DcParameterMapper dcParameterMapper; private DcParameterMapper dcParameterMapper;
@Autowired @Autowired
private ResrceService resrceService; private ResrceService resrceService;
@ -60,6 +62,13 @@ public class EdcDataResourceServiceImpl extends ServiceImpl<EdcDataResourceMappe
return super.list(queryWrapper); return super.list(queryWrapper);
} }
@Override
public void removeAll(EdcDataResource edcDataResource) {
QueryWrapper<EdcDataResource> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(edcDataResource);
super.remove(queryWrapper);
}
@Override @Override
public void saveResourceParamByMq(String text) { public void saveResourceParamByMq(String text) {
// json解析获取json中数据 // json解析获取json中数据
@ -68,9 +77,6 @@ public class EdcDataResourceServiceImpl extends ServiceImpl<EdcDataResourceMappe
String site = jsonObject.getString("SITE"); String site = jsonObject.getString("SITE");
String resource = jsonObject.getString("RESOURCE"); String resource = jsonObject.getString("RESOURCE");
String sendTime = jsonObject.getString("SEND_TIME"); String sendTime = jsonObject.getString("SEND_TIME");
if (StringUtil.isBlank(handle)) {
throw BusinessException.build("唯一标识不能为空!");
}
if (StringUtil.isBlank(site)) { if (StringUtil.isBlank(site)) {
throw BusinessException.build("站点不能为空!"); throw BusinessException.build("站点不能为空!");
} }
@ -94,12 +100,12 @@ public class EdcDataResourceServiceImpl extends ServiceImpl<EdcDataResourceMappe
map.put(param,paramVal); map.put(param,paramVal);
} }
// 获取数据收集组HANDLE // 获取数据收集组HANDLE
String resourceBo = HandleEnum.RESOURCE.getHandle(site, resource); String resourceBo = HandleEnum.RESOURCE.getHandle(site, "Z_EDC_DATA_RESOURCE");
String dcGroupBo = edcDataResourceMapper.getDcGroupBoByResourceBo(resourceBo); String dcGroupBo = edcDataResourceMapper.getDcGroupBoByResourceBo(resourceBo);
if (dcGroupBo == null){ if (dcGroupBo == null){
dcGroupBo = edcDataResourceMapper.getDcGroupBoByResourceBo2(resourceBo); dcGroupBo = edcDataResourceMapper.getDcGroupBoByResourceBo2(resourceBo);
if (dcGroupBo == null){ if (dcGroupBo == null){
throw BusinessException.build("设备编号未找到数据收集组!"); throw BusinessException.build("设备编号["+ resource +"]未找到数据收集组!");
} }
} }
// 获取数据收集组的字段配置信息 // 获取数据收集组的字段配置信息
@ -129,9 +135,12 @@ public class EdcDataResourceServiceImpl extends ServiceImpl<EdcDataResourceMappe
} }
StringBuilder sqlStr = new StringBuilder(); StringBuilder sqlStr = new StringBuilder();
String nowString = LocalDateTime.now().toString().substring(0, 19).replace('T', ' '); String nowString = LocalDateTime.now().toString().substring(0, 19).replace('T', ' ');
sqlStr.append("INSERT INTO Z_EDC_DATA_") EdcDataResource edcDataResource = new EdcDataResource();
.append(resource.replace("-","_")) edcDataResource.setResrce(resource);
.append("@ODS") edcDataResourceService.removeAll(edcDataResource);
sqlStr.append("INSERT INTO Z_EDC_DATA_RESOURCE")
//.append(resource.replace("-","_"))
//.append("@ODS")
.append(" (HANDLE,SITE,RESRCE,DC_GROUP_BO,DATE_TIME,CREATED_DATE_TIME,CREATE_USER,") .append(" (HANDLE,SITE,RESRCE,DC_GROUP_BO,DATE_TIME,CREATED_DATE_TIME,CREATE_USER,")
.append(columnSql.substring(0,columnSql.length()-1)) .append(columnSql.substring(0,columnSql.length()-1))
.append(") ") .append(") ")

Loading…
Cancel
Save