/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.watermeter.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.watermeter.config.ComConstans;
import com.tofly.watermeter.custom.entity.meterRead.QyAndQd;
import com.tofly.watermeter.entity.Cbqybm;
import com.tofly.watermeter.service.CbqybmService;
import org.springframework.stereotype.Service;
import com.tofly.watermeter.mapper.CbqybmMapper;

import java.util.List;

/**
 * 抄表区域编码
 *
 * @author wangjieliu
 * @date Sat May 29 00:00:00 CST 2021
 */
@Service("cbqybmService")
public class CbqybmServiceImpl extends ServiceImpl<CbqybmMapper, Cbqybm> implements CbqybmService {

    @Override
    public List<QyAndQd> getQyAndQd(String isState) {
        if ("1".equals(isState)){
            //查询必须分配的用户的区域和区域段信息
            return baseMapper.getQyAndQdAllocation();
        } else if ("2".equals(isState)) {
            //获取所有的树形结构
            return baseMapper.getQyAndQdPlan();
        } else {
            //获取已分配
            return baseMapper.getQyAndQd();
        }
    }

    @Override
    public Boolean updateSendZt(List<String> strings) {
        return this.update(new UpdateWrapper<Cbqybm>().lambda()
                .set(Cbqybm::getUpdateFlag, ComConstans.STR_ZERO).in(Cbqybm::getQybm));
    }
}
