package com.ruoyi.demo.controller;


import com.ruoyi.common.core.domain.R;
import com.ruoyi.demo.entity.vo.AddStatusVo;
import com.ruoyi.demo.entity.vo.ListQueryBody;
import com.ruoyi.demo.entity.vo.OpcloseTimeVo;
import com.ruoyi.demo.entity.vo.WdOpcloseVo;
import com.ruoyi.demo.service.WdInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/WdInfo")
public class WdInfoController {
    @Autowired
    WdInfoService wdInfoService;

//    获取各地区网点分类分布情况
//    已废弃
//    @PostMapping("/categoryDistribution")
//    public R categoryDistribution(ListQueryBody body){
//        List<String> addrCodes = body.getAddrCode();
//        List<String> typeCodes = body.getTypeCode();
//        return R.ok(wdInfoService.searchAddrTypeDistribution(addrCodes,typeCodes));
//    }

//    获取各地区网点类型分布情况
//    已废弃
//    @PostMapping("/wdTypeDistribution")
//    public R wdTypeDistribution(ListQueryBody body){
//        List<String> addrCodes = body.getAddrCode();
//        List<String> typeCodes = body.getTypeCode();
//        return R.ok(wdInfoService.searchWdTypeDistribution(addrCodes,typeCodes));
//    }

//    获取所有网点类型网点数量(降序)
//    已废弃
//    @GetMapping("/total")
//    public R total(){
//        return R.ok(wdInfoService.searchWdTotal());
//    }

    //    网点数量新增情况
    @PostMapping("/addStatus")
    public R addStatus(ListQueryBody body){
        List<String> addrCode = body.getAddrCode();
        List<String> typeCode = body.getTypeCode(); // 网点类型
        List<AddStatusVo> addStatusVos = wdInfoService.searchAddStatus(addrCode, typeCode);
        return R.ok(addStatusVos);
    }

    //    近期各地区网点开关数量变化情况
    @PostMapping("/opclose")
    public R opclose(@RequestBody ListQueryBody body){
        List<String> addrCode = body.getAddrCode();
        List<String> wdTypeCode = body.getTypeCode(); // 网点类型
        List<WdOpcloseVo> wdOpcloseVos = wdInfoService.searchWdOpcloses(addrCode, wdTypeCode);
        return R.ok(wdOpcloseVos);
    }

    // 各地区网点开店时间分布情况
    @PostMapping("/opentime")
    public R openTime (@RequestBody ListQueryBody body) {
        List<String> addrCodes = body.getAddrCode();
        List<String> typeCodeBys = body.getTypeCodeBy();
        List<OpcloseTimeVo> vos = wdInfoService.searchOpenTimes(addrCodes, typeCodeBys);
        return R.ok(vos);
    }

    // 各地区网点关店时间分布情况
    @PostMapping("/closetime")
    public R closeTime (@RequestBody ListQueryBody body) {
        List<String> addrCodes = body.getAddrCode();
        List<String> typeCodeBys = body.getTypeCodeBy();
        List<OpcloseTimeVo> vos = wdInfoService.searchCloseTimes(addrCodes, typeCodeBys);
        return R.ok(vos);
    }
}
