GuideScreenDaoImpl.java 4.58 KB
package com.zteits.park.dao.impl;

import java.util.List;

import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.park.param.GuideScreenListGeoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.zteits.clouds.api.dto.park.param.GuideScreenListByAreaCodesRequest;
import com.zteits.park.dao.GuideScreenDao;
import com.zteits.park.domain.GuideScreenGeo;
import com.zteits.park.domain.GuideScreenLevelStatistics;
import com.zteits.park.domain.TdGGuideParkRel;
import com.zteits.park.domain.TdGGuideScreen;
import com.zteits.park.domain.TdGGuideScreenExample;
import com.zteits.park.mapper.TdGGuideScreenMapper;
import com.zteits.park.mapper.smapper.TdGGuideParkRelSMapper;
import com.zteits.park.mapper.smapper.TdGGuideScreenSMapper;

/**
 * Copyright: Copyright (c) 2017  zteits
 *
 * @ClassName: com.zteits.park.dao.impl
 * @Description:
 * @version: v1.0.0
 * @author: atao
 * @date: 2017/7/3   下午4:30
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2017/7/3      atao          v1.0.0          创建
 */
@Component
public class GuideScreenDaoImpl implements GuideScreenDao {

    @Autowired
    private TdGGuideScreenSMapper tdGGuideScreenSMapper;
    @Autowired
    private TdGGuideScreenMapper tdGGuideScreenMapper;
    @Autowired
    private TdGGuideParkRelSMapper tdGGuideParkRelSMapper;

    @Override
    public PageInfo<TdGGuideScreen> listGuideScreenByAreaCodes(GuideScreenListByAreaCodesRequest request) {

        PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());

        List<TdGGuideScreen> list = tdGGuideScreenSMapper.listGuideScreenByAreaCodes(request);
        return new PageInfo<TdGGuideScreen>(list);
    }

    @Override
    public List<GuideScreenLevelStatistics> statisticsGuideScreenLevelByAreaCodes(List<Long> areaCodes,String cityId,
        Integer dataState,Long orgId) {

        List<GuideScreenLevelStatistics> result = tdGGuideScreenSMapper.statisticsGuideScreenLevelByAreaCodes(
            areaCodes, cityId,dataState,orgId);
        return result;
    }

    @Override
    public List<GuideScreenGeo> listGuideScreenGeo(GuideScreenListGeoRequest request) {

        List<GuideScreenGeo> result = tdGGuideScreenSMapper.listGuideScreenGeo(request);
        return result;
    }

    @Override
    public List<TdGGuideParkRel> getGuideScreenInfo(String guideNo, Integer dataState) {
        List<TdGGuideParkRel> result = tdGGuideParkRelSMapper.getGuideScreenInfo(guideNo, dataState);
        return result;
    }

    @Override
    public TdGGuideScreen getBaseGuideScreenInfo(String guideNo, Integer dataState) {
        TdGGuideScreenExample example = new TdGGuideScreenExample();
        TdGGuideScreenExample.Criteria sql = example.createCriteria();
        sql.andGuideNoEqualTo(guideNo);
        if(dataState!=null){
            sql.andDataStatusEqualTo(dataState);
        }
        List<TdGGuideScreen> tdGGuideScreenList = tdGGuideScreenMapper.selectByExample(example);
        if(CollectionUtil.isNotEmpty(tdGGuideScreenList)){
            return tdGGuideScreenList.get(0);
        }
        return null;
    }

    @Override
    public List<TdGGuideScreen> getAllGuideScreenInfo(Long orgId, List<String> guideNos) {

        TdGGuideScreenExample example = new TdGGuideScreenExample();
        example.createCriteria().andGuideNoIn(guideNos).andOrgIdEqualTo(orgId)
            .andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
        return tdGGuideScreenMapper.selectByExample(example);
    }

    @Override
	public void deleteALLGuideScreenInfo(List<String> guideNos,Long orgId) {
		TdGGuideScreenExample example = new TdGGuideScreenExample();
		example.createCriteria().andGuideNoIn(guideNos).andOrgIdEqualTo(orgId);
		tdGGuideScreenMapper.deleteByExample(example);
	}

	@Override
	public Boolean bathInsertGuideScreens(List<TdGGuideScreen> tdGGuideScreens) {
		return tdGGuideScreenSMapper.bathInsertGuideScreens(tdGGuideScreens) > 0;
	}

	@Override
	public Boolean updateByExampleSelective(TdGGuideScreen tdGGuideScreen) {
		TdGGuideScreenExample example = new TdGGuideScreenExample();
		example.createCriteria().andGuideNoEqualTo(tdGGuideScreen.getGuideNo()).andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
		return tdGGuideScreenMapper.updateByExampleSelective(tdGGuideScreen, example)> 0;
	}

}