package com.sckw.example.controller;

import com.sckw.core.web.context.LoginUserHolder;
import com.sckw.example.service.TransportService;
import com.sckw.system.api.RemoteSystemService;
import com.sckw.system.api.model.dto.res.EntCacheResDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
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.RestController;

/**
 * @desc: 测试
 * @author: lfdc
 * @date: 2023-09-08 14:20
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/transportTest")
public class TransportController {

    @Autowired
    private TransportService transportService;

    @DubboReference(version = "1.0.0", group = "design", check = false)
    private RemoteSystemService systemService;

    /**
     * 统计承运接单
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/statisticsLogistics", method = RequestMethod.GET)
    public Integer statisticsLogistics() {
        EntCacheResDto entCacheResDto = systemService.queryEntTreeById(LoginUserHolder.getEntId());
        Long topEntId = entCacheResDto.getId();
        Integer integer = transportService.statisticsLogistics(topEntId);
        return integer;
    }

    /**
     * 统计调度派车
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/statisticsWaybillSendCar", method = RequestMethod.GET)
    public Integer statisticsWaybillSendCar() {
        EntCacheResDto entCacheResDto = systemService.queryEntTreeById(LoginUserHolder.getEntId());
        Long topEntId = entCacheResDto.getId();
        Integer integer = transportService.statisticsWaybillSendCar(topEntId);
        return integer;
    }

    /**
     * 统计待核运单
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/statisticsPendingVerificationWaybill", method = RequestMethod.GET)
    public Integer statisticsPendingVerificationWaybill(){
        EntCacheResDto entCacheResDto = systemService.queryEntTreeById(LoginUserHolder.getEntId());
        Long topEntId = entCacheResDto.getId();
        Integer integer = transportService.statisticsPendingVerificationWaybill(topEntId);
        return integer;
    }

    @RequestMapping(value = "/refreshScopeDemo", method = RequestMethod.GET)
    public void refreshScopeDemo(){
        transportService.refreshScopeDemo();
    }


}
