package com.casic.PgInterface.rs;

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

@Component
@Path("pgAssetPlanRs")
public class PgAssetPlanRs {

    @Resource
    private PgAssetPlanManager pgAssetPlanManager;

    /**
     * 获取巡检记录
     */
    @POST
    @Path("getPgAssetPlanList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgAssetPlanList(@FormParam("startDay") String startDay,
                                                 @FormParam("endDay") String endDay,
                                                 @FormParam("inSpectionPlace") String inSpectionPlace){
        Map<String,Object> resultMap=new HashMap<>();
        String msg="";

        List<PgAssetPlanDto> pgAssetPlanDtoList=new ArrayList<>();
        try{
            pgAssetPlanDtoList=pgAssetPlanManager.getPgAssetPlanDtoList(startDay,endDay,inSpectionPlace);
            if(pgAssetPlanDtoList!=null&&pgAssetPlanDtoList.size()!=0)
                msg="巡检信息获取成功";
            else
                msg="不存在巡检信息";
        }
        catch(Exception ex){
            ex.printStackTrace();
            msg="巡检信息获取失败";
        }

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

        return resultMap;
    }
}
