|
@@ -1,6 +1,7 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -27,7 +28,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -295,6 +298,36 @@ public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataMapper, DeviceD
|
|
|
return R.ok(this.getMercDataOneMonth(dto.getMercId(), dto.getDateValue()));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("图表数据")
|
|
|
+ @Override
|
|
|
+ public R<List<DeviceDataDto.DayChartVo>> dayChart(@RequestBody @Valid DeviceDataDto.DayChartDto dto) {
|
|
|
+ List<DeviceDataDto.DayChartVo> dayChartVos = baseMapper.dayChart(dto.getMercId(), dto.getBeginInt(), dto.getEndDateInt(),dto.getType());
|
|
|
+ Map<Integer, DeviceDataDto.DayChartVo> voMap = dayChartVos.stream().collect(Collectors.toMap(DeviceDataDto.DayChartVo::getTime, i -> i));
|
|
|
+ List<String> dayList = DataTime.getBetweenDates(dto.getBeginDate().toString(), dto.getEndDate().toString(), true);
|
|
|
+ List<Integer> dayList2 = dayList.stream().map(i -> Integer.valueOf(StrUtil.replace(i, "-", ""))).collect(Collectors.toList());
|
|
|
+ List<DeviceDataDto.DayChartVo> list = new ArrayList<>();
|
|
|
+ dayList2.forEach(
|
|
|
+ i -> {
|
|
|
+ Integer num = 0;
|
|
|
+ Integer totalMoney = 0;
|
|
|
+ BigDecimal totalMoneyYuan = new BigDecimal(0);
|
|
|
+ DeviceDataDto.DayChartVo dayChartVo = voMap.get(i);
|
|
|
+ if (Emptys.check(dayChartVo)) {
|
|
|
+ num = dayChartVo.getNum();
|
|
|
+ totalMoney = dayChartVo.getTotalMoney();
|
|
|
+ totalMoneyYuan = dayChartVo.getTotalMoneyYuan();
|
|
|
+ }
|
|
|
+ list.add(new DeviceDataDto.DayChartVo()
|
|
|
+ .setTime(i)
|
|
|
+ .setNum(num)
|
|
|
+ .setTotalMoney(totalMoney)
|
|
|
+ .setTotalMoneyYuan(totalMoneyYuan)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
+ return R.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
public static class SaveOrAccum {
|
|
|
|
|
|
public R saveOrAccum(DeviceDataDto.SaveOrAccum saveOrAccum, DeviceDataServiceImpl deviceDataService) {
|