package com.gyee.runeconomy.controller.FiveLoss;

import com.alibaba.fastjson.JSONObject;
import com.gyee.runeconomy.dto.result.JsonResult;
import com.gyee.runeconomy.dto.result.ResultCode;
import com.gyee.runeconomy.service.fiveloss.FiveLossService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 损失电量分析
 */
@RestController
@CrossOrigin
@RequestMapping("/fjjxb")
public class FiveLossInfoController {

    @Resource
    private FiveLossService fiveLossService;

//    @GetMapping("/five/loss/cal")
//    public JSONObject fiveLossCal(String ids){
//        Map<String, Object> map = fiveLossService.fiveLossCalByZSGL3(ids);
//        if (map.size() > 0)
//            return JsonResult.successData(ResultCode.SUCCESS, map);
//
//        return JsonResult.error(ResultCode.ERROR_MODEL);
//    }

    @GetMapping("/loss/power/analysis")
    public JSONObject fiveLossCal(
            @RequestParam(value = "wpids", required = true) String wpids,
            @RequestParam(value = "beginDate", required = true) String beginDate,
            @RequestParam(value = "endDate", required = true) String endDate
    ){
        Map<String, Object> map = fiveLossService.lossPowerAnalysis(wpids, beginDate, endDate);
        if (map.size() > 0)
            return JsonResult.successData(ResultCode.SUCCESS, map);

        return JsonResult.error(ResultCode.ERROR_MODEL);
//        System.out.println("ceshi");
//        return "ok";
    }
}
