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);
void removeAll(EdcDataResource edcDataResource);
/**
* -DNC
* @param text

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

Loading…
Cancel
Save