package cn.com.ty.lift.business.push.entity;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 根据急修查询相关推送
 *
 * @author wcz
 * @since 2020/4/24
 */
@Data
@NoArgsConstructor
public class RepairTips {
    /**
     * 维保公司id
     */
    private long    mtCompanyId;
    /**
     * 区域主管id
     */
    private long    directorId;
    /**
     * 文员
     */
    private String  clerk;
    /**
     * 区域
     */
    private String  areaName;
    /**
     * 急修单总数
     */
    private int total;

    private int repairing;

    private int finish;

    /**
     * 返回区域主管和文员的id列表
     */
    public List<Long> members() {
        List<Long> members = new ArrayList<>();
        if (Objects.nonNull(directorId)) {
            members.add(directorId);
        }
        if (StrUtil.isNotBlank(clerk)) {
            try {
                if (clerk.contains(",")) {
                    members.addAll(Arrays.stream(clerk.split(",")).map(c -> Long.parseLong(c.trim())).collect(Collectors.toSet()));
                } else {
                    members.add(Long.parseLong(clerk.trim()));
                }
            } catch (Exception ignore) {
            }
        }
        return members;
    }
}