package cn.superdesk.uniorder.dubbo.consumer.invoice.customer.invoiced;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoiced;
import cn.superdesk.uniorder.dto.param.invoice.customer.invoiced.*;
import cn.superdesk.uniorder.dto.param.invoice.excel.*;
import cn.superdesk.uniorder.dto.vo.invoice.customer.invoiced.InvoiceInvoicedExcelExportVo;
import cn.superdesk.uniorder.dto.vo.invoice.customer.invoiced.InvoiceInvoicedHeadSum;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.customer.invoiced.DubboInvoiceInvoicedService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-03-16 17:29:47
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-03-16 17:29:47
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class InvoiceInvoicedDubboConsumerService {

	@Reference(version = "1.0.0", timeout = 6000000, retries = -1)
	private DubboInvoiceInvoicedService dubboInvoiceInvoicedService;

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;


	/****************************************** extends BaseService 部分 start ******************************************/

	public void addObj(InvoiceInvoicedParam param) {

		dubboInvoiceInvoicedService.addObj(param);

	}

	public void updateObj(InvoiceInvoicedParam param) {

		dubboInvoiceInvoicedService.updateObj(param);
	}

	public void deleteObj(Long id) {

		dubboInvoiceInvoicedService.deleteObj(id);
	}

	public InvoiceInvoiced findById(Long id) {

		return dubboInvoiceInvoicedService.findById(id);
	}

	public PageInfo<InvoiceInvoiced> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {

		return dubboInvoiceInvoicedService.findByPaging(conditions, pageNun, pageSize);
	}

	public List<InvoiceInvoiced> findAll(Map<String, Object> queryMap) {

		return dubboInvoiceInvoicedService.findAll(queryMap);
	}

	/****************************************** extends BaseService 部分   end ******************************************/


	public void addInvoiceInvoiced(InvoiceInvoicedParam param) {

		dubboInvoiceInvoicedService.addInvoiceInvoiced(param);
	}


	public void updateInvoiceInvoiced(InvoiceInvoicedParam param) {

		dubboInvoiceInvoicedService.updateInvoiceInvoiced(param);
	}

	public void updateInvoiceInvoiced(InvoiceInvoiced entity) {
		dubboInvoiceInvoicedService.updateInvoiceInvoiced(entity);
	}

	public void updateOpFields(String token, InvoiceInvoicedOpUpdateFieldsForm form) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.updateOpFields(form, loginSysUser);
	}

	public void updateInvoiceInvoicedByPrimaryKeySelective(InvoiceInvoiced entity) {
		dubboInvoiceInvoicedService.updateInvoiceInvoicedByPrimaryKeySelective(entity);
	}

	public void updateOpRemark(String token, InvoiceInvoicedOpUpdateFieldRamarkForm form) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		dubboInvoiceInvoicedService.updateOpRemark(form, loginSysUser);
	}

	public void batchUpdateFields(String token, InvoiceInvoicedOpBatchUpdateFieldsForm form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		dubboInvoiceInvoicedService.batchUpdateFields(form, loginSysUser);
	}


	public void deleteInvoiceInvoiced(Long id) {
		dubboInvoiceInvoicedService.deleteInvoiceInvoiced(id);
	}


	public InvoiceInvoiced findInvoiceInvoicedById(Long id) {

		return dubboInvoiceInvoicedService.findInvoiceInvoicedById(id);
	}


	public R<List<InvoiceInvoiced>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {

		return dubboInvoiceInvoicedService.pageQuery(conditions, pageNun, pageSize);
	}

	public List<InvoiceInvoicedExcelExportVo> queryByCriteria(InvoiceInvoicedQueryCriteria criteria) {

		return dubboInvoiceInvoicedService.queryByCriteria(criteria);
	}

	public R<List<InvoiceInvoicedExcelExportVo>> pageQueryByCriteria(InvoiceInvoicedQueryCriteria criteria) {

		return dubboInvoiceInvoicedService.pageQueryByCriteria(criteria);
	}

	public String exportInvoiceInvoiceds(String token, InvoiceInvoicedQueryCriteria criteria) {

		Boolean isPass = permissionDubboCustomerService.addOnPerm(token, criteria);
		if (isPass.equals(false)) {
			return null;
		}

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceInvoicedService.exportInvoiceInvoiceds(criteria, loginSysUser);
	}


	public R<InvoiceInvoicedHeadSum> headSumInvoiceInvoiceds(InvoiceInvoicedQueryCriteria criteria) {
		return dubboInvoiceInvoicedService.headSumInvoiceInvoiceds(criteria);
	}

	/****************************************** 任务 start ******************************************/
//	public void processInvoiceInvoicedsOverdueTask(String token, InvoiceInvoicedExcelExportVo taskParams){
//
//		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
//		dubboInvoiceInvoicedService.processInvoiceInvoicedsOverdueTask(taskParams, loginSysUser);
//
//	}


	/****************************************** excel import start ******************************************/


	public void saveOrUpdate4ThirdPartTaxationSzhtxxE6ExcelRowByInvoiceNumber(TaxationSzhtxxE6ExcelRow excelRow, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4ThirdPartTaxationSzhtxxE6ExcelRowByInvoiceNumber(excelRow, loginSysUser);
	}

	public void saveOrUpdate4ThirdPartTaxationSzhtxxE6ExcelRowListByInvoiceNumber(List<TaxationSzhtxxE6ExcelRow> excelRowList, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4ThirdPartTaxationSzhtxxE6ExcelRowListByInvoiceNumber(excelRowList, loginSysUser);
	}

	public void saveOrUpdate4ThirdPartTaxationYqzs17WinV30ExcelRowListByInvoiceNumber(List<TaxationYqzs17WinV30ExcelRow> excelRowList, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4ThirdPartTaxationYqzs17WinV30ExcelRowListByInvoiceNumber(excelRowList, loginSysUser);
	}

	public void saveOrUpdate4SuperdeskFinanceArtificial001ExcelRowListByInvoiceNumber(List<SuperdeskFinanceArtificial001ExcelRow> excelRowList, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4SuperdeskFinanceArtificial001ExcelRowListByInvoiceNumber(excelRowList, loginSysUser);
	}


	void saveOrUpdate4InvoiceInvoicedHistoryExcelRowByInvoiceNumber(InvoiceInvoicedHistoryExcelRow excelRow, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4InvoiceInvoicedHistoryExcelRowByInvoiceNumber(excelRow, loginSysUser);
	}

	void saveOrUpdate4InvoiceInvoicedHistoryExcelRowListByInvoiceNumber(List<InvoiceInvoicedHistoryExcelRow> excelRowList, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4InvoiceInvoicedHistoryExcelRowListByInvoiceNumber(excelRowList, loginSysUser);
	}

	void saveOrUpdate4InvoiceInvoicedNormalExcelRowByInvoiceNumber(InvoiceInvoicedNormalExcelRow excelRow, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4InvoiceInvoicedNormalExcelRowByInvoiceNumber(excelRow, loginSysUser);
	}

	void saveOrUpdate4InvoiceInvoicedNormalExcelRowListByInvoiceNumber(List<InvoiceInvoicedNormalExcelRow> excelRowList, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedService.saveOrUpdate4InvoiceInvoicedNormalExcelRowListByInvoiceNumber(excelRowList, loginSysUser);
	}
}
