package com.bonus.material.devchange.service;

import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.devchange.domain.DeviceCountBean;
import com.bonus.material.devchange.domain.DeviceTreeBean;
import com.bonus.material.devchange.domain.MaDevInfo;
import com.bonus.material.devchange.domain.MapBean;
import com.bonus.material.devchange.mapper.MaDevInfoMapper;
import com.bonus.material.devchange.mapper.MaDevRetireWarningMapper;
import com.bonus.material.device.domain.vo.DevInfoPropertyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

import static com.bonus.common.biz.constant.MaterialConstants.ADMIN_ID;
import static com.bonus.common.biz.constant.MaterialConstants.PROVINCE_COMPANY_DEPT_ID;

@Service
public class MaDevRetireWarningServiceImpl implements MaDevRetireWarningService{

    @Autowired
    private MaDevRetireWarningMapper mapper;


    @Override
    public List<MaDevInfo> list(MaDevInfo o) {
        Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
        Long userId = SecurityUtils.getLoginUser().getUserid();
        // 管理员和省公司可查看所有数据
//        if (userId != null && deptId != null
//                && !userId.equals(ADMIN_ID)
//                && !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
//            o.setCompanyId(deptId);
//        }
        if(ADMIN_ID.equals(userId)){
            o.setCompanyId(1L);
        }else{
            o.setCompanyId(deptId);
        }
        return mapper.list(o);
    }

    @Override
    public Integer updateDeviceStatus(String ids,String status) {
//        String[] split = ids.split(",");
//        if(split.length>0){
//            List<MapBean> list = new ArrayList<>();
//            for (String s : split) {
//                list.add(new MapBean(s,status));
//            }
//            return mapper.updateDeviceStatus(list);
//        }else {
            return 0;
//        }
    }

}
