package com.zcloud.zcGbsServicer.domain.model;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.cola.domain.Entity;
import com.jjb.saas.framework.domain.model.BaseE;
import com.zcloud.gbscommon.utils.Tools;
import com.zcloud.zcGbsServicer.domain.enums.DeviceTypeEnum;
import com.zcloud.zcGbsServicer.domain.enums.PersonTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
* web-domain
* @Author makejava
* @Date 2026-01-21 17:21:48
*/
@Data
public class ControlRoomE extends BaseE {
    //业务主键ID
    private String roomId;
    //消防控制室名称
    private String roomName;
    //消防控制室状态(字典码)
    private String roomStatus;
    //消防控制室状态名称
    private String roomStatusName;
    //负责人
    private String principalName;
    //负责人手机号
    private String principalPhone;
    //经度
    private Double lng;
    //纬度
    private Double lat;
    //设备数量
    private Integer deviceCount;
    //人员数量
    private Integer personCount;

    //消防控制室设备
    private List<ResourceDeviceE> devices;

    //消防控制室人员
    private List<ResourcePersonE> persons;

    //初始化
    public void addInit(List<ResourcePersonE> persons, List<ResourceDeviceE> devices){
        if (StrUtil.isBlank(this.roomId)) {
            this.roomId = Tools.get32UUID();
        }
        if (CollUtil.isNotEmpty(devices)) {
            this.devices = devices;
            devices.forEach(resourceDeviceE -> {
                resourceDeviceE.setBizId(this.roomId);
                resourceDeviceE.setBizType(DeviceTypeEnum.CONTROL_ROOM.getCode());
            });
        }
        if (CollUtil.isNotEmpty(persons)) {
            this.persons = persons;
            persons.forEach(resourcePersonE -> {
                resourcePersonE.setBizId(this.roomId);
                resourcePersonE.setBizType(PersonTypeEnum.CONTROL_ROOM.getCode());
            });
        }
    }

    //设置相关信息
    public void relationInfo(int deviceCount, int personCount){
        this.deviceCount = deviceCount;
        this.personCount = personCount;
    }

    //设置相关数据
    public void relationData(List<ResourceDeviceE> devices, List<ResourcePersonE> persons){
        this.devices = devices;
        this.persons = persons;
    }


}

