区域树分页查询添加cameraName条件参数
添加节假日售票统计接口
This commit is contained in:
parent
ebba496e0c
commit
0ceebfdfb3
@ -26,7 +26,7 @@ public class RegionApi {
|
||||
|
||||
@GetMapping("/list")
|
||||
@DS("hiking")
|
||||
public CommonResult<List<RegionCameraListDTO>> list(Integer pageNum, Integer pageSize) {
|
||||
return regionService.getRegionList(pageNum, pageSize);
|
||||
public CommonResult<List<RegionCameraListDTO>> list(Integer pageNum, Integer pageSize, String cameraName) {
|
||||
return regionService.getRegionList(pageNum, pageSize, cameraName);
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ import java.util.List;
|
||||
@FeignClient("hiking-server")
|
||||
public interface RegionClientApi {
|
||||
@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;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -144,13 +146,20 @@ public class SaleDataApi {
|
||||
return saleDataService.findEventsByYear(year).size();
|
||||
}
|
||||
|
||||
@GetMapping("/selectSaleCountByDate")
|
||||
@Operation(summary = "查询某年某月某日售票数量")
|
||||
public Integer selectSaleCountByDate(String date) {
|
||||
System.out.println("date: "+date);
|
||||
String dateParam = date.replace("-", "");
|
||||
System.out.println("dateParam: "+dateParam);
|
||||
return saleDataService.selectSaleCountByDate(dateParam);
|
||||
// @GetMapping("/selectSaleCountByDate")
|
||||
// @Operation(summary = "查询某年某月某日售票数量")
|
||||
// public Integer selectSaleCountByDate(String date) {
|
||||
// System.out.println("date: "+date);
|
||||
// String dateParam = date.replace("-", "");
|
||||
// System.out.println("dateParam: "+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")
|
||||
// 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 区域分页
|
||||
*/
|
||||
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 selectByRegionName(String regionName);
|
||||
}
|
@ -85,9 +85,9 @@ public class RegionServiceImpl implements RegionService {
|
||||
}
|
||||
|
||||
@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的接口");
|
||||
return regionClientApi.list(pageNum, pageSize);
|
||||
return regionClientApi.list(pageNum, pageSize, cameraName);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
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 java.math.BigDecimal;
|
||||
@ -100,4 +102,6 @@ public interface SaleDataService {
|
||||
BigDecimal findyearJun(List<SaleData> list);
|
||||
|
||||
Integer selectSaleCountByDate(String dateParam);
|
||||
|
||||
CommonResult<HolidayTree> selectHolidayCount(Integer date);
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
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.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.HolidayTree;
|
||||
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.mongodb.saledata.SaleDataTodayRepository;
|
||||
@ -32,7 +34,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
@Autowired
|
||||
private SaleDataTodayRepository saleDataRepository;
|
||||
|
||||
public String publicMethod(String endTime){
|
||||
public String publicMethod(String endTime) {
|
||||
// 创建 DateTimeFormatter 实例以解析指定日期的格式
|
||||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
// 解析指定日期字符串为 LocalDate 对象
|
||||
@ -51,13 +53,13 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,String>> findCheckticketcountBytime(String starTime, String endTime) {
|
||||
public List<Map<String, String>> findCheckticketcountBytime(String starTime, String endTime) {
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Calendar calendar2 = Calendar.getInstance();
|
||||
Date date1= null;
|
||||
Date date2= null;
|
||||
Date date1 = null;
|
||||
Date date2 = null;
|
||||
try {
|
||||
date1 = inputFormat.parse(starTime);
|
||||
date2 = inputFormat.parse(endTime);
|
||||
@ -67,11 +69,11 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
calendar.setTime(date1);
|
||||
calendar2.setTime(date2);
|
||||
// calendar.add(Calendar.DAY_OF_YEAR, -9);
|
||||
List<Map<String,String>>map = new ArrayList<>();
|
||||
while (!calendar.getTime().after(date2)){
|
||||
Map<String,String>map1= new HashMap<>();
|
||||
List<Map<String, String>> map = new ArrayList<>();
|
||||
while (!calendar.getTime().after(date2)) {
|
||||
Map<String, String> map1 = new HashMap<>();
|
||||
String date = inputFormat.format(calendar.getTime());
|
||||
map1.put("date",outputFormat.format(calendar.getTime()));
|
||||
map1.put("date", outputFormat.format(calendar.getTime()));
|
||||
map1.put("count", String.valueOf(saleDataRepository.countBySddate(date)));
|
||||
map.add(map1);
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
@ -83,11 +85,11 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
public List<Map<String, String>> findByGender(String starTime, String endTime) {
|
||||
AggregationVO allByCertificateno = saleDataRepository.findAllByCertificatenoSDTime(starTime, this.publicMethod(endTime));
|
||||
List<Map<String, String>> map = new ArrayList<>();
|
||||
Map<String,String>map1=new HashMap<>();
|
||||
Map<String,String>map2=new HashMap<>();
|
||||
map1.put("sex","女生" );
|
||||
map1.put("count",Long.toString(allByCertificateno.getFemaleCount()));
|
||||
map2.put("sex","男生" );
|
||||
Map<String, String> map1 = new HashMap<>();
|
||||
Map<String, String> map2 = new HashMap<>();
|
||||
map1.put("sex", "女生");
|
||||
map1.put("count", Long.toString(allByCertificateno.getFemaleCount()));
|
||||
map2.put("sex", "男生");
|
||||
map2.put("count", Long.toString(allByCertificateno.getMaleCount()));
|
||||
map.add(map1);
|
||||
map.add(map2);
|
||||
@ -96,28 +98,28 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> findByAge(String starTime, String endTime) {
|
||||
AgeVo byAge = saleDataRepository.findByAge(starTime,this.publicMethod(endTime));
|
||||
AgeVo byAge = saleDataRepository.findByAge(starTime, this.publicMethod(endTime));
|
||||
System.out.println("byAge = " + byAge);
|
||||
List<Map<String,String>>map=new ArrayList<>();
|
||||
Map<String,String>map1=new LinkedHashMap<>();
|
||||
Map<String,String>map2=new LinkedHashMap<>();
|
||||
Map<String,String>map3=new LinkedHashMap<>();
|
||||
Map<String,String>map4=new LinkedHashMap<>();
|
||||
Map<String,String>map5=new LinkedHashMap<>();
|
||||
Map<String,String>map6=new LinkedHashMap<>();
|
||||
List<Map<String, String>> map = new ArrayList<>();
|
||||
Map<String, String> map1 = new LinkedHashMap<>();
|
||||
Map<String, String> map2 = new LinkedHashMap<>();
|
||||
Map<String, String> map3 = new LinkedHashMap<>();
|
||||
Map<String, String> map4 = new LinkedHashMap<>();
|
||||
Map<String, String> map5 = new LinkedHashMap<>();
|
||||
Map<String, String> map6 = new LinkedHashMap<>();
|
||||
|
||||
map1.put("age","20以下");
|
||||
map1.put("count",byAge.getOne());
|
||||
map2.put("age","20-30");
|
||||
map2.put("count",byAge.getTwo());
|
||||
map3.put("age","30-40");
|
||||
map3.put("count",byAge.getThree());
|
||||
map4.put("age","40-50");
|
||||
map4.put("count",byAge.getFour());
|
||||
map5.put("age","50-60");
|
||||
map5.put("count",byAge.getFive());
|
||||
map6.put("age","60以上");
|
||||
map6.put("count",byAge.getSix());
|
||||
map1.put("age", "20以下");
|
||||
map1.put("count", byAge.getOne());
|
||||
map2.put("age", "20-30");
|
||||
map2.put("count", byAge.getTwo());
|
||||
map3.put("age", "30-40");
|
||||
map3.put("count", byAge.getThree());
|
||||
map4.put("age", "40-50");
|
||||
map4.put("count", byAge.getFour());
|
||||
map5.put("age", "50-60");
|
||||
map5.put("count", byAge.getFive());
|
||||
map6.put("age", "60以上");
|
||||
map6.put("count", byAge.getSix());
|
||||
map.add(map1);
|
||||
map.add(map2);
|
||||
map.add(map3);
|
||||
@ -165,6 +167,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
// String end = date.format(endOfYear);
|
||||
return saleDataRepository.findBySddateBetween(starTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaleData> findEventsThisYear() {
|
||||
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
@ -173,7 +176,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
LocalDate endOfYear = thisYear.withDayOfYear(thisYear.lengthOfYear());
|
||||
String start = date.format(startOfYear);
|
||||
String end = date.format(endOfYear);
|
||||
return saleDataRepository.findBySddateBetween(start,end);
|
||||
return saleDataRepository.findBySddateBetween(start, end);
|
||||
}
|
||||
|
||||
|
||||
@ -185,7 +188,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
// LocalDate endOfYear = thisYear.withDayOfYear(thisYear.lengthOfYear());
|
||||
// String start = date.format(startOfYear);
|
||||
// String end = date.format(endOfYear);
|
||||
return saleDataRepository.findBySddateBetween(starTime,endTime);
|
||||
return saleDataRepository.findBySddateBetween(starTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -228,15 +231,14 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> findBySaleMethod(String starTime, String endTime) {
|
||||
List<SaleData> saleDataList = saleDataRepository.findAllByTransactiontypenoTime(starTime, this.publicMethod(endTime));
|
||||
int[] saleMethodCounts = new int[5];
|
||||
Map<String,String>map=new LinkedHashMap<>();
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
for (SaleData saleData : saleDataList) {
|
||||
String transactiontypeno = saleData.getTransactiontypeno();
|
||||
switch (transactiontypeno){
|
||||
switch (transactiontypeno) {
|
||||
case "SD01":
|
||||
saleMethodCounts[0]++;
|
||||
break;
|
||||
@ -261,11 +263,11 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
map.put("特殊退票", String.valueOf(saleMethodCounts[2]));
|
||||
map.put("预约单", String.valueOf(saleMethodCounts[3]));
|
||||
map.put("快速购票", String.valueOf(saleMethodCounts[4]));
|
||||
List<Map<String,String>>mapList=new ArrayList<>();
|
||||
List<Map<String, String>> mapList = new ArrayList<>();
|
||||
for (Map.Entry<String, String> stringStringEntry : map.entrySet()) {
|
||||
Map<String, String> map1=new LinkedHashMap<>();
|
||||
map1.put("transactiontypeno",stringStringEntry.getKey());
|
||||
map1.put("count",stringStringEntry.getValue());
|
||||
Map<String, String> map1 = new LinkedHashMap<>();
|
||||
map1.put("transactiontypeno", stringStringEntry.getKey());
|
||||
map1.put("count", stringStringEntry.getValue());
|
||||
mapList.add(map1);
|
||||
}
|
||||
return mapList;
|
||||
@ -279,23 +281,23 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
List<Map<String, String>> mapArrayList = new ArrayList<>();
|
||||
for (String s : countMap.keySet()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("TypeName",s);
|
||||
map.put("count",countMap.get(s).toString());
|
||||
map.put("TypeName", s);
|
||||
map.put("count", countMap.get(s).toString());
|
||||
mapArrayList.add(map);
|
||||
// map.clear();
|
||||
}
|
||||
if (mapArrayList.size() == 0){
|
||||
if (mapArrayList.size() == 0) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("TypeName","景点");
|
||||
map.put("count","0");
|
||||
map.put("TypeName", "景点");
|
||||
map.put("count", "0");
|
||||
mapArrayList.add(map);
|
||||
HashMap<String, String> map1 = new HashMap<>();
|
||||
map1.put("TypeName","公园");
|
||||
map1.put("count","0");
|
||||
map1.put("TypeName", "公园");
|
||||
map1.put("count", "0");
|
||||
mapArrayList.add(map1);
|
||||
HashMap<String, String> map2 = new HashMap<>();
|
||||
map2.put("TypeName","遗迹");
|
||||
map2.put("count","0");
|
||||
map2.put("TypeName", "遗迹");
|
||||
map2.put("count", "0");
|
||||
mapArrayList.add(map2);
|
||||
}
|
||||
|
||||
@ -316,7 +318,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
for (SaleData saleData : saleDataList) {
|
||||
String sddate = saleData.getSddate();
|
||||
String substring = sddate.substring(6, 8);
|
||||
switch (substring){
|
||||
switch (substring) {
|
||||
case "01":
|
||||
Counts[0]++;
|
||||
break;
|
||||
@ -336,17 +338,17 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Map<String,String>>mapList=new ArrayList<>();
|
||||
Map<String,String> map=new LinkedHashMap();
|
||||
List<Map<String, String>> mapList = new ArrayList<>();
|
||||
Map<String, String> map = new LinkedHashMap();
|
||||
map.put("第一天", String.valueOf(Counts[0]));
|
||||
map.put("第二天", String.valueOf(Counts[1]));
|
||||
map.put("第三天", String.valueOf(Counts[2]));
|
||||
map.put("第四天", String.valueOf(Counts[3]));
|
||||
map.put("第五天", String.valueOf(Counts[4]));
|
||||
for (Map.Entry stringStringEntry : map.entrySet()) {
|
||||
Map map1=new LinkedHashMap();
|
||||
map1.put("day",stringStringEntry.getKey());
|
||||
map1.put("count",stringStringEntry.getValue());
|
||||
Map map1 = new LinkedHashMap();
|
||||
map1.put("day", stringStringEntry.getKey());
|
||||
map1.put("count", stringStringEntry.getValue());
|
||||
mapList.add(map1);
|
||||
}
|
||||
return mapList;
|
||||
@ -366,7 +368,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
for (SaleData saleData : saleDataList) {
|
||||
String sddate = saleData.getSddate();
|
||||
String substring = sddate.substring(6, 8);
|
||||
switch (substring){
|
||||
switch (substring) {
|
||||
case "01":
|
||||
Counts[0]++;
|
||||
break;
|
||||
@ -392,8 +394,8 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Map<String,String>>mapList=new ArrayList<>();
|
||||
Map<String,String> map=new LinkedHashMap();
|
||||
List<Map<String, String>> mapList = new ArrayList<>();
|
||||
Map<String, String> map = new LinkedHashMap();
|
||||
map.put("第一天", String.valueOf(Counts[0]));
|
||||
map.put("第二天", String.valueOf(Counts[1]));
|
||||
map.put("第三天", String.valueOf(Counts[2]));
|
||||
@ -402,9 +404,9 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
map.put("第六天", String.valueOf(Counts[5]));
|
||||
map.put("第七天", String.valueOf(Counts[6]));
|
||||
for (Map.Entry stringStringEntry : map.entrySet()) {
|
||||
Map map1=new LinkedHashMap();
|
||||
map1.put("day",stringStringEntry.getKey());
|
||||
map1.put("count",stringStringEntry.getValue());
|
||||
Map map1 = new LinkedHashMap();
|
||||
map1.put("day", stringStringEntry.getKey());
|
||||
map1.put("count", stringStringEntry.getValue());
|
||||
mapList.add(map1);
|
||||
}
|
||||
return mapList;
|
||||
@ -424,23 +426,23 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
assert date1 != null;
|
||||
calendar.setTime(date1);
|
||||
calendar.add(Calendar.DAY_OF_YEAR, -29);
|
||||
Map<String,String> map = new LinkedHashMap<>();
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
int count = 0;
|
||||
while (!calendar.getTime().after(date1)){
|
||||
while (!calendar.getTime().after(date1)) {
|
||||
String date = inputFormat.format(calendar.getTime());
|
||||
long i = saleDataRepository.countBySddate(date);
|
||||
count+=i;
|
||||
count += i;
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
return String.valueOf(count/30);
|
||||
return String.valueOf(count / 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal findyearJun(List<SaleData> list) {
|
||||
BigDecimal total=new BigDecimal(0);
|
||||
BigDecimal total = new BigDecimal(0);
|
||||
for (SaleData saleData : list) {
|
||||
BigDecimal amount = saleData.getAmount();
|
||||
total=total.add(amount);
|
||||
total = total.add(amount);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@ -450,5 +452,59 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
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";
|
||||
@GetMapping(PREFIX + "/list/testFeign")
|
||||
@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;
|
||||
|
||||
@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的请求");
|
||||
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()));
|
||||
}
|
||||
|
||||
default List<CameraDO> selectCameraByRegionIndexCodePage(String regionIndexCode, Integer start, Integer end) {
|
||||
return selectList(new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getRegionIndexCode, regionIndexCode).last("limit " + start + "," + end));
|
||||
default List<CameraDO> selectCameraByRegionIndexCodeAndCameraNamePage(String regionIndexCode, String cameraName, Integer start, Integer 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);
|
||||
|
||||
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
|
||||
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;
|
||||
List<RegionDO> regionDOListResult = regionMapper.selectList();
|
||||
List<RegionCameraListDTO> regions = new ArrayList<>();
|
||||
@ -116,7 +116,7 @@ public class RegionServiceImpl implements RegionService {
|
||||
temp.setLeaf(regionDO.getLeaf());
|
||||
System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user