package com.sundot.airport.item.service.impl;

import com.sundot.airport.item.domain.*;
import com.sundot.airport.item.mapper.HkLargeScreenMapper;
import com.sundot.airport.item.service.IHkLargeScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class HkLargeScreenServiceImpl implements IHkLargeScreenService {

    @Autowired
    private HkLargeScreenMapper mapper;

    @Override
    public HkScreenOperationSummaryVO getOperationSummary(Date startDate, Date endDate) {
        HkScreenOperationSummaryVO vo = mapper.getOperationSummary(startDate, endDate);
        return vo != null ? vo : new HkScreenOperationSummaryVO();
    }

    @Override
    public List<HkScreenT1PassengerTrendVO> getT1PassengerTrend(Date startDate, Date endDate) {
        return mapper.getT1PassengerTrend(startDate, endDate);
    }

    @Override
    public List<HkScreenT2PassengerTrendVO> getT2PassengerTrend(Date startDate, Date endDate) {
        return mapper.getT2PassengerTrend(startDate, endDate);
    }

    @Override
    public List<HkScreenLuggageCheckTrendVO> getLuggageCheckTrend(Date startDate, Date endDate) {
        return mapper.getLuggageCheckTrend(startDate, endDate);
    }

    @Override
    public List<HkScreenCargoTrendVO> getCargoTrend(Date startDate, Date endDate) {
        return mapper.getCargoTrend(startDate, endDate);
    }

    @Override
    public List<HkScreenVehicleCheckTrendVO> getVehicleCheckTrend(Date startDate, Date endDate) {
        return mapper.getVehicleCheckTrend(startDate, endDate);
    }

    @Override
    public List<HkScreenSeizureCategoryVO> getSeizureCategoryList(Date startDate, Date endDate) {
        HkScreenSeizureTotalVO total = mapper.getSeizureCategoryTotal(startDate, endDate);
        List<HkScreenSeizureCategoryVO> list = new ArrayList<>();
        if (total == null) return list;
        list.add(item("火种",     total.getFireSource()));
        list.add(item("刀具",     total.getKnife()));
        list.add(item("警械器具", total.getPoliceWeapon()));
        list.add(item("烟花爆竹", total.getFirework()));
        list.add(item("活体动物", total.getLiveAnimal()));
        list.add(item("腐蚀性物品", total.getCorrosive()));
        list.add(item("用假冒他", total.getFakeId()));
        list.add(item("爆炸装置", total.getExplosive()));
        list.add(item("工具",     total.getTool()));
        list.add(item("枪支弹药", total.getGunAmmo()));
        list.add(item("扫黄打非", total.getIllegal()));
        list.add(item("其他",     total.getOther()));
        return list;
    }

    @Override
    public List<HkScreenBrigadeSeizureVO> getBrigadeSeizureCompare(Date startDate, Date endDate) {
        return mapper.getBrigadeSeizureCompare(startDate, endDate);
    }

    @Override
    public HkScreenPowerBankSummaryVO getPowerBankSummary(Date startDate, Date endDate) {
        HkScreenPowerBankSummaryVO vo = mapper.getPowerBankSummary(startDate, endDate);
        return vo != null ? vo : new HkScreenPowerBankSummaryVO();
    }

    @Override
    public HkScreenPendingConfiscateSummaryVO getPendingConfiscateSummary(Date startDate, Date endDate) {
        HkScreenPendingConfiscateSummaryVO vo = mapper.getPendingConfiscateSummary(startDate, endDate);
        return vo != null ? vo : new HkScreenPendingConfiscateSummaryVO();
    }

    private HkScreenSeizureCategoryVO item(String name, Long total) {
        HkScreenSeizureCategoryVO vo = new HkScreenSeizureCategoryVO();
        vo.setName(name);
        vo.setTotal(total != null ? total : 0L);
        return vo;
    }
}
