package com.zjrs.zwnw.psam.bpo.impl;

import org.apache.commons.lang.StringUtils;
import org.mohrss.leaf.core.framework.domain.bpo.impl.BPOImpl;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import org.mohrss.leaf.core.framework.web.exception.AppException;
import com.zjrs.zwnw.psam.blo.SjtjBLO;
import com.zjrs.zwnw.psam.bpo.SjtjBPO;
import com.zjrs.zwnw.psam.dto.PsamKglDTO;
import com.zjrs.zwnw.psam.dto.PsamTjDTO;
import com.zjrs.zwnw.psam.dto.PsamXfycDTO;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *
 * @author liangxiudong
 * @since 2021-04-07
 */
@Service
public class SjtjBPOImpl extends BPOImpl implements SjtjBPO {
    @Resource
    private SjtjBLO sjtjBLO;

    @Override
    public AjaxResponse kzttjList() {
        AjaxResponse ajaxResponse = new AjaxResponse();
        List<PsamTjDTO> list=sjtjBLO.getKzttjList();
        ajaxResponse.setData("data",list);
        return ajaxResponse;
    }

    @Override
    public void exportKzttjList(HttpServletResponse res) {
        sjtjBLO.exportKzttjList(res);
    }

    @Override
    public PageResult getShsltjList(PsamKglDTO dto, int page, int rows) {
        return this.sjtjBLO.getShsltjList(dto, page, rows);
    }

    @Override
    public void exportShsltjList(PsamKglDTO dto, HttpServletResponse res) {
        sjtjBLO.exportShsltjList(dto,res);
    }

    @Override
    public PageResult getJgtjList(PsamKglDTO dto, int page, int rows) {
        return this.sjtjBLO.getJgtjList(dto, page, rows);
    }

    @Override
    public PageResult getJgtjDetailList(PsamKglDTO dto, int page, int rows) {
        if (StringUtils.isBlank(dto.getRsPsamAzjgxxLsh())){
            throw new AppException("安装机构流水号 不可为空");
        }
        return this.sjtjBLO.getJgtjDetailList(dto, page, rows);
    }

    @Override
    public void exportJgtjList(PsamKglDTO dto, HttpServletResponse res) {
        sjtjBLO.exportJgtjList(dto,res);
    }

    @Override
    public PageResult getShtjList(PsamKglDTO dto, int page, int rows) {
        return this.sjtjBLO.getShtjList(dto, page, rows);
    }

    @Override
    public void exportShtjList(PsamKglDTO dto, HttpServletResponse res) {
        sjtjBLO.exportShtjList(dto,res);
    }

    @Override
    public PageResult getShtjDetailList(PsamKglDTO dto, int page, int rows) {
        if (StringUtils.isBlank(dto.getZtid())){
            throw new AppException("单位主体ID 不可为空");
        }
        return this.sjtjBLO.getShtjDetailList(dto, page, rows);
    }

    @Override
    public PageResult getRqList(PsamKglDTO dto, int page, int rows) {
        if (StringUtils.isNotBlank(dto.getFfrqBegin())&&StringUtils.isNotBlank(dto.getFfrqEnd())&&
                StringUtils.isBlank(dto.getSqrqBegin())&&StringUtils.isBlank(dto.getSqrqEnd())) {
            return this.sjtjBLO.getRqListByFfrq(dto,page,rows);
        }else if (StringUtils.isBlank(dto.getFfrqBegin())&&StringUtils.isBlank(dto.getFfrqEnd())&&
                StringUtils.isNotBlank(dto.getSqrqBegin())&&StringUtils.isNotBlank(dto.getSqrqEnd())) {
            return this.sjtjBLO.getRqListBySqrq(dto,page,rows);
        }else{
            throw new AppException("请输入 “发放日期起”和“发放日期至” 或“申请日期起”和“申请日期至”");
        }
    }

    @Override
    public void exportRqList(PsamKglDTO dto, HttpServletResponse res) {
        this.sjtjBLO.exportRqList(dto,res);
    }

    @Override
    public PageResult getXfyckList(PsamXfycDTO dto, int page, int rows) {
        return sjtjBLO.getXfyckList(dto,page,rows);
    }

    @Override
    public PageResult getXfmxList(PsamKglDTO dto, int page, int rows) {
        if (StringUtils.isBlank(dto.getPsambh())){
            throw new AppException("PSAM卡编号不能为空");
        }
        return this.sjtjBLO.getXfmxList(dto,page,rows);
    }
}
