|
@@ -12,6 +12,7 @@ import com.xy.collections.list.JList;
|
|
|
import com.xy.config.DeviceThreadPoolConfig;
|
|
|
import com.xy.config.FileConfig;
|
|
|
import com.xy.dto.DeviceChargingHistoryDto;
|
|
|
+import com.xy.dto.MercDeviceAlgorithmChargingDto;
|
|
|
import com.xy.dto.OrderMercManageDto;
|
|
|
import com.xy.dto.be.MercDto;
|
|
|
import com.xy.entity.DeviceChargingHistory;
|
|
@@ -40,6 +41,7 @@ import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.xy.utils.Beans.copy;
|
|
|
+import static com.xy.utils.PlusBeans.toIPage;
|
|
|
import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
|
|
|
/**
|
|
@@ -84,6 +86,50 @@ public class DeviceChargingHistoryServiceImpl extends ServiceImpl<DeviceCharging
|
|
|
return R.ok(pageBean);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("月统计分页")
|
|
|
+ @PostMapping("moonCountPage")
|
|
|
+ public R<PageBean<DeviceChargingHistoryDto.MoonCountVo>> moonCountPage(@RequestBody DeviceChargingHistoryDto.MoonCountPage moonCountPage) {
|
|
|
+ JList<DeviceChargingHistoryDto.MoonCountVo> moonCountVos = new JArrayList<>();
|
|
|
+ //查询数据
|
|
|
+ List<String> attrNames = Arrays.asList(
|
|
|
+ LambdaUtils.getUnderlineCaseName(DeviceChargingHistory::getMercId)
|
|
|
+ );
|
|
|
+ List<String> selectNames = Arrays.asList(
|
|
|
+ attrNames.get(0),
|
|
|
+ String.format("count(*) %s", LambdaUtils.getProperty(DeviceChargingHistory::getChargingSize)),
|
|
|
+ String.format("sum(%s) %s", LambdaUtils.getUnderlineCaseName(DeviceChargingHistory::getChargingMoney), LambdaUtils.getProperty(DeviceChargingHistory::getChargingMoney))
|
|
|
+ );
|
|
|
+ QueryWrapper<DeviceChargingHistory> queryWrapper = new QueryWrapper<DeviceChargingHistory>()
|
|
|
+ .select(selectNames.toArray(new String[selectNames.size()]))
|
|
|
+ .in(Emptys.check(moonCountPage.getMercIds()), attrNames.get(0), moonCountPage.getMercIds())
|
|
|
+ .between("DATE_FORMAT(" + LambdaUtils.getUnderlineCaseName(DeviceChargingHistory::getCreateTime) + ", '%Y-%m-%d')", moonCountPage.getBeginDate(), moonCountPage.getEndDate())
|
|
|
+ .groupBy(attrNames);
|
|
|
+ IPage<DeviceChargingHistory> iPage = page(toIPage(moonCountPage.getPage()), queryWrapper);
|
|
|
+ List<DeviceChargingHistory> records = iPage.getRecords();
|
|
|
+ if (!Emptys.check(records)) {
|
|
|
+ return R.ok(new PageBean<>());
|
|
|
+ }
|
|
|
+ String date = String.format("%s~%s", moonCountPage.getBeginDate(), moonCountPage.getEndDate());
|
|
|
+ records.forEach(deviceChargingHistory -> {
|
|
|
+ DeviceChargingHistoryDto.MoonCountVo moonCountVo = new DeviceChargingHistoryDto.MoonCountVo()
|
|
|
+ .setDate(date)
|
|
|
+ .setMercId(deviceChargingHistory.getMercId())
|
|
|
+ .setDeviceSize(deviceChargingHistory.getChargingSize())
|
|
|
+ .setChargingMoney(deviceChargingHistory.getChargingMoney());
|
|
|
+ moonCountVos.add(moonCountVo);
|
|
|
+ });
|
|
|
+ //翻译商户名称
|
|
|
+ Beans.copy(moonCountVos).target(() -> mercService.list(new MercDto.SelectList().setMercIds(moonCountVos.getProperty(DeviceChargingHistoryDto.MoonCountVo::getMercId).comparing())).getData(),
|
|
|
+ DeviceChargingHistoryDto.MoonCountVo::getMercId, DeviceChargingHistoryDto.MoonCountVo::getMercName, MercDto.Vo::getId, MercDto.Vo::getName)
|
|
|
+ .builder();
|
|
|
+ PageBean<DeviceChargingHistoryDto.MoonCountVo> pageBean = new PageBean<DeviceChargingHistoryDto.MoonCountVo>()
|
|
|
+ .setCurrent(iPage.getCurrent())
|
|
|
+ .setSize(iPage.getSize())
|
|
|
+ .setTotal(iPage.getTotal())
|
|
|
+ .setRecords(moonCountVos);
|
|
|
+ return R.ok(pageBean);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("月统计")
|
|
|
@PostMapping("moonCount")
|
|
|
public R<List<DeviceChargingHistoryDto.MoonCountVo>> moonCount(@RequestBody DeviceChargingHistoryDto.MoonCount moonCount) {
|
|
@@ -103,10 +149,10 @@ public class DeviceChargingHistoryServiceImpl extends ServiceImpl<DeviceCharging
|
|
|
ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, dateDifference.size());
|
|
|
dateDifference.forEach(date -> execute.execute(() -> {
|
|
|
QueryWrapper<DeviceChargingHistory> queryWrapper = new QueryWrapper<DeviceChargingHistory>()
|
|
|
- .select(selectNames.get(0), selectNames.get(1), selectNames.get(2), selectNames.get(3))
|
|
|
+ .select(selectNames.toArray(new String[selectNames.size()]))
|
|
|
.in(Emptys.check(moonCount.getMercIds()), attrNames.get(0), moonCount.getMercIds())
|
|
|
.eq(attrNames.get(1), date)
|
|
|
- .groupBy(attrNames.get(0), attrNames.get(1));
|
|
|
+ .groupBy(attrNames);
|
|
|
List<DeviceChargingHistory> deviceChargingHistories = list(queryWrapper);
|
|
|
deviceChargingHistories.forEach(deviceChargingHistory -> {
|
|
|
DeviceChargingHistoryDto.MoonCountVo moonCountVo = new DeviceChargingHistoryDto.MoonCountVo()
|