package com.nantian.cloud.jljc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nantian.cloud.jljc.entity.TDualcontrolProgressApply;
import com.nantian.cloud.jljc.mapper.TDualcontrolProgressApplyMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nantian.cloud.jljc.service.TDualcontrolProgressApplyService;
import com.nantian.sc.cloud.common.data.datascope.DataScope;
import com.nantian.sc.cloud.common.security.service.ScUser;
import com.nantian.sc.cloud.common.security.util.SecurityUtils;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.util.List;
import java.util.Map;

/**
 * 能耗双控-完成情况修改申请 服务实现类
 */
@Service("tDualcontrolProgressApplyService")
public class TDualcontrolProgressApplyServiceImpl extends ServiceImpl<TDualcontrolProgressApplyMapper, TDualcontrolProgressApply> implements TDualcontrolProgressApplyService {

    @Override
    public IPage<TDualcontrolProgressApply> pageByScope(Page page, TDualcontrolProgressApply apply) {
        ScUser u = SecurityUtils.getUser();
        String code = apply.getItemCode() != null ? apply.getItemCode() : u.getDeptId().toString();
        code = code.replaceAll("0000","").replaceAll("00","");
        apply.setItemCode(code);
        return baseMapper.pageByScope(page, apply, u.getDeptId().toString());
    }

    @Override
    public Map<String,String> countByScope(TDualcontrolProgressApply apply) {
        ScUser u = SecurityUtils.getUser();
        String code = apply.getItemCode() != null ? apply.getItemCode() : u.getDeptId().toString();
        code = code.replaceAll("0000","").replaceAll("00","");
        apply.setItemCode(code);
        return baseMapper.countByScope(apply,u.getDeptId().toString());
    }

    @Override
    public IPage<TDualcontrolProgressApply> ownApply(Page page, TDualcontrolProgressApply apply) {
        ScUser u = SecurityUtils.getUser();
        return baseMapper.ownApply(page,apply,u.getDeptId().toString());
    }
}
