ToolController.java 1.89 KB
package com.viontech.keliu.controller;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.viontech.keliu.service.PersonGroupService;
import com.viontech.keliu.service.PersonRecordService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: zhuhai
 * Date: 2022-11-03
 * Time: 15:15
 */
@RestController
@RequestMapping("/tool")
public class ToolController {

    @Resource
    private PersonRecordService personRecordService;
    /*@Resource
    private PersonGroupService personGroupService;*/
    /*@GetMapping("/buildData")
    public String buildData(String startDate, String endDate) {
        DateTime startDateTime = DateUtil.parse(startDate, "yyyy-MM-dd");
        DateTime endDateTime = DateUtil.parse(endDate, "yyyy-MM-dd");
        List<DateTime> dateTimes = DateUtil.rangeToList(startDateTime, endDateTime, DateField.DAY_OF_MONTH);
        for (DateTime dateTime : dateTimes) {
            personGroupService.personToGroup(mallIdList, dateTime);
        }
        return "success";
    }*/

    @GetMapping("/build/personRecord")
    public String buildPersonRecord(Long mallId, String startDate, String endDate) {
        DateTime startDateTime = DateUtil.parse(startDate, "yyyy-MM-dd");
        DateTime endDateTime = DateUtil.parse(endDate, "yyyy-MM-dd");
        List<DateTime> dateTimes = DateUtil.rangeToList(startDateTime, endDateTime, DateField.DAY_OF_MONTH);
        for (DateTime dateTime : dateTimes) {
            personRecordService.handlePersonRecord(mallId, dateTime);
        }
        return "success";
    }
}