|
@@ -682,4 +682,40 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getRestaurantConsumptionChartData(IocParam iocParam) {
|
|
|
+ String[] param = {"consumptionAmount","consumptionOrder"};
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CANTEEN_TOTAL_URL)+"?startTime="+startStr+"&endTime="+endStr+"&scope=day";
|
|
|
+ RestTemplate restTemplate = restTemplateConfig.build();
|
|
|
+ // 发送GET请求
|
|
|
+ ResponseEntity<Map> responseEntity = restTemplate.getForEntity(url, Map.class);
|
|
|
+ // 获取响应对象里的 body 对象
|
|
|
+ Map<String, Object> body = responseEntity.getBody();
|
|
|
+ // 获取状态码
|
|
|
+ Integer code = (Integer)body.get("cod");
|
|
|
+ // 获取响应信息
|
|
|
+ String message = (String)body.get("msg");
|
|
|
+ if(code==200){
|
|
|
+ ArrayList dataList = (ArrayList)body.get("data");
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ for(int i=0;i<dataList.size();i++){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(i);
|
|
|
+ Label label = new Label();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(param[0],MathUtils.division(Double.valueOf(json.get("consumeTotal").toString()),100,2));
|
|
|
+ jsonObject.put(param[1],json.get("count"));
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(String.valueOf(json.get("time")));
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(labels1);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("获取餐厅消费分析数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|