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

import cn.superdesk.data.extract.enums.opCenter.OpCenterBizPlatformEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.organisation.SysOrganization;
import cn.superdesk.uniorder.dto.param.organisation.SysOrgQueryParam;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionOrg;
import cn.superdesk.uniorder.dto.vo.sys.SysOrgVo;
import cn.superdesk.uniorder.dto.vo.sys.SysSelectVo;
import cn.superdesk.uniorder.dubbo.facade.organisation.DubboSysOrganizationService;
import cn.superdesk.uniorder.service.organisation.SysOrganizationService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

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

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


	@Autowired
	private SysOrganizationService sysOrganizationService;

	@Override
	public void addObj(SysOrganization t) {
		sysOrganizationService.insertSelective(t);

	}

	@Override
	public void updateObj(SysOrganization t) {
		sysOrganizationService.updateByPrimaryKeySelective(t);

	}

	@Override
	public List<SysOrganization> findByOutOrgId(Long orgId) {
		return sysOrganizationService.findByOutOrgId(orgId);
	}

	public List<SysOrganization> findByOutOrgIds(List<Long> outOrgIds) {
		return sysOrganizationService.findByOutOrgIds(outOrgIds);
	}

	public List<String> convertOutOrgIds2OrgNames(List<Long> outOrgIds) {
		return sysOrganizationService.convertOutOrgIds2OrgNames(outOrgIds);
	}

	@Override
	public List<SysOrganization> findByOutOrgName(String organizationName) {
		return sysOrganizationService.findByOutOrgName(organizationName);
	}

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

		return sysOrganizationService.getProjectSelect(params, pageNum, pageSize);
	}

	@Override
	public void delObj(Long id) {

		sysOrganizationService.deleteObj(id);
	}

	/****************************************** 服务之窗-项目 start ******************************************/

	public void mergeReceiveOrganization(String message) {
		sysOrganizationService.mergeReceiveOrganization(message);
	}

	public void deleteReceiveOrganization(String message) {
		sysOrganizationService.deleteReceiveOrganization(message);
	}

	@Override
	public R<List<SysOrgVo>> getOrgList(SysOrgQueryParam param) {
		PageHelper.startPage(param.getPageNumber(), param.getPageSize());
		List<SysOrgVo> list = sysOrganizationService.getOrgList(param);
		PageInfo<SysOrgVo> page = new PageInfo<>(list);
		return new R<List<SysOrgVo>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), list);
	}

	@Override
	public List<SysSelectVo> selectList(SysOrgQueryParam params) {

		return sysOrganizationService.selectOrgListByPlatform(params);

	}
	/****************************************** 服务之窗-项目   end ******************************************/

}
