1;历史数据新增

This commit is contained in:
wangshuai 2024-08-04 11:02:12 +08:00
parent 781a39d137
commit 6d9480ad5d
3 changed files with 30 additions and 17 deletions

View File

@ -66,4 +66,6 @@ public interface BusStoreDayHistoryInfoMapper
BusStoreDayHistoryInfo getByDate(@Param("id") Long id, @Param("sT") String sT, @Param("eT") String eT);
List<BusStoreDayHistoryInfo> selectBusStoreDayHistoryInfoListByDate(@Param("id") Long id,@Param("date") String date);
void insertBatchStoreDayHistoryInfo(@Param("addList") List<BusStoreDayHistoryInfo> addList);
}

View File

@ -842,33 +842,35 @@ public class MeituanServiceImpl implements IMeituanService {
@Override
public void getReturnInfo(Long id) {
getComments(null);
log.error("***********history************************");
List<BusStoreDayHistoryInfo> addList = new ArrayList<>();
List<BusStoreDayHistoryInfo> editList = new ArrayList<>();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime date = LocalDateTime.now().minusDays(1);
BusStoreInfo storeInfo = new BusStoreInfo();
BusStoreDayInfo storeInfo = new BusStoreDayInfo();
if (id != null){
storeInfo.setId(id);
storeInfo.setStoreId(id);
}
List<BusStoreInfo> storeInfoList = busStoreInfoMapper.selectBusStoreInfoListA(storeInfo);
for (BusStoreInfo busStoreInfo : storeInfoList) {
List<BusStoreDayInfo> list1 = busStoreDayInfoMapper.selectBusStoreDayInfoListByDate(busStoreInfo.getId(),date.format(dateTimeFormatter));
if (list1.size() == 1) {
BusStoreDayInfo busStoreDayInfo = list1.get(0);
List<BusStoreDayHistoryInfo> list2 = busStoreDayHistoryInfoMapper.selectBusStoreDayHistoryInfoListByDate(busStoreInfo.getId(),date.format(dateTimeFormatter));
if (list2.size() > 0){
BusStoreDayHistoryInfo target = new BusStoreDayHistoryInfo();
BeanUtils.copyProperties(busStoreDayInfo, target);
target.setId(list2.get(0).getId());
busStoreDayHistoryInfoMapper.updateBusStoreDayHistoryInfo(target);
}else {
// List<BusStoreInfo> storeInfoList = busStoreInfoMapper.selectBusStoreInfoListA(storeInfo);
List<BusStoreDayInfo> list1 = busStoreDayInfoMapper.selectBusStoreDayInfoListByDate(storeInfo.getStoreId(),date.format(dateTimeFormatter));
for (BusStoreDayInfo busStoreDayInfo : list1) {
// if (list1.size() == 1) {
// BusStoreDayInfo busStoreDayInfo = list1.get(0);
List<BusStoreDayHistoryInfo> list2 = busStoreDayHistoryInfoMapper.selectBusStoreDayHistoryInfoListByDate(busStoreDayInfo.getStoreId(),date.format(dateTimeFormatter));
if (list2.size() == 0){
BusStoreDayHistoryInfo target = new BusStoreDayHistoryInfo();
BeanUtils.copyProperties(busStoreDayInfo, target);
target.setId(null);
target.setCreateTime(Date.from(date.atZone(ZoneId.systemDefault()).toInstant()));
busStoreDayHistoryInfoMapper.insertBusStoreDayHistoryInfo(target);
// busStoreDayHistoryInfoMapper.insertBusStoreDayHistoryInfo(target);
addList.add(target);
}
}
// }
}
if(addList.size()>0){
busStoreDayHistoryInfoMapper.insertBatchStoreDayHistoryInfo(addList);
}
log.error("***********historyEnd************************");
}
private String getRate(int a, int b){

View File

@ -126,6 +126,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<insert id="insertBatchStoreDayHistoryInfo">
insert into bus_store_day_history_info (store_id,last_order_num,last_positive_reviews_num,last_five_star_reviews_num,
last_return_visit_num,last_return_visit_rate,today_return_visit_num,score,create_time) values
<foreach collection="addList" separator="," item="item">
(#{item.storeId},#{item.lastOrderNum},#{item.lastPositiveReviewsNum},#{item.lastFiveStarReviewsNum},
#{item.lastReturnVisitNum},#{item.lastReturnVisitRate},#{item.todayReturnVisitNum},#{item.score},#{item.createTime})
</foreach>
</insert>
<update id="updateBusStoreDayHistoryInfo" parameterType="BusStoreDayHistoryInfo">
update bus_store_day_history_info