package com.casic.PgInterface.rs;

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

@Component
@Path("pgAssetRecordRs")
public class PgAssetRecordRs {

    @Resource
    private PgAssetInSpectionRecordManager pgAssetInSpectionRecordManager;

    /**
     * 获取巡检记录
     */
    @POST
    @Path("getPgAssetRecordList")
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String,Object> getPgAssetRecordList(@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<PgAssetInSpectionRecordDto> pgAssetInSpectionRecordDtoList=new ArrayList<>();
        try{
            pgAssetInSpectionRecordDtoList=pgAssetInSpectionRecordManager.getPgAssetInSpectionRecordLsit(recordNo,planName,startTime,endTime);
            if(pgAssetInSpectionRecordDtoList!=null&&pgAssetInSpectionRecordDtoList.size()!=0)
                msg="巡检信息获取成功";
            else
                msg="不存在巡检信息";
        }
        catch(Exception ex){
            ex.printStackTrace();
            msg="巡检信息获取失败";
        }

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

        return resultMap;
    }

}