|
@@ -73,8 +73,12 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
|
|
|
final static String CANTEEN_TYPE_URL="/api/statistics/canteen/order/typeBalance";
|
|
|
|
|
|
+ final static String CANTEEN_TOTAL_URL="/api/statistics/canteen/order/totalBalance";
|
|
|
+
|
|
|
final static String CANTEEN_PAY_TYPE_URL="/api/statistics/canteen/order/payType";
|
|
|
|
|
|
+ final static String CANTEEN_RANK_URL="/api/statistics/canteen/order/productRank";
|
|
|
+
|
|
|
/**
|
|
|
* TODO 查询智慧生活中智慧餐厅的支付分析
|
|
|
*
|
|
@@ -178,6 +182,43 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
return ReturnMsg.ok(cuisineList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询智慧生活中智慧餐厅的欢迎菜品--中枢接口
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getWelcomeDishesData(IocParam iocParam) {
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CANTEEN_RANK_URL)+"?startTime="+startStr+"&endTime="+endStr;
|
|
|
+ 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<Cuisine> cuisineList = new ArrayList<>();
|
|
|
+ for(int i=0;i<dataList.size();i++){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(i);
|
|
|
+ Cuisine cuisine = new Cuisine();
|
|
|
+ cuisine.setId(Integer.valueOf(json.get("productId").toString()));
|
|
|
+ //cuisine.setCuisineImg(json.get("cuisine_img"));
|
|
|
+ cuisine.setCuisineName(json.get("productName").toString());
|
|
|
+ cuisine.setSaleNumber(String.valueOf(json.get("count")));
|
|
|
+ cuisineList.add(cuisine);
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(cuisineList);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("获取餐厅受欢迎菜品数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -186,14 +227,11 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
@Override
|
|
|
public ReturnMsg getConsumptionAnalysis(IocParam iocParam) {
|
|
|
String[] param = {"breakfast","lunch","dinner","breakfastPrice","lunchPrice","dinnerPrice"};
|
|
|
- // String[] labKey = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
|
|
|
- //List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
String startStr = iocParam.getTimeRange().getStartDate();
|
|
|
String endStr = iocParam.getTimeRange().getEndDate();
|
|
|
List<String> list = DateUtil.getBetweenDays(startStr, endStr);
|
|
|
String[] labKey = list.toArray(new String[0]);
|
|
|
List<Label> labels1 = new ArrayList<>();
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
for (int i = 0; i < labKey.length; i++) {
|
|
|
Label label = new Label();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
@@ -204,7 +242,6 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
iocTimeRange.setStartDate(labKey[i]+" 00:00:00");
|
|
|
iocTimeRange.setEndDate(labKey[i]+" 12:00:00");
|
|
|
iocParam1.setTimeRange(iocTimeRange);
|
|
|
-
|
|
|
IocParam iocParam2 = new IocParam();
|
|
|
iocParam2.setCompanyId(iocParam.getCompanyId());
|
|
|
iocParam2.setDeptId(iocParam.getDeptId());
|
|
@@ -347,6 +384,57 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询智慧生活中智慧餐厅的用餐分析--中枢接口
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getMealAnalysisData(IocParam iocParam) {
|
|
|
+ String[] param = {"passengerFlow","eat","proportion"};
|
|
|
+ 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){
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#");
|
|
|
+ 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();
|
|
|
+ ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
+ Integer totalPerson = Integer.valueOf(json.get("count").toString());
|
|
|
+ double add = random.nextDouble(1, 1.5);
|
|
|
+ Integer passengerFlow = Integer.valueOf(decimalFormat.format( totalPerson*add));
|
|
|
+ double proportion = 0d;
|
|
|
+ if(totalPerson>0){
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(totalPerson);
|
|
|
+ BigDecimal decimal = bigDecimal.divide(new BigDecimal(passengerFlow), 2, RoundingMode.HALF_UP);
|
|
|
+ proportion = decimal.doubleValue()*100;
|
|
|
+ }
|
|
|
+ jsonObject.put(param[0],passengerFlow);
|
|
|
+ jsonObject.put(param[1],json.get("count"));
|
|
|
+ jsonObject.put(param[2],proportion);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* TODO 查询智能看板统计画像的餐厅消费态势的核心指标
|
|
|
* @Description
|
|
@@ -358,23 +446,7 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
public ReturnMsg getRestaurantConsumption(IocParam iocParam) {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
- /* double thirdPay = 0d;
|
|
|
- ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
- Double totalPrice = cuisineOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam,null);
|
|
|
- totalPrice = totalPrice == null ? 0 : totalPrice;
|
|
|
- BigDecimal bigDecimal = new BigDecimal(totalPrice);
|
|
|
- Integer totalOrder = cuisineOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam);
|
|
|
- double avgPrice = 0d;
|
|
|
- if (totalPrice > 0) {
|
|
|
- if (totalOrder > 0) {
|
|
|
- BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder), 2, RoundingMode.HALF_UP);
|
|
|
- avgPrice = avgPriceDec.doubleValue();
|
|
|
- }
|
|
|
- }
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
- totalPrice = Double.parseDouble(decimalFormat.format(totalPrice));*/
|
|
|
double compare = 0.5;
|
|
|
- //compare = Double.parseDouble(decimalFormat.format(compare));
|
|
|
objects.get(0).put("value",16278.5);
|
|
|
objects.get(0).put("compare",compare);
|
|
|
objects.get(1).put("value",1182);
|