|
@@ -3,12 +3,20 @@ package com.boman.gen.controller;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.boman.gen.mapper.MoveDataMapper;
|
|
import com.boman.gen.mapper.MoveDataMapper;
|
|
|
|
+import com.google.gson.JsonArray;
|
|
|
|
+import com.google.gson.JsonElement;
|
|
|
|
+import com.google.gson.JsonObject;
|
|
|
|
+import com.google.gson.JsonParser;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.BufferedWriter;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileReader;
|
|
|
|
+import java.io.FileWriter;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -24,14 +32,69 @@ public class MoveDataController {
|
|
|
|
|
|
|
|
|
|
@GetMapping("/hj/{limit}/{offset}")
|
|
@GetMapping("/hj/{limit}/{offset}")
|
|
- public String moveData(@PathVariable("limit") int limit, @PathVariable("offset") int offset){
|
|
|
|
|
|
+ public String moveData(@PathVariable("limit") int limit, @PathVariable("offset") int offset) {
|
|
List<JSONObject> select = moveDataMapper.select(limit, offset);
|
|
List<JSONObject> select = moveDataMapper.select(limit, offset);
|
|
return JSON.toJSONString(select);
|
|
return JSON.toJSONString(select);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/selectY/{limit}/{offset}")
|
|
@GetMapping("/selectY/{limit}/{offset}")
|
|
- public String selectY(@PathVariable("limit") int limit, @PathVariable("offset") int offset){
|
|
|
|
|
|
+ public String selectY(@PathVariable("limit") int limit, @PathVariable("offset") int offset) {
|
|
List<JSONObject> select = moveDataMapper.select(limit, offset);
|
|
List<JSONObject> select = moveDataMapper.select(limit, offset);
|
|
return JSON.toJSONString(select);
|
|
return JSON.toJSONString(select);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+ private static void jsonToExcel() throws Exception {
|
|
|
|
+ JsonParser jsonParser = new JsonParser();
|
|
|
|
+ JsonArray asJsonArray = (JsonArray) jsonParser.parse(new FileReader("F:\\desk\\hj_hj_all.json"));
|
|
|
|
+ for (int i = 0; i < asJsonArray.size(); i++) {
|
|
|
|
+ JsonElement jsonElement = asJsonArray.get(i);
|
|
|
|
+ JsonObject featuresObj = jsonElement.getAsJsonObject();
|
|
|
|
+ String zjlx = getString(featuresObj, "zjlx");
|
|
|
|
+ String zjhm = getString(featuresObj, "zjhm");
|
|
|
|
+ String hh = getString(featuresObj, "hh");
|
|
|
|
+ String xz = getString(featuresObj, "xz");
|
|
|
|
+ String hjdxz = getString(featuresObj, "hjdxz");
|
|
|
|
+ String yhzgx = getString(featuresObj, "yhzgx");
|
|
|
|
+ String hzxm = getString(featuresObj, "hzxm");
|
|
|
|
+ String hzzjlx = getString(featuresObj, "hzzjlx");
|
|
|
|
+ String hzsfhm = getString(featuresObj, "hzsfhm");
|
|
|
|
+ String xm = getString(featuresObj, "xm");
|
|
|
|
+ String csrq = getString(featuresObj, "csrq");
|
|
|
|
+ String xb = getString(featuresObj, "xb");
|
|
|
|
+ String hhid = getString(featuresObj, "hhid");
|
|
|
|
+ String hklx = getString(featuresObj, "hklx");
|
|
|
|
+ String swrq = getString(featuresObj, "swrq");
|
|
|
|
+ String akmlxdh = getString(featuresObj, "akmlxdh");
|
|
|
|
+ String lxdh = getString(featuresObj, "lxdh");
|
|
|
|
+ String akmdz = getString(featuresObj, "akmdz");
|
|
|
|
+
|
|
|
|
+ String sqlStr = "insert into hj_hj (zjlx, zjhm, hh, xz, hjdxz, yhzgx,hzxm,hzzjlx, hzsfhm,xm,csrq,xb,hhid,hklx,swrq,akmlxdh,lxdh,akmdz) " +
|
|
|
|
+ "values (" + zjlx + ", " + zjhm + ", " + hh + ", " + xz + ", " + hjdxz + ", " + yhzgx + ", "
|
|
|
|
+ + hzxm + ", " + hzzjlx + ", " + hzsfhm + " , " + xm + ", " + csrq + ", " + xb + ", " + hhid
|
|
|
|
+ + ", " + hklx + ", " + swrq + ", " + akmlxdh + ", " + lxdh + ", " + akmdz + "); -- " + i + "\r\n";
|
|
|
|
+ System.err.println("count: " + i + ", " + sqlStr);
|
|
|
|
+ File file = new File("F:\\desk\\hj_hj_all.sql");
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ file.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ FileWriter fileWriter = new FileWriter(file, true);
|
|
|
|
+ BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
|
|
|
+ bufferedWriter.write(sqlStr);
|
|
|
|
+ bufferedWriter.close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String getString(JsonObject featuresObj, String type) {
|
|
|
|
+ JsonElement zjlx = featuresObj.get(type);
|
|
|
|
+ if (null == zjlx) {
|
|
|
|
+ return "''";
|
|
|
|
+ }
|
|
|
|
+// String zjlx1 = zjlx.toString().replace("\"", "");
|
|
|
|
+ return zjlx.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
|
+ System.out.println();
|
|
|
|
+ jsonToExcel();
|
|
|
|
+ }
|
|
|
|
+}
|