新票务集合补充
This commit is contained in:
parent
2dba47b01b
commit
3d7b4a00a2
@ -18,5 +18,13 @@ public interface CheckTicketTodayRepository extends MongoRepository<CheckTicketT
|
||||
* @return java.util.List<cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicket>
|
||||
*/
|
||||
@Query(value = "{ 'dataId': { $in: ?0 } }", fields = "{ 'dataId': 1, '_id': 0 }")
|
||||
List<CheckTicket> findByDataIdIn(List<String> dataIdList);
|
||||
List<CheckTicketToday> findByDataIdIn(List<String> dataIdList);
|
||||
/**
|
||||
* 找到所有不在时间段内的日期字段
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return java.util.List<cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketToday>
|
||||
*/
|
||||
@Query("{ 'checkticketdate': { $not: { $gte: ?0, $lt: ?1 } } }")
|
||||
List<CheckTicketToday> findNotInTimeRange(String startDate, String endDate);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.infra.dal.mongodb.saledata;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicket;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketToday;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.saledata.SaleData;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.saledata.SaleDataToday;
|
||||
import org.springframework.data.mongodb.repository.Aggregation;
|
||||
@ -68,5 +69,13 @@ public interface SaleDataTodayRepository extends MongoRepository<SaleDataToday,S
|
||||
* @return java.util.List<cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicket>
|
||||
*/
|
||||
@Query(value = "{ 'dataId': { $in: ?0 } }", fields = "{ 'dataId': 1, '_id': 0 }")
|
||||
List<CheckTicket> findByDataIdIn(List<String> dataIdList);
|
||||
List<SaleDataToday> findByDataIdIn(List<String> dataIdList);
|
||||
/**
|
||||
* 找到所有不在时间段内的日期字段
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return java.util.List<cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketToday>
|
||||
*/
|
||||
@Query("{ 'sddate': { $not: { $gte: ?0, $lt: ?1 } } }")
|
||||
List<SaleDataToday> findNotInTimeRange(String startDate, String endDate);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketToday;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -39,4 +40,11 @@ public interface CheckTicketService {
|
||||
*/
|
||||
List<Integer> insertByMongoDB(List<CheckTicket> checkTicketList);
|
||||
List<Integer> insertTodayByMongoDB(List<CheckTicketToday> checkTicketList);
|
||||
/**
|
||||
* 删除不在指定日期内的数据(mongodb)
|
||||
* @param startDate 如:"20240729"
|
||||
* @param endDate 如:"20240829"
|
||||
* @return java.util.List<java.lang.String> 删除的日期
|
||||
*/
|
||||
List<String> deleteNotInTimeZonesByMongoDB(String startDate,String endDate);
|
||||
}
|
@ -86,9 +86,9 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
List<String> dataIdList = checkTicketList.stream().map(CheckTicketToday::getDataId).collect(Collectors.toList());
|
||||
// 获取重复的dataId
|
||||
// 查询数据库中存在的 dataId
|
||||
List<CheckTicket> existingTickets = checkTicketTodayRepository.findByDataIdIn(dataIdList);
|
||||
List<CheckTicketToday> existingTickets = checkTicketTodayRepository.findByDataIdIn(dataIdList);
|
||||
// 把CheckTicket对象列表改为dataId字符串列表
|
||||
List<String> duplicatesDataId = existingTickets.stream().map(CheckTicket::getDataId).collect(Collectors.toList());
|
||||
List<String> duplicatesDataId = existingTickets.stream().map(CheckTicketToday::getDataId).collect(Collectors.toList());
|
||||
// 对checkTicketList过滤掉重复的dataId对应的数据,得到需要插入的不重复数据
|
||||
List<CheckTicketToday> insertCheckTicketList = checkTicketList.stream().filter(ticket -> !duplicatesDataId.contains(ticket.getDataId())).collect(Collectors.toList());
|
||||
try {
|
||||
@ -102,4 +102,18 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
return resultNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> deleteNotInTimeZonesByMongoDB(String startDate, String endDate) {
|
||||
|
||||
// 执行查询并获取要删除的数据
|
||||
List<CheckTicketToday> entitiesToDelete = checkTicketTodayRepository.findNotInTimeRange(startDate, endDate);
|
||||
// 执行删除操作
|
||||
checkTicketTodayRepository.deleteAll(entitiesToDelete);
|
||||
// 获取要删除的日期列表
|
||||
List<String> deletedDates = entitiesToDelete.stream()
|
||||
.map(CheckTicketToday::getCheckticketdate)
|
||||
.collect(Collectors.toList());
|
||||
return deletedDates;
|
||||
}
|
||||
|
||||
}
|
@ -42,4 +42,11 @@ public interface SaleDataService {
|
||||
*/
|
||||
List<Integer> insertByMongoDB(List<SaleData> saleDataList);
|
||||
List<Integer> insertTodayByMongoDB(List<SaleDataToday> saleDataList);
|
||||
/**
|
||||
* 删除不在指定日期内的数据(mongodb)
|
||||
* @param startDate 如:"20240729"
|
||||
* @param endDate 如:"20240829"
|
||||
* @return java.util.List<java.lang.String> 删除的日期
|
||||
*/
|
||||
List<String> deleteNotInTimeZonesByMongoDB(String startDate,String endDate);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.infra.service.saledata;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicket;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.checkticket.CheckTicketToday;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.saledata.SaleData;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.saledata.SaleDataDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.saledata.SaleDataToday;
|
||||
@ -77,9 +78,9 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
List<String> dataIdList = saleDataList.stream().map(SaleDataToday::getDataId).collect(Collectors.toList());
|
||||
// 获取重复的dataId
|
||||
// 查询数据库中存在的 dataId
|
||||
List<CheckTicket> existingTickets = saleDataRepository.findByDataIdIn(dataIdList);
|
||||
List<SaleDataToday> existingTickets = saleDataTodayRepository.findByDataIdIn(dataIdList);
|
||||
// 把CheckTicket对象列表改为dataId字符串列表
|
||||
List<String> duplicatesDataId = existingTickets.stream().map(CheckTicket::getDataId).collect(Collectors.toList());
|
||||
List<String> duplicatesDataId = existingTickets.stream().map(SaleDataToday::getDataId).collect(Collectors.toList());
|
||||
// 对checkTicketList过滤掉重复的dataId对应的数据,得到需要插入的不重复数据
|
||||
List<SaleDataToday> insertSaleDataList = saleDataList.stream().filter(saleData -> !duplicatesDataId.contains(saleData.getDataId())).collect(Collectors.toList());
|
||||
try {
|
||||
@ -92,6 +93,18 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
resultNum.add(duplicatesDataId.size());
|
||||
return resultNum;
|
||||
}
|
||||
@Override
|
||||
public List<String> deleteNotInTimeZonesByMongoDB(String startDate, String endDate) {
|
||||
|
||||
// 执行查询并获取要删除的数据
|
||||
List<SaleDataToday> entitiesToDelete = saleDataTodayRepository.findNotInTimeRange(startDate, endDate);
|
||||
// 执行删除操作
|
||||
saleDataTodayRepository.deleteAll(entitiesToDelete);
|
||||
// 获取要删除的日期列表
|
||||
List<String> deletedDates = entitiesToDelete.stream()
|
||||
.map(SaleDataToday::getSddate)
|
||||
.collect(Collectors.toList());
|
||||
return deletedDates;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user