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

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.prolog.common.util.ToolKits;
import com.prolog.cs.platform.power.model.Organization;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.exception.BizException;
import com.prolog.framework.core.exception.ParameterException;
import com.prolog.framework.core.exception.PrologException;
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.BussinessConstant;
import com.prolog.rdc.tms.constant.DataDictionaryConstant;
import com.prolog.rdc.tms.constant.RabbitMQConstant;
import com.prolog.rdc.tms.constant.SeriaNnumberConstant;
import com.prolog.rdc.tms.constant.StatusConstant;
import com.prolog.rdc.tms.dao.mapper.LmsTmsZoneMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseBranchApTimeMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseBranchMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseCarportMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseTranslineMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseVehicleTypeMapper;
import com.prolog.rdc.tms.dao.mapper.TmsTransferStationMapper;
import com.prolog.rdc.tms.model.dto.SysRefdatadDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StandardTemplateDetailsListDTO;
import com.prolog.rdc.tms.model.dto.basicData.AppointTimeQueryDTO;
import com.prolog.rdc.tms.model.dto.basicData.BranchByEncodingNameDTO;
import com.prolog.rdc.tms.model.dto.basicData.BranchByNameDTO;
import com.prolog.rdc.tms.model.dto.basicData.BranchConsigneeAndShipperPopupDTO;
import com.prolog.rdc.tms.model.dto.basicData.BranchImportPageDTO;
import com.prolog.rdc.tms.model.dto.basicData.BranchParkingSpaceImportPageDTO;
import com.prolog.rdc.tms.model.dto.basicData.ImportMatchingDataDTO;
import com.prolog.rdc.tms.model.dto.basicData.TmsBaseBranchApTimeDTO;
import com.prolog.rdc.tms.model.dto.basicData.TmsBaseBranchDTO;
import com.prolog.rdc.tms.model.dto.basicData.TmsBaseCarportDTO;
import com.prolog.rdc.tms.model.entity.LmsTmsZoneModel;
import com.prolog.rdc.tms.model.entity.TmsBaseBranchApTimeModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseBranchModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseCarportModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseLineModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseVehicleTypeModel;
import com.prolog.rdc.tms.model.entity.line.TmsTransferStationModel;
import com.prolog.rdc.tms.model.vo.AppointTimeQueryVO;
import com.prolog.rdc.tms.model.vo.SysRefdatadQueryVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ImportLogAddVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ImportPageVO;
import com.prolog.rdc.tms.model.vo.basicData.BranchByEncodingNameVO;
import com.prolog.rdc.tms.model.vo.basicData.BranchByNameVO;
import com.prolog.rdc.tms.model.vo.basicData.BranchConsigneeAndShipperPopupVO;
import com.prolog.rdc.tms.model.vo.basicData.ImportMatchingDataVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseBranchApTimeVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseBranchQueryPopVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseBranchQueryVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseBranchSaveVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseBranchUpdateVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseCarportSaveVO;
import com.prolog.rdc.tms.model.vo.basicData.TmsBaseCarportUpdateVO;
import com.prolog.rdc.tms.model.vo.xlsimport.BranchImportStdVO;
import com.prolog.rdc.tms.model.vo.xlsimport.CarportImportStdVO;
import com.prolog.rdc.tms.rmi.feign.UserFeign;
import com.prolog.rdc.tms.service.SysCodeengineService;
import com.prolog.rdc.tms.service.SysRefdatadService;
import com.prolog.rdc.tms.service.basicConfigure.ImportLogService;
import com.prolog.rdc.tms.service.basicConfigure.SysImportTemplethService;
import com.prolog.rdc.tms.service.basicData.BranchService;
import com.prolog.rdc.tms.util.FileUtils;
import com.prolog.rdc.tms.util.ImportUtils;
import com.prolog.rdc.tms.util.PublicMethods;
import com.prolog.wms.base.util.ExcelUtils;
import com.prolog.wms.base.util.JsonMapper;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * 基础数据-仓库管理实现层
 *
 * @author :xyf
 * @version :1.0.0
 * @className :BranchServiceImpl
 * @creationTime :2022/03/31
 * @description :
 * @modifier :xyf
 * @modifyTime :2022/03/31
 * @reviseRemarks:
 */
@Slf4j
@Service
public class BranchServiceImpl implements BranchService {

	@Autowired
	private TmsBaseBranchMapper tmsBaseBranchMapper;

	@Autowired
	private TmsBaseCarportMapper tmsBaseCarportMapper;

	@Autowired
	private SysCodeengineService sysCodeengineService;

	@Autowired
	private SysRefdatadService sysRefdatadService;

	@Autowired
	private TmsBaseTranslineMapper tmsBaseTranslineMapper;

	@Autowired
	private TmsTransferStationMapper tmsTransferStationMapper;

	@Autowired
	private SysImportTemplethService sysImportTemplethService;

	@Autowired
	private ImportLogService importLogService;

	@Autowired
	private LmsTmsZoneMapper lmsTmsZoneMapper;

	@Autowired
	private TmsBaseVehicleTypeMapper tmsBaseVehicleTypeMapper;

	@Autowired
	private UserFeign userTmsResource;

	@Autowired
	private TmsBaseBranchApTimeMapper tmsBaseBranchApTimeMapper;

	@Autowired
	private AmqpTemplate amqpTemplate;

	/**
	 * 仓库分页查询
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<TmsBaseBranchDTO> queryBranch(TmsBaseBranchQueryVO vo) throws Exception {
		ToolKits.isParamNull(vo.getPageNum(), "页码不为空");
		ToolKits.isParamNull(vo.getPageSize(), "页数不为空");

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

		// STD-DEVELOP20220823 lhb JC-HZ-001仓库支持多部门 20220908 start
		vo.setEnterpriseId(user.getEnterpriseId());
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				vo.setIsDept("Y");
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				vo.setIsDept("N");
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				vo.setIdArrs(user.getWarehouses().stream().toArray(Long[]::new));
				vo.setIsData("Y");
			}
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		PageUtils.startPage(vo.getPageNum(), vo.getPageSize());
		List<TmsBaseBranchDTO> list = tmsBaseBranchMapper.queryBranch(vo);
		// STD-DEVELOP20220823 lhb JC-HZ-001 仓库支持多部门 20220908 end

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		String[] objectcodes = { DataDictionaryConstant.MAINDATA_STATUS, // 启用、停用
				DataDictionaryConstant.AVAILABLE_TIME, // 可预约时间点
				DataDictionaryConstant.AVAILABLE_UNIT, // 预约时间单位
				DataDictionaryConstant.APPOINTMENT_TYPE, // 预约模式
				DataDictionaryConstant.CALL_HANDLE_TYPE, // 叫号处理方式
				DataDictionaryConstant.OVER_NUM_HANDLE_TYPE, // 叫号处理方式
				DataDictionaryConstant.PICK_UP_SIGN_TIME, // 提货签到时间点
				DataDictionaryConstant.DELIVERY_SIGN_TIME, // 送达签到时间点
				DataDictionaryConstant.SIGN_TIME_UNIT, // 签到时间单位
				DataDictionaryConstant.WHETHER };
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("获取数据字典失败");
		}
		List<TmsBaseBranchDTO> dtos = new ArrayList<TmsBaseBranchDTO>();
		for (TmsBaseBranchDTO model : list) {
			TmsBaseBranchDTO dto = new TmsBaseBranchDTO();
			BeanUtils.copyProperties(model, dto);

			for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
				if (DataDictionaryConstant.MAINDATA_STATUS.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getStatus()))) {
					dto.setStatusName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.AVAILABLE_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptTime()))) {
					dto.setAptTimeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.AVAILABLE_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptUnit()))) {
					dto.setAptUnitName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.AVAILABLE_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptCanNotCancel()))) {
					dto.setAptCanNotCancelName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.AVAILABLE_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptCanNotCancelUnit()))) {
					dto.setAptCanNotCancelUnitName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.APPOINTMENT_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptType()))) {
					dto.setAptTypeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.CALL_HANDLE_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getCallHandleType()))) {
					dto.setCallHandleTypeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.OVER_NUM_HANDLE_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getOverNumHandleType()))) {
					dto.setOverNumHandleTypeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.WHETHER.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpSign()))) {
					dto.setPickUpSignName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.WHETHER.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpPicture()))) {
					dto.setPickUpPictureName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.WHETHER.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliverySign()))) {
					dto.setDeliverySignName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.WHETHER.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliveryPicture()))) {
					dto.setDeliveryPictureName(sysrefdataddto.getName());
				}

				if (DataDictionaryConstant.PICK_UP_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpSignTime()))) {
					dto.setPickUpSignTimeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpSignTimeUnit()))) {
					dto.setPickUpSignTimeUnitName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.DELIVERY_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliverySignTime()))) {
					dto.setDeliverySignTimeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliverySignTimeUnit()))) {
					dto.setDeliverySignTimeUnitName(sysrefdataddto.getName());
				}
			}

			// 预约时间段
			Criteria criteriaApTime = Criteria.forClass(TmsBaseBranchApTimeModel.class);
			Restriction r6 = Restrictions.eq(TmsBaseBranchApTimeModel::getEnterpriseId, user.getEnterpriseId());
			Restriction r7 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, model.getId());
			criteriaApTime.setRestriction(Restrictions.and(r6, r7));
			criteriaApTime.setOrder(Order.newInstance().asc(new String[] { "startTime" }));
			List<TmsBaseBranchApTimeModel> apTimeList = tmsBaseBranchApTimeMapper.findByCriteria(criteriaApTime);
			List<String> apTimes = Lists.newArrayList();

			for (TmsBaseBranchApTimeModel apTimeModel : apTimeList) {
				apTimes.add(apTimeModel.getStartTime() + "-" + apTimeModel.getEndTime());
			}
			// 可预约时间段
			dto.setApTimeDuras(apTimes.stream().collect(Collectors.joining(",")));

			dto.setAptTimeName(dto.getAptTimeName() + dto.getAptTimeDura() + dto.getAptUnitName());
			dto.setAptCanNotCancelName(dto.getAptCanNotCancelName() + dto.getAptCanNotCancelDura() + dto.getAptCanNotCancelUnitName());

			dtos.add(dto);
		}

		Page<TmsBaseBranchDTO> page = PageUtils.getPage(dtos);
		if (list instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseBranchDTO> p0 = (com.github.pagehelper.Page<TmsBaseBranchDTO>) list;
			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;
	}

	/**
	 * 仓库弹出框分页查询
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<TmsBaseBranchDTO> queryBranchPopup(TmsBaseBranchQueryVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		if (vo.getPageNum() == 0) {
			throw new BizException("当前页不能为0");
		}
		if (vo.getPageSize() == 0) {
			throw new BizException("页行数不能为0");
		}

		// STD-DEVELOP20220823 lhb JC-HZ-001仓库支持多部门 20220908 start
		vo.setEnterpriseId(user.getEnterpriseId());
		vo.setStatus(StatusConstant.STATUS_ENABLE);
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 自有账号
			// 判断是否为部门权限
			vo.setIsDept("Y");
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				vo.setIsData("Y");
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				vo.setIdArrs(user.getWarehouses().stream().toArray(Long[]::new));
			}
		}

		PageUtils.startPage(vo.getPageNum(), vo.getPageSize());
		List<TmsBaseBranchDTO> list = tmsBaseBranchMapper.queryBranch(vo);

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		String[] objectcodes = { DataDictionaryConstant.PICK_UP_SIGN_TIME, // 提货签到时间点
				DataDictionaryConstant.DELIVERY_SIGN_TIME, // 送达签到时间点
				DataDictionaryConstant.SIGN_TIME_UNIT // 签到时间单位
		};
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("获取数据字典失败");
		}

		for (TmsBaseBranchDTO dto : list) {
			for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
				if (DataDictionaryConstant.PICK_UP_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getPickUpSignTime()))) {
					dto.setPickUpSignTimeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getPickUpSignTimeUnit()))) {
					dto.setPickUpSignTimeUnitName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.DELIVERY_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getDeliverySignTime()))) {
					dto.setDeliverySignTimeName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getDeliverySignTimeUnit()))) {
					dto.setDeliverySignTimeUnitName(sysrefdataddto.getName());
				}
			}
		}
		Page<TmsBaseBranchDTO> page = PageUtils.getPage(list);
		if (list instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseBranchDTO> p0 = (com.github.pagehelper.Page<TmsBaseBranchDTO>) list;
			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;
		// STD-DEVELOP20220823 lhb JC-HZ-001 仓库支持多部门 20220908 end
	}

	/**
	 * 仓库收发货方弹窗
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<BranchConsigneeAndShipperPopupDTO> popupBranchConsigneeAndShipperData(BranchConsigneeAndShipperPopupVO branchConsigneeAndShipperPopupVO) {
		ToolKits.isParamNull(branchConsigneeAndShipperPopupVO, "仓库弹窗请求不为空");
		ToolKits.isParamNull(branchConsigneeAndShipperPopupVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(branchConsigneeAndShipperPopupVO.getPageSize(), "页数不为空");

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

		// 响应对象集合
		List<BranchConsigneeAndShipperPopupDTO> branchConsigneeAndShipperPopupDTOs = new ArrayList<BranchConsigneeAndShipperPopupDTO>();

		// STD-DEVELOP20220823 lhb JC-HZ-001仓库支持多部门 20220908 start
		branchConsigneeAndShipperPopupVO.setEnterpriseId(user.getEnterpriseId());
		branchConsigneeAndShipperPopupVO.setStatus(StatusConstant.STATUS_ENABLE);
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			branchConsigneeAndShipperPopupVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				branchConsigneeAndShipperPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				branchConsigneeAndShipperPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				branchConsigneeAndShipperPopupVO.setIdArrs(user.getWarehouses().stream().toArray(Long[]::new));
				branchConsigneeAndShipperPopupVO.setIsData("Y");
			}
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}
		PageUtils.startPage(branchConsigneeAndShipperPopupVO.getPageNum(), branchConsigneeAndShipperPopupVO.getPageSize());
		List<TmsBaseBranchDTO> tmsBaseBranchModels = tmsBaseBranchMapper.popupBranchConsigneeAndShipperData(branchConsigneeAndShipperPopupVO);
		// STD-DEVELOP20220823 lhb JC-HZ-001仓库支持多部门 20220908 end
		for (TmsBaseBranchDTO tmsBaseBranchModel : tmsBaseBranchModels) {
			// 响应对象
			BranchConsigneeAndShipperPopupDTO branchConsigneeAndShipperPopupDTO = new BranchConsigneeAndShipperPopupDTO();
			branchConsigneeAndShipperPopupDTO.setShipperUnitId(tmsBaseBranchModel.getId());
			branchConsigneeAndShipperPopupDTO.setShipperUnitCode(tmsBaseBranchModel.getCode());
			branchConsigneeAndShipperPopupDTO.setShipperUnitName(tmsBaseBranchModel.getName());
			branchConsigneeAndShipperPopupDTO.setShipperId(tmsBaseBranchModel.getId());
			branchConsigneeAndShipperPopupDTO.setShipperCode(tmsBaseBranchModel.getCode());
			branchConsigneeAndShipperPopupDTO.setShipperName(tmsBaseBranchModel.getName());
			branchConsigneeAndShipperPopupDTO.setShipperContact(tmsBaseBranchModel.getContact());
			branchConsigneeAndShipperPopupDTO.setShipperPhoneNumber(tmsBaseBranchModel.getPhoneNumber());
			branchConsigneeAndShipperPopupDTO.setShipperLandlineNumber(tmsBaseBranchModel.getLandlineNumber());
			branchConsigneeAndShipperPopupDTO.setShipperEmail(tmsBaseBranchModel.getEmail());
			branchConsigneeAndShipperPopupDTO.setShipperRelatedPhoneNumber(null);
			branchConsigneeAndShipperPopupDTO.setShipperProvince(tmsBaseBranchModel.getProvince());
			branchConsigneeAndShipperPopupDTO.setShipperProvinceName(tmsBaseBranchModel.getProvinceName());
			branchConsigneeAndShipperPopupDTO.setShipperCity(tmsBaseBranchModel.getCity());
			branchConsigneeAndShipperPopupDTO.setShipperCityName(tmsBaseBranchModel.getCityName());
			branchConsigneeAndShipperPopupDTO.setShipperDistrict(tmsBaseBranchModel.getDistrict());
			branchConsigneeAndShipperPopupDTO.setShipperDistrictName(tmsBaseBranchModel.getDistrictName());
			branchConsigneeAndShipperPopupDTO.setShipperAddress(tmsBaseBranchModel.getAddress());
			branchConsigneeAndShipperPopupDTO.setShipperLongitude(tmsBaseBranchModel.getLongitude());
			branchConsigneeAndShipperPopupDTO.setShipperLatitude(tmsBaseBranchModel.getLatitude());
			branchConsigneeAndShipperPopupDTO.setShipperMemo(tmsBaseBranchModel.getMemo());
			branchConsigneeAndShipperPopupDTO.setShipperPickUpSign(tmsBaseBranchModel.getPickUpSign());
			branchConsigneeAndShipperPopupDTO.setShipperAutoPickUpSign(tmsBaseBranchModel.getAutoPickUpSign());
			branchConsigneeAndShipperPopupDTO.setShipperPickUpPicture(tmsBaseBranchModel.getPickUpPicture());
			branchConsigneeAndShipperPopupDTO.setShipperPickUpRail(tmsBaseBranchModel.getDefaultPickUpRail());

			branchConsigneeAndShipperPopupDTO.setConsigneeUnitId(tmsBaseBranchModel.getId());
			branchConsigneeAndShipperPopupDTO.setConsigneeUnitCode(tmsBaseBranchModel.getCode());
			branchConsigneeAndShipperPopupDTO.setConsigneeUnitName(tmsBaseBranchModel.getName());
			branchConsigneeAndShipperPopupDTO.setConsigneeId(tmsBaseBranchModel.getId());
			branchConsigneeAndShipperPopupDTO.setConsigneeCode(tmsBaseBranchModel.getCode());
			branchConsigneeAndShipperPopupDTO.setConsigneeName(tmsBaseBranchModel.getName());
			branchConsigneeAndShipperPopupDTO.setConsigneeContact(tmsBaseBranchModel.getContact());
			branchConsigneeAndShipperPopupDTO.setConsigneePhoneNumber(tmsBaseBranchModel.getPhoneNumber());
			branchConsigneeAndShipperPopupDTO.setConsigneeLandlineNumber(tmsBaseBranchModel.getLandlineNumber());
			branchConsigneeAndShipperPopupDTO.setConsigneeEmail(tmsBaseBranchModel.getEmail());
			branchConsigneeAndShipperPopupDTO.setConsigneeRelatedPhoneNumber(null);
			branchConsigneeAndShipperPopupDTO.setConsigneeProvince(tmsBaseBranchModel.getProvince());
			branchConsigneeAndShipperPopupDTO.setConsigneeProvinceName(tmsBaseBranchModel.getProvinceName());
			branchConsigneeAndShipperPopupDTO.setConsigneeCity(tmsBaseBranchModel.getCity());
			branchConsigneeAndShipperPopupDTO.setConsigneeCityName(tmsBaseBranchModel.getCityName());
			branchConsigneeAndShipperPopupDTO.setConsigneeDistrict(tmsBaseBranchModel.getDistrict());
			branchConsigneeAndShipperPopupDTO.setConsigneeDistrictName(tmsBaseBranchModel.getDistrictName());
			branchConsigneeAndShipperPopupDTO.setConsigneeAddress(tmsBaseBranchModel.getAddress());
			branchConsigneeAndShipperPopupDTO.setConsigneeLongitude(tmsBaseBranchModel.getLongitude());
			branchConsigneeAndShipperPopupDTO.setConsigneeLatitude(tmsBaseBranchModel.getLatitude());
			branchConsigneeAndShipperPopupDTO.setConsigneeMemo(tmsBaseBranchModel.getMemo());
			branchConsigneeAndShipperPopupDTO.setConsigneeDeliverySign(tmsBaseBranchModel.getDeliverySign());
			branchConsigneeAndShipperPopupDTO.setConsigneeAutoDeliverySign(tmsBaseBranchModel.getAutoDeliverySign());
			branchConsigneeAndShipperPopupDTO.setConsigneeDeliveryPicture(tmsBaseBranchModel.getDeliveryPicture());
			branchConsigneeAndShipperPopupDTO.setConsigneeDeliveryRail(tmsBaseBranchModel.getDefaultDeliveryRail());
			branchConsigneeAndShipperPopupDTO.setReturnOrderFlag(null);
			branchConsigneeAndShipperPopupDTO.setReturnOrderDeadline(null);
			branchConsigneeAndShipperPopupDTO.setConsigneeReturnOrderPicture(tmsBaseBranchModel.getReturnOrderPicture());

			branchConsigneeAndShipperPopupDTO.setPickUpSignTime(tmsBaseBranchModel.getPickUpSignTime());
			branchConsigneeAndShipperPopupDTO.setPickUpSignTimeDura(tmsBaseBranchModel.getPickUpSignTimeDura());
			branchConsigneeAndShipperPopupDTO.setPickUpSignTimeUnit(tmsBaseBranchModel.getPickUpSignTimeUnit());

			branchConsigneeAndShipperPopupDTO.setDeliverySignTime(tmsBaseBranchModel.getDeliverySignTime());
			branchConsigneeAndShipperPopupDTO.setDeliverySignTimeDura(tmsBaseBranchModel.getDeliverySignTimeDura());
			branchConsigneeAndShipperPopupDTO.setDeliverySignTimeUnit(tmsBaseBranchModel.getDeliverySignTimeUnit());

			branchConsigneeAndShipperPopupDTO.setStationId(tmsBaseBranchModel.getStationId());
			branchConsigneeAndShipperPopupDTO.setStationCode(tmsBaseBranchModel.getStationCode());
			branchConsigneeAndShipperPopupDTO.setStationName(tmsBaseBranchModel.getStationName());
			branchConsigneeAndShipperPopupDTO.setStationAreas(tmsBaseBranchModel.getStationAreas());
			branchConsigneeAndShipperPopupDTO.setStationDeliveryOrder(tmsBaseBranchModel.getStationDeliveryOrder());

			branchConsigneeAndShipperPopupDTOs.add(branchConsigneeAndShipperPopupDTO);
		}

		Page<BranchConsigneeAndShipperPopupDTO> page = PageUtils.getPage(branchConsigneeAndShipperPopupDTOs);
		if (tmsBaseBranchModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseBranchDTO> p0 = (com.github.pagehelper.Page<TmsBaseBranchDTO>) tmsBaseBranchModels;
			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 vo
	 * @return
	 */
	@Override
	public Page<TmsBaseBranchModel> queryBranchByBooking(TmsBaseBranchQueryPopVO vo) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		ToolKits.isParamNull(vo.getPageNum(), "页码不能为空");
		ToolKits.isParamNull(vo.getPageSize(), "每页条数不能为空");

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		Restriction r2 = ToolKits.isEmpty(vo.getCode()) ? null : Restrictions.like("code", "%" + vo.getCode() + "%");
		Restriction r3 = ToolKits.isEmpty(vo.getName()) ? null : Restrictions.like("name", "%" + vo.getName() + "%");
		Restriction r4 = Restrictions.eq("status", StatusConstant.STATUS_ENABLE);

