package cn.com.ty.lift.business.emergency.dto;

import cn.com.ty.lift.business.emergency.entity.EmergencyRepair;
import cn.com.ty.lift.business.emergency.entity.ErRecordCost;
import cn.com.ty.lift.business.emergency.entity.ErRecordImg;
import cn.com.ty.lift.business.emergency.entity.LiftFault;
import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
import cn.com.ty.lift.common.utils.ValuePool;
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *     急修请求返回结果
 * </p>
 * @author wcz
 * @since  2019/12/6
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class RepairResponse extends EmergencyRepair{

    /**
     * 区域名称
     */
    private String areaName;

    /**
     * 项目名称
     */
    private String projectName;

    /**
     * 项目编号
     */
    private String projectCode;
    /**
     * 项目地址
     */
    private String projectAddress;

    /**
     * 电梯注册代码
     */
    private String registrationCode;

    /**
     * 电梯位置
     */
    private String devicePosition;
    /**
     * 电梯经纬度
     */
    private String coordinate;

    /**
     * 单位设备编号
     */
    private String useCompanyCode;

    /**
     * 电梯类别
     */
    private Integer liftCategory;
    /**
     * 电梯类型
     */
    private Integer liftType;
    /**
     * 维修工
     */
    private String workerName;
    /**
     * 维修工电话
     */
    private String workerMobile;

    /**
     * 创建人(召修人)
     */
    private String createName;
    /**
     * 电梯公司状态
     */
    private Integer liftCompanyStatus;

    /**
     * 维修时长毫秒数
     */
    private long repairDiff;

    private String repairDuration;
    /**
     * 重写getter方法，换算时长 XX天XX小时XX分XX秒
     */
    public String getRepairDuration() {
        return DateUtil.formatBetween(this.repairDiff, BetweenFormater.Level.SECOND);
    }
    /**
     * 接单等待毫秒数
     */
    private long waitDiff;

    private String waitDuration;
    /**
     * 重写getter方法，换算时长 XX天XX小时XX分XX秒
     */
    public String getWaitDuration() {
        return DateUtil.formatBetween(this.waitDiff, BetweenFormater.Level.SECOND);
    }

    /**
     * 急修评价
     */
    private Evaluation evaluation;
    /**
     * 收费项
     */
    private List<ErRecordCost> erRecordCosts;
    /**
     * 急修图片
     */
    private List<ErRecordImg> erRecordImgs;
    /**
     * 故障部位
     */
    private Collection<LiftFault> faultParts;
    /**
     * 故障原因
     */
    private Collection<LiftFault> faultReasons;
    /**
     * 故障处理
     */
    private Collection<LiftFault> faultHandles;
    /**
     * 故障性质
     */
    private Collection<LiftFault> faultNatures;
    /**
     * 故障责任
     */
    private Collection<LiftFault> faultDuties;

    //报修来源（1 物业；2 维保；3 物联）
    private String sourceDesc;
    private String getSourceDesc(){
        int source = ValuePool.nullable(this.getSource(), 0);
        switch (source){
            case 1:
                return "物业";
            case 2:
                return "维保";
            case 3:
                return "物联";
            default:
                return "--";
        }
    }

    //急修原因（0 其他；1 停电；2 故障）
    private String repairReasonDesc;
    public String getRepairReasonDesc(){
        int repairReason = ValuePool.nullable(this.getRepairReason(), 0);
        switch (repairReason){
            case 0:
                return "其他";
            case 1:
                return "停电";
            case 2:
                return "故障";
            default:
                return "--";
        }
    }
    /**
     * 用户建议
     */
    private String advice;

    /**
     * 服务态度
     */
    private Integer serviceLevel;

    /**
     * 保养满意度
     */
    private Integer starLevel;

    /**
     * 手写签名图片
     */
    private String imgUrl;
}
