package cn.superdesk.uniorder.dubbo.provider.organisation;

import cn.superdesk.uniorder.common.exception.utils.ExceptionUtils;
import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.organisation.SysClique;
import cn.superdesk.uniorder.dto.param.organisation.SysCliqueFindByTreeCriteria;
import cn.superdesk.uniorder.dto.param.organisation.SysCliqueParam;
import cn.superdesk.uniorder.dto.vo._function.tree.SysCliqueTreeModel;
import cn.superdesk.uniorder.dubbo.facade.organisation.DubboSysCliqueService;
import cn.superdesk.uniorder.service.organisation.SysCliqueService;
import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
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;

/**
 * @Description: 集团
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-04-28 14:08:25
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-04-28 14:08:25
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service(version = "1.0.0", retries = -1, timeout = 10000)
public class DubboSysCliqueServiceImpl implements DubboSysCliqueService {

	@Autowired
	private SysCliqueService sysCliqueService;


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

	@Override
	public void addObj(SysCliqueParam param) {

		SysClique sysClique = AnBeanUtils.copy(param, SysClique.class);
		sysCliqueService.insertSelective(sysClique);

	}

	@Override
	public void updateObj(SysCliqueParam param) {

		SysClique sysClique = AnBeanUtils.copy(param, SysClique.class);
		sysCliqueService.updateByPrimaryKeySelective(sysClique);
	}

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

	@Override
	public SysClique findById(Long id) {
		return sysCliqueService.findById(id);
	}

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

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

		return sysCliqueService.findAll(queryMap);
	}

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


	@Override
	public void addSysClique(SysCliqueParam param) {

		SysClique sysClique = AnBeanUtils.copy(param, SysClique.class);
		sysCliqueService.addSysClique(sysClique);
	}

	@Override
	public void updateSysClique(SysCliqueParam param) {

		SysClique sysClique = AnBeanUtils.copy(param, SysClique.class);
		sysCliqueService.updateSysClique(sysClique);
	}

	@Override
	public void deleteSysClique(Long id) {
		sysCliqueService.deleteSysClique(id);
	}

	@Override
	public SysClique findSysCliqueById(Long id) {
		return sysCliqueService.findSysCliqueById(id);
	}

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

	}

	/****************************************** kafka start ******************************************/

	@Override
	public void kafkaMergeReceiveClique(String message) {

		try {

			SysClique sysCliqueEntity = AnJsonUtils.toObject(message, SysClique.class);
			log.info("\n转换:\n{}", AnJsonUtils.toJson(sysCliqueEntity));

			sysCliqueService.kafkaMergeReceiveClique(sysCliqueEntity);
		} catch (Exception e) {
			log.error("kafka 小邮局 同步 错误 \n " + ExceptionUtils.getMessage(e));

			e.printStackTrace();
		}
	}

	@Override
	public void kafkaDeleteReceiveClique(String message) {

		try {
			SysClique sysCliqueEntity = AnJsonUtils.toObject(message, SysClique.class);
			log.info("\n转换:\n{}", AnJsonUtils.toJson(sysCliqueEntity));

			sysCliqueService.kafkaDeleteReceiveClique(sysCliqueEntity);
		} catch (Exception e) {
			log.error("kafka 小邮局 订单 退单 同步 错误 \n " + ExceptionUtils.getMessage(e));

			e.printStackTrace();
		}
	}

	/****************************************** kafka   end ******************************************/


	@Override
	public List<SysCliqueTreeModel> findByTree() {
		return sysCliqueService.findByTree();
	}

	@Override
	public List<SysCliqueTreeModel> findByTree002(SysCliqueFindByTreeCriteria criteria) {
		return sysCliqueService.findByTree002(criteria);
	}

	@Override
	public List<SysCliqueTreeModel> findByTree003(SysCliqueFindByTreeCriteria criteria) {
		return sysCliqueService.findByTree003(criteria);
	}

	@Override
	public List<SysCliqueTreeModel> findByTree004(SysCliqueFindByTreeCriteria criteria) {
		return sysCliqueService.findByTree004(criteria);
	}

}
