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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.common.core.util.StringUtil;
import com.tofly.watermeter.custom.entity.CustomSbYjgl;
import com.tofly.watermeter.custom.entity.Statistic;
import com.tofly.watermeter.custom.entity.file.TurnoverFileInfo;
import com.tofly.watermeter.entity.Bwsbyjgl;
import com.tofly.watermeter.mapper.BwsbyjglMapper;
import com.tofly.watermeter.service.BwsbyjglService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 水表移交管理表
 *
 * @author wangjieliu
 * @date Fri Mar 19 00:00:00 CST 2021
 */
@Service("bwsbyjglService")
public class BwsbyjglServiceImpl extends ServiceImpl<BwsbyjglMapper, Bwsbyjgl> implements BwsbyjglService {

    @Override
    public List<Map> selectById(Long id) {
        return baseMapper.select(id);
    }

    @Override
    public IPage<Map> getScrapInfo(Page page, Statistic statistic) {
        Long cj=statistic.getBwSbcj();
        Long kj=statistic.getBwSbkj();
        Long lx=statistic.getBwSblx();
        Date start = statistic.getStartTime();
        Date end = statistic.getEndTime();
        return baseMapper.getScrapInfo(page , cj , kj , lx , start , end);
    }

    @Override
    public IPage<Map> getScrap(Page page, Statistic statistic) {
        List<String> cjList = null;
        List<String> kjList = null;
        List<String> lxList = null;
        String bwSbcj = statistic.getSbcj();
        String bwSbkj = statistic.getSbkj();
        String bwSblx = statistic.getSblx();
        if (StringUtil.isNotEmpty(bwSbcj)){
            cjList = Arrays.asList(bwSbcj.split(","));
        }
        if (StringUtil.isNotEmpty(bwSbkj)){
            kjList = Arrays.asList(bwSbkj.split(","));
        }
        if (StringUtil.isNotEmpty(bwSblx)){
            lxList = Arrays.asList(bwSblx.split(","));
        }
        return baseMapper.getScrap(page,statistic, cjList , kjList , lxList);
    }

    @Override
    public boolean insertBatch(List<TurnoverFileInfo> bwsbyjglList, CustomSbYjgl bwsbyjgl) {
        return baseMapper.insertBatch(bwsbyjglList , bwsbyjgl);
    }


}
