package com.prolog.rdc.tms.service.basicConfigure.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.prolog.common.util.DateUtils;
import com.prolog.common.util.ToolKits;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.core.restriction.Criteria;
import com.prolog.framework.core.restriction.Order;
import com.prolog.framework.core.restriction.Restriction;
import com.prolog.framework.core.restriction.Restrictions;
import com.prolog.framework.dao.util.PageUtils;
import com.prolog.product.core.framework.entity.UserEntity;
import com.prolog.product.core.framework.util.PlgFxUsrUtils;
import com.prolog.rdc.tms.constant.DataDictionaryConstant;
import com.prolog.rdc.tms.constant.SeriaNnumberConstant;
import com.prolog.rdc.tms.dao.mapper.TmsStrategyTransferMapper;
import com.prolog.rdc.tms.dao.mapper.TmsStrategyTransferStationMapper;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferMatchingDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferPageDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferStationDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferViewDTO;
import com.prolog.rdc.tms.model.entity.TmsStrategyTransferModel;
import com.prolog.rdc.tms.model.entity.TmsStrategyTransferStationModel;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferMatchingVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferPageVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferStationSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferStationUpdateVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferUpdateVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferViewVO;
import com.prolog.rdc.tms.service.SysCodeengineService;
import com.prolog.rdc.tms.service.SysRefdatadService;
import com.prolog.rdc.tms.service.basicConfigure.StrategyTransferService;
import com.prolog.rdc.tms.util.PublicMethods;

import lombok.extern.slf4j.Slf4j;

/**
 * 策略中心-中转策略实现层
 *
 * @author zhangsj
 * @since 2022/7/16 9:45
 */
@Service
@Slf4j
public class StrategyTransferServiceImpl implements StrategyTransferService {

	@Autowired
	private TmsStrategyTransferMapper tmsStrategyTransferMapper;

	@Autowired
	private TmsStrategyTransferStationMapper tmsStrategyTransferStationMapper;

	@Autowired
	private SysRefdatadService sysRefdatadService;

	@Autowired
	private SysCodeengineService sysCodeengineService;

	/**
	 * 分页查询
	 *
	 * @param strategyPageVO
	 * @return
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<StrategyTransferPageDTO> queryPageData(StrategyTransferPageVO strategyPageVO) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 中转策略状态
		List<Map<String, Object>> restMessage = sysRefdatadService.getDropDownById(DataDictionaryConstant.GENERAL_STATUS, null, null, null);

		Criteria criteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r1 = Restrictions.eq(TmsStrategyTransferModel::getEnterpriseId, user.getEnterpriseId());
		Restriction r2 = ToolKits.isEmpty(strategyPageVO.getStatus()) ? null : Restrictions.eq(TmsStrategyTransferModel::getStatus, strategyPageVO.getStatus());
		Restriction r3 = ToolKits.isEmpty(strategyPageVO.getName()) ? null : Restrictions.like(TmsStrategyTransferModel::getName, "%" + strategyPageVO.getName() + "%");
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		criteria.setOrder(Order.newInstance().desc("updatetime"));

		PageUtils.startPage(strategyPageVO.getPageNum(), strategyPageVO.getPageSize());
		List<TmsStrategyTransferModel> tmsStrategyTransferModels = tmsStrategyTransferMapper.findByCriteria(criteria);

		// 返回数据集
		List<StrategyTransferPageDTO> strategyTransferPageDTOS = Lists.newArrayList();

		for (TmsStrategyTransferModel tmsStrategyTransferModel : tmsStrategyTransferModels) {
			StrategyTransferPageDTO strategyTransferPageDTO = new StrategyTransferPageDTO();
			BeanUtils.copyProperties(tmsStrategyTransferModel, strategyTransferPageDTO);
			// 状态翻译
			strategyTransferPageDTO.setStatusName(PublicMethods.change(restMessage, String.valueOf(strategyTransferPageDTO.getStatus())));
			List<String> conditionsBuff = Lists.newArrayList();
			conditionsBuff.add("客户");
			conditionsBuff.add(tmsStrategyTransferModel.getConsigneeUnitName());
			conditionsBuff.add(tmsStrategyTransferModel.getConsigneeName());
			strategyTransferPageDTO.setConditionName(conditionsBuff.stream().collect(Collectors.joining(" ")));

			// 查询对应条件
			Criteria criteriaStation = Criteria.forClass(TmsStrategyTransferStationModel.class);
			r1 = Restrictions.eq(TmsStrategyTransferStationModel::getEnterpriseId, user.getEnterpriseId());
			r2 = Restrictions.eq(TmsStrategyTransferStationModel::getStrategyId, tmsStrategyTransferModel.getId());
			criteriaStation.setRestriction(Restrictions.and(r1, r2));
			criteriaStation.setOrder(Order.newInstance().asc("transferOrder"));
			List<TmsStrategyTransferStationModel> stationModels = tmsStrategyTransferStationMapper.findByCriteria(criteriaStation);
			// 不为空拼接条件
			if (ToolKits.isNotEmpty(stationModels)) {
				List<String> stations = Lists.newArrayList();
				for (TmsStrategyTransferStationModel stationModel : stationModels) {
					stations.add(stationModel.getTransferStationName());
				}
				strategyTransferPageDTO.setTransferStationOrder(stations.stream().collect(Collectors.joining("->")));
			}
			strategyTransferPageDTOS.add(strategyTransferPageDTO);
		}
		// 分页重组
		Page<StrategyTransferPageDTO> page = PageUtils.getPage(strategyTransferPageDTOS);
		if (tmsStrategyTransferModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsStrategyTransferModel> p0 = (com.github.pagehelper.Page<TmsStrategyTransferModel>) tmsStrategyTransferModels;
			page.setPageCount(p0.getPages());
			page.setPageNum(p0.getPageNum());
			page.setPageSize(p0.getPageSize());
			page.setTotalCount(p0.getTotal());
			page.setStartRow(p0.getStartRow());
			page.setEndRow(p0.getEndRow());
		}
		return page;
	}

	/**
	 * 查看
	 *
	 * @param transferViewVO
	 * @return
	 */
	public StrategyTransferViewDTO viewData(StrategyTransferViewVO transferViewVO) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 状态
		List<Map<String, Object>> restStatus = sysRefdatadService.getDropDownById(DataDictionaryConstant.GENERAL_STATUS, null, null, null);

