anomalyCheckController.java 1.56 KB
package com.bsth.controller.realcontrol;

import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 相关数据异常检测
 * Created by panzhao on 2017/4/14.
 */
@RestController
@RequestMapping("anomalyCheck")
public class anomalyCheckController {


    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    DayOfSchedule dayOfSchedule;
    /**
     * 出现重复班次的车辆
     * @param nbbm
     */
    @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
    public void schRepeat(@RequestParam String nbbm){
        logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
        List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);

        Set<ScheduleRealInfo> set = new HashSet<>();
        for(ScheduleRealInfo sch : list){
            if(!set.add(sch)){
                logger.info("出现一次重复班次,班次ID:" + sch.getId());
            }
        }

        if(set.size() > 0){
            dayOfSchedule.replaceByNbbm(nbbm, set);
        }
    }
}