|
@@ -335,9 +335,55 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
lists.add(cakeBreakfast);
|
|
|
lists.add(cakeLunch);
|
|
|
lists.add(cakeDinner);
|
|
|
+ return ReturnMsg.ok(lists);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询智慧生活中智慧餐厅的盈利分析--中枢接口
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getProfitAnalysisData(IocParam iocParam) throws ParseException {
|
|
|
+ List<Cake> lists = new ArrayList<>();
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CANTEEN_TYPE_URL)+"?startTime="+startStr+"&endTime="+endStr+"&scope=year";
|
|
|
+ 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<>();
|
|
|
+ if(dataList!=null&&dataList.size()>0){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(0);
|
|
|
+ double breakfast = MathUtils.division(Double.valueOf(json.get("breakfastConsumeTotal").toString()),100,2);
|
|
|
+ double dinner = MathUtils.division(Double.valueOf(json.get("dinnerConsumeTotal").toString()),100,2);
|
|
|
+ double lunch = MathUtils.division(Double.valueOf(json.get("lunchConsumeTotal").toString()),100,2);
|
|
|
+ Cake cakeBreakfast = new Cake();
|
|
|
+ Cake cakeLunch = new Cake();
|
|
|
+ Cake cakeDinner = new Cake();
|
|
|
+ cakeBreakfast.setName("早餐");
|
|
|
+ cakeLunch.setName("午餐");
|
|
|
+ cakeDinner.setName("晚餐");
|
|
|
+ cakeBreakfast.setValue(breakfast);
|
|
|
+ cakeDinner.setValue(dinner);
|
|
|
+ cakeLunch.setValue(lunch);
|
|
|
+ lists.add(cakeBreakfast);
|
|
|
+ lists.add(cakeLunch);
|
|
|
+ lists.add(cakeDinner);
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(lists);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("获取餐厅消费分析数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
|
|
|
- return ReturnMsg.ok(lists);
|
|
|
}
|
|
|
|
|
|
/**
|