package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.tunnelFacility;

import com.alibaba.fastjson2.JSONArray;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.HorizontalChannelDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelFacilityDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV1DO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;

import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.stream.Collectors;

import com.alibaba.excel.annotation.*;

@Schema(description = "管理后台 - 隧道设施 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TunnelFacilityRespVO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29458")
    @ExcelProperty("主键")
    private String id;

    @Schema(description = "设施名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @ExcelProperty("设施名称")
    private String facilityName;

    @Schema(description = "设施编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @ExcelProperty("设施编码")
    private String facilityEncode;

    @Schema(description = "所属路段", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("所属路段")
    private String belongSections;

    @Schema(description = "管理中心", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("管理中心")
    private String managementCenter;

    @Schema(description = "隧道所", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("隧道所")
    private String tunnelDept;

    @Schema(description = "隧道类型 0双洞双向1单洞双向2单洞单向", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @ExcelProperty("隧道类型 0双洞双向1单洞双向2单洞单向")
    private Integer tunnelType;

    @Schema(description = "排序")
    @ExcelProperty("排序")
    private Integer sort;

    @Schema(description = "上行路")
    @ExcelProperty("上行路")
    private TunnelHoleV1DO uplinkRoad;

    @Schema(description = "下行路")
    @ExcelProperty("下行路")
    private TunnelHoleV1DO downlinkRoad;

    @Schema(description = "横通道")
    @ExcelProperty("横通道")
    private List<HorizontalChannelDO> horizontalChannel;

    /**
     * 启用  0启用
     */
    @Schema(description = "0启用")
    private Integer enable;

    @Schema(description = "创建时间")
    @ExcelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date createTime;

    @Schema(description = "更新时间")
    @ExcelProperty("更新时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date updateTime;

    @Schema(description = "创建人")
    @ExcelProperty("创建人")
    private String createBy;

    @Schema(description = "更新人")
    @ExcelProperty("更新人")
    private String updateBy;

    public static TunnelFacilityRespVO convert2VO(TunnelFacilityDO tunnelFacilityDO) {
        TunnelFacilityRespVO tunnelFacilityRespVO = new TunnelFacilityRespVO();
        BeanUtils.copyProperties(tunnelFacilityDO,tunnelFacilityRespVO);
        tunnelFacilityRespVO.setHorizontalChannel(JSONArray.parseArray(tunnelFacilityDO.getHorizontalChannel().toJSONString(), HorizontalChannelDO.class));
        return tunnelFacilityRespVO;
    }

    public static List<TunnelFacilityRespVO> convert2VO(List<TunnelFacilityDO> tunnelFacilityDOList) {
        return tunnelFacilityDOList.stream().map(TunnelFacilityRespVO::convert2VO).collect(Collectors.toList());
    }

}
