|
@@ -1,18 +1,19 @@
|
|
package com.hwrj.cloud.admin.controller;
|
|
package com.hwrj.cloud.admin.controller;
|
|
|
|
|
|
import com.hwrj.cloud.admin.service.BigScreamService;
|
|
import com.hwrj.cloud.admin.service.BigScreamService;
|
|
|
|
+import com.hwrj.cloud.admin.service.UmsCompanyService;
|
|
import com.hwrj.cloud.common.api.CommonResult;
|
|
import com.hwrj.cloud.common.api.CommonResult;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@Api(tags = "BigScreamController",description = "大屏数据展示")
|
|
@Api(tags = "BigScreamController",description = "大屏数据展示")
|
|
@@ -22,25 +23,136 @@ public class BigScreamController {
|
|
@Autowired
|
|
@Autowired
|
|
private BigScreamService bigScreamService;
|
|
private BigScreamService bigScreamService;
|
|
|
|
|
|
- @ApiOperation("获取平台信息")
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private UmsCompanyService companyService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation("林业态势-获取平台信息")
|
|
@GetMapping("/1/data1")
|
|
@GetMapping("/1/data1")
|
|
public CommonResult data11(@RequestParam(value = "id",required = false,defaultValue = "1")Long id){
|
|
public CommonResult data11(@RequestParam(value = "id",required = false,defaultValue = "1")Long id){
|
|
Map<String, Object> map = bigScreamService.data1(id);
|
|
Map<String, Object> map = bigScreamService.data1(id);
|
|
return CommonResult.success(map);
|
|
return CommonResult.success(map);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取供应商分布信息")
|
|
|
|
|
|
+ @ApiOperation("林业态势-获取供应商分布信息")
|
|
@GetMapping("/1/data2")
|
|
@GetMapping("/1/data2")
|
|
public CommonResult data12(@RequestParam(value = "compType",required = false)String compType){
|
|
public CommonResult data12(@RequestParam(value = "compType",required = false)String compType){
|
|
List<Map<String, Object>> map = bigScreamService.date2(compType);
|
|
List<Map<String, Object>> map = bigScreamService.date2(compType);
|
|
- return CommonResult.success(map);
|
|
|
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
|
+ for (Map<String,Object> m:map) {
|
|
|
|
+ if (m.containsKey("lng")&&m.containsKey("lat")){
|
|
|
|
+ String lng = m.get("lng").toString();
|
|
|
|
+ String lat = m.get("lat").toString();
|
|
|
|
+ List<String> str = new LinkedList<>();
|
|
|
|
+ str.add(lng);
|
|
|
|
+ str.add(lat);
|
|
|
|
+ m.put("lnglat",str);
|
|
|
|
+ }
|
|
|
|
+ maps.add(m);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(maps);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取产品分布信息")
|
|
|
|
|
|
+ @ApiOperation("产品现状-获取产品分布信息")
|
|
@GetMapping("/1/data3")
|
|
@GetMapping("/1/data3")
|
|
public CommonResult data13(){
|
|
public CommonResult data13(){
|
|
List<Map<String, Object>> map = bigScreamService.data4();
|
|
List<Map<String, Object>> map = bigScreamService.data4();
|
|
return CommonResult.success(map);
|
|
return CommonResult.success(map);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation("林业态势-获取产品分布信息")
|
|
|
|
+ @GetMapping("/1/data6")
|
|
|
|
+ public CommonResult data16(){
|
|
|
|
+
|
|
|
|
+ String title = "供应信息";
|
|
|
|
+ String[] titles = {"供应商名称","供应产品","规格","参考价格"};
|
|
|
|
+ List<String> strings = bigScreamService.data6();
|
|
|
|
+ Map<String, Object> listData = getListData(title, titles, strings);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(listData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("林业态势-需求信息")
|
|
|
|
+ @GetMapping("/1/data7")
|
|
|
|
+ public CommonResult data17(){
|
|
|
|
+
|
|
|
|
+ String title = "需求信息";
|
|
|
|
+ String[] titles = {"需求主体","需求产品"};
|
|
|
|
+ List<String> strings = bigScreamService.data7();
|
|
|
|
+ Map<String, Object> listData = getListData(title, titles, strings);
|
|
|
|
+
|
|
|
|
+ return CommonResult.success(listData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("林业态势-左下角")
|
|
|
|
+ @GetMapping("/1/data8")
|
|
|
|
+ public CommonResult data18(){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String[] titles = {"id","name","num"};
|
|
|
|
+ List<String> strings = bigScreamService.data8();
|
|
|
|
+ List<Map<String, Object>> title = getTitle(strings, titles, "name", "企业分布");
|
|
|
|
+ return CommonResult.success(title);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分装返回大屏数据
|
|
|
|
+ * @param title
|
|
|
|
+ * @param titles
|
|
|
|
+ * @param strings 必须用---分割成和titles一样长度的数组的字符串
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String,Object> getListData(String title,String[] titles,List<String> strings){
|
|
|
|
+ Map<String,Object> has = new HashMap<>();
|
|
|
|
+ has.put("title",title);
|
|
|
|
+ List<Map<String,Object>> tabHeader = new LinkedList<>();
|
|
|
|
+ for (int i = 0 ;i<titles.length;i++) {
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ map.put("name",titles[i]);
|
|
|
|
+ tabHeader.add(map);
|
|
|
|
+ }
|
|
|
|
+ has.put("tabHeader",tabHeader);
|
|
|
|
+ List<List<Map<String,Object>>> list = new ArrayList<>();
|
|
|
|
+ for (String str:strings) {
|
|
|
|
+ String[] split = str.split("---");
|
|
|
|
+ List<Map<String,Object>> maps = new LinkedList<>();
|
|
|
|
+ for (int i = 0;i<split.length;i++){
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ map.put("value",split[i]);
|
|
|
|
+ maps.add(map);
|
|
|
|
+ }
|
|
|
|
+ list.add(maps);
|
|
|
|
+ }
|
|
|
|
+ has.put("list",list);
|
|
|
|
+ return has;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param strings 数据
|
|
|
|
+ * @param params
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Map<String,Object>> getTitle(List<String> strings,String[] params,String title,String addStr){
|
|
|
|
+ if (strings == null|| strings.size()<1){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
+ for (String str:strings) {
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ String[] split = str.split("---");
|
|
|
|
+ for (int i = 0;i<split.length;i++){
|
|
|
|
+ String param = params[i];
|
|
|
|
+ String s = split[i];
|
|
|
|
+ if ((!StringUtils.isEmpty(title))&&title.equals(param)){
|
|
|
|
+ s=s+addStr;
|
|
|
|
+ }
|
|
|
|
+ map.put(param,s);
|
|
|
|
+ }
|
|
|
|
+ list.add(map);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|