package com.casic.PgInterface.rs;

import com.casic.PgInterface.maintenance.dto.PgMaintanceRecordHeadDto;
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("pgMaintanceRecordRs")
public class PgMaintanceRecordRs {

    @Resource
    private PgMaintanceRecordHeadManager pgMaintanceRecordHeadManager;

    /**
     * 获取维护记录
     */
    @POST
    @Path("getPgMaintanceList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgMaintanceList(@FormParam("recordNo") String recordNo,
                                                 @FormParam("planName") String planName,
                                                 @FormParam("startTime") String startTime,
                                                 @FormParam("endTime") String endTime){
        Map<String,Object> resultMap=new HashMap<>();
        String msg="";

        List<PgMaintanceRecordHeadDto> pgMaintanceRecordHeadDtoList=new ArrayList<>();
        try{
            pgMaintanceRecordHeadDtoList=pgMaintanceRecordHeadManager.getPgMaintanceRecordHeadLsit(recordNo,planName,startTime,endTime);
            if(pgMaintanceRecordHeadDtoList!=null&&pgMaintanceRecordHeadDtoList.size()!=0)
                msg="维护信息获取成功";
            else
                msg="不存在维护信息";
        }
        catch(Exception ex){
            ex.printStackTrace();
            msg="巡检信息获取失败";
        }

        resultMap.put("msg",msg);
        resultMap.put("resutl",pgMaintanceRecordHeadDtoList);

        return resultMap;
    }

}
