|
@@ -1,32 +1,54 @@
|
|
|
package info.aspirecn.rdc.iov.sjjh.servicenode.supplier.utils;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
-import cn.hutool.json.JSON;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.nio.charset.Charset;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author xusonglin
|
|
|
* @version V1.0
|
|
|
**/
|
|
|
+@Slf4j
|
|
|
@Component
|
|
|
public class VehicleJsonHelper {
|
|
|
private Map<String, String> millageObject;
|
|
|
private Map<String, Integer> totalMileObject;
|
|
|
private JSONObject earliestOrderMonthObject;
|
|
|
|
|
|
+ private String getJson(String path) {
|
|
|
+ InputStream is = this.getClass().getResourceAsStream(path);
|
|
|
+ if (is == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
|
|
+ String s;
|
|
|
+ StringBuilder configContentStr = new StringBuilder();
|
|
|
+ try {
|
|
|
+ while ((s = br.readLine()) != null) {
|
|
|
+ configContentStr.append(s);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
+ log.info("supplier10000036.getJson Exception=", e);
|
|
|
+ }
|
|
|
+ return configContentStr.toString();
|
|
|
+ }
|
|
|
+
|
|
|
public Map<String, String> getMillage() {
|
|
|
if (millageObject != null) {
|
|
|
return millageObject;
|
|
|
}
|
|
|
- String filePath = "millage.json";
|
|
|
- JSON json = JSONUtil.readJSON(FileUtil.file(filePath), Charset.defaultCharset());
|
|
|
- millageObject = com.alibaba.fastjson.JSON.parseObject(json.toString(), Map.class);
|
|
|
+
|
|
|
+ millageObject = JSON.parseObject(getJson("/config/millage.json"), Map.class);
|
|
|
return millageObject;
|
|
|
}
|
|
|
|
|
@@ -34,9 +56,7 @@ public class VehicleJsonHelper {
|
|
|
if (totalMileObject != null) {
|
|
|
return totalMileObject;
|
|
|
}
|
|
|
- String filePath = "totalMile.json";
|
|
|
- JSON json = JSONUtil.readJSON(FileUtil.file(filePath), Charset.defaultCharset());
|
|
|
- totalMileObject = com.alibaba.fastjson.JSON.parseObject(json.toString(), Map.class);
|
|
|
+ totalMileObject = JSON.parseObject(getJson("/config/totalMile.json"), Map.class);
|
|
|
return totalMileObject;
|
|
|
}
|
|
|
|
|
@@ -44,9 +64,8 @@ public class VehicleJsonHelper {
|
|
|
if (earliestOrderMonthObject != null) {
|
|
|
return earliestOrderMonthObject;
|
|
|
}
|
|
|
- String filePath = "earliestOrderMonth.json";
|
|
|
- JSON json = JSONUtil.readJSON(FileUtil.file(filePath), Charset.defaultCharset());
|
|
|
- earliestOrderMonthObject = com.alibaba.fastjson.JSON.parseObject(json.toString());
|
|
|
+
|
|
|
+ earliestOrderMonthObject = JSON.parseObject(getJson("/config/earliestOrderMonth.json"));
|
|
|
return earliestOrderMonthObject;
|
|
|
}
|
|
|
}
|