package com.casic.PgInterface.rs;

import com.casic.PgInterface.maintenance.dto.PgMaintanceRecordHeadStatic;
import com.casic.PgInterface.maintenance.manager.PgMaintanceRecordHeadManager;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
@Path("pgMaintanceRecordStaticRs")
public class PgMaintanceRecordStaticRs {

    @Resource
    private PgMaintanceRecordHeadManager pgMaintanceRecordHeadManager;


    @POST
    @Path("getPgMaintanceRecordHeadStaticList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgMaintanceRecordHeadStaticList(@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<PgMaintanceRecordHeadStatic> pgMaintanceRecordHeadStaticList=new ArrayList<>();
        try{
            pgMaintanceRecordHeadStaticList=pgMaintanceRecordHeadManager.getPgMaintanceRecordHeadStaticLisByTime(startTime,endTime,staticType);
            if(pgMaintanceRecordHeadStaticList!=null&&pgMaintanceRecordHeadStaticList.size()!=0)
                msg="维护统计信息获取成功";
            else
                msg="维护统计失败";
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            msg="统计失败";
        }

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

        return resultMap;
    }
}
