区域树分页查询添加cameraName条件参数
添加节假日售票统计接口
This commit is contained in:
parent
ebba496e0c
commit
0ceebfdfb3
@ -26,7 +26,7 @@ public class RegionApi {
|
|||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@DS("hiking")
|
@DS("hiking")
|
||||||
public CommonResult<List<RegionCameraListDTO>> list(Integer pageNum, Integer pageSize) {
|
public CommonResult<List<RegionCameraListDTO>> list(Integer pageNum, Integer pageSize, String cameraName) {
|
||||||
return regionService.getRegionList(pageNum, pageSize);
|
return regionService.getRegionList(pageNum, pageSize, cameraName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ import java.util.List;
|
|||||||
@FeignClient("hiking-server")
|
@FeignClient("hiking-server")
|
||||||
public interface RegionClientApi {
|
public interface RegionClientApi {
|
||||||
@GetMapping("/rpc-api/hiking/region/list/testFeign")
|
@GetMapping("/rpc-api/hiking/region/list/testFeign")
|
||||||
CommonResult<List<RegionCameraListDTO>> list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize);
|
CommonResult<List<RegionCameraListDTO>> list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("cameraName") String cameraName);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.datacenter.controller.app.saledata;
|
package cn.iocoder.yudao.module.datacenter.controller.app.saledata;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.HolidayTree;
|
||||||
import cn.iocoder.yudao.module.datacenter.service.saledata.SaleDataService;
|
import cn.iocoder.yudao.module.datacenter.service.saledata.SaleDataService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -144,13 +146,20 @@ public class SaleDataApi {
|
|||||||
return saleDataService.findEventsByYear(year).size();
|
return saleDataService.findEventsByYear(year).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/selectSaleCountByDate")
|
// @GetMapping("/selectSaleCountByDate")
|
||||||
@Operation(summary = "查询某年某月某日售票数量")
|
// @Operation(summary = "查询某年某月某日售票数量")
|
||||||
public Integer selectSaleCountByDate(String date) {
|
// public Integer selectSaleCountByDate(String date) {
|
||||||
System.out.println("date: "+date);
|
// System.out.println("date: "+date);
|
||||||
String dateParam = date.replace("-", "");
|
// String dateParam = date.replace("-", "");
|
||||||
System.out.println("dateParam: "+dateParam);
|
// System.out.println("dateParam: "+dateParam);
|
||||||
return saleDataService.selectSaleCountByDate(dateParam);
|
// return saleDataService.selectSaleCountByDate(dateParam);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@GetMapping("/holidayCount")
|
||||||
|
@Operation(summary = "查询节假日售票数量")
|
||||||
|
public CommonResult<HolidayTree> selectHolidayCount(String year) {
|
||||||
|
Integer currentYear = Integer.parseInt(year);
|
||||||
|
return saleDataService.selectHolidayCount(currentYear);
|
||||||
}
|
}
|
||||||
// @GetMapping("/test")
|
// @GetMapping("/test")
|
||||||
// public void testMethod(){
|
// public void testMethod(){
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class HolidayTree {
|
||||||
|
|
||||||
|
// 第一层: 年份 -> 节假日数据
|
||||||
|
private Map<String, YearNode> yearMap = new HashMap<>();
|
||||||
|
|
||||||
|
public void addHolidayData(String year, String holidayName, Integer day, Integer count) {
|
||||||
|
YearNode yearNode = yearMap.computeIfAbsent(year, k -> new YearNode(year));
|
||||||
|
yearNode.addHolidayData(holidayName, day, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第一层节点: 年份
|
||||||
|
static class YearNode {
|
||||||
|
private String year;
|
||||||
|
private Map<String, HolidayNode> holidayMap = new HashMap<>();
|
||||||
|
|
||||||
|
public YearNode(String year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加节假日数据
|
||||||
|
public void addHolidayData(String holidayName, Integer day, Integer count) {
|
||||||
|
HolidayNode holidayNode = holidayMap.computeIfAbsent(holidayName, k -> new HolidayNode(holidayName));
|
||||||
|
holidayNode.addHolidayDay(day, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, HolidayNode> getHolidayMap() {
|
||||||
|
return holidayMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第二层节点: 节假日
|
||||||
|
static class HolidayNode {
|
||||||
|
private String holidayName;
|
||||||
|
private Map<Integer, Integer> holidayDays = new HashMap<>(); // 第几天 -> 数量
|
||||||
|
|
||||||
|
public HolidayNode(String holidayName) {
|
||||||
|
this.holidayName = holidayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加节假日的具体天数与数量
|
||||||
|
public void addHolidayDay(Integer day, Integer count) {
|
||||||
|
holidayDays.put(day, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHolidayName() {
|
||||||
|
return holidayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getHolidayDays() {
|
||||||
|
return holidayDays;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取最终的树形数据
|
||||||
|
public Map<String, YearNode> getYearMap() {
|
||||||
|
return yearMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试打印树形数据
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// HolidayTree tree = new HolidayTree();
|
||||||
|
//
|
||||||
|
// // 添加一些示例数据
|
||||||
|
// tree.addHolidayData("2023", "New Year", 1, 100);
|
||||||
|
// tree.addHolidayData("2023", "New Year", 2, 120);
|
||||||
|
// tree.addHolidayData("2023", "Spring Festival", 1, 200);
|
||||||
|
// tree.addHolidayData("2024", "New Year", 1, 150);
|
||||||
|
//
|
||||||
|
// // 打印树形数据
|
||||||
|
// tree.getYearMap().forEach((year, yearNode) -> {
|
||||||
|
// System.out.println("Year: " + year);
|
||||||
|
// yearNode.getHolidayMap().forEach((holiday, holidayNode) -> {
|
||||||
|
// System.out.println(" Holiday: " + holiday);
|
||||||
|
// holidayNode.getHolidayDays().forEach((day, count) -> {
|
||||||
|
// System.out.println(" Day " + day + ": " + count);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
}
|
@ -55,7 +55,7 @@ public interface RegionService {
|
|||||||
* @return 区域分页
|
* @return 区域分页
|
||||||
*/
|
*/
|
||||||
PageResult<RegionDO> getRegionPage(RegionPageReqVO pageReqVO);
|
PageResult<RegionDO> getRegionPage(RegionPageReqVO pageReqVO);
|
||||||
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize);
|
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize, String cameraName);
|
||||||
RegionDO selectByIndexCode(String indexCode);
|
RegionDO selectByIndexCode(String indexCode);
|
||||||
RegionDO selectByRegionName(String regionName);
|
RegionDO selectByRegionName(String regionName);
|
||||||
}
|
}
|
@ -85,9 +85,9 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize) {
|
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize, String cameraName) {
|
||||||
System.out.println("调用hiking--server的接口");
|
System.out.println("调用hiking--server的接口");
|
||||||
return regionClientApi.list(pageNum, pageSize);
|
return regionClientApi.list(pageNum, pageSize, cameraName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.datacenter.service.saledata;
|
package cn.iocoder.yudao.module.datacenter.service.saledata;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.HolidayTree;
|
||||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -100,4 +102,6 @@ public interface SaleDataService {
|
|||||||
BigDecimal findyearJun(List<SaleData> list);
|
BigDecimal findyearJun(List<SaleData> list);
|
||||||
|
|
||||||
Integer selectSaleCountByDate(String dateParam);
|
Integer selectSaleCountByDate(String dateParam);
|
||||||
|
|
||||||
|
CommonResult<HolidayTree> selectHolidayCount(Integer date);
|
||||||
}
|
}
|
@ -1,11 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.datacenter.service.saledata;
|
package cn.iocoder.yudao.module.datacenter.service.saledata;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.ticket.IdCardUtil;
|
import cn.iocoder.yudao.framework.common.util.ticket.IdCardUtil;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AgeVo;
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AgeVo;
|
||||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO;
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO;
|
||||||
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.HolidayTree;
|
||||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.SaleDataItemTypeVo;
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.SaleDataItemTypeVo;
|
||||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
||||||
import cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata.SaleDataTodayRepository;
|
import cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata.SaleDataTodayRepository;
|
||||||
@ -165,6 +167,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
// String end = date.format(endOfYear);
|
// String end = date.format(endOfYear);
|
||||||
return saleDataRepository.findBySddateBetween(starTime, endTime);
|
return saleDataRepository.findBySddateBetween(starTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SaleData> findEventsThisYear() {
|
public List<SaleData> findEventsThisYear() {
|
||||||
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
@ -228,7 +231,6 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findBySaleMethod(String starTime, String endTime) {
|
public List<Map<String, String>> findBySaleMethod(String starTime, String endTime) {
|
||||||
List<SaleData> saleDataList = saleDataRepository.findAllByTransactiontypenoTime(starTime, this.publicMethod(endTime));
|
List<SaleData> saleDataList = saleDataRepository.findAllByTransactiontypenoTime(starTime, this.publicMethod(endTime));
|
||||||
@ -450,5 +452,59 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
return saleDataRepository.countBySddate(dateParam);
|
return saleDataRepository.countBySddate(dateParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<HolidayTree> selectHolidayCount(Integer currentYear) {
|
||||||
|
HolidayTree holidayTree = new HolidayTree();
|
||||||
|
|
||||||
|
// 获取当前年份及前两年
|
||||||
|
// int startYear = currentYear - 2;
|
||||||
|
// int endYear = currentYear;
|
||||||
|
|
||||||
|
// 节假日名称列表
|
||||||
|
List<String> holidays = Arrays.asList("五一", "国庆", "春节");
|
||||||
|
|
||||||
|
// 遍历每一年
|
||||||
|
// for (int year = startYear; year <= endYear; year++) {
|
||||||
|
// 获取每个节假日的前五天数据
|
||||||
|
for (String holiday : holidays) {
|
||||||
|
List<String> holidayDates = getHolidayDates(holiday, currentYear); // 获取节假日的五天日期
|
||||||
|
for (String date : holidayDates) {
|
||||||
|
// 查询每个日期的数量
|
||||||
|
System.out.println(date);
|
||||||
|
int count = saleDataRepository.countBySddate(date);
|
||||||
|
holidayTree.addHolidayData(String.valueOf(currentYear), holiday, Integer.parseInt(date.substring(6)), count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
return CommonResult.success(holidayTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据节假日和年份获取节假日及其五天的数据(从节假日当天开始的五天)
|
||||||
|
private List<String> getHolidayDates(String holiday, int year) {
|
||||||
|
List<String> dates = new ArrayList<>();
|
||||||
|
|
||||||
|
if (holiday.equals("五一")) {
|
||||||
|
// 五一:5月1日到5月5日
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
String date = String.format("%04d05%02d", year, 1 + i); // 构建 20230501 格式的日期
|
||||||
|
dates.add(date);
|
||||||
|
}
|
||||||
|
} else if (holiday.equals("国庆")) {
|
||||||
|
// 国庆:10月1日到10月5日
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
String date = String.format("%04d10%02d", year, 1 + i); // 构建 20231001 格式的日期
|
||||||
|
dates.add(date);
|
||||||
|
}
|
||||||
|
} else if (holiday.equals("春节")) {
|
||||||
|
// 春节假设固定日期2月1日-2月5日
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
String date = String.format("%04d02%02d", year, 1 + i); // 构建 20230201 格式的日期
|
||||||
|
dates.add(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ public interface RegionApi {
|
|||||||
String PREFIX = ApiConstants.PREFIX + "/region";
|
String PREFIX = ApiConstants.PREFIX + "/region";
|
||||||
@GetMapping(PREFIX + "/list/testFeign")
|
@GetMapping(PREFIX + "/list/testFeign")
|
||||||
@Operation(summary = "获取区域树状列表")
|
@Operation(summary = "获取区域树状列表")
|
||||||
CommonResult<List<RegionCameraListDTO>> getRegionCameraList(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize);
|
CommonResult<List<RegionCameraListDTO>> getRegionCameraList(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("cameraName") String cameraName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ public class RegionApiImpl implements RegionApi {
|
|||||||
private RegionService regionService;
|
private RegionService regionService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<List<RegionCameraListDTO>> getRegionCameraList(Integer pageNum, Integer pageSize) {
|
public CommonResult<List<RegionCameraListDTO>> getRegionCameraList(Integer pageNum, Integer pageSize, String cameraName) {
|
||||||
System.out.println("收到打datacenter的请求");
|
System.out.println("收到打datacenter的请求");
|
||||||
return regionService.getRegionList(pageNum, pageSize);
|
return regionService.getRegionList(pageNum, pageSize, cameraName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public interface CameraMapper extends BaseMapperX<CameraDO> {
|
|||||||
return update(updateObj, new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getCameraIndexCode, updateObj.getCameraIndexCode()));
|
return update(updateObj, new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getCameraIndexCode, updateObj.getCameraIndexCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<CameraDO> selectCameraByRegionIndexCodePage(String regionIndexCode, Integer start, Integer end) {
|
default List<CameraDO> selectCameraByRegionIndexCodeAndCameraNamePage(String regionIndexCode, String cameraName, Integer start, Integer end) {
|
||||||
return selectList(new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getRegionIndexCode, regionIndexCode).last("limit " + start + "," + end));
|
return selectList(new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getRegionIndexCode, regionIndexCode).like(CameraDO::getCameraName, cameraName).last("limit " + start + "," + end));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,5 +58,5 @@ public interface RegionService {
|
|||||||
RegionDO selectByRegionName(String regionName);
|
RegionDO selectByRegionName(String regionName);
|
||||||
|
|
||||||
public void updateRegionCheckByCameraIndexCode(RegionSaveReqVO updateReqVO);
|
public void updateRegionCheckByCameraIndexCode(RegionSaveReqVO updateReqVO);
|
||||||
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize);
|
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize, String cameraName);
|
||||||
}
|
}
|
@ -103,7 +103,7 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize) {
|
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize, String cameraName) {
|
||||||
Integer start = (pageNum - 1) * pageSize;
|
Integer start = (pageNum - 1) * pageSize;
|
||||||
List<RegionDO> regionDOListResult = regionMapper.selectList();
|
List<RegionDO> regionDOListResult = regionMapper.selectList();
|
||||||
List<RegionCameraListDTO> regions = new ArrayList<>();
|
List<RegionCameraListDTO> regions = new ArrayList<>();
|
||||||
@ -116,7 +116,7 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
temp.setLeaf(regionDO.getLeaf());
|
temp.setLeaf(regionDO.getLeaf());
|
||||||
System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
||||||
if(temp.getLeaf() == 1) {
|
if(temp.getLeaf() == 1) {
|
||||||
cameraMapper.selectCameraByRegionIndexCodePage(temp.getRegionIndexCode(), start, pageSize).forEach(cameraDO -> {
|
cameraMapper.selectCameraByRegionIndexCodeAndCameraNamePage(temp.getRegionIndexCode(), cameraName, start, pageSize).forEach(cameraDO -> {
|
||||||
temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class));
|
temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user