|
|
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static com.steerinfo.dil.util.EasyExcelUitl.exportExcelFile;
|
|
|
@@ -345,27 +346,30 @@ public class UniversalController extends BaseRESTfulController {
|
|
|
@ApiOperation("通用导出")
|
|
|
@PostMapping("/excleExport")
|
|
|
public RESTfulResult excleExport(@RequestBody Map<String,Object> map) throws IOException {
|
|
|
-
|
|
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(map));
|
|
|
jsonObject.putAll( JSONObject.parseObject(JSONObject.toJSONString(map.get("requestQuery"))));
|
|
|
- JSONObject json = HttpUtil.sendPost("http://http://172.16.90.202:8083"+map.get("requestUrl").toString(),jsonObject);
|
|
|
-// String jsonStr = getJsonData(jsonObject, "http://localhost:8080"+map.get("requestUrl").toString());
|
|
|
-// JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
- System.out.println(json);
|
|
|
+ String url = "http://172.16.90.202:80"+map.get("requestUrl").toString() + "&pageNum=1&pageSize=10000";
|
|
|
+ JSONObject json = HttpUtil.sendPost(url,jsonObject);
|
|
|
Map<String, Object> data = (Map<String, Object>) json.get("data");
|
|
|
String listStr = data.get("list").toString();
|
|
|
String columnDataStr=data.get("columnData").toString();
|
|
|
- List<Map<String,Object>> listMap = JSON.parseObject(listStr,new TypeReference<List<Map<String,Object>>>(){});
|
|
|
+ List<Map<String,Object>> listMap = JSON.parseObject(listStr,new TypeReference<List<Map<String,Object>>>(){});
|
|
|
List<Map<String,Object>> columnData = JSON.parseObject(columnDataStr,new TypeReference<List<Map<String,Object>>>(){});
|
|
|
LinkedHashMap<String, String> columnMaps = Maps.newLinkedHashMap();
|
|
|
for (int i = 0; i <columnData.size() ; i++) {
|
|
|
columnMaps.put(columnData.get(i).get("prop").toString(),columnData.get(i).get("label").toString());
|
|
|
}
|
|
|
byte[] stream1 = exportExcelFile(columnMaps, listMap);
|
|
|
- FileOutputStream outputStream1 = new FileOutputStream(new File("C:/Users/Administrator/OneDrive/文档/"+map.get("exclename").toString()+".xlsx"));
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String path = "/data/file/"+ map.get("userName") + "-" + simpleDateFormat.format(new Date()) + "-" + map.get("exclename").toString() + ".xlsx";
|
|
|
+ FileOutputStream outputStream1 = new FileOutputStream(new File(path));
|
|
|
outputStream1.write(stream1);
|
|
|
+ outputStream1.flush();
|
|
|
outputStream1.close();
|
|
|
- return success();
|
|
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
+ response.put("fileName",map.get("userName") + "-" + simpleDateFormat.format(new Date()) + "-" + map.get("exclename").toString() + ".xlsx");
|
|
|
+ response.put("filePath",path);
|
|
|
+ return success(response);
|
|
|
}
|
|
|
|
|
|
}
|