package com.casic.PgInterface.rs;

import com.casic.PgInterface.maintenance.dto.PgAssetInSpectionRecordStatic;
import com.casic.PgInterface.maintenance.manager.PgAssetInSpectionRecordManager;
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("pgAssetRecordStaticRs")
public class PgAssetRecordStaticRs {

    @Resource
    private PgAssetInSpectionRecordManager pgAssetInSpectionRecordManager;

    @POST
    @Path("getPgAssetRecordHeadStaticList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgAssetRecordHeadStaticList(@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<PgAssetInSpectionRecordStatic> pgAssetInSpectionRecordStaticList = null;
        try{
            pgAssetInSpectionRecordStaticList=pgAssetInSpectionRecordManager.getPgAssetInSpectionRecordStaticLisByTime(startTime,endTime,staticType);
            if(pgAssetInSpectionRecordStaticList!=null&&pgAssetInSpectionRecordStaticList.size()!=0)
                msg="巡检统计信息获取成功";
            else
                msg="统计信息获取失败";
        }
        catch (Exception ex){
            ex.printStackTrace();
            msg="统计失败";
        }

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

        return resultMap;
    }


}