		TmsStrategyTransferModel tmsStrategyTransferModel = tmsStrategyTransferMapper.findById(transferViewVO.getId(), TmsStrategyTransferModel.class);
		ToolKits.isParamNull(tmsStrategyTransferModel, "策略ID【" + transferViewVO.getId() + "】有误,查询为空!");

		// 返回数据
		StrategyTransferViewDTO strategyTransferViewDTO = new StrategyTransferViewDTO();
		BeanUtils.copyProperties(tmsStrategyTransferModel, strategyTransferViewDTO);

		// 状态翻译
		strategyTransferViewDTO.setStatusName(PublicMethods.change(restStatus, String.valueOf(tmsStrategyTransferModel.getStatus())));

		// 查询对应条件
		Criteria criteria = Criteria.forClass(TmsStrategyTransferStationModel.class);
		Restriction r1 = Restrictions.eq(TmsStrategyTransferStationModel::getStrategyId, tmsStrategyTransferModel.getId());
		criteria.setRestriction(r1);
		List<TmsStrategyTransferStationModel> transferStationModels = tmsStrategyTransferStationMapper.findByCriteria(criteria);

		// 条件集合
		List<StrategyTransferStationDTO> transferStationViewDTOS = Lists.newArrayList();
		if (ToolKits.isNotEmpty(transferStationModels)) {
			// 中转时间类型
			List<Map<String, Object>> restTransDateType = sysRefdatadService.getDropDownById(DataDictionaryConstant.TRANSFER_TIME_TYPE, null, null, null);

			for (TmsStrategyTransferStationModel conditionModel : transferStationModels) {
				StrategyTransferStationDTO transferStationViewDTO = new StrategyTransferStationDTO();
				BeanUtils.copyProperties(conditionModel, transferStationViewDTO);

				transferStationViewDTO.setDeliveryStartTimeTypeName(PublicMethods.change(restTransDateType, String.valueOf(conditionModel.getDeliveryStartTimeType())));
				transferStationViewDTO.setDeliveryEndTimeTypeName(PublicMethods.change(restTransDateType, String.valueOf(conditionModel.getDeliveryEndTimeType())));
				transferStationViewDTO.setSendStartTimeTypeName(PublicMethods.change(restTransDateType, String.valueOf(conditionModel.getSendStartTimeType())));
				transferStationViewDTO.setSendEndTimeTypeName(PublicMethods.change(restTransDateType, String.valueOf(conditionModel.getSendEndTimeType())));
				transferStationViewDTOS.add(transferStationViewDTO);
			}
		}
		strategyTransferViewDTO.setTransferStationViewDTOS(transferStationViewDTOS);

