package com.casic.PgInterface.rs;

import com.casic.PgInterface.maintenance.dto.PgAssetPlanStatic;
import com.casic.PgInterface.maintenance.manager.PgAssetPlanManager;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
@Path("pgAssetPlanStaticRs")
public class PgAssetPlanStaticRs {

    @Resource
    private PgAssetPlanManager pgAssetPlanManager;

    @POST
    @Path("getPgAssetPlanStaticList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgAssetPlanStaticList(@FormParam("startTime") String startTime,
                                                       @FormParam("endTime") String endTime,
                                                       @FormParam("staticType") String staticType) throws Exception{
        Map<String,Object> resultMap=new HashMap<>();
        String msg="";
        String result="";

        List<PgAssetPlanStatic> pgAssetPlanStaticList = null;
        try{
            pgAssetPlanStaticList=pgAssetPlanManager.getPgAssetPlanStaticLisByTime(startTime,endTime,staticType);
            if(pgAssetPlanStaticList!=null&&pgAssetPlanStaticList.size()!=0)
                msg="巡检统计信息获取成功";
            else
                msg="统计信息获取失败";
        }
        catch (Exception ex){
            ex.printStackTrace();
            msg="统计失败";
        }

        resultMap.put("msg",msg);
        resultMap.put("result",pgAssetPlanStaticList);

        return resultMap;
    }

}
