Browse Source

代码调整

feature/big-screen
kerry 5 years ago
parent
commit
7e020fd047
  1. 4
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java
  2. 1
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  3. 24
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  5. 8
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  6. 18
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java
  7. 4
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

4
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java

@ -12,7 +12,7 @@ public abstract class AbstractPointInfo implements BasePointInfo {
protected int idleDayCount; // 到现在为止,埋点闲置的天数 protected int idleDayCount; // 到现在为止,埋点闲置的天数
//是否是测试模板 //是否是测试模板
protected boolean isTestTemplate; protected boolean testTemplate;
@Override @Override
public void resetIdleDayCount() { public void resetIdleDayCount() {
@ -42,7 +42,7 @@ public abstract class AbstractPointInfo implements BasePointInfo {
} }
public void setTestTemplate(boolean testTemplate) { public void setTestTemplate(boolean testTemplate) {
isTestTemplate = testTemplate; testTemplate = testTemplate;
} }
/** /**

1
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -67,7 +67,6 @@ public class ChartInfo extends AbstractPointInfo {
private BaseBook book; private BaseBook book;
private boolean testTemplate;
private boolean testChart; private boolean testChart;

24
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

@ -4,15 +4,15 @@ import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.burying.point.AbstractPointInfo; import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fr.third.joda.time.DateTime;
/** /**
* 对应一张模版的记录 * 对应一张模版的记录
@ -78,7 +78,7 @@ public class TemplateInfo extends AbstractPointInfo {
} }
public static TemplateInfo newInstance(String templateID, String originID, String saveRecord) { public static TemplateInfo newInstance(String templateID, String originID, String saveRecord) {
String createTime = new SimpleDateFormat(SIMPLE_DATE_PATTRN).format(Calendar.getInstance().getTime()); String createTime = DateTime.now().toString(SIMPLE_DATE_PATTRN);
return newInstance(templateID, originID, saveRecord, createTime); return newInstance(templateID, originID, saveRecord, createTime);
} }
@ -109,9 +109,9 @@ public class TemplateInfo extends AbstractPointInfo {
} }
public long getSaveTime() { public long getSaveTime() {
String save_record = (String) consumingMap.get(ATTR_SAVE_RECORD); String saveRecord = (String) consumingMap.get(ATTR_SAVE_RECORD);
JSONObject jo = new JSONObject(save_record); JSONObject jo = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
return jo.optLong("time"); return jo.getLong("time");
} }
public String getTemplateCreateTime() { public String getTemplateCreateTime() {
@ -131,7 +131,7 @@ public class TemplateInfo extends AbstractPointInfo {
if (idleDayCount >= 0) { if (idleDayCount >= 0) {
writer.attr(ATTR_DAY_COUNT, this.idleDayCount); writer.attr(ATTR_DAY_COUNT, this.idleDayCount);
} }
writer.attr(TEST_TEMPLATE_FLAG, this.isTestTemplate); writer.attr(TEST_TEMPLATE_FLAG, this.testTemplate);
writeProcessMap(writer); writeProcessMap(writer);
writeConsumingMap(writer); writeConsumingMap(writer);
@ -164,7 +164,7 @@ public class TemplateInfo extends AbstractPointInfo {
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) { if (!reader.isChildNode()) {
idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
isTestTemplate = reader.getAttrAsBoolean(TEST_TEMPLATE_FLAG, false); testTemplate = reader.getAttrAsBoolean(TEST_TEMPLATE_FLAG, false);
templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY); originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY);
} else { } else {
@ -196,7 +196,7 @@ public class TemplateInfo extends AbstractPointInfo {
@Override @Override
public boolean isTestTemplate() { public boolean isTestTemplate() {
return isTestTemplate; return testTemplate;
} }
public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) { public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) {
@ -219,8 +219,8 @@ public class TemplateInfo extends AbstractPointInfo {
@Override @Override
public Map<String, String> getSendInfo() { public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>(); Map<String, String> sendMap = new HashMap<>();
sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString()); sendMap.put(CONSUMING_URL, JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
sendMap.put(PROCESS_URL, new JSONObject(processMap).toString()); sendMap.put(PROCESS_URL, JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
return sendMap; return sendMap;
} }

4
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -2,6 +2,8 @@ package com.fr.design.mainframe.template.info;
import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.burying.point.AbstractPointInfo; import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -82,7 +84,7 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
} }
private TemplateInfo createTemplateInfo(String templateID, String originID, long saveTime, int timeConsume){ private TemplateInfo createTemplateInfo(String templateID, String originID, long saveTime, int timeConsume){
JSONObject saveRecord = new JSONObject(); JSONObject saveRecord = JSONFactory.createJSON(JSON.OBJECT);
saveRecord.put("time", saveTime); saveRecord.put("time", saveTime);
saveRecord.put("consume", timeConsume); saveRecord.put("consume", timeConsume);
if (this.contains(templateID)){ if (this.contains(templateID)){

8
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -3,7 +3,9 @@ package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -101,7 +103,7 @@ public class TemplateInfoCollectorTest {
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}",
new JSONObject(processMap).toString()); JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Assert.assertEquals(71113, consumingMap.get("uid")); Assert.assertEquals(71113, consumingMap.get("uid"));
Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time")); Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
@ -131,7 +133,7 @@ public class TemplateInfoCollectorTest {
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", new JSONObject(processMap).toString()); "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals(71113, consumingMap.get("uid")); Assert.assertEquals(71113, consumingMap.get("uid"));
@ -159,7 +161,7 @@ public class TemplateInfoCollectorTest {
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0,\"cell_count\":13," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0,\"cell_count\":13," +
"\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + "\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", new JSONObject(processMap).toString()); "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals(71113, consumingMap.get("uid")); Assert.assertEquals(71113, consumingMap.get("uid"));

18
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java

@ -3,6 +3,8 @@ package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -105,18 +107,18 @@ public class TemplateInfoTest {
assertJsonStringEquals("{\"uid\":71113,\"originID\":\"\",\"create_time\":\"2020-05-07 17:28\"," + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"\",\"create_time\":\"2020-05-07 17:28\"," +
"\"saveRecord\":\"{\\\"time\\\":1588843693000,\\\"consume\\\":4}\"," + "\"saveRecord\":\"{\\\"time\\\":1588843693000,\\\"consume\\\":4}\"," +
"\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," + "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", new JSONObject(consumingMap).toString()); "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
assertJsonStringEquals("{\"uid\":71113,\"originID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"create_time\":\"2020-05-07 17:45\",\"saveRecord\":\"{\\\"time\\\":1588844751000,\\\"consume\\\":1058}\"," + "\"create_time\":\"2020-05-07 17:45\",\"saveRecord\":\"{\\\"time\\\":1588844751000,\\\"consume\\\":1058}\"," +
"\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"," + "\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"," +
"\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", new JSONObject(consumingMap1).toString()); "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap1).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," + "\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"}", new JSONObject(processMap).toString()); "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," + "\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"}", new JSONObject(processMap1).toString()); "\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"}", JSONFactory.createJSON(JSON.OBJECT, processMap1).toString());
} }
private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException { private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException {
@ -126,16 +128,16 @@ public class TemplateInfoTest {
} }
@Test @Test
public void testGetSaveTime(){ public void testGetSaveTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
String saveRecord = (String) consumingMap.get("saveRecord"); String saveRecord = (String) consumingMap.get("saveRecord");
JSONObject object = new JSONObject(saveRecord); JSONObject object = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
Assert.assertEquals(1588843693000L, object.optLong("time")); Assert.assertEquals(1588843693000L, object.optLong("time"));
} }
@Test @Test
public void testGetTemplateCreateTime(){ public void testGetTemplateCreateTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals("2020-05-07 17:28", (String)consumingMap.get("create_time")); Assert.assertEquals("2020-05-07 17:28", (String) consumingMap.get("create_time"));
} }
} }

4
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -185,12 +185,12 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
} }
} }
private void addComponentCreateInfo(JSONObject jsonObject) { private void addComponentCreateInfo(JSONObject jsonObject) {
String componentID = jsonObject.optString("componentID"); String componentID = jsonObject.getString("componentID");
componentProcessInfoMap.put(componentID, jsonObject); componentProcessInfoMap.put(componentID, jsonObject);
} }
private void addComponentRemoveInfo(JSONObject jsonObject) { private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.optString("componentID"); String componentID = jsonObject.getString("componentID");
JSONObject info = componentProcessInfoMap.get(componentID); JSONObject info = componentProcessInfoMap.get(componentID);
if (info == null) { if (info == null) {
info = jsonObject; info = jsonObject;

Loading…
Cancel
Save