diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 003a482b7..6f3c9bdea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -226,20 +226,27 @@ public class InformationCollector implements XMLReadable, XMLWriter { } private void sendFunctionsInfo(){ - long currentTime = new Date().getTime(); - ArrayList> content = null; - content = getFunctionsContentAsByte(currentTime); - boolean success = false; - String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); - if(content.size() > 0){ - for(int i=0; i> content = null; + content = getFunctionsContent(current, new Date(lastTime)); + boolean success = false; + FineLoggerFactory.getLogger().info("Start sent function records to the cloud center..."); + String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); + if(content.size() > 0){ + for(int i=0; i> records = new ArrayList>(); - QueryCondition condition = QueryFactory.create().addRestriction( - RestrictionFactory.lte(COLUMN_TIME, currentTime) - ); - try { - DataList focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition); - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - String bbsUserName = MarketConfig.getInstance().getBbsUsername(); - String uuid = envManager.getUUID(); - if(!focusPoints.isEmpty()){ - for(FocusPoint focusPoint : focusPoints.getList()){ - Map record = new HashMap<>(); - record.put(ATTR_ID, focusPoint.getId()); - record.put(ATTR_TEXT, focusPoint.getText()); - record.put(ATTR_SOURCE, focusPoint.getSource()); - record.put(ATTR_TIME, focusPoint.getTime().getTime()); - record.put(ATTR_TITLE, focusPoint.getTitle()); - record.put(ATTR_USER_NAME, bbsUserName); - record.put(ATTR_UUID, uuid); - records.add(record); - } - } - } catch (MetricException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return records; - } - - private void deleteFunctionRecords(long currentTime) { - QueryCondition condition = QueryFactory.create().addRestriction( - RestrictionFactory.lte(COLUMN_TIME, currentTime) - ); + public static ArrayList getFunctionsContent(Date current, Date last){ + ArrayList> records = new ArrayList>(); + QueryCondition condition = QueryFactory.create() + .addRestriction(RestrictionFactory.lte(COLUMN_TIME, current)) + .addRestriction(RestrictionFactory.gte(COLUMN_TIME, last)); try { - MetricRegistry.getMetric().clean(condition); - }catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage(), e); + DataList focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition); + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + String bbsUserName = MarketConfig.getInstance().getBbsUsername(); + String uuid = envManager.getUUID(); + if(!focusPoints.isEmpty()){ + for(FocusPoint focusPoint : focusPoints.getList()){ + Map record = new HashMap<>(); + record.put(ATTR_ID, focusPoint.getId()); + record.put(ATTR_TEXT, focusPoint.getText()); + record.put(ATTR_SOURCE, focusPoint.getSource()); + record.put(ATTR_TIME, focusPoint.getTime().getTime()); + record.put(ATTR_TITLE, focusPoint.getTitle()); + record.put(ATTR_USER_NAME, bbsUserName); + record.put(ATTR_UUID, uuid); + records.add(record); + } + } + } catch (MetricException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } + return records; } private class StartStopTime implements XMLReadable, XMLWriter {