		return strategyTransferViewDTO;
	}

	/**
	 * 新增
	 *
	 * @param strategyTransferSaveVO
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveData(StrategyTransferSaveVO strategyTransferSaveVO) {
		ToolKits.isParamNull(strategyTransferSaveVO, "保存请求不为空！");
		ToolKits.isParamNull(strategyTransferSaveVO.getTransferStationSaveVOS(), "中转站不为空！");
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 当前时间
		Date date = DateUtils.nowDate();

		// 判定是否有重复条件流程
		Criteria criteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r1 = Restrictions.eq(TmsStrategyTransferModel::getName, strategyTransferSaveVO.getName());
		Restriction r2 = Restrictions.eq(TmsStrategyTransferModel::getEnterpriseId, user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsStrategyTransferModel> tmsStrategyTransferModels = tmsStrategyTransferMapper.findByCriteria(criteria);
		if (ToolKits.isNotEmpty(tmsStrategyTransferModels)) {
			throw new RuntimeException("策略名称【" + strategyTransferSaveVO.getName() + "】已存在");
		}

		Restriction r3 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeId, strategyTransferSaveVO.getConsigneeId());
		Restriction r4 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeUnitId, strategyTransferSaveVO.getConsigneeUnitId());
		criteria.setRestriction(Restrictions.and(r2, r3, r4));
		List<TmsStrategyTransferModel> consignees = tmsStrategyTransferMapper.findByCriteria(criteria);
		if (ToolKits.isNotEmpty(consignees)) {
			throw new RuntimeException("相同收货方的策略已存在");
		}

		// 保存策略表
		String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_STRATEGY_TRANSFER_ID, "L");
		ToolKits.isParamNull(id, "获取运单中转策略表ID失败！");

		TmsStrategyTransferModel tmsStrategyTransferModel = new TmsStrategyTransferModel();
		BeanUtils.copyProperties(strategyTransferSaveVO, tmsStrategyTransferModel);

		tmsStrategyTransferModel.setId(Long.valueOf(id));
		tmsStrategyTransferModel.setStatus(DataDictionaryConstant.GENERAL_STATUS_ENABLE);
		tmsStrategyTransferModel.setRematchLine(ToolKits.isEmpty(strategyTransferSaveVO.getRematchLine()) ? DataDictionaryConstant.REMATCH_LINE_NO : strategyTransferSaveVO.getRematchLine());

		tmsStrategyTransferModel.setEnterpriseId(user.getEnterpriseId());
		tmsStrategyTransferModel.setEnterpriseName(user.getEnterpriseName());

		tmsStrategyTransferModel.setCreatetime(date);
		tmsStrategyTransferModel.setCreateperson(user.getNickname());
		tmsStrategyTransferModel.setUpdatetime(date);
		tmsStrategyTransferModel.setUpdateperson(user.getNickname());

		tmsStrategyTransferMapper.save(tmsStrategyTransferModel);

		// 保存策略条件表
		for (StrategyTransferStationSaveVO transferStationSaveVO : strategyTransferSaveVO.getTransferStationSaveVOS()) {
			String conditionId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_STRATEGY_TRANSFER_STATION_ID, "L");
			ToolKits.isParamNull(conditionId, "获取中转策略中转站表ID失败！");

			ToolKits.isParamNull(transferStationSaveVO.getDeliveryStartTimeType(), "预计到达开始时间类型不为空");
			ToolKits.isParamNull(transferStationSaveVO.getDeliveryEndTimeType(), "预计到达结束时间类型不为空");
			ToolKits.isParamNull(transferStationSaveVO.getSendStartTimeType(), "预计发出开始时间类型不为空");
			ToolKits.isParamNull(transferStationSaveVO.getSendEndTimeType(), "预计到达结束时间类型不为空");

			TmsStrategyTransferStationModel transferStationModel = new TmsStrategyTransferStationModel();
			BeanUtils.copyProperties(transferStationSaveVO, transferStationModel);

			transferStationModel.setId(Long.valueOf(conditionId));
			transferStationModel.setStrategyId(Long.valueOf(id));

			transferStationModel.setEnterpriseId(user.getEnterpriseId());
			transferStationModel.setEnterpriseName(user.getEnterpriseName());

			transferStationModel.setCreatetime(date);
			transferStationModel.setCreateperson(user.getNickname());
			transferStationModel.setUpdatetime(date);
			transferStationModel.setUpdateperson(user.getNickname());

			tmsStrategyTransferStationMapper.save(transferStationModel);
		}

	}

	/**
	 * 修改
	 *
	 * @param transferUpdateVO
	 */
	@Override
	public void updateData(StrategyTransferUpdateVO transferUpdateVO) {
		ToolKits.isParamNull(transferUpdateVO, "修改请求不为空！");
		ToolKits.isParamNull(transferUpdateVO.getTransferStationUpdateVOS(), "中转站不为空！");

		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 当前时间
		Date date = DateUtils.nowDate();

		TmsStrategyTransferModel tmsStrategyTransferModel = tmsStrategyTransferMapper.findById(transferUpdateVO.getId(), TmsStrategyTransferModel.class);
		ToolKits.isParamNull(tmsStrategyTransferModel, "策略ID【" + transferUpdateVO.getId() + "】有误,查询为空!");

		Criteria criteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r2 = Restrictions.eq(TmsStrategyTransferModel::getEnterpriseId, user.getEnterpriseId());
		Restriction r3 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeId, transferUpdateVO.getConsigneeId());
		Restriction r4 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeUnitId, transferUpdateVO.getConsigneeUnitId());
		Restriction r5 = Restrictions.ne(TmsStrategyTransferModel::getId, transferUpdateVO.getId());
		criteria.setRestriction(Restrictions.and(r2, r3, r4,r5));
		List<TmsStrategyTransferModel> consignees = tmsStrategyTransferMapper.findByCriteria(criteria);
		if (ToolKits.isNotEmpty(consignees)) {
			throw new RuntimeException("相同收货方的策略已存在");
		}

		BeanUtils.copyProperties(transferUpdateVO, tmsStrategyTransferModel);

		tmsStrategyTransferModel.setUpdatetime(date);
		tmsStrategyTransferModel.setUpdateperson(user.getNickname());

		// 修改策略表
		tmsStrategyTransferMapper.update(tmsStrategyTransferModel);

		// 删除条件
		Criteria transferStationCriteria = Criteria.forClass(TmsStrategyTransferStationModel.class);
		r2 = Restrictions.eq(TmsStrategyTransferStationModel::getStrategyId, transferUpdateVO.getId());
		transferStationCriteria.setRestriction(Restrictions.and(r2));
		tmsStrategyTransferStationMapper.deleteByCriteria(transferStationCriteria);
		// 修改策略条件表
		for (StrategyTransferStationUpdateVO stationUpdateVO : transferUpdateVO.getTransferStationUpdateVOS()) {

			String conditionId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_STRATEGY_TRANSFER_STATION_ID, "L");
			ToolKits.isParamNull(conditionId, "获取运单中转策略中转站表ID失败！");

			ToolKits.isParamNull(stationUpdateVO.getDeliveryStartTimeType(), "预计到达开始时间类型不为空");
			ToolKits.isParamNull(stationUpdateVO.getDeliveryEndTimeType(), "预计到达结束时间类型不为空");
			ToolKits.isParamNull(stationUpdateVO.getSendStartTimeType(), "预计发出开始时间类型不为空");
			ToolKits.isParamNull(stationUpdateVO.getSendEndTimeType(), "预计到达结束时间类型不为空");

			TmsStrategyTransferStationModel tmsStrategyTransferConditionModel = new TmsStrategyTransferStationModel();
			BeanUtils.copyProperties(stationUpdateVO, tmsStrategyTransferConditionModel);

			tmsStrategyTransferConditionModel.setId(Long.valueOf(conditionId));
			tmsStrategyTransferConditionModel.setStrategyId(tmsStrategyTransferModel.getId());

			tmsStrategyTransferConditionModel.setEnterpriseId(user.getEnterpriseId());
			tmsStrategyTransferConditionModel.setEnterpriseName(user.getEnterpriseName());

			tmsStrategyTransferConditionModel.setCreatetime(date);
			tmsStrategyTransferConditionModel.setCreateperson(user.getNickname());
			tmsStrategyTransferConditionModel.setUpdatetime(date);
			tmsStrategyTransferConditionModel.setUpdateperson(user.getNickname());

			tmsStrategyTransferStationMapper.save(tmsStrategyTransferConditionModel);
		}

	}

	/**
	 * 停用
	 *
	 * @param ids
	 */
	@Override
	public void disableData(List<Long> ids) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 当前时间
		Date date = DateUtils.nowDate();

		// 封装修改参数
		Map<String, Object> mapUpdate = Maps.newHashMap();
		mapUpdate.put("status", DataDictionaryConstant.GENERAL_STATUS_STOP);
		mapUpdate.put("updateperson", user.getNickname());
		mapUpdate.put("updatetime", date);

		Criteria criteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r1 = Restrictions.in("id", ids.stream().toArray());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));

		tmsStrategyTransferMapper.updateMapByCriteria(mapUpdate, criteria);
	}

	/**
	 * 启用
	 *
	 * @param ids
	 */
	@Override
	public void activeData(List<Long> ids) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "没有操作权限！");

		// 当前时间
		Date date = DateUtils.nowDate();

		// 封装修改参数
		Map<String, Object> mapUpdate = Maps.newHashMap();
		mapUpdate.put("status", DataDictionaryConstant.GENERAL_STATUS_ENABLE);
		mapUpdate.put("updateperson", user.getNickname());
		mapUpdate.put("updatetime", date);

		Criteria criteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r1 = Restrictions.in("id", ids.stream().toArray());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));

		tmsStrategyTransferMapper.updateMapByCriteria(mapUpdate, criteria);
	}

	/**
	 * 匹配
	 *
	 * @param transferMatchingVO
	 * @return
	 */
	@Override
	public List<StrategyTransferMatchingDTO> matchingData(StrategyTransferMatchingVO transferMatchingVO) {
		log.info("中转策略匹配:" + JSON.toJSONString(transferMatchingVO));
		ToolKits.isParamNull(transferMatchingVO, "运单匹配中转策略请求不为空");
		ToolKits.isParamNull(transferMatchingVO.getConsigneeId(), "收货方不为空");
		ToolKits.isParamNull(transferMatchingVO.getConsigneeUnitId(), "收货方单位不为空");

		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		List<StrategyTransferMatchingDTO> list = Lists.newArrayList();

		Criteria carrierCriteria = Criteria.forClass(TmsStrategyTransferModel.class);
		Restriction r1 = Restrictions.eq(TmsStrategyTransferModel::getEnterpriseId, user.getEnterpriseId());
		Restriction r2 = Restrictions.eq(TmsStrategyTransferModel::getStatus, DataDictionaryConstant.GENERAL_STATUS_ENABLE);
		Restriction r3 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeUnitId, transferMatchingVO.getConsigneeUnitId());
		Restriction r4 = Restrictions.eq(TmsStrategyTransferModel::getConsigneeId, transferMatchingVO.getConsigneeId());
		carrierCriteria.setRestriction(Restrictions.and(r1, r2, r3, r4));
		List<TmsStrategyTransferModel> tmsStrategyTransferModels = tmsStrategyTransferMapper.findByCriteria(carrierCriteria);

		if (ToolKits.isEmpty(tmsStrategyTransferModels)) {
			log.info("没有匹配到中转策略");
			return null;
		}
		for (TmsStrategyTransferModel tmsStrategyTransferModel : tmsStrategyTransferModels) {
			StrategyTransferMatchingDTO strategyTransferMatchingDTO = new StrategyTransferMatchingDTO();
			strategyTransferMatchingDTO.setRematchLine(tmsStrategyTransferModel.getRematchLine());

			Criteria transferCriteria = Criteria.forClass(TmsStrategyTransferStationModel.class);
			r2 = Restrictions.eq(TmsStrategyTransferStationModel::getStrategyId, tmsStrategyTransferModel.getId());
			r3 = Restrictions.eq(TmsStrategyTransferStationModel::getEnterpriseId, user.getEnterpriseId());
			transferCriteria.setRestriction(Restrictions.and(r2, r3));
			List<TmsStrategyTransferStationModel> transferStationModels = tmsStrategyTransferStationMapper.findByCriteria(transferCriteria);

			if (ToolKits.isEmpty(transferStationModels)) {
				continue;
			}
			List<StrategyTransferStationDTO> transferStationDTOS = Lists.newArrayList();
			for (TmsStrategyTransferStationModel stationModel : transferStationModels) {
				StrategyTransferStationDTO stationDTO = new StrategyTransferStationDTO();
				BeanUtils.copyProperties(stationModel, stationDTO);
				transferStationDTOS.add(stationDTO);
			}
			strategyTransferMatchingDTO.setTransferStationDTOS(transferStationDTOS);
			list.add(strategyTransferMatchingDTO);
		}
		log.info("匹配到的中转策略:" + JSON.toJSONString(list));
		return list;
	}
}
