package com.bonus.canteen.core.report.datascreen.controller;

import cn.hutool.core.text.CharSequenceUtil;
import com.bonus.canteen.core.report.datascreen.dto.DatascreenDTO;
import com.bonus.canteen.core.report.datascreen.service.DatascreenService;
import com.bonus.canteen.core.report.datascreen.vo.DsAuthorityCanteenVO;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.houqin.utils.LeRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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.ArrayList;
import java.util.List;

@RestController
@RequestMapping({"/datascreen"})
@Api(
   value = "报表中心/数据大屏/前厅版本数据",
   tags = {"前厅版本数据"}
)
public class DatascreenController {
   private static final Logger log = LoggerFactory.getLogger(DatascreenController.class);
   @Autowired
   @Lazy
   private DatascreenService datascreenService;
//   @Autowired
//   @Lazy
//   private DashboardAuthorityService dashboardAuthorityService;
//   @Autowired
//   private DashboardService dashboardService;

   @PostMapping({"/getdatascreen"})
   @ApiOperation("获取数据大屏前厅版本数据内容")
   public AjaxResult getDatascreenData(@RequestBody DatascreenDTO dto) {
      List<DsAuthorityCanteenVO> canteenList = new ArrayList();
//      if (CharSequenceUtil.isNotBlank(content.getAuthorityId())) {
//         List<DashboardAuthority> authorities = this.dashboardAuthorityService.getDashboardAuthorityBySubject(content.getAuthorityId());
//         authorities.forEach((authority) -> {
//            DsAuthorityCanteenVO authorityPair;
//            if (CharSequenceUtil.isEmpty(authority.getStallIds())) {
//               authorityPair = new DsAuthorityCanteenVO();
//               authorityPair.setCanteenId(authority.getCanteenId());
//               authorityPair.setShopstallId(-1L);
//               canteenList.add(authorityPair);
//            } else {
//               String[] stallIds = authority.getStallIds().split(",");
//               String[] var4 = stallIds;
//               int var5 = stallIds.length;
//
//               for(int var6 = 0; var6 < var5; ++var6) {
//                  String stallId = var4[var6];
//                  authorityPair = new DsAuthorityCanteenVO();
//                  authorityPair.setCanteenId(authority.getCanteenId());
//                  authorityPair.setShopstallId(Long.valueOf(stallId));
//                  canteenList.add(authorityPair);
//               }
//
//            }
//         });
//      }

      DsAuthorityCanteenVO dsAuthorityCanteenVO = new DsAuthorityCanteenVO();
      dsAuthorityCanteenVO.setCanteenId(dto.getCanteenId());
      canteenList.add(dsAuthorityCanteenVO);
      return AjaxResult.success(this.datascreenService.getCurrentMealtimeNum(canteenList));
   }

}
