package cn.superdesk.uniorder.dubbo.provider.accounting.supplier;

import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplierIssues;
import cn.superdesk.uniorder.dto.param.accounting.unified.supplier.AccountingUnifiedSupplierIssuesParam;
import cn.superdesk.uniorder.dubbo.facade.accounting.supplier.DubboAccountingUnifiedSupplierIssuesService;
import cn.superdesk.uniorder.service.accounting.unified.supplier.AccountingUnifiedSupplierIssuesService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @Description: 问题订单
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-02-24 13:44:11
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-02-24 13:44:11
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service(version = "1.0.0", retries = -1, timeout = 10000)
public class DubboAccountingUnifiedSupplierIssuesServiceImpl implements DubboAccountingUnifiedSupplierIssuesService {

	@Autowired
	private AccountingUnifiedSupplierIssuesService accountingUnifiedSupplierIssuesService;


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

	@Override
	public void addObj(AccountingUnifiedSupplierIssuesParam param) {

		AccountingUnifiedSupplierIssues accountingUnifiedSupplierIssues = AnBeanUtils.copy(param, AccountingUnifiedSupplierIssues.class);
		accountingUnifiedSupplierIssuesService.insertSelective(accountingUnifiedSupplierIssues);

	}

	@Override
	public void updateObj(AccountingUnifiedSupplierIssuesParam param) {

		AccountingUnifiedSupplierIssues accountingUnifiedSupplierIssues = AnBeanUtils.copy(param, AccountingUnifiedSupplierIssues.class);
		accountingUnifiedSupplierIssuesService.updateByPrimaryKeySelective(accountingUnifiedSupplierIssues);
	}

	@Override
	public void deleteObj(Long id) {
		accountingUnifiedSupplierIssuesService.deleteObj(id);
	}

	@Override
	public AccountingUnifiedSupplierIssues findById(Long id) {
		return accountingUnifiedSupplierIssuesService.findById(id);
	}

	@Override
	public PageInfo<AccountingUnifiedSupplierIssues> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {
		return accountingUnifiedSupplierIssuesService.findByPaging(conditions, pageNun, pageSize);
	}

	@Override
	public List<AccountingUnifiedSupplierIssues> findAll(Map<String, Object> queryMap) {

		return accountingUnifiedSupplierIssuesService.findAll(queryMap);
	}

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


	@Override
	public void addAccountingUnifiedSupplierIssues(AccountingUnifiedSupplierIssuesParam param) {

		AccountingUnifiedSupplierIssues accountingUnifiedSupplierIssues = AnBeanUtils.copy(param, AccountingUnifiedSupplierIssues.class);
		accountingUnifiedSupplierIssuesService.addAccountingUnifiedSupplierIssues(accountingUnifiedSupplierIssues);
	}

	@Override
	public void updateAccountingUnifiedSupplierIssues(AccountingUnifiedSupplierIssuesParam param) {

		AccountingUnifiedSupplierIssues accountingUnifiedSupplierIssues = AnBeanUtils.copy(param, AccountingUnifiedSupplierIssues.class);
		accountingUnifiedSupplierIssuesService.updateAccountingUnifiedSupplierIssues(accountingUnifiedSupplierIssues);
	}

	@Override
	public void deleteAccountingUnifiedSupplierIssues(Long id) {
		accountingUnifiedSupplierIssuesService.deleteAccountingUnifiedSupplierIssues(id);
	}

	@Override
	public AccountingUnifiedSupplierIssues findAccountingUnifiedSupplierIssuesById(Long id) {
		return accountingUnifiedSupplierIssuesService.findAccountingUnifiedSupplierIssuesById(id);
	}

	@Override
	public R<List<AccountingUnifiedSupplierIssues>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {
		return accountingUnifiedSupplierIssuesService.pageQuery(conditions, pageNun, pageSize);

	}

	@Override
	public void init001AccountingUnifiedSupplierIssuess(Integer isCreateExcel, LoginSysUser loginSysUser) {


		// 异步操作 包裹 mark by linjinyu at 20210223
		log.info("\n异步操作 包裹 外层 init001AccountingUnifiedSupplierIssuess params: \n{}", isCreateExcel);

		CompletableFuture.runAsync(() -> {

			try {
				accountingUnifiedSupplierIssuesService.init001AccountingUnifiedSupplierIssuess(isCreateExcel, loginSysUser);

			} catch (Exception e2) {
				log.error("\n异步操作 包裹 内层 init001AccountingUnifiedSupplierIssuess{} -> 执行 异常:{}", isCreateExcel, e2);
			}
		});

//		return "已经实现了,但websocket没通,彩娇还没完成 202102251600";
	}
}
