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

import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dto.param.organisation.SysEnterpriseQueryCriteria;
import cn.superdesk.uniorder.dto.vo.sys.SysOrganizationXEnterpriseVo;
import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.organisation.SysEnterprise;
import cn.superdesk.uniorder.dto.param.organisation.SysEnterpriseParam;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionVirt;
import cn.superdesk.uniorder.dubbo.facade.organisation.DubboSysEnterpriseService;
import cn.superdesk.uniorder.service.organisation.SysEnterpriseService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Service(version = "1.0.0", retries = -1, timeout = 10000)
public class DubboSysEnterpriseServiceImpl implements DubboSysEnterpriseService {


	@Autowired
	private SysEnterpriseService sysEnterpriseService;


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

	@Override
	public void addObj(SysEnterpriseParam param) {

		SysEnterprise sysEnterprise = AnBeanUtils.copy(param, SysEnterprise.class);
		sysEnterpriseService.insertSelective(sysEnterprise);

	}

	@Override
	public void updateObj(SysEnterpriseParam param) {

		SysEnterprise sysEnterprise = AnBeanUtils.copy(param, SysEnterprise.class);
		sysEnterpriseService.updateByPrimaryKeySelectiveWithRet(sysEnterprise);
	}

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

	@Override
	public SysEnterprise findById(Long id) {
		return sysEnterpriseService.findById(id);
	}

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

	@Override
	public List<SysOrganizationXEnterpriseVo> findSysOrganizationXEnterprise(Map<String, Object> queryMap) {

		return sysEnterpriseService.findSysOrganizationXEnterprise(queryMap);
	}

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


	@Override
	public void addSysEnterprise(SysEnterpriseParam param) {

		SysEnterprise sysEnterprise = AnBeanUtils.copy(param, SysEnterprise.class);
		sysEnterpriseService.addSysEnterprise(sysEnterprise);
	}

	@Override
	public void updateSysEnterprise(SysEnterpriseParam param) {

		SysEnterprise sysEnterprise = AnBeanUtils.copy(param, SysEnterprise.class);
		sysEnterpriseService.updateSysEnterprise(sysEnterprise);
	}

	@Override
	public void deleteSysEnterprise(Long id) {
		sysEnterpriseService.deleteSysEnterprise(id);
	}

	@Override
	public SysEnterprise findSysEnterpriseById(Long id) {
		return sysEnterpriseService.findSysEnterpriseById(id);
	}

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

	}

	@Override
	public R<List<SysOrganizationXEnterpriseVo>> pageQuery(SysEnterpriseQueryCriteria queryCriteria, LoginSysUser loginSysUser) {
		return sysEnterpriseService.pageQuery(queryCriteria, loginSysUser);
	}

	/****************************************** 之前的 要合并 start ******************************************/


	@Override
	public void add(SysEnterprise t) {

		sysEnterpriseService.insertSelective(t);
	}

	@Override
	public void update(SysEnterprise t) {

		sysEnterpriseService.updateByPrimaryKeySelectiveWithRet(t);
	}


	@Override
	public List<SysEnterprise> findByName(Long orgId, String enterpriseName) {
		return sysEnterpriseService.findByVirtName(orgId, enterpriseName);
	}

	@Override
	public R<List<SelectOptionVirt>> getVirtSelect(Map<String, Object> params, int pageNum, int pageSize) {

		return sysEnterpriseService.getVirtSelect(params, pageNum, pageSize);
	}

	@Override
	public R<List<SelectOptionVirt>> getVirtSelectByOutOrgId(Long outOrgId, int pageNum, int pageSize) {


		return sysEnterpriseService.getVirtSelectByOutOrgId(outOrgId, pageNum, pageSize);
	}

	@Override
	public SysEnterprise findByVirtId(Long id) {

		SysEnterprise sysEnterprise = sysEnterpriseService.findByOutVirtId(id);

		if (sysEnterprise != null)
			return sysEnterprise;

		return null;
	}

	@Override
	public List<SysEnterprise> findByOutVirtIds(List<Long> outVirtIds) {
		return sysEnterpriseService.findByOutVirtIds(outVirtIds);
	}

	@Override
	public Map<Long, SysEnterprise> findByOutVirtIdsConvertKV(List<Long> outVirtIds) {
		return sysEnterpriseService.findByOutVirtIdsConvertKV(outVirtIds);
	}

	@Override
	public List<String> convertOutVirtIds2VirtNames(List<Long> outVirtIds) {
		return sysEnterpriseService.convertOutVirtIds2VirtNames(outVirtIds);
	}

	@Override
	public void addSpecDaiDeLiangHang(Long id) {

		sysEnterpriseService.addSpecDaiDeLiangHang(id);
	}

	@Override
	public void deleteDaiDeLiangHang(Long id) {

		sysEnterpriseService.deleteDaiDeLiangHang(id);
	}


	@Override
	public void mergeReceiveVirtualarchitecture4SuperdeskMall(String message) {
		sysEnterpriseService.mergeReceiveVirtualarchitecture4SuperdeskMall(message);
	}

	@Override
	public void deleteReceiveVirtualarchitecture4SuperdeskMall(String message) {
		sysEnterpriseService.deleteReceiveVirtualarchitecture4SuperdeskMall(message);
	}


	@Override
	public void mergeReceiveVirtualarchitecture4SuperdeskTransfer(String message) {
		sysEnterpriseService.mergeReceiveVirtualarchitecture4SuperdeskTransfer(message);
	}

	@Override
	public void deleteReceiveVirtualarchitecture4SuperdeskTransfer(String message) {
		sysEnterpriseService.deleteReceiveVirtualarchitecture4SuperdeskTransfer(message);
	}

	/**
	 * 同步集采企业数据
	 * @param message
	 */
	@Override
	public void mergeReceiveVirtualarchitecture4Qchjc(String message) {
		sysEnterpriseService.mergeReceiveVirtualarchitecture4Qchjc(message);
	}

	/****************************************** 之前的 要合并   end ******************************************/

}
