package com.sa.ibiz.demo.mob.controller.demo.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.sa.ibiz.demo.demo.domain.ZB;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ZB_Calendar_ZBXX{

    //前台传入的开始时间
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(access=Access.WRITE_ONLY)
    private Timestamp srfbegintime;
    //前台传入的结束时间
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(access=Access.WRITE_ONLY)
    private Timestamp srfendtime;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    private Timestamp begintime;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    private Timestamp endtime;
    private String icon;
    private String hrefTarget;
    private String text;
    private String cls;
    private String type;
    private String srfkey;
    private String srfmajortext;
    private String iconCls;
    private String bkcolor;
    private String id;
    private String content;
    private String color;
    private String href;
    private String qtip;
    private boolean disabled;


    /**
     * 日历部件[值班信息]设置数据源查询条件
     * @param searchFilter
     * @return
     */
    public com.sa.ibiz.demo.demo.service.dto.ZBSearchFilter getZBSearchFilter(ZB_Calendar_ZBXX searchFilter) {

        com.sa.ibiz.demo.demo.service.dto.ZBSearchFilter filter=new com.sa.ibiz.demo.demo.service.dto.ZBSearchFilter();
        QueryWrapper<com.sa.ibiz.demo.demo.domain.ZB> qw =filter.getSelectCond();
        qw.ge("zbsj",srfbegintime);
        qw.le("zbsj",srfendtime);
        return filter;
    }

    /**
    * 日历部件[值班信息]将数据源结果填入list集合中
    * @param
    * @param records
    */
    public void addZBToRecords(Page<com.sa.ibiz.demo.demo.domain.ZB> zbSearchResult, List<ZB_Calendar_ZBXX> records) {
        for(com.sa.ibiz.demo.demo.domain.ZB source:zbSearchResult.getRecords()) {
        ZB_Calendar_ZBXX target=new ZB_Calendar_ZBXX();
        target.fromZB(source);
        records.add(target);
        }
     }

    /**
    * 日历部件[值班信息]数据源结果vo对象转换
    * @param sourceEntity
    */
    public  void fromZB(com.sa.ibiz.demo.demo.domain.ZB sourceEntity)  {
        this.setEndtime(sourceEntity.getZbsj());
        this.setIcon("");
        this.setHrefTarget("");
        this.setText("");
        this.setCls("");
        this.setBegintime(sourceEntity.getZbsj());
        this.setType("ZB");
        this.setSrfkey(sourceEntity.getZbid());
        this.setSrfmajortext(sourceEntity.getZbname());
        this.setIconCls("");
        this.setBkcolor("");
        this.setId(sourceEntity.getZbid());
        this.setContent(sourceEntity.getZbname());
        this.setColor("");
        this.setHref("");
        this.setQtip("");
        this.setDisabled(false);
    }


    /**
    * 将全部数据源结果集封装成page对象
    * @param records
    * @return
    */
    public Page<ZB_Calendar_ZBXX> addRecordsToPage(List<ZB_Calendar_ZBXX> records) {
        Page<ZB_Calendar_ZBXX> targetpage=new Page<ZB_Calendar_ZBXX>(0,0,records.size(),false);
            targetpage.setAsc(null);
            targetpage.setDesc(null);
            targetpage.setOptimizeCountSql(false);
            targetpage.setRecords(records);
            return targetpage;
        }
}