|
@@ -2,6 +2,7 @@ package com.sky.ioc.service.canteen.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.sky.ioc.config.RestTemplateConfig;
|
|
|
import com.sky.ioc.entity.Indeicator;
|
|
|
import com.sky.ioc.entity.Label;
|
|
|
import com.sky.ioc.entity.Cake;
|
|
@@ -20,10 +21,7 @@ import com.sky.ioc.mapper.FoodMenusMapper;
|
|
|
import com.sky.ioc.mapper.job.TokenMapper;
|
|
|
import com.sky.ioc.mapper.security.SecurityDoorRecordMapper;
|
|
|
import com.sky.ioc.service.canteen.RestaurantService;
|
|
|
-import com.sky.ioc.tool.DateUtil;
|
|
|
-import com.sky.ioc.tool.FalseData;
|
|
|
-import com.sky.ioc.tool.GeneralMethod;
|
|
|
-import com.sky.ioc.tool.ReturnMsg;
|
|
|
+import com.sky.ioc.tool.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -68,7 +66,15 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
@Autowired
|
|
|
CuisineOderItemMapper cuisineOderItemMapper;
|
|
|
|
|
|
- final static String CANTEEN_ORDER_URL="%s/api/canteen/CANTEEN/order/list";
|
|
|
+ @Autowired
|
|
|
+ private RestTemplateConfig restTemplateConfig;
|
|
|
+
|
|
|
+ final static String CANTEEN_ORDER_URL="/api/canteen/CANTEEN/order/list";
|
|
|
+
|
|
|
+ final static String CANTEEN_TYPE_URL="/api/statistics/canteen/order/typeBalance";
|
|
|
+
|
|
|
+ final static String CANTEEN_PAY_TYPE_URL="/api/statistics/canteen/order/payType";
|
|
|
+
|
|
|
/**
|
|
|
* TODO 查询智慧生活中智慧餐厅的支付分析
|
|
|
*
|
|
@@ -481,4 +487,81 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
return ReturnMsg.ok();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getConsumptionAnalysisData(IocParam iocParam) {
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CANTEEN_TYPE_URL)+"?startTime="+startStr+"&endTime="+endStr+"&scope=day";
|
|
|
+ String[] param = {"breakfast","lunch","dinner","breakfastPrice","lunchPrice","dinnerPrice"};
|
|
|
+ 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],json.get("breakfastCount"));
|
|
|
+ jsonObject.put(param[1],json.get("lunchCount"));
|
|
|
+ jsonObject.put(param[2],json.get("dinnerCount"));
|
|
|
+ jsonObject.put(param[3], MathUtils.division(Long.valueOf(json.get("breakfastConsumeAvg").toString()),100,2));
|
|
|
+ jsonObject.put(param[4],MathUtils.division(Long.valueOf(json.get("lunchConsumeAvg").toString()),100,2));
|
|
|
+ jsonObject.put(param[5],MathUtils.division(Long.valueOf(json.get("dinnerConsumeAvg").toString()),100,2));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getPaymentAnalysisData(IocParam iocParam) {
|
|
|
+ List<Cake> lists = new ArrayList<>();
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CANTEEN_PAY_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");
|
|
|
+ if(dataList!=null&&dataList.size()>0){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(0);
|
|
|
+ ArrayList types = (ArrayList) json.get("payType");
|
|
|
+ for (int j = 0; j < types.size(); j++) {
|
|
|
+ LinkedHashMap type = (LinkedHashMap) types.get(j);
|
|
|
+ Cake cake = new Cake();
|
|
|
+ cake.setName(String.valueOf(type.get("name")));
|
|
|
+ cake.setValue(MathUtils.division(Double.valueOf(type.get("consumeTotal").toString()),100,2));
|
|
|
+ lists.add(cake);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(lists);
|
|
|
+ }else{
|
|
|
+ log.info("获取餐厅支付类型分析数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|