package com.unis.base.server.service.impl;

import com.github.pagehelper.PageHelper;
import com.unis.base.common.vo.PriceMonitorQueryVo;
import com.unis.base.common.vo.PriceMonitorVO;
import com.unis.base.server.domain.PriceMonitorDomain;
import com.unis.base.server.service.PriceMonitorSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhaoyaodong
 * @version 1.0
 * @Title PriceMonitorSerivceImpl
 * @ProjectName PriceMonitorSerivceImpl
 * @Descripti/n
 * @date 2019/08/24 17点26分
 */
@Service
public class PriceMonitorSerivceImpl implements PriceMonitorSerivce {
    @Autowired
    private PriceMonitorDomain priceMonitorDomain;

    /**
     * 获取价格监测列表
     */
    @Override
    public List<PriceMonitorVO> getPriceMonitorList(PriceMonitorQueryVo priceMonitorQueryVo) {
        return priceMonitorDomain.getPriceMonitorList(priceMonitorQueryVo);
    }

    /**
     * 根据id查询相对应的信息
     *
     * @param jgjcxxid
     * @return PriceMonitorVO
     */
    @Override
    public PriceMonitorVO getPriceMonitorById(String jgjcxxid) {
        return priceMonitorDomain.getPriceMonitorById(jgjcxxid);
    }

    /**
     * 分页查看价格监测信息
     */

    @Override
    public List<PriceMonitorVO> getPriceMonitorPage(PriceMonitorQueryVo priceMonitorQueryVo, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return priceMonitorDomain.getPriceMonitorList(priceMonitorQueryVo);
    }

    /**
     * 更新信息
     */

    @Override
    public int update(PriceMonitorVO tyJgjcxxbVO) {
        return priceMonitorDomain.update(tyJgjcxxbVO);
    }

    /**
     * 删除
     */
    @Override
    public int delete(String jcxxid) {
        //根据编号获取廒间信息
        PriceMonitorVO tyJgjcxxbVO = priceMonitorDomain.getPriceMonitorById(jcxxid);
        tyJgjcxxbVO.setStatus(0);
        return priceMonitorDomain.update(tyJgjcxxbVO);
    }

    /**
     * 添加
     */

    @Override
    public Integer insert(PriceMonitorVO tyJgjcxxbVO) {
        Integer insert = priceMonitorDomain.insert(tyJgjcxxbVO);
        return insert;
    }

    /**
     * 根据年份查询该年分的月报
     * @param priceMonitorQueryVo
     * @return PriceMonitorQueryVo
     */
    @Override
    public List<PriceMonitorQueryVo> getLevelMonthlyReport(PriceMonitorQueryVo priceMonitorQueryVo) {
        List<PriceMonitorQueryVo> levelMonthlyReport = priceMonitorDomain.getLevelMonthlyReport(priceMonitorQueryVo);

        System.out.println("////////////2");
        return levelMonthlyReport;
    }
}
