package com.hzya.frame.grpU8.nxproof.oerdjml.dao.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.grpU8.nxproof.oerdjml.dao.IOerDjmlDao;
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.GbiZbsyrecAllEntity;
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author:hecan
 * @Description:
 * @params:
 * @return:
 * @Date: 2023/6/19 14:55
 */
@Repository(value = "oerDjmlDao")
public class OerDjmlDaoImpl extends MybatisGenericDao<OerDjmlEntity,String> implements IOerDjmlDao {
    @DS("#oerDjmlEntity.dataSourceCode")
    @Override
    public String getMaxDjbgByGsdm(OerDjmlEntity oerDjmlEntity) {
        oerDjmlEntity = (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_djbhMax",oerDjmlEntity);
        if(null == oerDjmlEntity){
            throw new RuntimeException("查询最大单据号错误！请联系管理员");
        }else{
           return oerDjmlEntity.getDjbh();
        }
    }
    @DS("#oerDjmlEntity.dataSourceCode")
    @Override
    public String getMaxMlIdByGsdm(OerDjmlEntity oerDjmlEntity) {
        oerDjmlEntity= (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_mlidMax",oerDjmlEntity);
        if(null == oerDjmlEntity){
            throw new RuntimeException("查询最大MlId错误！请联系管理员");
        }else{
            return oerDjmlEntity.getMlId();
        }
    }

    @Override
    public String getMaxDjbgByGsdmZy(OerDjmlEntity oerDjmlEntity) {
        oerDjmlEntity = (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_djbhMax_zy",oerDjmlEntity);
        if(null == oerDjmlEntity){
            throw new RuntimeException("指标占用查询最大单据号错误！请联系管理员");
        }else{
            return oerDjmlEntity.getDjbh();
        }
    }

    @Override
    public OerDjmlEntity queryOerDjmlEntity(OerDjmlEntity oerDjmlEntity) {
        oerDjmlEntity = (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_Rpt_Rt_content",oerDjmlEntity);
        if(null == oerDjmlEntity){
            throw new RuntimeException("查询失败");
        }else{
            return oerDjmlEntity;
        }
    }
    @DS("#entity.dataSourceCode")
    @Override
    public List<OerDjmlEntity> queryOerDjml(OerDjmlEntity entity) {
        List<OerDjmlEntity> o = (List<OerDjmlEntity>) super.selectList(getSqlIdPrifx() + "queryOerDjml", entity);
        return o;
    }
    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateOerDjmlZt(OerDjmlEntity entity) {
        Integer o = super.update(getSqlIdPrifx() + "updateOerDjmlZt", entity);
        return o;
    }

    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateOerDjml(OerDjmlEntity entity) {
        Integer o = super.update(getSqlIdPrifx() + "updateOerDjml", entity);
        return o;
    }
    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateGbiZbsyrecByDjid(GbiZbsyrecAllEntity entity) {
        Integer o = super.update(getSqlIdPrifx() + "updateGbiZbsyrecByDjid", entity);
        return o;
    }

    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateData(OerDjmlEntity entity) {
        Integer o = super.update(getSqlIdPrifx() + "OerDjmlEntity_update_data", entity);
        return o;
    }
    @DS("#entity.dataSourceCode")
    @Override
    public Integer saveData(OerDjmlEntity entity) {
        Integer o = super.insert(getSqlIdPrifx() + "OerDjmlEntity_insert", entity);
        return o;
    }

}
