|
@@ -316,30 +316,34 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
* @date 2023/2/22 15:22
|
|
|
*/
|
|
|
@Override
|
|
|
- public ReturnMsg getRestaurantConsumption() {
|
|
|
+ public ReturnMsg getRestaurantConsumption(IocParam iocParam) {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
+ double thirdPay = 0d;
|
|
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
- int orderConut = random.nextInt(800, 2000);//订单数
|
|
|
- int price = random.nextInt(10,30);//单价
|
|
|
- int thirdPay = random.nextInt(1000,10000);//第三方支付
|
|
|
- int totalPrice = orderConut*price;//总金额
|
|
|
- while (thirdPay>totalPrice){
|
|
|
- thirdPay = random.nextInt(1000,10000);//第三方支付
|
|
|
+ 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();
|
|
|
+ }
|
|
|
}
|
|
|
- BigDecimal bigDecimal2 = new BigDecimal(thirdPay);
|
|
|
- double thirdPay2 = (bigDecimal2.divide(new BigDecimal("1000"), 2, RoundingMode.HALF_UP).doubleValue()*6);
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
+ totalPrice = Double.parseDouble(decimalFormat.format(totalPrice));
|
|
|
double compare = random.nextDouble(-1, 1);
|
|
|
compare = Double.parseDouble(decimalFormat.format(compare));
|
|
|
objects.get(0).put("value",totalPrice);
|
|
|
- objects.get(0).put("compare",0.4);
|
|
|
- objects.get(1).put("value",orderConut);
|
|
|
- objects.get(1).put("compare",0.4);
|
|
|
- objects.get(2).put("value",price);
|
|
|
- objects.get(2).put("compare",0.4);
|
|
|
+ objects.get(0).put("compare",compare);
|
|
|
+ objects.get(1).put("value",totalOrder);
|
|
|
+ objects.get(1).put("compare",compare);
|
|
|
+ objects.get(2).put("value",avgPrice);
|
|
|
+ objects.get(2).put("compare",compare);
|
|
|
|
|
|
- objects.get(3).put("value",thirdPay2);
|
|
|
+ objects.get(3).put("value",thirdPay);
|
|
|
indeicator.setWorthAttention("提高合同额");
|
|
|
indeicator.setList(objects);
|
|
|
return ReturnMsg.ok(indeicator);
|
|
@@ -354,10 +358,33 @@ public class RestaurantServiceImpl implements RestaurantService {
|
|
|
* @date 2023/2/22 15:22
|
|
|
*/
|
|
|
@Override
|
|
|
- public ReturnMsg getRestaurantConsumptionChart() {
|
|
|
+ public ReturnMsg getRestaurantConsumptionChart(IocParam iocParam) {
|
|
|
String[] param = {"consumptionAmount","consumptionOrder"};
|
|
|
- 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();
|
|
|
+ IocParam iocParam1 = new IocParam();
|
|
|
+ IocTimeRange iocTimeRange = new IocTimeRange();
|
|
|
+ iocTimeRange.setStartDate(labKey[i]+" 00:00:00");
|
|
|
+ iocTimeRange.setEndDate(labKey[i]+" 23:59:00");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ Double totalPrice = cuisineOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam1,null);
|
|
|
+ totalPrice = totalPrice == null ? 0 : totalPrice;
|
|
|
+ totalPrice = Double.valueOf(decimalFormat.format(totalPrice));
|
|
|
+ Integer totalOrder = cuisineOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam1);
|
|
|
+ jsonObject.put(param[0],totalPrice);
|
|
|
+ jsonObject.put(param[1],totalOrder);
|
|
|
+
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(labKey[i]);
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
}
|