		// 权限控制
		Restriction r5 = null;
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			r5 = Restrictions.in("id", user.getWarehouses().stream().toArray(Long[]::new));
		} else {// 非自有账号不能查询仓库
			throw new BizException("当前人员没有操作权限！");
		}

		criteria.setRestriction(Restrictions.and(r1, r2, r3, r4, r5));
		criteria.setOrder(Order.newInstance().desc(new String[] { "updatetime" }));
		PageUtils.startPage(vo.getPageNum(), vo.getPageSize());
		List<TmsBaseBranchModel> list = tmsBaseBranchMapper.findByCriteria(criteria);
		return PageUtils.getPage(list);
	}

	/**
	 * 仓库查看
	 */
	@Override
	public TmsBaseBranchDTO viewBranch(Long id) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		String[] objectcodes = { DataDictionaryConstant.MAINDATA_STATUS, // 启用、停用
				DataDictionaryConstant.AVAILABLE_TIME, // 可预约时间点
				DataDictionaryConstant.AVAILABLE_UNIT, // 预约时间单位
				DataDictionaryConstant.APPOINTMENT_TYPE, // 预约模式
				DataDictionaryConstant.CALL_HANDLE_TYPE, // 叫号处理方式
				DataDictionaryConstant.OVER_NUM_HANDLE_TYPE, // 叫号处理方式
				DataDictionaryConstant.PICK_UP_SIGN_TIME, // 提货签到时间点
				DataDictionaryConstant.DELIVERY_SIGN_TIME, // 送达签到时间点
				DataDictionaryConstant.SIGN_TIME_UNIT // 签到时间单位
		};
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("获取数据字典失败");
		}

		TmsBaseBranchModel model = tmsBaseBranchMapper.findById(id, TmsBaseBranchModel.class);
		TmsBaseBranchDTO dto = new TmsBaseBranchDTO();
		BeanUtils.copyProperties(model, dto);
		for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
			if (DataDictionaryConstant.MAINDATA_STATUS.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getStatus()))) {
				dto.setStatusName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.AVAILABLE_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptTime()))) {
				dto.setAptTimeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.AVAILABLE_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptUnit()))) {
				dto.setAptUnitName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.AVAILABLE_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptCanNotCancel()))) {
				dto.setAptCanNotCancelName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.AVAILABLE_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptCanNotCancelUnit()))) {
				dto.setAptCanNotCancelUnitName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.APPOINTMENT_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getAptType()))) {
				dto.setAptTypeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.CALL_HANDLE_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getCallHandleType()))) {
				dto.setCallHandleTypeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.OVER_NUM_HANDLE_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getOverNumHandleType()))) {
				dto.setOverNumHandleTypeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.PICK_UP_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpSignTime()))) {
				dto.setPickUpSignTimeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getPickUpSignTimeUnit()))) {
				dto.setPickUpSignTimeUnitName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.DELIVERY_SIGN_TIME.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliverySignTime()))) {
				dto.setDeliverySignTimeName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.SIGN_TIME_UNIT.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getDeliverySignTimeUnit()))) {
				dto.setDeliverySignTimeUnitName(sysrefdataddto.getName());
			}
		}
		// 预约时间段
		Criteria criteria = Criteria.forClass(TmsBaseBranchApTimeModel.class);
		Restriction r1 = Restrictions.eq(TmsBaseBranchApTimeModel::getEnterpriseId, user.getEnterpriseId());
		Restriction r2 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, id);
		criteria.setRestriction(Restrictions.and(r1, r2));
		criteria.setOrder(Order.newInstance().asc(new String[] { "startTime" }));
		List<TmsBaseBranchApTimeModel> apTimeList = tmsBaseBranchApTimeMapper.findByCriteria(criteria);
		List<TmsBaseBranchApTimeDTO> apTimeDTOS = Lists.newArrayList();
		for (TmsBaseBranchApTimeModel apTimeModel : apTimeList) {
			TmsBaseBranchApTimeDTO apTimeDTO = new TmsBaseBranchApTimeDTO();
			BeanUtils.copyProperties(apTimeModel, apTimeDTO);
			apTimeDTOS.add(apTimeDTO);
		}
		dto.setApTimeDTOList(apTimeDTOS);
		return dto;
	}

	/**
	 * 仓库新增
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveBranch(TmsBaseBranchSaveVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}

		// 非自有账号不能新增仓库
		if (ObjectUtil.notEqual(user.getUserType(), BussinessConstant.USER_TYPE_ZY)) {
			throw new PrologException("当前人员没有操作权限！");
		}

		if ((ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isEmpty(vo.getNonAptSpecEndDate())) || (ToolKits.isEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()))) {
			throw new PrologException("不可预约指定日期的开始日期和结束日期要么同时输入，要么都不输入！");
		}

		if (ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()) && vo.getNonAptSpecStartDate().compareTo(vo.getNonAptSpecEndDate()) > -1) {
			throw new PrologException("不可预约指定日期的开始日期需要小于结束日期！");
		}

		// 判断仓库编码是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseBranchModel.class, "code", vo.getCode(), "enterpriseId", user.getEnterpriseId(), "status", StatusConstant.STATUS_ENABLE, tmsBaseBranchMapper, "仓库编码已存在");
		PublicMethods.isThereAnyinformation(TmsBaseBranchModel.class, "code", vo.getCode(), "enterpriseId", user.getEnterpriseId(), "status", StatusConstant.STATUS_DISABLE, tmsBaseBranchMapper, "仓库编码已存在，请直接启用");

		// 判断仓库名称是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseBranchModel.class, "name", vo.getName(), "enterpriseId", user.getEnterpriseId(), "status", StatusConstant.STATUS_ENABLE, tmsBaseBranchMapper, "仓库名称已存在");
		PublicMethods.isThereAnyinformation(TmsBaseBranchModel.class, "name", vo.getName(), "enterpriseId", user.getEnterpriseId(), "status", StatusConstant.STATUS_DISABLE, tmsBaseBranchMapper, "仓库名称已存在，请直接启用");

		String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_ID, "L");
		if (ToolKits.isEmpty(id)) {
			throw new RuntimeException("仓库id获取失败");
		}
		Date date = DateUtil.date();
		TmsBaseBranchModel model = new TmsBaseBranchModel();
		BeanUtils.copyProperties(vo, model);
		model.setId(Long.valueOf(id));

		model.setPickUpSign(ToolKits.isEmpty(vo.getPickUpSign()) ? StatusConstant.WHETHER_NO : vo.getPickUpSign());
		model.setAutoPickUpSign(ToolKits.isEmpty(vo.getAutoPickUpSign()) ? StatusConstant.WHETHER_NO : vo.getAutoPickUpSign());
		model.setPickUpPicture(ToolKits.isEmpty(vo.getPickUpPicture()) ? StatusConstant.WHETHER_NO : vo.getPickUpPicture());
		model.setDeliverySign(ToolKits.isEmpty(vo.getDeliverySign()) ? StatusConstant.WHETHER_NO : vo.getDeliverySign());
		model.setAutoDeliverySign(ToolKits.isEmpty(vo.getAutoDeliverySign()) ? StatusConstant.WHETHER_NO : vo.getAutoDeliverySign());
		model.setDeliveryPicture(ToolKits.isEmpty(vo.getDeliveryPicture()) ? StatusConstant.WHETHER_NO : vo.getDeliveryPicture());
		model.setReturnOrderPicture(ToolKits.isEmpty(vo.getReturnOrderPicture()) ? StatusConstant.WHETHER_NO : vo.getReturnOrderPicture());

		model.setStatus(StatusConstant.STATUS_ENABLE);
		model.setSource(DataDictionaryConstant.SOURCE_ADD);
		model.setCreatetime(date);
		model.setCreateperson(user.getNickname());
		model.setUpdateperson(user.getNickname());
		model.setUpdatetime(date);
		model.setEnterpriseId(user.getEnterpriseId());
		model.setEnterpriseName(user.getEnterpriseName());
		tmsBaseBranchMapper.save(model);

		// 参考预约时间段保存
		if (ToolKits.isNotEmpty(vo.getApTimeSaveVOList())) {
			// 验证时间段大小关系
			List<String> apTimeList = Lists.newArrayList();
			for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
				apTimeList.add(apTimeSaveVO.getStartTime());
				apTimeList.add(apTimeSaveVO.getEndTime());
			}
			String apTimeStr1 = apTimeList.stream().collect(Collectors.joining(","));
			String apTimeStr2 = apTimeList.stream().sorted().collect(Collectors.joining(","));
			if (!apTimeStr1.equals(apTimeStr2)) {
				throw new PrologException("可预约时间段的先后关系不正确");
			}
			for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
				TmsBaseBranchApTimeModel apTimeModel = new TmsBaseBranchApTimeModel();
				String apTimeId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_APT_TIME_DURA, "L");
				if (ToolKits.isEmpty(apTimeId)) {
					throw new RuntimeException("仓库预约时间段id获取失败");
				}
				BeanUtils.copyProperties(apTimeSaveVO, apTimeModel);
				apTimeModel.setId(Long.valueOf(apTimeId));
				apTimeModel.setBranchId(Long.valueOf(id));
				apTimeModel.setCreatetime(date);
				apTimeModel.setCreateperson(user.getNickname());
				apTimeModel.setUpdateperson(user.getNickname());
				apTimeModel.setUpdatetime(date);
				apTimeModel.setEnterpriseId(user.getEnterpriseId());
				apTimeModel.setEnterpriseName(user.getEnterpriseName());
				tmsBaseBranchApTimeMapper.save(apTimeModel);
			}
		}
	}

	/**
	 * 仓库复制
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void copyBranch(TmsBaseBranchSaveVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		// 非自有账号不能操作
		if (ObjectUtil.notEqual(user.getUserType(), BussinessConstant.USER_TYPE_ZY)) {
			throw new PrologException("当前人员没有操作权限！");
		}
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}

		if ((ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isEmpty(vo.getNonAptSpecEndDate())) || (ToolKits.isEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()))) {
			throw new PrologException("不可预约指定日期的开始日期和结束日期要么同时输入，要么都不输入！");
		}

		if (ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()) && vo.getNonAptSpecStartDate().compareTo(vo.getNonAptSpecEndDate()) > -1) {
			throw new PrologException("不可预约指定日期的开始日期需要小于结束日期！");
		}
		// 校验是否已存在编码
		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		Restriction r2 = Restrictions.eq("code", vo.getCode());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseBranchModel> list = tmsBaseBranchMapper.findByCriteria(criteria);
		if (ToolKits.isNotEmpty(list)) {
			throw new BizException("系统已存在编码为【" + vo.getCode() + "】的仓库");
		}

		String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_ID, "L");
		if (ToolKits.isEmpty(id)) {
			throw new RuntimeException("仓库id获取失败");
		}
		Date date = DateUtil.date();
		TmsBaseBranchModel model = new TmsBaseBranchModel();
		BeanUtils.copyProperties(vo, model);
		model.setId(Long.valueOf(id));
		model.setPickUpSign(ToolKits.isEmpty(vo.getPickUpSign()) ? StatusConstant.WHETHER_NO : vo.getPickUpSign());
		model.setAutoPickUpSign(ToolKits.isEmpty(vo.getAutoPickUpSign()) ? StatusConstant.WHETHER_NO : vo.getAutoPickUpSign());
		model.setPickUpPicture(ToolKits.isEmpty(vo.getPickUpPicture()) ? StatusConstant.WHETHER_NO : vo.getPickUpPicture());
		model.setDeliverySign(ToolKits.isEmpty(vo.getDeliverySign()) ? StatusConstant.WHETHER_NO : vo.getDeliverySign());
		model.setAutoDeliverySign(ToolKits.isEmpty(vo.getAutoDeliverySign()) ? StatusConstant.WHETHER_NO : vo.getAutoDeliverySign());
		model.setDeliveryPicture(ToolKits.isEmpty(vo.getDeliveryPicture()) ? StatusConstant.WHETHER_NO : vo.getDeliveryPicture());
		model.setReturnOrderPicture(ToolKits.isEmpty(vo.getReturnOrderPicture()) ? StatusConstant.WHETHER_NO : vo.getReturnOrderPicture());
		model.setStatus(StatusConstant.STATUS_ENABLE);
		model.setCreatetime(date);
		model.setCreateperson(user.getNickname());
		model.setEnterpriseId(user.getEnterpriseId());
		model.setEnterpriseName(user.getEnterpriseName());
		model.setSource(DataDictionaryConstant.SOURCE_ADD);
		tmsBaseBranchMapper.save(model);

		// 参考预约时间段保存
		if (ToolKits.isNotEmpty(vo.getApTimeSaveVOList())) {
			// 验证时间段大小关系
			List<String> apTimeList = Lists.newArrayList();
			for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
				apTimeList.add(apTimeSaveVO.getStartTime());
				apTimeList.add(apTimeSaveVO.getEndTime());
			}
			String apTimeStr1 = apTimeList.stream().collect(Collectors.joining(","));
			String apTimeStr2 = apTimeList.stream().sorted().collect(Collectors.joining(","));
			if (!apTimeStr1.equals(apTimeStr2)) {
				throw new PrologException("可预约时间段的先后关系不正确");
			}
			for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
				TmsBaseBranchApTimeModel apTimeModel = new TmsBaseBranchApTimeModel();
				String apTimeId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_APT_TIME_DURA, "L");
				if (ToolKits.isEmpty(apTimeId)) {
					throw new RuntimeException("仓库预约时间段id获取失败");
				}
				BeanUtils.copyProperties(apTimeSaveVO, apTimeModel);
				apTimeModel.setId(Long.valueOf(apTimeId));
				apTimeModel.setBranchId(Long.valueOf(id));
				apTimeModel.setCreatetime(date);
				apTimeModel.setCreateperson(user.getNickname());
				apTimeModel.setUpdateperson(user.getNickname());
				apTimeModel.setUpdatetime(date);
				apTimeModel.setEnterpriseId(user.getEnterpriseId());
				apTimeModel.setEnterpriseName(user.getEnterpriseName());
				tmsBaseBranchApTimeMapper.save(apTimeModel);
			}
		}
	}

	/**
	 * 仓库修改
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateBranch(TmsBaseBranchUpdateVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		// 非自有账号不能操作
		if (ObjectUtil.notEqual(user.getUserType(), BussinessConstant.USER_TYPE_ZY)) {
			throw new PrologException("当前人员没有操作权限！");
		}
		if ((ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isEmpty(vo.getNonAptSpecEndDate())) || (ToolKits.isEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()))) {
			throw new PrologException("不可预约指定日期的开始日期和结束日期要么同时输入，要么都不输入！");
		}

		if (ToolKits.isNotEmpty(vo.getNonAptSpecStartDate()) && ToolKits.isNotEmpty(vo.getNonAptSpecEndDate()) && vo.getNonAptSpecStartDate().compareTo(vo.getNonAptSpecEndDate()) > -1) {
			throw new PrologException("不可预约指定日期的开始日期需要小于结束日期！");
		}

		ToolKits.isParamNull(vo.getId(), "仓库ID不能为空！");
		TmsBaseBranchModel model = tmsBaseBranchMapper.findById(vo.getId(), TmsBaseBranchModel.class);
		if (ToolKits.isNotEmpty(model)) {
			// 如果对仓库编码进行了修改操作,则需要判断修改后的仓库编码在系统中是否已存在(当前用户企业ID下的仓库中)
			if (!Objects.equals(model.getCode(), vo.getCode())) {
				// 校验是否已存在编码
				Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
				Restriction r1 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
				Restriction r2 = Restrictions.eq("code", vo.getCode());
				criteria.setRestriction(Restrictions.and(r1, r2));
				List<TmsBaseBranchModel> list = tmsBaseBranchMapper.findByCriteria(criteria);
				if (ToolKits.isNotEmpty(list)) {
					throw new BizException("系统已存在编码为【" + vo.getCode() + "】的仓库");
				}
			}
			Date date = DateUtil.date();
			BeanUtils.copyProperties(vo, model);
			model.setUpdatetime(date);
			model.setUpdateperson(user.getNickname());
			tmsBaseBranchMapper.update(model);

			// 仓库预约时间段更新
			if (ToolKits.isNotEmpty(vo.getApTimeSaveVOList())) {
				// 验证时间段大小关系
				List<String> apTimeList = Lists.newArrayList();
				for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
					apTimeList.add(apTimeSaveVO.getStartTime());
					apTimeList.add(apTimeSaveVO.getEndTime());
				}
				String apTimeStr1 = apTimeList.stream().collect(Collectors.joining(","));
				String apTimeStr2 = apTimeList.stream().sorted().collect(Collectors.joining(","));
				if (!apTimeStr1.equals(apTimeStr2)) {
					throw new PrologException("可预约时间段的先后关系不正确");
				}
				// 删除时间段
				Criteria flowConditionCriteria = Criteria.forClass(TmsBaseBranchApTimeModel.class);
				Restriction r7 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, vo.getId());
				flowConditionCriteria.setRestriction(Restrictions.and(r7));
				tmsBaseBranchApTimeMapper.deleteByCriteria(flowConditionCriteria);

				for (TmsBaseBranchApTimeVO apTimeSaveVO : vo.getApTimeSaveVOList()) {
					// 新增
					TmsBaseBranchApTimeModel apTimeModel = new TmsBaseBranchApTimeModel();
					String apTimeId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_APT_TIME_DURA, "L");
					if (ToolKits.isEmpty(apTimeId)) {
						throw new RuntimeException("仓库预约时间段id获取失败");
					}
					BeanUtils.copyProperties(apTimeSaveVO, apTimeModel);
					apTimeModel.setId(Long.valueOf(apTimeId));
					apTimeModel.setBranchId(Long.valueOf(vo.getId()));
					apTimeModel.setCreatetime(date);
					apTimeModel.setCreateperson(user.getNickname());
					apTimeModel.setUpdateperson(user.getNickname());
					apTimeModel.setUpdatetime(date);
					apTimeModel.setEnterpriseId(user.getEnterpriseId());
					apTimeModel.setEnterpriseName(user.getEnterpriseName());
					tmsBaseBranchApTimeMapper.save(apTimeModel);
				}
			}
		}

	}

	/**
	 * 仓库停用
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void deleteBranch(List<String> ids) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		// 非自有账号不能操作
		if (ObjectUtil.notEqual(user.getUserType(), BussinessConstant.USER_TYPE_ZY)) {
			throw new PrologException("当前人员没有操作权限！");
		}
		List<TmsBaseBranchModel> list = tmsBaseBranchMapper.findByIds(TmsBaseBranchModel.class, ids.toArray(), null);
		for (TmsBaseBranchModel model : list) {
			model.setStatus(StatusConstant.STATUS_DISABLE);
			model.setUpdatetime(new Date());
			model.setUpdateperson(user.getNickname());
			tmsBaseBranchMapper.update(model);

			// 停用对应车位
			Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
			Restriction r1 = Restrictions.eq("branchid", model.getId());
			criteria.setRestriction(r1);
			Map<String, Object> map = Maps.newHashMap();
			map.put("status", StatusConstant.STATUS_DISABLE);
			map.put("updatetime", new Date());
			map.put("updateperson", user.getNickname());
			tmsBaseCarportMapper.updateMapByCriteria(map, criteria);
		}
	}

	/**
	 * 仓库启用
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void activeBranch(List<String> ids) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		// 非自有账号不能操作
		if (ObjectUtil.notEqual(user.getUserType(), BussinessConstant.USER_TYPE_ZY)) {
			throw new PrologException("当前人员没有操作权限！");
		}
		List<TmsBaseBranchModel> list = tmsBaseBranchMapper.findByIds(TmsBaseBranchModel.class, ids.toArray(), null);
		for (TmsBaseBranchModel model : list) {
			model.setStatus(StatusConstant.STATUS_ENABLE);
			model.setUpdatetime(new Date());
			model.setUpdateperson(user.getNickname());
			tmsBaseBranchMapper.update(model);
		}
	}

	/**
	 * 车位查询
	 */
	@Override
	public List<TmsBaseCarportDTO> queryCarport(Long branchid, String userId) throws Exception {
		ToolKits.isParamNull(branchid, "仓库ID不为空");
		ToolKits.isParamNull(userId, "用户ID不为空");

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

		Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
		Restriction r1 = Restrictions.eq(TmsBaseCarportModel::getBranchid, branchid);
		Restriction r2 = Restrictions.like(TmsBaseCarportModel::getOperatorIds, "%" + userId + "%");
		Restriction r3 = Restrictions.eq(TmsBaseCarportModel::getStatus, DataDictionaryConstant.STATUS_ENABLE);
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		criteria.setOrder(Order.newInstance().desc(new String[] { "updatetime" }));
		List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByCriteria(criteria);

		List<TmsBaseCarportDTO> dtos = new ArrayList<TmsBaseCarportDTO>();
		for (TmsBaseCarportModel model : list) {
			TmsBaseCarportDTO dto = new TmsBaseCarportDTO();
			BeanUtils.copyProperties(model, dto);
			dtos.add(dto);
		}
		return dtos;
	}

	/**
	 * 车位列表查询
	 *
	 *
	 */
	public List<TmsBaseCarportDTO> queryCarportList(Long branchid) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		ToolKits.isParamNull(branchid, "仓库ID不能为空");

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		String[] objectcodes = { DataDictionaryConstant.MAINDATA_STATUS, DataDictionaryConstant.CARPORT_TYPE, DataDictionaryConstant.VEHICLE_TYPE_CATEGORY };
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new BizException("获取数据字典失败");
		}

		Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
		Restriction r1 = Restrictions.eq("branchid", branchid);
		criteria.setRestriction(Restrictions.and(r1));
		criteria.setOrder(Order.newInstance().desc(new String[] { "createtime" }));
		List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByCriteria(criteria);

		List<TmsBaseCarportDTO> dtos = new ArrayList<TmsBaseCarportDTO>();
		for (TmsBaseCarportModel model : list) {
			TmsBaseCarportDTO dto = new TmsBaseCarportDTO();
			BeanUtils.copyProperties(model, dto);
			for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
				if (DataDictionaryConstant.MAINDATA_STATUS.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getStatus()))) {
					dto.setStatusName(sysrefdataddto.getName());
				}
				if (DataDictionaryConstant.CARPORT_TYPE.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getType()))) {
					dto.setTypeName(sysrefdataddto.getName());
				}

				if (DataDictionaryConstant.VEHICLE_TYPE_CATEGORY.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getCarType()))) {
					dto.setCarTypeName(sysrefdataddto.getName());
				}
			}
			dtos.add(dto);
		}
		return dtos;
	}

	/**
	 * 车位查看
	 */
	@Override
	public TmsBaseCarportDTO viewCarport(Long id) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		// 启用、停用
		String[] objectcodes = { DataDictionaryConstant.MAINDATA_STATUS, DataDictionaryConstant.VEHICLE_TYPE_CATEGORY };
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new BizException("获取数据字典失败");
		}

		TmsBaseCarportModel model = tmsBaseCarportMapper.findById(id, TmsBaseCarportModel.class);
		TmsBaseCarportDTO dto = new TmsBaseCarportDTO();
		BeanUtils.copyProperties(model, dto);
		for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
			if (DataDictionaryConstant.MAINDATA_STATUS.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getStatus()))) {
				dto.setStatusName(sysrefdataddto.getName());
			}
			if (DataDictionaryConstant.VEHICLE_TYPE_CATEGORY.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(dto.getType()))) {
				dto.setTypeName(sysrefdataddto.getName());
			}
		}
		return dto;
	}

	/**
	 * 车位新增
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveCarport(TmsBaseCarportSaveVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		if (ToolKits.isEmpty(vo.getBranchid())) {
			throw new BizException("仓库ID不能为空！");
		}

		// 校验是否已存在编码
		Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
		Restriction r1 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		Restriction r2 = Restrictions.eq("code", vo.getCode());
		Restriction r3 = Restrictions.eq("branchid", vo.getBranchid());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByCriteria(criteria);
		if (ToolKits.isNotEmpty(list)) {
			throw new BizException("当前仓库下,系统已存在编码为【" + vo.getCode() + "】的车位");
		}

		String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_CARPORT_ID, "L");
		if (ToolKits.isEmpty(id)) {
			throw new BizException("车位id获取失败");
		}
		ToolKits.isParamNull(vo.getBranchid(), "仓库ID不能为空");
		TmsBaseCarportModel model = new TmsBaseCarportModel();
		BeanUtils.copyProperties(vo, model);
		model.setId(Long.valueOf(id));
		model.setStatus(StatusConstant.STATUS_ENABLE);
		model.setDatasource(DataDictionaryConstant.SOURCE_ADD);
		model.setCreatetime(new Date());
		model.setCreateperson(user.getNickname());
		model.setEnterpriseId(user.getEnterpriseId());
		model.setEnterpriseName(user.getEnterpriseName());
		tmsBaseCarportMapper.save(model);
	}

	/**
	 * 车位修改
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateCarport(TmsBaseCarportUpdateVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		ToolKits.isParamNull(vo.getId(), "车位ID不能为空！");
		TmsBaseCarportModel model = tmsBaseCarportMapper.findById(vo.getId(), TmsBaseCarportModel.class);
		if (ToolKits.isNotEmpty(model)) {
			if (!Objects.equals(model.getCode(), vo.getCode())) {
				// 校验是否已存在编码
				Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
				Restriction r1 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
				Restriction r2 = Restrictions.eq("code", vo.getCode());
				Restriction r3 = Restrictions.eq("branchid", vo.getBranchid());
				criteria.setRestriction(Restrictions.and(r1, r2, r3));
				List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByCriteria(criteria);
				if (ToolKits.isNotEmpty(list)) {
					throw new BizException("当前仓库下,系统已存在编码为【" + vo.getCode() + "】的车位");
				}
			}

			BeanUtils.copyProperties(vo, model);
			model.setUpdatetime(new Date());
			model.setUpdateperson(user.getNickname());
			model.setType(Integer.valueOf(vo.getType()));
			tmsBaseCarportMapper.update(model);
		}
	}

	/**
	 * 车位停用
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void deleteCarport(List<String> ids) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByIds(TmsBaseCarportModel.class, ids.toArray(), null);
		for (TmsBaseCarportModel model : list) {
			model.setStatus(StatusConstant.STATUS_DISABLE);
			model.setUpdatetime(new Date());
			model.setUpdateperson(user.getNickname());
			tmsBaseCarportMapper.update(model);
		}
	}

	/**
	 * 车位启用
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void activeCarport(List<String> ids) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		List<TmsBaseCarportModel> list = tmsBaseCarportMapper.findByIds(TmsBaseCarportModel.class, ids.toArray(), null);
		for (TmsBaseCarportModel model : list) {
			model.setStatus(StatusConstant.STATUS_ENABLE);
			model.setUpdatetime(new Date());
			model.setUpdateperson(user.getNickname());
			tmsBaseCarportMapper.update(model);
		}
	}

	/**
	 * 仓库地址解析专用查询
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<TmsBaseBranchDTO> queryBranchForAddress(TmsBaseBranchQueryVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		if (ToolKits.isEmpty(user)) {
			throw new BizException("当前人员没有操作权限！");
		}
		if (vo.getPageNum() == 0) {
			throw new BizException("当前页不能为0");
		}
		if (vo.getPageSize() == 0) {
			throw new BizException("页行数不能为0");
		}

		SysRefdatadQueryVO sysrefdatadqueryvo = new SysRefdatadQueryVO();
		String[] objectcodes = { DataDictionaryConstant.MAINDATA_STATUS,// 启用、停用
		};
		sysrefdatadqueryvo.setObjectcodes(objectcodes);
		List<SysRefdatadDTO> sysrefdataddtos = new ArrayList<SysRefdatadDTO>();
		try {
			sysrefdataddtos = sysRefdatadService.getSysRefdatadData(sysrefdatadqueryvo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("获取数据字典失败");
		}

		// STD-DEVELOP20220823 lhb JC-HZ-001仓库支持多部门 20220908 start
		vo.setEnterpriseId(user.getEnterpriseId());
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			vo.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				vo.setIsData("Y");
				vo.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				vo.setIdArrs(user.getWarehouses().stream().toArray(Long[]::new));
			}
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		PageUtils.startPage(vo.getPageNum(), vo.getPageSize());
		List<TmsBaseBranchDTO> list = tmsBaseBranchMapper.queryBranch(vo);
		// STD-DEVELOP20220823 lhb JC-HZ-001 仓库支持多部门 20220908 end

		List<TmsBaseBranchDTO> dtos = new ArrayList<TmsBaseBranchDTO>();
		for (TmsBaseBranchDTO model : list) {
			TmsBaseBranchDTO dto = new TmsBaseBranchDTO();
			BeanUtils.copyProperties(model, dto);
			for (SysRefdatadDTO sysrefdataddto : sysrefdataddtos) {
				if (DataDictionaryConstant.MAINDATA_STATUS.equals(sysrefdataddto.getObjectcode()) && sysrefdataddto.getCode().equals(String.valueOf(model.getStatus()))) {
					dto.setStatusName(sysrefdataddto.getName());
				}
			}
			dtos.add(dto);
		}

		Page<TmsBaseBranchDTO> page = PageUtils.getPage(dtos);
		if (list instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseBranchDTO> p0 = (com.github.pagehelper.Page<TmsBaseBranchDTO>) list;
			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;
	}

	/**
	 * 车位批量删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchDeleteCarportData(List<Long> ids) throws Exception {
		ToolKits.isParamNull(ids, "车位批量删除请求不为空");

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

		for (Long id : ids) {
			ToolKits.isParamNull(id, "车位ID不为空");

			tmsBaseCarportMapper.deleteById(id, TmsBaseCarportModel.class);
		}
	}

	/**
	 * 仓库批量删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchDeleteBranchData(List<Long> ids) throws Exception {
		ToolKits.isParamNull(ids, "仓库批量删除请求不为空");

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

		for (Long id : ids) {
			ToolKits.isParamNull(id, "仓库ID不为空");

			TmsBaseBranchModel tmsBaseBranchModel = tmsBaseBranchMapper.findById(id, TmsBaseBranchModel.class);
			Criteria criteria = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r1 = Restrictions.eq("startLineId", id);
			Restriction r2 = Restrictions.eq("endLineId", id);
			Restriction r3 = Restrictions.or(r1, r2);
			Restriction r4 = Restrictions.eq("status", StatusConstant.STATUS_ENABLE);
			criteria.setRestriction(Restrictions.and(r3, r4));
			List<TmsBaseLineModel> tmsBaseTranslineModels = tmsBaseTranslineMapper.findByCriteria(criteria);

			if (ToolKits.isNotEmpty(tmsBaseTranslineModels)) {
				throw new RuntimeException("仓库【" + tmsBaseBranchModel.getName() + "】正在被线路【" + tmsBaseTranslineModels.get(0).getLineName() + "】使用，不能删除");
			}

			// 删除仓库
			tmsBaseBranchMapper.deleteById(id, TmsBaseBranchModel.class);

			// 停用的线路清空该仓库
			Criteria criteria1 = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r11 = Restrictions.eq("startLineId", id);
			Restriction r21 = Restrictions.eq("status", StatusConstant.STATUS_DISABLE);
			criteria1.setRestriction(Restrictions.and(r11, r21));

			Map<String, Object> map = Maps.newHashMap();
			map.put("startLineId", "");
			map.put("startLineCode", "");
			map.put("startLineName", "");
			map.put("updatetime", new Date());
			map.put("updateperson", user.getNickname());
			tmsBaseTranslineMapper.updateMapByCriteria(map, criteria1);

			Criteria criteria2 = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r12 = Restrictions.eq("startLineId", id);
			Restriction r22 = Restrictions.eq("status", StatusConstant.STATUS_DISABLE);
			criteria2.setRestriction(Restrictions.and(r12, r22));

			map = Maps.newHashMap();
			map.put("endLineId", "");
			map.put("endLineCode", "");
			map.put("endLineName", "");
			map.put("updatetime", new Date());
			map.put("updateperson", user.getNickname());
			tmsBaseTranslineMapper.updateMapByCriteria(map, criteria2);

			// 删除车位
			Criteria carportCri = Criteria.forClass(TmsBaseCarportModel.class);
			Restriction carportR1 = Restrictions.eq("branchid", id);
			carportCri.setRestriction(carportR1);
			tmsBaseCarportMapper.deleteByCriteria(carportCri);

			// 删除中转站
			Criteria stationCri = Criteria.forClass(TmsTransferStationModel.class);
			Restriction stationR1 = Restrictions.eq("branchId", id);
			stationCri.setRestriction(stationR1);
			tmsTransferStationMapper.deleteByCriteria(stationCri);
		}
	}

	/**
	 * 仓库导入撤销
	 */
	@Transactional(rollbackFor = Exception.class)
	@Override
	public void rollbackData(String batchno) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限！");
		ToolKits.isParamNull(batchno, "导入批次号不能为空");

		Criteria branchCriteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction branchR1 = Restrictions.eq("importBatchNumber", batchno);
		branchCriteria.setRestriction(branchR1);
		List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(branchCriteria);
		if (ToolKits.isEmpty(tmsBaseBranchModels)) {
			throw new ParameterException("批次号[" + batchno + "]错误，查询为空");
		}

		// 当前时间
		Date date = new Date();

		// 校验是否在正常的线路中
		for (TmsBaseBranchModel model : tmsBaseBranchModels) {
			Criteria criteria = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r1 = Restrictions.eq("startLineId", model.getId());
			Restriction r2 = Restrictions.eq("endLineId", model.getId());
			Restriction r3 = Restrictions.or(r1, r2);
			Restriction r4 = Restrictions.eq("status", StatusConstant.STATUS_ENABLE);
			criteria.setRestriction(Restrictions.and(r3, r4));
			List<TmsBaseLineModel> tmsBaseTranslineModels = tmsBaseTranslineMapper.findByCriteria(criteria);

			if (ToolKits.isNotEmpty(tmsBaseTranslineModels)) {
				throw new ParameterException("仓库【" + model.getName() + "】正在被线路【" + tmsBaseTranslineModels.get(0).getLineName() + "】使用，不能删除");
			}

			// 删除仓库
			tmsBaseBranchMapper.deleteById(model.getId(), TmsBaseBranchModel.class);

			// 停用的线路清空该仓库
			Criteria criteria1 = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r11 = Restrictions.eq("startLineId", model.getId());
			Restriction r21 = Restrictions.eq("status", StatusConstant.STATUS_DISABLE);
			criteria1.setRestriction(Restrictions.and(r11, r21));

			Map<String, Object> map = Maps.newHashMap();
			map.put("startLineId", "");
			map.put("startLineCode", "");
			map.put("startLineName", "");
			map.put("updatetime", date);
			map.put("updateperson", user.getNickname());
			tmsBaseTranslineMapper.updateMapByCriteria(map, criteria1);

			Criteria criteria2 = Criteria.forClass(TmsBaseLineModel.class);
			Restriction r12 = Restrictions.eq("startLineId", model.getId());
			Restriction r22 = Restrictions.eq("status", StatusConstant.STATUS_DISABLE);
			criteria2.setRestriction(Restrictions.and(r12, r22));

			map = Maps.newHashMap();
			map.put("endLineId", "");
			map.put("endLineCode", "");
			map.put("endLineName", "");
			map.put("updatetime", date);
			map.put("updateperson", user.getNickname());
			tmsBaseTranslineMapper.updateMapByCriteria(map, criteria2);

			// 删除车位
			Criteria carportCri = Criteria.forClass(TmsBaseCarportModel.class);
			Restriction carportR1 = Restrictions.eq("branchid", model.getId());
			carportCri.setRestriction(carportR1);
			tmsBaseCarportMapper.deleteByCriteria(carportCri);

			// 删除中转站
			Criteria stationCri = Criteria.forClass(TmsTransferStationModel.class);
			Restriction stationR1 = Restrictions.eq("branchid", model.getId());
			stationCri.setRestriction(stationR1);
			tmsTransferStationMapper.deleteByCriteria(stationCri);
		}
	}

	/**
	 * 车位导入撤销
	 */
	@Transactional(rollbackFor = Exception.class)
	@Override
	public void rollbackCarportData(String batchno) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限！");
		ToolKits.isParamNull(batchno, "导入批次号不能为空");

		Criteria carportCriteria = Criteria.forClass(TmsBaseCarportModel.class);
		Restriction carportR1 = Restrictions.eq("importBatchNumber", batchno);
		carportCriteria.setRestriction(carportR1);
		List<TmsBaseCarportModel> tmsBaseCarportModels = tmsBaseCarportMapper.findByCriteria(carportCriteria);

		if (ToolKits.isEmpty(tmsBaseCarportModels)) {
			throw new ParameterException("批次号[" + batchno + "]错误，查询为空");
		}

		tmsBaseCarportMapper.deleteByCriteria(carportCriteria);
	}

	/**
	 * 仓库导入分页查询
	 */
	@Override
	@SuppressWarnings("resource")
	public RestMessage<Object> pageBranchByImportBatchNumberData(ImportPageVO importPageVO) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		// 响应对象集合
		List<BranchImportPageDTO> branchImportPageDTOs = new ArrayList<BranchImportPageDTO>();

		// 分页
		PageUtils.startPage(importPageVO.getPageNum(), importPageVO.getPageSize());

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("importBatchNumber", importPageVO.getImportBatchNumber());
		Restriction r2 = Restrictions.eq("source", DataDictionaryConstant.SOURCE_EXCEL);
		Restriction r3 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		criteria.setOrder(Order.newInstance().desc(new String[] { "updatetime" }));
		List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(criteria);
		for (TmsBaseBranchModel tmsBaseBranchModel : tmsBaseBranchModels) {
			// 响应对象
			BranchImportPageDTO branchImportPageDTO = new BranchImportPageDTO();
			BeanUtils.copyProperties(tmsBaseBranchModel, branchImportPageDTO);
			branchImportPageDTOs.add(branchImportPageDTO);
		}

		Page<BranchImportPageDTO> page = PageUtils.getPage(branchImportPageDTOs);
		if (tmsBaseBranchModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseBranchModel> p0 = (com.github.pagehelper.Page<TmsBaseBranchModel>) tmsBaseBranchModels;
			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 RestMessage.newInstance(true, "查询成功", page);
	}

	/**
	 * 仓库车位导入分页查询
	 */
	@Override
	@SuppressWarnings("resource")
	public RestMessage<Object> pageBranchParkingSpaceByImportBatchNumberData(ImportPageVO importPageVO) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		// 响应对象集合
		List<BranchParkingSpaceImportPageDTO> branchParkingSpaceImportPageDTOs = new ArrayList<BranchParkingSpaceImportPageDTO>();

		// 分页
		PageUtils.startPage(importPageVO.getPageNum(), importPageVO.getPageSize());

		Criteria criteria = Criteria.forClass(TmsBaseCarportModel.class);
		Restriction r1 = Restrictions.eq("importBatchNumber", importPageVO.getImportBatchNumber());
		Restriction r2 = Restrictions.eq("source", DataDictionaryConstant.SOURCE_EXCEL);
		Restriction r3 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		criteria.setOrder(Order.newInstance().desc(new String[] { "updatetime" }));
		List<TmsBaseCarportModel> tmsBaseCarportModels = tmsBaseCarportMapper.findByCriteria(criteria);

		for (TmsBaseCarportModel tmsBaseCarportModel : tmsBaseCarportModels) {
			// 响应对象
			BranchParkingSpaceImportPageDTO branchParkingSpaceImportPageDTO = new BranchParkingSpaceImportPageDTO();
			BeanUtils.copyProperties(tmsBaseCarportModel, branchParkingSpaceImportPageDTO);
			branchParkingSpaceImportPageDTOs.add(branchParkingSpaceImportPageDTO);
		}

		Page<BranchParkingSpaceImportPageDTO> page = PageUtils.getPage(branchParkingSpaceImportPageDTOs);
		if (tmsBaseCarportModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsBaseCarportModel> p0 = (com.github.pagehelper.Page<TmsBaseCarportModel>) tmsBaseCarportModels;
			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 RestMessage.newInstance(true, "查询成功", page);
	}

	/**
	 * 地址解析
	 */
	@Transactional(rollbackFor = Exception.class)
	@Override
	public void parseBranchAddress(Long id, BigDecimal longitude, BigDecimal latitude, String address) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		TmsBaseBranchModel tmsBaseBranchModel = tmsBaseBranchMapper.findById(id, TmsBaseBranchModel.class);

		ToolKits.isParamNull(tmsBaseBranchModel, "仓库不存在");

		tmsBaseBranchModel.setLongitude(longitude);
		tmsBaseBranchModel.setLatitude(latitude);
		tmsBaseBranchModel.setAddress(ToolKits.isEmpty(address) ? null : address);
		tmsBaseBranchModel.setUpdateperson(user.getNickname());
		tmsBaseBranchModel.setUpdatetime(DateUtil.date());
		tmsBaseBranchMapper.update(tmsBaseBranchModel);
	}

	/**
	 * 根据仓库编码名称查询仓库资料
	 */
	@Override
	public BranchByEncodingNameDTO getBranchByEncodingNameData(BranchByEncodingNameVO branchByEncodingNameVO) {
		ToolKits.isParamNull(branchByEncodingNameVO, "根据仓库编码名称查询仓库资料请求不为空");
		ToolKits.isParamNull(branchByEncodingNameVO.getCode(), "仓库编码不为空");
		ToolKits.isParamNull(branchByEncodingNameVO.getName(), "仓库名称不为空");

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

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("code", branchByEncodingNameVO.getCode());
		Restriction r2 = Restrictions.eq("name", branchByEncodingNameVO.getName());
		Restriction r3 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(criteria);
		Assert.isTrue(tmsBaseBranchModels.size() > 0, "不存在编码为【" + branchByEncodingNameVO.getCode() + "】,名称为【" + branchByEncodingNameVO.getName() + "】的仓库");
		Assert.isTrue(tmsBaseBranchModels.size() == 1, "编码为【" + branchByEncodingNameVO.getCode() + "】,名称为【" + branchByEncodingNameVO.getName() + "】的仓库资料重复");

		// 仓库资料对象
		TmsBaseBranchModel tmsBaseBranchModel = tmsBaseBranchModels.get(0);
		Assert.isTrue(tmsBaseBranchModel.getStatus() == StatusConstant.STATUS_ENABLE, "仓库【" + branchByEncodingNameVO.getName() + "】未启用");

		// 响应对象
		BranchByEncodingNameDTO branchByEncodingNameDTO = new BranchByEncodingNameDTO();
		BeanUtils.copyProperties(tmsBaseBranchModel, branchByEncodingNameDTO);

		return branchByEncodingNameDTO;
	}

	/**
	 * 根据仓库编码名称查询仓库资料
	 */
	@Override
	public BranchByEncodingNameDTO getBranchByEncodingNameDataIntf(BranchByEncodingNameVO branchByEncodingNameVO) {
		ToolKits.isParamNull(branchByEncodingNameVO, "根据仓库编码名称查询仓库资料请求不为空");
		ToolKits.isParamNull(branchByEncodingNameVO.getCode(), "仓库编码不为空");
		ToolKits.isParamNull(branchByEncodingNameVO.getName(), "仓库名称不为空");

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("code", branchByEncodingNameVO.getCode());
		Restriction r2 = Restrictions.eq("name", branchByEncodingNameVO.getName());
		Restriction r3 = Restrictions.eq("enterpriseId", branchByEncodingNameVO.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(criteria);
		Assert.isTrue(tmsBaseBranchModels.size() > 0, "不存在编码为【" + branchByEncodingNameVO.getCode() + "】,名称为【" + branchByEncodingNameVO.getName() + "】的仓库");
		Assert.isTrue(tmsBaseBranchModels.size() == 1, "编码为【" + branchByEncodingNameVO.getCode() + "】,名称为【" + branchByEncodingNameVO.getName() + "】的仓库资料重复");

		// 仓库资料对象
		TmsBaseBranchModel tmsBaseBranchModel = tmsBaseBranchModels.get(0);
		Assert.isTrue(tmsBaseBranchModel.getStatus() == StatusConstant.STATUS_ENABLE, "仓库【" + branchByEncodingNameVO.getName() + "】未启用");

		// 响应对象
		BranchByEncodingNameDTO branchByEncodingNameDTO = new BranchByEncodingNameDTO();
		BeanUtils.copyProperties(tmsBaseBranchModel, branchByEncodingNameDTO);

		return branchByEncodingNameDTO;
	}

	/**
	 * 根据仓库名称查询仓库资料
	 */
	@Override
	public BranchByNameDTO getBranchByNameData(BranchByNameVO branchByNameVO) {
		ToolKits.isParamNull(branchByNameVO, "根据仓库名称查询仓库资料请求不为空");
		ToolKits.isParamNull(branchByNameVO.getName(), "仓库名称不为空");

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

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = Restrictions.eq("name", branchByNameVO.getName());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(criteria);
		Assert.isTrue(tmsBaseBranchModels.size() > 0, "不存在名称为【" + branchByNameVO.getName() + "】的仓库");
		Assert.isTrue(tmsBaseBranchModels.size() == 1, "名称为【" + branchByNameVO.getName() + "】的仓库资料重复");

		// 仓库资料对象
		TmsBaseBranchModel tmsBaseBranchModel = tmsBaseBranchModels.get(0);
		Assert.isTrue(tmsBaseBranchModel.getStatus() == StatusConstant.STATUS_ENABLE, "仓库【" + branchByNameVO.getName() + "】未启用");

		// 响应对象
		BranchByNameDTO branchByNameDTO = new BranchByNameDTO();
		BeanUtils.copyProperties(tmsBaseBranchModel, branchByNameDTO);

		return branchByNameDTO;
	}

	// 仓库导入(新)
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchImportBranchData(MultipartFile file, String importBatchNumber) throws Exception {
		// 人员权限
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");
		// 导入文件判断
		FileUtils.multipartFileJudge(file);
		// 导入日志对象
		ImportLogAddVO logAddVO = new ImportLogAddVO();
		logAddVO.setImportObjNo(DataDictionaryConstant.BRANCH_IMPORT);
		logAddVO.setImportBatchNumber(importBatchNumber);
		// 导入统计
		int count = 0;
		try {
			// 导入执行
			count = this.batchInsertProcess(file, importBatchNumber, user);
			logAddVO.setStatus(DataDictionaryConstant.IMPORT_STATUS_YES);
			logAddVO.setSuccessNum(count);
			logAddVO.setFailNum(0);
			importLogService.addImportLogData(logAddVO);
		} catch (Exception e) {
			Class<BranchImportStdVO> importVOClass = BranchImportStdVO.class;
			List<BranchImportStdVO> importVOs = ExcelUtils.read(file, importVOClass);

			logAddVO.setStatus(DataDictionaryConstant.IMPORT_STATUS_NO);
			logAddVO.setSuccessNum(0);
			logAddVO.setFailNum(importVOs.size());
			logAddVO.setFailReason(e.getMessage());
			// 为了避免导入失败时导入日志的保存事务也被回滚,所以采用消息队列异步保存导入失败的日志
			amqpTemplate.convertAndSend(RabbitMQConstant.BRANCH_IMPORT_LOG, logAddVO);
			e.printStackTrace();
			throw new ParameterException(e.getMessage());
		}
	}

	// 仓库异步保存导入失败日志
	@RabbitListener(queues = RabbitMQConstant.BRANCH_IMPORT_LOG)
	@Transactional(rollbackFor = Exception.class)
	public void saveFailImportLog(ImportLogAddVO logAddVO) {
		try {
			importLogService.addImportLogData(logAddVO);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仓库导入过程(新)
	 *
	 * @param file
	 * @param
	 * @param
	 * @return
	 * @throws Exception
	 */
	public int batchInsertProcess(MultipartFile file, String importBatchNumber, UserEntity user) {
		Date date = new Date();
		Properties properties = new Properties();
		// 待转换的对象
		Class<BranchImportStdVO> importVOClass = BranchImportStdVO.class;
		// 标准模板查询
		List<StandardTemplateDetailsListDTO> standardTemplateDetailsListDTOs = sysImportTemplethService.listStandardTemplateDetailsData(DataDictionaryConstant.BRANCH_IMPORT);
		for (StandardTemplateDetailsListDTO standardTemplateDetailsListDTO : standardTemplateDetailsListDTOs) {
			// 属性字段和注解属性字段值 键值对
			properties.setProperty(standardTemplateDetailsListDTO.getStdColNo(), standardTemplateDetailsListDTO.getCustColName());
		}
		// @ExcelProperty注解属性修改
		ImportUtils.setHeaderValue(properties, importVOClass);
		// EXCEL转对象
		List<BranchImportStdVO> importVOs = null;
		try {
			importVOs = ExcelUtils.read(file, importVOClass);
		} catch (Exception e) {
			e.printStackTrace();

			throw new ParameterException("EXCEL转对象失败:" + e.getMessage());
		}

		ToolKits.isParamNull(importVOs, "EXCEL文件内容为空,请重新导入");
		log.info("仓库导入详情:{}", JsonMapper.toJson(importVOs));

		int i = 1;
		for (BranchImportStdVO importVO : importVOs) {
			if (ToolKits.isEmpty(importVO.getCode())) {
				throw new PrologException("第" + i + "行导入数据,仓库编码不能为空");
			}
			if (ToolKits.isEmpty(importVO.getName())) {
				throw new PrologException("第" + i + "行导入数据,仓库名称不能为空");
			}
			if (ToolKits.isEmpty(importVO.getDepartmentName())) {
				throw new PrologException("第" + i + "行导入数据,部门名称不能为空");
			}
			i++;
		}
		// 验证导入文件中仓库编号是否重复
		Map<String, Long> codeMap = importVOs.stream().collect(Collectors.groupingBy(BranchImportStdVO::getCode, Collectors.counting()));
		for (Map.Entry<String, Long> longEntry : codeMap.entrySet()) {
			if (longEntry.getValue() > 1) {
				throw new ParameterException(String.format("导入文件中，仓库编号[%s]重复", longEntry.getKey()));
			}
		}
		// 验证导入文件中仓库名称是否重复
		Map<String, Long> nameMap = importVOs.stream().collect(Collectors.groupingBy(BranchImportStdVO::getName, Collectors.counting()));
		for (Map.Entry<String, Long> longEntry : nameMap.entrySet()) {
			if (longEntry.getValue() > 1) {
				throw new ParameterException(String.format("导入文件中，仓库名称[%s]重复", longEntry.getKey()));
			}
		}

		i = 0;
		for (BranchImportStdVO importVO : importVOs) {
			// 仓库对象
			TmsBaseBranchModel tmsBaseBranchModel = new TmsBaseBranchModel();
			BeanUtils.copyProperties(importVO, tmsBaseBranchModel);

			List<Organization> data1 = Lists.newArrayList();
			if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
				// 自有账号
				// 所属部门名称判定是否存在
				String[] departments = importVO.getDepartmentName().split(",");
				List<String> deptIds = Lists.newArrayList();
				List<String> deptCodes = Lists.newArrayList();
				// STD-DEVELOP20220823 lhb JC-HZ-001 仓库支持多部门 20220908 start
				for (String dept : departments) {
					RestMessage<List<Organization>> departMents = userTmsResource.search(null, dept, null, String.valueOf(user.getEnterpriseId()));
					if (!departMents.isSuccess()) {
						throw new RuntimeException("用户部门信息查询失败");
					} else {
						data1 = departMents.getData();
						if (data1.size() == 0) {
							throw new RuntimeException("部门【" + dept + "】不存在!");
						}
						if (!user.getDepts().contains(data1.get(0).getId())) {
							throw new RuntimeException("部门【" + dept + "】不存在，请先维护部门!");
						}
						deptIds.add(data1.get(0).getId());
						deptCodes.add(data1.get(0).getCode());
					}
				}
				tmsBaseBranchModel.setDepartmentId(deptIds.stream().collect(Collectors.joining(",")));
				tmsBaseBranchModel.setDepartmentCode(deptCodes.stream().collect(Collectors.joining(",")));
				tmsBaseBranchModel.setDepartmentName(importVO.getDepartmentName());
				// STD-DEVELOP20220823 lhb JC-HZ-001 仓库支持多部门 20220908 end
			} else {
				throw new PrologException("非自有账号不能进行仓库导入操作");
			}

			if (ToolKits.isNotEmpty(importVO.getPhoneNumber()) && !Validator.isMobile(importVO.getPhoneNumber())) {
				throw new ParameterException(String.format("%s手机号不符合规范", importVO.getPhoneNumber()));
			}

			if (ToolKits.isNotEmpty(importVO.getEmail()) && !Validator.isEmail(importVO.getEmail())) {
				throw new ParameterException(String.format("%邮箱不符合规范", importVO.getEmail()));
			}

			if (ToolKits.isNotEmpty(importVO.getPostCode()) && !Validator.isZipCode(importVO.getPostCode())) {
				throw new ParameterException(String.format("%邮编不符合规范", importVO.getPostCode()));
			}

			if (ToolKits.isNotEmpty(importVO.getLandlineNumber())) {
				Matcher matcher = null;
				Pattern p1 = Pattern.compile("^[0][1-9]{2,3}-[0-9]{5,10}$"); // 验证带区号的
				Pattern p2 = Pattern.compile("^[1-9]{1}[0-9]{5,8}$"); // 验证没有区号的
				if (importVO.getLandlineNumber().length() > 9) {
					matcher = p1.matcher(importVO.getLandlineNumber());
					if (!matcher.matches()) {
						throw new ParameterException("座机号不符合规范");
					}
				} else {
					matcher = p2.matcher(importVO.getLandlineNumber());
					if (!matcher.matches()) {
						throw new ParameterException("座机号不符合规范");
					}
				}
			}
			Map<String, Object> map = Maps.newHashMap();
			map.put("code", importVO.getCode());
			map.put("enterpriseId", user.getEnterpriseId());
			map.put("status", StatusConstant.STATUS_ENABLE);

			Map<String, Object> map2 = Maps.newHashMap();
			map2.put("name", importVO.getName());
			map2.put("enterpriseId", user.getEnterpriseId());
			map2.put("status", StatusConstant.STATUS_ENABLE);

			// 判断仓库编码 仓库名称 是否已存在
			PublicMethods.doesItExistByMap(tmsBaseBranchMapper, map, TmsBaseBranchModel.class, "仓库编码[" + importVO.getCode() + "]已存在");
			PublicMethods.doesItExistByMap(tmsBaseBranchMapper, map2, TmsBaseBranchModel.class, "仓库名称[" + importVO.getName() + "]已存在");
			// 判断仓库编码 仓库名称 是否已停用
			map.put("status", StatusConstant.STATUS_DISABLE);
			map2.put("status", StatusConstant.STATUS_DISABLE);
			PublicMethods.doesItExistByMap(tmsBaseBranchMapper, map, TmsBaseBranchModel.class, "仓库编码[" + importVO.getCode() + "]已停用,请直接启用");
			PublicMethods.doesItExistByMap(tmsBaseBranchMapper, map2, TmsBaseBranchModel.class, "仓库名称[" + importVO.getName() + "]已停用,请直接启用");

			// 仓库ID
			String branchId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_ID, "L");
			ToolKits.isParamNull(branchId, "仓库ID生成失败");

			// 判断省市区
			if (ToolKits.isNotEmpty(importVO.getProvinceName())) {
				List<LmsTmsZoneModel> lmsTmsZoneModels = lmsTmsZoneMapper.getZoneListByZname(importVO.getProvinceName(), "2", null);

				if (ToolKits.isEmpty(lmsTmsZoneModels)) {
					throw new ParameterException("省名称[" + importVO.getProvinceName() + "]错误");
				}

				tmsBaseBranchModel.setProvince(lmsTmsZoneModels.get(0).getZoneid());
			}
			if (ToolKits.isNotEmpty(importVO.getCityName())) {
				List<LmsTmsZoneModel> lmsTmsZoneModels = lmsTmsZoneMapper.getZoneListByZname(importVO.getCityName(), "3", importVO.getProvinceName());

				if (ToolKits.isEmpty(lmsTmsZoneModels)) {
					throw new ParameterException("市名称[" + importVO.getCityName() + "]错误");
				}

				tmsBaseBranchModel.setCity(lmsTmsZoneModels.get(0).getZoneid());
			}
			if (ToolKits.isNotEmpty(importVO.getDistrictName())) {
				List<LmsTmsZoneModel> lmsTmsZoneModels = lmsTmsZoneMapper.getZoneListByZname(importVO.getDistrictName(), "4", importVO.getCityName());

				if (ToolKits.isEmpty(lmsTmsZoneModels)) {
					throw new ParameterException("区名称[" + importVO.getDistrictName() + "]错误");
				}

				tmsBaseBranchModel.setDistrict(lmsTmsZoneModels.get(0).getZoneid());
			}

			// 仓库对象
			tmsBaseBranchModel.setId(Long.valueOf(branchId));
			tmsBaseBranchModel.setStatus(StatusConstant.STATUS_ENABLE);
			tmsBaseBranchModel.setSource(DataDictionaryConstant.SOURCE_EXCEL);
			tmsBaseBranchModel.setImportBatchNumber(importBatchNumber);
			tmsBaseBranchModel.setEnterpriseId(user.getEnterpriseId());
			tmsBaseBranchModel.setEnterpriseName(user.getEnterpriseName());
			tmsBaseBranchModel.setCreateperson(user.getNickname());
			tmsBaseBranchModel.setCreatetime(date);
			tmsBaseBranchModel.setUpdateperson(user.getNickname());
			tmsBaseBranchModel.setUpdatetime(date);

			if (ToolKits.isNotEmpty(importVO.getPickUpSign())) {
				tmsBaseBranchModel.setPickUpSign(Integer.parseInt(importVO.getPickUpSign()));
			}

			if (ToolKits.isNotEmpty(importVO.getAutoPickUpSign())) {
				tmsBaseBranchModel.setAutoPickUpSign(Integer.parseInt(importVO.getAutoPickUpSign()));
			}

			if (ToolKits.isNotEmpty(importVO.getPickUpPicture())) {
				tmsBaseBranchModel.setPickUpPicture(Integer.parseInt(importVO.getPickUpPicture()));
			}

			if (ToolKits.isNotEmpty(importVO.getDeliverySign())) {
				tmsBaseBranchModel.setDeliverySign(Integer.parseInt(importVO.getDeliverySign()));
			}

			if (ToolKits.isNotEmpty(importVO.getAutoDeliverySign())) {
				tmsBaseBranchModel.setAutoDeliverySign(Integer.parseInt(importVO.getAutoDeliverySign()));
			}

			if (ToolKits.isNotEmpty(importVO.getDeliveryPicture())) {
				tmsBaseBranchModel.setDeliveryPicture(Integer.parseInt(importVO.getDeliveryPicture()));
			}

			if (ToolKits.isNotEmpty(importVO.getReturnOrderPicture())) {
				tmsBaseBranchModel.setReturnOrderPicture(Integer.parseInt(importVO.getReturnOrderPicture()));
			}
			if (ToolKits.isNotEmpty(importVO.getPickUpSignTime())) {
				tmsBaseBranchModel.setPickUpSignTime(Integer.valueOf(importVO.getPickUpSignTime()));
			}
			if (ToolKits.isNotEmpty(importVO.getPickUpSignTimeUnit())) {
				tmsBaseBranchModel.setPickUpSignTimeUnit(Integer.valueOf(importVO.getPickUpSignTimeUnit()));
			}
			if (ToolKits.isNotEmpty(importVO.getDeliverySignTime())) {
				tmsBaseBranchModel.setDeliverySignTime(Integer.valueOf(importVO.getDeliverySignTime()));
			}
			if (ToolKits.isNotEmpty(importVO.getDeliverySignTimeUnit())) {
				tmsBaseBranchModel.setDeliverySignTimeUnit(Integer.valueOf(importVO.getDeliverySignTimeUnit()));
			}
			tmsBaseBranchMapper.save(tmsBaseBranchModel);
			i++;
		}
		return i;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchImportCarportData(MultipartFile file, String importBatchNumber) throws Exception {
		// 人员权限
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");
		// 导入文件判断
		FileUtils.multipartFileJudge(file);
		// 导入日志对象
		ImportLogAddVO logAddVO = new ImportLogAddVO();
		logAddVO.setImportObjNo(DataDictionaryConstant.BRANCH_PARKING_SPACE_IMPORT);
		logAddVO.setImportBatchNumber(importBatchNumber);
		// 导入统计
		int count = 0;
		try {
			// 导入执行
			count = this.batchInsertCarportProcess(file, importBatchNumber, user);
			logAddVO.setStatus(DataDictionaryConstant.IMPORT_STATUS_YES);
			logAddVO.setSuccessNum(count);
			logAddVO.setFailNum(0);
			importLogService.addImportLogData(logAddVO);
		} catch (Exception e) {
			Class<BranchImportStdVO> importVOClass = BranchImportStdVO.class;
			List<BranchImportStdVO> importVOs = ExcelUtils.read(file, importVOClass);

			logAddVO.setStatus(DataDictionaryConstant.IMPORT_STATUS_NO);
			logAddVO.setSuccessNum(0);
			logAddVO.setFailNum(importVOs.size());
			logAddVO.setFailReason(e.getMessage());
			// 为了避免导入失败时导入日志的保存事务也被回滚,所以采用消息队列异步保存导入失败的日志
			amqpTemplate.convertAndSend(RabbitMQConstant.BRANCH_CARPORT_IMPORT_LOG, logAddVO);
			e.printStackTrace();
			throw new ParameterException(e.getMessage());
		}
	}

	// 仓库车位异步保存导入失败日志
	@RabbitListener(queues = RabbitMQConstant.BRANCH_CARPORT_IMPORT_LOG)
	@Transactional(rollbackFor = Exception.class)
	public void saveFailImportLog2(ImportLogAddVO logAddVO) {
		try {
			importLogService.addImportLogData(logAddVO);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仓库车位导入过程(新)
	 *
	 * @param file
	 * @param
	 * @param
	 * @return
	 * @throws Exception
	 */
	public int batchInsertCarportProcess(MultipartFile file, String importBatchNumber, UserEntity plgFxUser) {
		Date date = new Date();
		Properties properties = new Properties();
		// 待转换的对象
		Class<CarportImportStdVO> importVOClass = CarportImportStdVO.class;

		// 标准模板查询
		List<StandardTemplateDetailsListDTO> standardTemplateDetailsListDTOs = sysImportTemplethService.listStandardTemplateDetailsData(DataDictionaryConstant.BRANCH_PARKING_SPACE_IMPORT);
		for (StandardTemplateDetailsListDTO standardTemplateDetailsListDTO : standardTemplateDetailsListDTOs) {
			// 属性字段和注解属性字段值 键值对
			properties.setProperty(standardTemplateDetailsListDTO.getStdColNo(), standardTemplateDetailsListDTO.getCustColName());
		}
		// @ExcelProperty注解属性修改
		ImportUtils.setHeaderValue(properties, importVOClass);

		// EXCEL转对象
		List<CarportImportStdVO> importVOs = null;
		try {
			importVOs = ExcelUtils.read(file, importVOClass);
		} catch (Exception e) {
			e.printStackTrace();

			throw new ParameterException("EXCEL转对象失败:" + e.getMessage());
		}

		ToolKits.isParamNull(importVOs, "EXCEL文件内容为空,请重新导入");
		log.info("仓库车位导入详情:{}", JsonMapper.toJson(importVOs));

		int i = 1;
		for (CarportImportStdVO importVO : importVOs) {
			if (ToolKits.isEmpty(importVO.getBranchCode())) {
				throw new PrologException("第" + i + "行导入数据,仓库编码不能为空");
			}
			if (ToolKits.isEmpty(importVO.getBranchName())) {
				throw new PrologException("第" + i + "行导入数据,仓库名称不能为空");
			}
			if (ToolKits.isEmpty(importVO.getCode())) {
				throw new PrologException("第" + i + "行导入数据,车位编码不能为空");
			}
			if (ToolKits.isEmpty(importVO.getName())) {
				throw new PrologException("第" + i + "行导入数据,车位名称不能为空");
			}
			if (ToolKits.isEmpty(importVO.getTypeName())) {
				throw new PrologException("第" + i + "行导入数据,类型不能为空");
			}
			i++;
		}
		// 验证导入文件中仓库车位编号是否重复
		Map<String, Long> codeMap = importVOs.stream().collect(Collectors.groupingBy(CarportImportStdVO::getCode, Collectors.counting()));
		for (Map.Entry<String, Long> longEntry : codeMap.entrySet()) {
			if (longEntry.getValue() > 1) {
				throw new ParameterException(String.format("导入文件中，仓库车位编号[%s]重复", longEntry.getKey()));
			}
		}
		// 验证导入文件中仓库车位名称是否重复
		Map<String, Long> nameMap = importVOs.stream().collect(Collectors.groupingBy(CarportImportStdVO::getName, Collectors.counting()));
		for (Map.Entry<String, Long> longEntry : nameMap.entrySet()) {
			if (longEntry.getValue() > 1) {
				throw new ParameterException(String.format("导入文件中，仓库车位名称[%s]重复", longEntry.getKey()));
			}
		}

		i = 0;
		for (CarportImportStdVO vo : importVOs) {
			// 仓库车位对象
			TmsBaseCarportModel tmsBaseCarportModel = new TmsBaseCarportModel();
			BeanUtils.copyProperties(vo, tmsBaseCarportModel);

			Map<String, Object> map = Maps.newHashMap();
			map.put("code", vo.getCode());
			map.put("enterpriseId", plgFxUser.getEnterpriseId());
			map.put("status", StatusConstant.STATUS_ENABLE);

			Map<String, Object> map2 = Maps.newHashMap();
			map2.put("name", vo.getName());
			map2.put("enterpriseId", plgFxUser.getEnterpriseId());
			map2.put("status", StatusConstant.STATUS_ENABLE);

			// 判断车位编码 车位名称 是否已存在
			PublicMethods.doesItExistByMap(tmsBaseCarportMapper, map, TmsBaseCarportModel.class, "车位编码[" + vo.getCode() + "]已存在");
			PublicMethods.doesItExistByMap(tmsBaseCarportMapper, map2, TmsBaseCarportModel.class, "车位名称[" + vo.getName() + "]已存在");

			// 判断车位编码 车位名称 是否已停用
			map.put("status", StatusConstant.STATUS_DISABLE);
			map2.put("status", StatusConstant.STATUS_DISABLE);
			PublicMethods.doesItExistByMap(tmsBaseCarportMapper, map, TmsBaseCarportModel.class, "车位编码[" + vo.getCode() + "]已停用,请直接启用");
			PublicMethods.doesItExistByMap(tmsBaseCarportMapper, map2, TmsBaseCarportModel.class, "车位名称[" + vo.getName() + "]已停用,请直接启用");

			// 校验仓库编码和仓库名称是否匹配
			Criteria branchCriteria = Criteria.forClass(TmsBaseBranchModel.class);
			Restriction branchR1 = Restrictions.eq("code", vo.getBranchCode());
			Restriction branchR2 = Restrictions.eq("name", vo.getBranchName());
			Restriction branchR3 = Restrictions.eq("enterpriseId", plgFxUser.getEnterpriseId());
			branchCriteria.setRestriction(Restrictions.and(branchR1, branchR2, branchR3));
			List<TmsBaseBranchModel> tmsBaseBranchModels = tmsBaseBranchMapper.findByCriteria(branchCriteria);

			if (ToolKits.isEmpty(tmsBaseBranchModels)) {
				throw new ParameterException("仓库编码[" + vo.getBranchCode() + "]与仓库名称[" + vo.getBranchName() + "]不匹配，或者仓库不存在");
			}

			tmsBaseCarportModel.setType(Integer.parseInt(vo.getTypeName()));
			if (ToolKits.isNotEmpty(vo.getCarType())) {
				Criteria typeCriteria = Criteria.forClass(TmsBaseVehicleTypeModel.class);
				Restriction typeR1 = Restrictions.eq("name", vo.getCarType());
				Restriction typeR2 = Restrictions.eq("enterpriseId", plgFxUser.getEnterpriseId());
				typeCriteria.setRestriction(Restrictions.and(typeR1, typeR2));
				List<TmsBaseVehicleTypeModel> tmsBaseVehicleTypeModels = tmsBaseVehicleTypeMapper.findByCriteria(typeCriteria);
				if (ToolKits.isEmpty(tmsBaseVehicleTypeModels)) {
					throw new ParameterException("适用车型[" + vo.getCarType() + "]不存在，请先维护车型");
				}
			}
			// 仓库车位ID
			String carportId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_CARPORT_ID, "L");
			ToolKits.isParamNull(carportId, "仓库车位ID生成失败");

			// 仓库车位对象
			tmsBaseCarportModel.setId(Long.valueOf(carportId));
			tmsBaseCarportModel.setStatus(StatusConstant.STATUS_ENABLE);
			tmsBaseCarportModel.setDatasource(DataDictionaryConstant.SOURCE_EXCEL);
			tmsBaseCarportModel.setImportBatchNumber(importBatchNumber);
			tmsBaseCarportModel.setEnterpriseId(plgFxUser.getEnterpriseId());
			tmsBaseCarportModel.setEnterpriseName(plgFxUser.getEnterpriseName());
			tmsBaseCarportModel.setCreateperson(plgFxUser.getNickname());
			tmsBaseCarportModel.setCreatetime(date);
			tmsBaseCarportModel.setUpdateperson(plgFxUser.getNickname());
			tmsBaseCarportModel.setUpdatetime(date);
			tmsBaseCarportModel.setBranchid(tmsBaseBranchModels.get(0).getId());
			tmsBaseCarportMapper.save(tmsBaseCarportModel);
			i++;
		}
		return i;
	}

	/**
	 * 查询仓库可预约时间段
	 */
	@Override
	public List<TmsBaseBranchApTimeDTO> queryAppointTime(AppointTimeQueryVO vo) throws Exception {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		Criteria criteria = Criteria.forClass(TmsBaseBranchApTimeModel.class);
		Restriction r1 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, vo.getBranchId());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseBranchApTimeModel> list = tmsBaseBranchApTimeMapper.findByCriteria(criteria);
		List<TmsBaseBranchApTimeDTO> dtos = Lists.newArrayList();
		for (TmsBaseBranchApTimeModel model : list) {
			TmsBaseBranchApTimeDTO dto = new TmsBaseBranchApTimeDTO();
			BeanUtils.copyProperties(model, dto);
			dtos.add(dto);
		}
		return dtos;
	}

	/**
	 * 查询仓库可预约时间段(拼接)
	 *
	 * @param vo
	 * @return
	 */
	@Override
	public List<AppointTimeQueryDTO> queryBranchTime(AppointTimeQueryVO vo) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		Criteria criteria = Criteria.forClass(TmsBaseBranchApTimeModel.class);
		Restriction r1 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, vo.getBranchId());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseBranchApTimeModel> tmsBaseBranchApTimeModels = tmsBaseBranchApTimeMapper.findByCriteria(criteria);
		List<AppointTimeQueryDTO> list = Lists.newArrayList();
		for (TmsBaseBranchApTimeModel model : tmsBaseBranchApTimeModels) {
			AppointTimeQueryDTO dto = new AppointTimeQueryDTO();
			dto.setValue(model.getStartTime() + "-" + model.getEndTime());
			dto.setLabel(model.getStartTime() + "-" + model.getEndTime());
			list.add(dto);
		}
		return list;
	}

	/**
	 * 通过仓库ID查询仓库
	 *
	 * @param
	 * @return
	 */
	@Override
	public TmsBaseBranchDTO getOneBranch(Long branchId) {
		ToolKits.isParamNull(branchId, "仓ID不为空");

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

		TmsBaseBranchModel model = tmsBaseBranchMapper.findById(branchId, TmsBaseBranchModel.class);
		if (ToolKits.isNotEmpty(model)) {
			TmsBaseBranchDTO tmsBaseBranchDTO = new TmsBaseBranchDTO();
			BeanUtils.copyProperties(model, tmsBaseBranchDTO);

			// 查询仓库的可预约时间段
			Criteria criteria = Criteria.forClass(TmsBaseBranchApTimeModel.class);
			Restriction r1 = Restrictions.eq(TmsBaseBranchApTimeModel::getBranchId, model.getId());
			Restriction r2 = Restrictions.eq(TmsBaseBranchApTimeModel::getEnterpriseId, user.getEnterpriseId());
			criteria.setRestriction(Restrictions.and(r1, r2));
			List<TmsBaseBranchApTimeModel> tmsBaseBranchApTimeModels = tmsBaseBranchApTimeMapper.findByCriteria(criteria);

			List<TmsBaseBranchApTimeDTO> tmsBaseBranchApTimeDTOs = new ArrayList<TmsBaseBranchApTimeDTO>();
			for (TmsBaseBranchApTimeModel tmsBaseBranchApTimeModel : tmsBaseBranchApTimeModels) {
				TmsBaseBranchApTimeDTO tmsBaseBranchApTimeDTO = new TmsBaseBranchApTimeDTO();
				tmsBaseBranchApTimeDTO.setId(tmsBaseBranchApTimeModel.getId());
				tmsBaseBranchApTimeDTO.setBranchId(branchId);
				tmsBaseBranchApTimeDTO.setStartTime(tmsBaseBranchApTimeModel.getStartTime());
				tmsBaseBranchApTimeDTO.setEndTime(tmsBaseBranchApTimeModel.getEndTime());

				tmsBaseBranchApTimeDTOs.add(tmsBaseBranchApTimeDTO);
			}
			tmsBaseBranchDTO.setApTimeDTOList(tmsBaseBranchApTimeDTOs);

			return tmsBaseBranchDTO;
		} else {
			return null;
		}
	}

	/**
	 * 运单导入时匹配仓资料
	 */
	@Override
	public ImportMatchingDataDTO importMatchingData(ImportMatchingDataVO importMatchingDataVO) {
		UserEntity user = importMatchingDataVO.getUser();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		Criteria criteria = Criteria.forClass(TmsBaseBranchModel.class);
		Restriction r1 = ToolKits.isEmpty(importMatchingDataVO.getUnitCode()) ? null : Restrictions.eq(TmsBaseBranchModel::getCode, importMatchingDataVO.getUnitCode());
		Restriction r2 = Restrictions.eq(TmsBaseBranchModel::getName, importMatchingDataVO.getUnitName());
		Restriction r3 = Restrictions.eq(TmsBaseBranchModel::getEnterpriseId, user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3));
		List<TmsBaseBranchModel> baseBranchModels = tmsBaseBranchMapper.findByCriteria(criteria);
		if (baseBranchModels.size() > 0) {
			Assert.isTrue(baseBranchModels.size() <= 1, "仓资料【" + importMatchingDataVO.getUnitName() + "】维护重复");

			ImportMatchingDataDTO importMatchingDataDTO = new ImportMatchingDataDTO();
			importMatchingDataDTO.setShipperUnitId(baseBranchModels.get(0).getId());
			importMatchingDataDTO.setShipperUnitCode(baseBranchModels.get(0).getCode());
			importMatchingDataDTO.setShipperUnitName(baseBranchModels.get(0).getName());
			importMatchingDataDTO.setShipperId(baseBranchModels.get(0).getId());
			importMatchingDataDTO.setShipperCode(baseBranchModels.get(0).getCode());
			importMatchingDataDTO.setShipperName(baseBranchModels.get(0).getName());
			importMatchingDataDTO.setShipperContact(baseBranchModels.get(0).getContact());
			importMatchingDataDTO.setShipperPhoneNumber(baseBranchModels.get(0).getPhoneNumber());
			importMatchingDataDTO.setShipperLandlineNumber(baseBranchModels.get(0).getLandlineNumber());
			importMatchingDataDTO.setShipperEmail(baseBranchModels.get(0).getEmail());
			importMatchingDataDTO.setShipperRelatedPhoneNumber(null);
			importMatchingDataDTO.setShipperProvince(baseBranchModels.get(0).getProvince());
			importMatchingDataDTO.setShipperProvinceName(baseBranchModels.get(0).getProvinceName());
			importMatchingDataDTO.setShipperCity(baseBranchModels.get(0).getCity());
			importMatchingDataDTO.setShipperCityName(baseBranchModels.get(0).getCityName());
			importMatchingDataDTO.setShipperDistrict(baseBranchModels.get(0).getDistrict());
			importMatchingDataDTO.setShipperDistrictName(baseBranchModels.get(0).getDistrictName());
			importMatchingDataDTO.setShipperAddress(baseBranchModels.get(0).getAddress());
			importMatchingDataDTO.setShipperLongitude(baseBranchModels.get(0).getLongitude());
			importMatchingDataDTO.setShipperLatitude(baseBranchModels.get(0).getLatitude());
			importMatchingDataDTO.setShipperMemo(baseBranchModels.get(0).getMemo());
			importMatchingDataDTO.setShipperPickUpSign(baseBranchModels.get(0).getPickUpSign());
			importMatchingDataDTO.setShipperAutoPickUpSign(baseBranchModels.get(0).getAutoPickUpSign());
			importMatchingDataDTO.setShipperPickUpPicture(baseBranchModels.get(0).getPickUpPicture());
			importMatchingDataDTO.setShipperPickUpRail(baseBranchModels.get(0).getDefaultPickUpRail());

			importMatchingDataDTO.setConsigneeUnitId(baseBranchModels.get(0).getId());
			importMatchingDataDTO.setConsigneeUnitCode(baseBranchModels.get(0).getCode());
			importMatchingDataDTO.setConsigneeUnitName(baseBranchModels.get(0).getName());
			importMatchingDataDTO.setConsigneeId(baseBranchModels.get(0).getId());
			importMatchingDataDTO.setConsigneeCode(baseBranchModels.get(0).getCode());
			importMatchingDataDTO.setConsigneeName(baseBranchModels.get(0).getName());
			importMatchingDataDTO.setConsigneeContact(baseBranchModels.get(0).getContact());
			importMatchingDataDTO.setConsigneePhoneNumber(baseBranchModels.get(0).getPhoneNumber());
			importMatchingDataDTO.setConsigneeLandlineNumber(baseBranchModels.get(0).getLandlineNumber());
			importMatchingDataDTO.setConsigneeEmail(baseBranchModels.get(0).getEmail());
			importMatchingDataDTO.setConsigneeRelatedPhoneNumber(null);
			importMatchingDataDTO.setConsigneeProvince(baseBranchModels.get(0).getProvince());
			importMatchingDataDTO.setConsigneeProvinceName(baseBranchModels.get(0).getProvinceName());
			importMatchingDataDTO.setConsigneeCity(baseBranchModels.get(0).getCity());
			importMatchingDataDTO.setConsigneeCityName(baseBranchModels.get(0).getCityName());
			importMatchingDataDTO.setConsigneeDistrict(baseBranchModels.get(0).getDistrict());
			importMatchingDataDTO.setConsigneeDistrictName(baseBranchModels.get(0).getDistrictName());
			importMatchingDataDTO.setConsigneeAddress(baseBranchModels.get(0).getAddress());
			importMatchingDataDTO.setConsigneeLongitude(baseBranchModels.get(0).getLongitude());
			importMatchingDataDTO.setConsigneeLatitude(baseBranchModels.get(0).getLatitude());
			importMatchingDataDTO.setConsigneeMemo(baseBranchModels.get(0).getMemo());
			importMatchingDataDTO.setConsigneeDeliverySign(baseBranchModels.get(0).getDeliverySign());
			importMatchingDataDTO.setConsigneeAutoDeliverySign(baseBranchModels.get(0).getAutoDeliverySign());
			importMatchingDataDTO.setConsigneeDeliveryPicture(baseBranchModels.get(0).getDeliveryPicture());
			importMatchingDataDTO.setConsigneeDeliveryRail(baseBranchModels.get(0).getDefaultDeliveryRail());
			importMatchingDataDTO.setReturnOrderFlag(StatusConstant.WHETHER_NO);
			importMatchingDataDTO.setReturnOrderDeadline(null);
			importMatchingDataDTO.setConsigneeReturnOrderPicture(baseBranchModels.get(0).getReturnOrderPicture());

			importMatchingDataDTO.setShipperSignTime(baseBranchModels.get(0).getPickUpSignTime());
			importMatchingDataDTO.setShipperSignTimeDura(baseBranchModels.get(0).getPickUpSignTimeDura());
			importMatchingDataDTO.setShipperSignTimeUnit(baseBranchModels.get(0).getPickUpSignTimeUnit());

			importMatchingDataDTO.setConsigneeSignTime(baseBranchModels.get(0).getDeliverySignTime());
			importMatchingDataDTO.setConsigneeSignTimeDura(baseBranchModels.get(0).getDeliverySignTimeDura());
			importMatchingDataDTO.setConsigneeSignTimeUnit(baseBranchModels.get(0).getDeliverySignTimeUnit());

			importMatchingDataDTO.setStationId(baseBranchModels.get(0).getStationId());
			importMatchingDataDTO.setStationCode(baseBranchModels.get(0).getStationCode());
			importMatchingDataDTO.setStationName(baseBranchModels.get(0).getStationName());
			importMatchingDataDTO.setStationAreas(baseBranchModels.get(0).getStationAreas());
			importMatchingDataDTO.setStationDeliveryOrder(baseBranchModels.get(0).getStationDeliveryOrder());

			return importMatchingDataDTO;
		} else {
			Assert.isTrue(importMatchingDataVO.isNoSave(), "仓资料【" + importMatchingDataVO.getUnitName() + "】未维护");

			String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.TMS_BASE_BRANCH_ID, "L");
			if (ToolKits.isEmpty(id)) {
				throw new RuntimeException("仓库id获取失败");
			}

			// 不存在则新增
			TmsBaseBranchModel tmsBaseBranchModel = new TmsBaseBranchModel();
			tmsBaseBranchModel.setId(Long.valueOf(id));
			if (ToolKits.isNotEmpty(importMatchingDataVO.getShipperUnitName())) {
				tmsBaseBranchModel.setCode(ToolKits.isEmpty(importMatchingDataVO.getShipperUnitCode()) ? "WMD-" + id : importMatchingDataVO.getShipperUnitCode());
				tmsBaseBranchModel.setName(importMatchingDataVO.getShipperUnitName());
				tmsBaseBranchModel.setShortName(importMatchingDataVO.getShipperUnitName());
				tmsBaseBranchModel.setContact(importMatchingDataVO.getShipperContact());
				tmsBaseBranchModel.setPhoneNumber(importMatchingDataVO.getShipperPhoneNumber());
				tmsBaseBranchModel.setLandlineNumber(importMatchingDataVO.getShipperLandlineNumber());
				tmsBaseBranchModel.setEmail(importMatchingDataVO.getShipperEmail());
				tmsBaseBranchModel.setPostCode(null);
				tmsBaseBranchModel.setProvince(importMatchingDataVO.getShipperProvince());
				tmsBaseBranchModel.setProvinceName(importMatchingDataVO.getShipperProvinceName());
				tmsBaseBranchModel.setCity(importMatchingDataVO.getShipperCity());
				tmsBaseBranchModel.setCityName(importMatchingDataVO.getShipperCityName());
				tmsBaseBranchModel.setDistrict(importMatchingDataVO.getShipperDistrict());
				tmsBaseBranchModel.setDistrictName(importMatchingDataVO.getShipperDistrictName());
				tmsBaseBranchModel.setAddress(importMatchingDataVO.getShipperAddress());
				tmsBaseBranchModel.setLongitude(importMatchingDataVO.getShipperLongitude());
				tmsBaseBranchModel.setLatitude(importMatchingDataVO.getShipperLatitude());
				tmsBaseBranchModel.setMemo(importMatchingDataVO.getShipperMemo());

				tmsBaseBranchModel.setPickUpSign(ToolKits.isEmpty(importMatchingDataVO.getShipperPickUpSign()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getShipperPickUpSign());
				tmsBaseBranchModel.setAutoPickUpSign(ToolKits.isEmpty(importMatchingDataVO.getShipperAutoPickUpSign()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getShipperAutoPickUpSign());
				tmsBaseBranchModel.setPickUpPicture(ToolKits.isEmpty(importMatchingDataVO.getShipperPickUpPicture()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getShipperPickUpPicture());
				tmsBaseBranchModel.setDefaultPickUpRail(importMatchingDataVO.getShipperPickUpRail());
				tmsBaseBranchModel.setDeliverySign(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setAutoDeliverySign(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setDeliveryPicture(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setReturnOrderPicture(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setDefaultDeliveryRail(null);

				tmsBaseBranchModel.setPickUpSignTime(importMatchingDataVO.getShipperSignTime());
				tmsBaseBranchModel.setPickUpSignTimeDura(importMatchingDataVO.getShipperSignTimeDura());
				tmsBaseBranchModel.setPickUpSignTimeUnit(importMatchingDataVO.getShipperSignTimeUnit());
				tmsBaseBranchModel.setDeliverySignTime(null);
				tmsBaseBranchModel.setDeliverySignTimeDura(null);
				tmsBaseBranchModel.setDeliverySignTimeUnit(null);
			} else {
				tmsBaseBranchModel.setCode(ToolKits.isEmpty(importMatchingDataVO.getConsigneeUnitCode()) ? "WMD-" + id : importMatchingDataVO.getConsigneeUnitCode());
				tmsBaseBranchModel.setName(importMatchingDataVO.getConsigneeUnitName());
				tmsBaseBranchModel.setShortName(importMatchingDataVO.getConsigneeUnitName());
				tmsBaseBranchModel.setContact(importMatchingDataVO.getConsigneeContact());
				tmsBaseBranchModel.setPhoneNumber(importMatchingDataVO.getConsigneePhoneNumber());
				tmsBaseBranchModel.setLandlineNumber(importMatchingDataVO.getConsigneeLandlineNumber());
				tmsBaseBranchModel.setEmail(importMatchingDataVO.getConsigneeEmail());
				tmsBaseBranchModel.setPostCode(null);
				tmsBaseBranchModel.setProvince(importMatchingDataVO.getConsigneeProvince());
				tmsBaseBranchModel.setProvinceName(importMatchingDataVO.getConsigneeProvinceName());
				tmsBaseBranchModel.setCity(importMatchingDataVO.getConsigneeCity());
				tmsBaseBranchModel.setCityName(importMatchingDataVO.getConsigneeCityName());
				tmsBaseBranchModel.setDistrict(importMatchingDataVO.getConsigneeDistrict());
				tmsBaseBranchModel.setDistrictName(importMatchingDataVO.getConsigneeDistrictName());
				tmsBaseBranchModel.setAddress(importMatchingDataVO.getConsigneeAddress());
				tmsBaseBranchModel.setLongitude(importMatchingDataVO.getConsigneeLongitude());
				tmsBaseBranchModel.setLatitude(importMatchingDataVO.getConsigneeLatitude());
				tmsBaseBranchModel.setMemo(importMatchingDataVO.getConsigneeMemo());

				tmsBaseBranchModel.setPickUpSign(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setAutoPickUpSign(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setPickUpPicture(StatusConstant.WHETHER_NO);
				tmsBaseBranchModel.setDefaultPickUpRail(null);
				tmsBaseBranchModel.setDeliverySign(ToolKits.isEmpty(importMatchingDataVO.getConsigneeDeliverySign()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getConsigneeDeliverySign());
				tmsBaseBranchModel.setAutoDeliverySign(ToolKits.isEmpty(importMatchingDataVO.getConsigneeAutoDeliverySign()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getConsigneeAutoDeliverySign());
				tmsBaseBranchModel.setDeliveryPicture(ToolKits.isEmpty(importMatchingDataVO.getConsigneeDeliveryPicture()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getConsigneeDeliveryPicture());
				tmsBaseBranchModel.setReturnOrderPicture(ToolKits.isEmpty(importMatchingDataVO.getConsigneeReturnOrderPicture()) ? StatusConstant.WHETHER_NO : importMatchingDataVO.getConsigneeReturnOrderPicture());
				tmsBaseBranchModel.setDefaultDeliveryRail(importMatchingDataVO.getConsigneeDeliveryRail());

				tmsBaseBranchModel.setPickUpSignTime(null);
				tmsBaseBranchModel.setPickUpSignTimeDura(null);
				tmsBaseBranchModel.setPickUpSignTimeUnit(null);
				tmsBaseBranchModel.setDeliverySignTime(importMatchingDataVO.getConsigneeSignTime());
				tmsBaseBranchModel.setDeliverySignTimeDura(importMatchingDataVO.getConsigneeSignTimeDura());
				tmsBaseBranchModel.setDeliverySignTimeUnit(importMatchingDataVO.getConsigneeSignTimeUnit());
			}

			tmsBaseBranchModel.setStatus(StatusConstant.STATUS_ENABLE);
			tmsBaseBranchModel.setSource(DataDictionaryConstant.SOURCE_EXCEL);
			tmsBaseBranchModel.setDepartmentId(importMatchingDataVO.getDepartmentId());
			tmsBaseBranchModel.setDepartmentCode(importMatchingDataVO.getDepartmentCode());
			tmsBaseBranchModel.setDepartmentName(importMatchingDataVO.getDepartmentName());
			tmsBaseBranchModel.setEnterpriseId(user.getEnterpriseId());
			tmsBaseBranchModel.setEnterpriseName(user.getEnterpriseName());
			tmsBaseBranchModel.setCreatetime(DateUtil.date());
			tmsBaseBranchModel.setCreateperson(user.getNickname());
			tmsBaseBranchModel.setUpdatetime(DateUtil.date());
			tmsBaseBranchModel.setUpdateperson(user.getNickname());
			tmsBaseBranchMapper.save(tmsBaseBranchModel);

			// 响应
			ImportMatchingDataDTO importMatchingDataDTO = new ImportMatchingDataDTO();
			importMatchingDataDTO.setShipperUnitId(tmsBaseBranchModel.getId());
			importMatchingDataDTO.setShipperUnitCode(tmsBaseBranchModel.getCode());
			importMatchingDataDTO.setShipperUnitName(tmsBaseBranchModel.getName());
			importMatchingDataDTO.setShipperId(tmsBaseBranchModel.getId());
			importMatchingDataDTO.setShipperCode(tmsBaseBranchModel.getCode());
			importMatchingDataDTO.setShipperName(tmsBaseBranchModel.getName());
			importMatchingDataDTO.setShipperContact(tmsBaseBranchModel.getContact());
			importMatchingDataDTO.setShipperPhoneNumber(tmsBaseBranchModel.getPhoneNumber());
			importMatchingDataDTO.setShipperLandlineNumber(tmsBaseBranchModel.getLandlineNumber());
			importMatchingDataDTO.setShipperEmail(tmsBaseBranchModel.getEmail());
			importMatchingDataDTO.setShipperRelatedPhoneNumber(null);
			importMatchingDataDTO.setShipperProvince(tmsBaseBranchModel.getProvince());
			importMatchingDataDTO.setShipperProvinceName(tmsBaseBranchModel.getProvinceName());
			importMatchingDataDTO.setShipperCity(tmsBaseBranchModel.getCity());
			importMatchingDataDTO.setShipperCityName(tmsBaseBranchModel.getCityName());
			importMatchingDataDTO.setShipperDistrict(tmsBaseBranchModel.getDistrict());
			importMatchingDataDTO.setShipperDistrictName(tmsBaseBranchModel.getDistrictName());
			importMatchingDataDTO.setShipperAddress(tmsBaseBranchModel.getAddress());
			importMatchingDataDTO.setShipperLongitude(tmsBaseBranchModel.getLongitude());
			importMatchingDataDTO.setShipperLatitude(tmsBaseBranchModel.getLatitude());
			importMatchingDataDTO.setShipperMemo(tmsBaseBranchModel.getMemo());
			importMatchingDataDTO.setShipperPickUpSign(tmsBaseBranchModel.getPickUpSign());
			importMatchingDataDTO.setShipperAutoPickUpSign(tmsBaseBranchModel.getAutoPickUpSign());
			importMatchingDataDTO.setShipperPickUpPicture(tmsBaseBranchModel.getPickUpPicture());
			importMatchingDataDTO.setShipperPickUpRail(tmsBaseBranchModel.getDefaultPickUpRail());

			importMatchingDataDTO.setConsigneeUnitId(tmsBaseBranchModel.getId());
			importMatchingDataDTO.setConsigneeUnitCode(tmsBaseBranchModel.getCode());
			importMatchingDataDTO.setConsigneeUnitName(tmsBaseBranchModel.getName());
			importMatchingDataDTO.setConsigneeId(tmsBaseBranchModel.getId());
			importMatchingDataDTO.setConsigneeCode(tmsBaseBranchModel.getCode());
			importMatchingDataDTO.setConsigneeName(tmsBaseBranchModel.getName());
			importMatchingDataDTO.setConsigneeContact(tmsBaseBranchModel.getContact());
			importMatchingDataDTO.setConsigneePhoneNumber(tmsBaseBranchModel.getPhoneNumber());
			importMatchingDataDTO.setConsigneeLandlineNumber(tmsBaseBranchModel.getLandlineNumber());
			importMatchingDataDTO.setConsigneeEmail(tmsBaseBranchModel.getEmail());
			importMatchingDataDTO.setConsigneeRelatedPhoneNumber(null);
			importMatchingDataDTO.setConsigneeProvince(tmsBaseBranchModel.getProvince());
			importMatchingDataDTO.setConsigneeProvinceName(tmsBaseBranchModel.getProvinceName());
			importMatchingDataDTO.setConsigneeCity(tmsBaseBranchModel.getCity());
			importMatchingDataDTO.setConsigneeCityName(tmsBaseBranchModel.getCityName());
			importMatchingDataDTO.setConsigneeDistrict(tmsBaseBranchModel.getDistrict());
			importMatchingDataDTO.setConsigneeDistrictName(tmsBaseBranchModel.getDistrictName());
			importMatchingDataDTO.setConsigneeAddress(tmsBaseBranchModel.getAddress());
			importMatchingDataDTO.setConsigneeLongitude(tmsBaseBranchModel.getLongitude());
			importMatchingDataDTO.setConsigneeLatitude(tmsBaseBranchModel.getLatitude());
			importMatchingDataDTO.setConsigneeMemo(tmsBaseBranchModel.getMemo());
			importMatchingDataDTO.setConsigneeDeliverySign(tmsBaseBranchModel.getDeliverySign());
			importMatchingDataDTO.setConsigneeAutoDeliverySign(tmsBaseBranchModel.getAutoDeliverySign());
			importMatchingDataDTO.setConsigneeDeliveryPicture(tmsBaseBranchModel.getDeliveryPicture());
			importMatchingDataDTO.setConsigneeDeliveryRail(tmsBaseBranchModel.getDefaultDeliveryRail());
			importMatchingDataDTO.setReturnOrderFlag(StatusConstant.WHETHER_NO);
			importMatchingDataDTO.setReturnOrderDeadline(null);
			importMatchingDataDTO.setConsigneeReturnOrderPicture(tmsBaseBranchModel.getReturnOrderPicture());

			importMatchingDataDTO.setShipperSignTime(tmsBaseBranchModel.getPickUpSignTime());
			importMatchingDataDTO.setShipperSignTimeDura(tmsBaseBranchModel.getPickUpSignTimeDura());
			importMatchingDataDTO.setShipperSignTimeUnit(tmsBaseBranchModel.getPickUpSignTimeUnit());

			importMatchingDataDTO.setConsigneeSignTime(tmsBaseBranchModel.getDeliverySignTime());
			importMatchingDataDTO.setConsigneeSignTimeDura(tmsBaseBranchModel.getDeliverySignTimeDura());
			importMatchingDataDTO.setConsigneeSignTimeUnit(tmsBaseBranchModel.getDeliverySignTimeUnit());

			importMatchingDataDTO.setStationId(tmsBaseBranchModel.getStationId());
			importMatchingDataDTO.setStationCode(tmsBaseBranchModel.getStationCode());
			importMatchingDataDTO.setStationName(tmsBaseBranchModel.getStationName());
			importMatchingDataDTO.setStationAreas(tmsBaseBranchModel.getStationAreas());
			importMatchingDataDTO.setStationDeliveryOrder(tmsBaseBranchModel.getStationDeliveryOrder());
			return importMatchingDataDTO;
		}
	}

	@Override
	public void updateBranchLatitudeAndLongitude(List<Long> idList, BigDecimal latitude, BigDecimal longitude) {
		List<TmsBaseBranchModel> tmsBaseBranchModelList = tmsBaseBranchMapper.findByIds(TmsBaseBranchModel.class, idList.toArray(), null);
		if (CollectionUtil.isNotEmpty(tmsBaseBranchModelList)) {
			UserEntity user = PlgFxUsrUtils.getUserEntity();
			tmsBaseBranchModelList.forEach(tmsBaseBranchMode -> {
				tmsBaseBranchMode.setUpdateperson(user.getNickname());
				tmsBaseBranchMode.setUpdatetime(new Date());
				tmsBaseBranchMode.setLongitude(longitude);
				tmsBaseBranchMode.setLatitude(latitude);
				tmsBaseBranchMapper.update(tmsBaseBranchMode);
			});
		}
	}

}
