package com.tourism.webadmin.app.website.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.tourism.common.core.util.MyDateUtil;
import com.tourism.webadmin.back.model.*;
import com.tourism.webadmin.back.service.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tourism.webadmin.app.website.service.CleanDataService;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 数据清洗接口。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Tag(name = "数据清洗接口")
@Slf4j
@RestController
@RequestMapping("/cleanData")
public class CleanDataController {

//    @Autowired
//    private CleanDataService cleanDataService;
//    @Autowired
//    private TourismProjectService tourismProjectService;
//    @Autowired
//    private TourismDatePriceService tourismDatePriceService;
//
//    /**
//     * 列出符合过滤条件个人订单列表。
//     *
//     *
//     * @return 应答结果对象，包含查询结果集。
//     */
//    @SaIgnore
//    @GetMapping("/cleanRichTextData")
//    public void cleanRichTextData() throws Exception{
//        cleanDataService.cleanRichTextData();
//    }
//
//    /**
//     * 根据项目生成未来三个月的日历价格。
//     * @return 应答结果对象，包含查询结果集。
//     */
//    @PostMapping("/generateDatePrice")
//    public void generateDatePrice(){
//        TourismProject tourismProject = new TourismProject();
//        List<TourismProject> tourismProjectList =
//                tourismProjectService.getTourismProjectList(tourismProject, "");
//        //for循环根据日期遍历
//        tourismProjectList.stream().forEach(item->{
//            Date date = DateUtils.addMonths(MyDateUtil.truncateToDay(new Date()),3);
//            List<TourismDatePrice> tourismDatePriceList = new ArrayList<>();
//            for(Date date1 = MyDateUtil.truncateToDay(new Date());date1.before(date);date1 = DateUtils.addDays(date1,1)) {
//                TourismDatePrice tourismDatePrice = new TourismDatePrice();
//                tourismDatePrice.setProjectId(item.getId());
//                tourismDatePrice.setAdultPrice(item.getPrice());
//                tourismDatePrice.setChildrenPrice(item.getPrice());
//                tourismDatePrice.setDepartureDate(date1);
//                tourismDatePriceList.add(tourismDatePrice);
//            }
//            tourismDatePriceService.saveNewBatch(tourismDatePriceList);
//        });
//
//    }

//
//    @Autowired
//    private TourTourismProjectTravelNotesService tourTourismProjectTravelNotesService;
//
//    @Autowired
//    private TourTourismTravelNotesContentService tourTourismTravelNotesContentService;
//
//    @Autowired
//    private TourismProjectTravelNotesWriteService tourismProjectTravelNotesWriteService;
//
//    @Autowired
//    private TourismProjectTravelNotesWriteService writeService;
//
//    @Autowired
//    private TourismTravelNotesContentWriteService contentWriteService;
//
//    @SaIgnore
//    @GetMapping("/test")
//    public void moveData(){
//        // 查询原游记信息
//        List<TourTourismProjectTravelNotes> originNoteList = tourTourismProjectTravelNotesService.getTourTourismProjectTravelNotesList(new TourTourismProjectTravelNotes(), "");
//        // 游记主表数据写入write表
//        List<TourismProjectTravelNotesWrite> writeList = new ArrayList<>();
//        List<TourismTravelNotesContentWrite> contentList = new ArrayList<>();
//        originNoteList.forEach(e->{
//            TourismProjectTravelNotesWrite write = new TourismProjectTravelNotesWrite();
//            write.setId(Long.valueOf(e.getId()));
//            write.setProjectTitle(e.getProjectTitle());
//            write.setRemarks(e.getRemarks());
//            //热点
//            write.setIsHotspot(e.getIsHotspot());
//            //标签
//            write.setNoteLabel(e.getProjectLabel());
//            //目的地
//            write.setEndPlace(e.getBelongTab());
//            write.setCountTimes(e.getCountTimes());
//            write.setTourismUrl(e.getTourismUrl());
//            write.setCreateTime(e.getCreateTime());
//            write.setCreateUserId(e.getCreateUserId());
//            write.setUpdateTime(e.getUpdateTime());
//            write.setUpdateUserId(e.getUpdateUserId());
//            write.setDataState(e.getDataState());
//            write.setTravelNotesBanner(e.getTravelNotesBanner());
//            write.setLikeCount(e.getLikeCount());
//            write.setPageViewCount(e.getPageViewCount());
//            write.setRole(e.getRole());
//            write.setDepartureTime(e.getDepartureTime());
//            write.setAverageCost(e.getAverageCost());
//            write.setRecommendationRate(e.getRecommendationRate());
//            write.setHotValue(e.getHotValue());
//            write.setIsOriginal(e.getIsOriginal());
//            write.setState(3);
//            write.setUnmountState(1);
//            writeList.add(write);
//        });
//
//        List<TourTourismTravelNotesContent> originContentList = tourTourismTravelNotesContentService.getTourTourismTravelNotesContentList(new TourTourismTravelNotesContent(), "");
//        // 游记富文本数据写入write_content表
//        originContentList.forEach(e->{
//            List<TourismTravelNotesContentWrite> content = tourismProjectTravelNotesWriteService.parseHTML(e);
//            contentList.addAll(content);
//        });
//
//        log.info("清洗完了~~~");
//
//        writeService.saveNewBatch(writeList);
//        contentWriteService.saveNewBatch(contentList);
//        // 结束
//    }
}
