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

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import cn.hutool.core.date.DatePattern;
import com.prolog.rdc.tms.model.ShipbillRouteDataModel;
import org.apache.ibatis.plugin.PluginException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.prolog.common.util.DateUtils;
import com.prolog.common.util.ToolKits;
import com.prolog.framework.authority.core.dto.UserDTO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.exception.BizException;
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.SeriaNnumberConstant;
import com.prolog.rdc.tms.constant.StatusConstant;
import com.prolog.rdc.tms.dao.mapper.TmsLoadingBillDetailMapper;
import com.prolog.rdc.tms.dao.mapper.TmsLoadingBillHeaderMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillContainerTempMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillDetailMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillDetailTempMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillHeaderMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillHeaderTempMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillPackageMapper;
import com.prolog.rdc.tms.dao.mapper.TmsShipbillTransportLogMapper;
import com.prolog.rdc.tms.dao.mapper.TmsVehicleGpsMapper;
import com.prolog.rdc.tms.model.constant.RedisConstant;
import com.prolog.rdc.tms.model.dto.ApprovalInfoDTO;
import com.prolog.rdc.tms.model.dto.ContainerTypeDTO;
import com.prolog.rdc.tms.model.dto.DeviceByOneDTO;
import com.prolog.rdc.tms.model.dto.ShipbillDetailViewDTO;
import com.prolog.rdc.tms.model.dto.ShipbillViewDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsExportShipbillDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsItemDetailDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsPackageDetailDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsPrintDetailDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsPrintHeadDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsQueryByShipbillDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsQueryTypeByReceiverDTO;
import com.prolog.rdc.tms.model.dto.WaitPickUpGoodsReceiverGetShipbillDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.SignconfigPopDTO;
import com.prolog.rdc.tms.model.dto.basicData.ApprovalLogDTO;
import com.prolog.rdc.tms.model.dto.basicData.ApprovalNodeSelDTO;
import com.prolog.rdc.tms.model.dto.basicData.ItemCheckDTO;
import com.prolog.rdc.tms.model.dto.fleetManagement.ContainerDTO;
import com.prolog.rdc.tms.model.dto.message.SendMessageDTO;
import com.prolog.rdc.tms.model.entity.SysParamConfigModel;
import com.prolog.rdc.tms.model.entity.SysRefdatadModel;
import com.prolog.rdc.tms.model.entity.TmsLoadingBillDetailModel;
import com.prolog.rdc.tms.model.entity.TmsLoadingBillHeaderModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillContainerTemp;
import com.prolog.rdc.tms.model.entity.TmsShipbillDetailModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillDetailTempModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillHeaderModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillHeaderTempModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillPackageModel;
import com.prolog.rdc.tms.model.entity.TmsShipbillTransLogModel;
import com.prolog.rdc.tms.model.entity.TmsVehicleGpsModel;
import com.prolog.rdc.tms.model.enums.MessageOrderTypeEnum;
import com.prolog.rdc.tms.model.enums.MessageTypeEnum;
import com.prolog.rdc.tms.model.vo.AMapVO;
import com.prolog.rdc.tms.model.vo.ApprovalVO;
import com.prolog.rdc.tms.model.vo.ContainerTemperatureVO;
import com.prolog.rdc.tms.model.vo.KD100VO;
import com.prolog.rdc.tms.model.vo.PickUpShipbillDetailVO;
import com.prolog.rdc.tms.model.vo.ShipbillNodeTrackingSaveNewVO;
import com.prolog.rdc.tms.model.vo.ShipbillOperateLogSaveNewVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsAdvancedQueryByShipbillVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsExportAllVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsExportPageVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsItemDetailVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsPackageDetailVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsQueryByShipbillVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsQueryTypeByReceiverVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsReceiverGetShipbillVO;
import com.prolog.rdc.tms.model.vo.WaitPickUpGoodsStartShipmentVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ApprovalBusinessNodeVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ApprovalOpenVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SignconfigPopVO;
import com.prolog.rdc.tms.model.vo.basicData.ItemCheckVO;
import com.prolog.rdc.tms.proxy.MainDataProxy;
import com.prolog.rdc.tms.proxy.UserProxy;
import com.prolog.rdc.tms.rmi.feign.MaindataFeign;
import com.prolog.rdc.tms.service.AMapService;
import com.prolog.rdc.tms.service.KD100Service;
import com.prolog.rdc.tms.service.LoadingBillService;
import com.prolog.rdc.tms.service.ShipbillNodeTrackingService;
import com.prolog.rdc.tms.service.ShipbillOperateLogService;
import com.prolog.rdc.tms.service.WaitPickUpGoodsService;
import com.prolog.rdc.tms.util.ConvertorUtil;
import com.prolog.rdc.tms.util.DateRdcUtils;
import com.prolog.rdc.tms.util.MessageUtil;
import com.prolog.rdc.tms.util.PublicMethods;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author zhangsj
 * @since 2022/6/8 10:45
 */
@Slf4j
@Service
public class WaitPickUpGoodsServiceImpl implements WaitPickUpGoodsService {

	@Autowired
	private TmsLoadingBillHeaderMapper tmsLoadingBillHeaderMapper;

	@Autowired
	private TmsLoadingBillDetailMapper tmsLoadingBillDetailMapper;

	@Autowired
	private TmsShipbillHeaderMapper tmsShipbillHeaderMapper;

	@Autowired
	private TmsShipbillDetailMapper tmsShipbillDetailMapper;

	@Autowired
	private TmsShipbillPackageMapper tmsShipbillPackageMapper;

	@Autowired
	private MaindataFeign maindataTmsResource;

	@Autowired
	private ShipbillOperateLogService shipbillOperateLogService;

	@Autowired
	private ShipbillNodeTrackingService shipbillNodeTrackingService;

	@Autowired
	private TmsShipbillTransportLogMapper tmsShipbillTransportLogMapper;

	@Autowired
	private ConvertorUtil convertorUtil;

	@Autowired
	private TmsShipbillHeaderTempMapper tmsShipbillHeaderTempMapper;

	@Autowired
	private TmsShipbillDetailTempMapper tmsShipbillDetailTempMapper;

	@Autowired
	private TmsVehicleGpsMapper tmsVehicleGpsMapper;

	@Autowired
	private MainDataProxy mainDataProxy;

	@Autowired
	private RedisTemplate redisTemplate;

	@Autowired
	private LoadingBillService loadingBillService;

	@Autowired
	private TmsShipbillContainerTempMapper shipbillContainerTempMapper;

	@Autowired
	private AMapService aMapService;

	@Autowired
	private KD100Service kd100Service;

	@Value("${prolog.system.username:interface_jxqn}")
	private String systemUsername;

	@Autowired
	private UserProxy userProxy;

	//private String init_latitude = "25.877518";
	//private String init_latitude = "25.879908824977687";
	private String init_latitude = "25.871831";
	//private String init_longitude = "114.897967";
	//private String init_longitude = "114.90347436332169";
	private String init_longitude = "114.891408";

	/**
	 * 运单模式分页查询
	 *
	 * @param waitPickUpGoodsQueryByShipbillVO
	 * @return
	 */
	@Override
	public Page<WaitPickUpGoodsQueryByShipbillDTO> queryTypeByShipbillPageData(WaitPickUpGoodsQueryByShipbillVO waitPickUpGoodsQueryByShipbillVO) {
		ToolKits.isParamNull(waitPickUpGoodsQueryByShipbillVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsQueryByShipbillVO.getPageSize(), "每页条数不为空");

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

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}

		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}

		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}

		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}

		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}

		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

		// 权限控制
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 判断是否是部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				waitPickUpGoodsQueryByShipbillVO.setIsDept(StatusConstant.IS_DEPT_YES);
				waitPickUpGoodsQueryByShipbillVO.setDepts(user.getDepts().toArray(new String[] {}));
			} else {
				waitPickUpGoodsQueryByShipbillVO.setIsDept(StatusConstant.IS_DEPT_NO);
				// 设置部门权限
				waitPickUpGoodsQueryByShipbillVO.setDepts(user.getDepts().toArray(new String[] {}));
				// 设置数据权限
				waitPickUpGoodsQueryByShipbillVO.setConsignors(user.getConsignors().toArray(new Long[] {}));
				waitPickUpGoodsQueryByShipbillVO.setWsarehouses(user.getWarehouses().toArray(new Long[] {}));
				waitPickUpGoodsQueryByShipbillVO.setCustomers(user.getCustomers().toArray(new Long[] {}));
				waitPickUpGoodsQueryByShipbillVO.setSuppliers(user.getSuppliers().toArray(new Long[] {}));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			waitPickUpGoodsQueryByShipbillVO.setUnitId(Long.valueOf(user.getLoginUserCompanyInfo().getId()));
		} else {
			throw new PrologException("当前人员没有操作权限");
		}
		waitPickUpGoodsQueryByShipbillVO.setUserType(user.getUserType());
		waitPickUpGoodsQueryByShipbillVO.setEnterpriseId(user.getEnterpriseId());

		PageUtils.startPage(waitPickUpGoodsQueryByShipbillVO.getPageNum(), waitPickUpGoodsQueryByShipbillVO.getPageSize());
		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsQueryByShipbillPage(waitPickUpGoodsQueryByShipbillVO);

		for (WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO : waitPickUpGoodsQueryByShipbillDTOS) {
			// 类型翻译
			waitPickUpGoodsQueryByShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
			waitPickUpGoodsQueryByShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
			waitPickUpGoodsQueryByShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
			waitPickUpGoodsQueryByShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
			waitPickUpGoodsQueryByShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
			waitPickUpGoodsQueryByShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
			waitPickUpGoodsQueryByShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
			waitPickUpGoodsQueryByShipbillDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
			waitPickUpGoodsQueryByShipbillDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
				waitPickUpGoodsQueryByShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsQueryByShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
				waitPickUpGoodsQueryByShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsQueryByShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}

			if (ObjectUtil.equal(DataDictionaryConstant.LINE_CARRIER_TYPE_SJ, waitPickUpGoodsQueryByShipbillDTO.getCarrierType())) {// 承运方类型为司机时展示司机姓名
				waitPickUpGoodsQueryByShipbillDTO.setCarrierName(waitPickUpGoodsQueryByShipbillDTO.getDriverName());
				waitPickUpGoodsQueryByShipbillDTO.setCarrierPhoneNumber(waitPickUpGoodsQueryByShipbillDTO.getDriverPhoneNumber());
			}

			waitPickUpGoodsQueryByShipbillDTO.setShipbillIds(waitPickUpGoodsQueryByShipbillDTO.getShipbillId());

			List<ContainerTypeDTO>  containerTypeDTOS = getContainerTypes(waitPickUpGoodsQueryByShipbillDTO.getContainerId());
			if (ToolKits.isNotEmpty(containerTypeDTOS)) {
				waitPickUpGoodsQueryByShipbillDTO.setContainerTypeDTOS(containerTypeDTOS);
			}
		}
		return PageUtils.getPage(waitPickUpGoodsQueryByShipbillDTOS);
	}

	public List<ContainerTypeDTO> getContainerTypes(String containerId) {
		if (ToolKits.isEmpty(containerId)) {
			return null;
		}
		List<ContainerTypeDTO> containerTypeDTOS = Lists.newArrayList();
		List<ContainerDTO> data = null;
		String[] containerIds = containerId.split(",");
		RestMessage<List<ContainerDTO>> restMessage = maindataTmsResource.findContainerByIdList(Arrays.stream(containerIds).map(Long::valueOf).collect(Collectors.toList()));
		if (!restMessage.isSuccess()) {
			throw new RuntimeException("容器获取失败!");
		} else {
			data = restMessage.getData();
		}
		if (ToolKits.isNotEmpty(data)) {
			data.stream().forEach(container->{
				ContainerTypeDTO typeDTO = new ContainerTypeDTO();
				typeDTO.setContainerId(container.getId().toString());
				typeDTO.setContainerCode(container.getCode());
				typeDTO.setContainerName(container.getName());
				typeDTO.setContainerType(container.getType());
				containerTypeDTOS.add(typeDTO);
			});
		}
		return containerTypeDTOS;
	}

	/**
	 * 运单模高级查询
	 *
	 * @param waitPickUpGoodsAdvancedQueryByShipbillVO
	 * @return
	 */
	@Override
	public Page<WaitPickUpGoodsQueryByShipbillDTO> advancedQueryTypeByShipbillPageData(WaitPickUpGoodsAdvancedQueryByShipbillVO waitPickUpGoodsAdvancedQueryByShipbillVO) {
		ToolKits.isParamNull(waitPickUpGoodsAdvancedQueryByShipbillVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsAdvancedQueryByShipbillVO.getPageSize(), "每页条数不为空");

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

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}

		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}

		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}

		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}

		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}

		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

		// 权限控制
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 判断是否是部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				waitPickUpGoodsAdvancedQueryByShipbillVO.setIsDept(StatusConstant.IS_DEPT_YES);
				waitPickUpGoodsAdvancedQueryByShipbillVO.setDepts(user.getDepts().toArray(new String[] {}));
			} else {
				waitPickUpGoodsAdvancedQueryByShipbillVO.setIsDept(StatusConstant.IS_DEPT_NO);
				// 设置部门权限
				waitPickUpGoodsAdvancedQueryByShipbillVO.setDepts(user.getDepts().toArray(new String[] {}));
				// 设置数据权限
				waitPickUpGoodsAdvancedQueryByShipbillVO.setConsignors(user.getConsignors().toArray(new Long[] {}));
				waitPickUpGoodsAdvancedQueryByShipbillVO.setWsarehouses(user.getWarehouses().toArray(new Long[] {}));
				waitPickUpGoodsAdvancedQueryByShipbillVO.setCustomers(user.getCustomers().toArray(new Long[] {}));
				waitPickUpGoodsAdvancedQueryByShipbillVO.setSuppliers(user.getSuppliers().toArray(new Long[] {}));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			waitPickUpGoodsAdvancedQueryByShipbillVO.setUnitId(Long.valueOf(user.getLoginUserCompanyInfo().getId()));
		} else {
			throw new PrologException("当前人员没有操作权限");
		}
		waitPickUpGoodsAdvancedQueryByShipbillVO.setUserType(user.getUserType());
		waitPickUpGoodsAdvancedQueryByShipbillVO.setEnterpriseId(user.getEnterpriseId());

		// 获取高级查询配置
		String conditions = null;
		RestMessage<String> restMessageAdvancedCfg = maindataTmsResource.getQueryConfiguration(DataDictionaryConstant.BIZ_TYPE_WAITPICKUPGOODS);
		if (!restMessageAdvancedCfg.isSuccess()) {
			throw new RuntimeException("获取高级查询配置失败!");
		} else {
			conditions = restMessageAdvancedCfg.getData();
		}
		waitPickUpGoodsAdvancedQueryByShipbillVO.setSql(conditions);

		PageUtils.startPage(waitPickUpGoodsAdvancedQueryByShipbillVO.getPageNum(), waitPickUpGoodsAdvancedQueryByShipbillVO.getPageSize());
		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsAdvancedQueryByShipbillPage(waitPickUpGoodsAdvancedQueryByShipbillVO);

		for (WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO : waitPickUpGoodsQueryByShipbillDTOS) {
			// 类型翻译
			waitPickUpGoodsQueryByShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
			waitPickUpGoodsQueryByShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
			waitPickUpGoodsQueryByShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
			waitPickUpGoodsQueryByShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
			waitPickUpGoodsQueryByShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
			waitPickUpGoodsQueryByShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
			waitPickUpGoodsQueryByShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
			waitPickUpGoodsQueryByShipbillDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
			waitPickUpGoodsQueryByShipbillDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
			waitPickUpGoodsQueryByShipbillDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
				waitPickUpGoodsQueryByShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsQueryByShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
				waitPickUpGoodsQueryByShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsQueryByShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}
		}
		return PageUtils.getPage(waitPickUpGoodsQueryByShipbillDTOS);
	}

	/**
	 * 收货方模式分页查询
	 *
	 * @param waitPickUpGoodsQueryTypeByReceiverVO
	 * @return
	 */
	@Override
	public Page<WaitPickUpGoodsQueryTypeByReceiverDTO> queryTypeByReceiverPageData(WaitPickUpGoodsQueryTypeByReceiverVO waitPickUpGoodsQueryTypeByReceiverVO) {
		ToolKits.isParamNull(waitPickUpGoodsQueryTypeByReceiverVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsQueryTypeByReceiverVO.getPageSize(), "每页条数不为空");

		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");
		// 权限控制
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 判断是否是部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				waitPickUpGoodsQueryTypeByReceiverVO.setIsDept(StatusConstant.IS_DEPT_YES);
				waitPickUpGoodsQueryTypeByReceiverVO.setDepts(user.getDepts().toArray(new String[] {}));
			} else {
				waitPickUpGoodsQueryTypeByReceiverVO.setIsDept(StatusConstant.IS_DEPT_NO);
				// 设置部门权限
				waitPickUpGoodsQueryTypeByReceiverVO.setDepts(user.getDepts().toArray(new String[] {}));
				// 设置数据权限
				waitPickUpGoodsQueryTypeByReceiverVO.setConsignors(user.getConsignors().toArray(new Long[] {}));
				waitPickUpGoodsQueryTypeByReceiverVO.setWsarehouses(user.getWarehouses().toArray(new Long[] {}));
				waitPickUpGoodsQueryTypeByReceiverVO.setCustomers(user.getCustomers().toArray(new Long[] {}));
				waitPickUpGoodsQueryTypeByReceiverVO.setSuppliers(user.getSuppliers().toArray(new Long[] {}));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			waitPickUpGoodsQueryTypeByReceiverVO.setUnitId(Long.valueOf(user.getLoginUserCompanyInfo().getId()));
		} else {
			throw new PrologException("当前人员没有操作权限");
		}
		waitPickUpGoodsQueryTypeByReceiverVO.setUserType(user.getUserType());
		waitPickUpGoodsQueryTypeByReceiverVO.setEnterpriseId(user.getEnterpriseId());

		PageUtils.startPage(waitPickUpGoodsQueryTypeByReceiverVO.getPageNum(), waitPickUpGoodsQueryTypeByReceiverVO.getPageSize());

		List<WaitPickUpGoodsQueryTypeByReceiverDTO> waitPickUpGoodsQueryTypeByReceiverDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsQueryTypeByReceiverPage(waitPickUpGoodsQueryTypeByReceiverVO);

		// 行号
		int id = 1;
		for (WaitPickUpGoodsQueryTypeByReceiverDTO dto : waitPickUpGoodsQueryTypeByReceiverDTOS) {
			// 设置行id
			dto.setId(id);
			// 目的地
			dto.setConsigneeProvinceCityDistrict(dto.getConsigneeProvinceName() + dto.getConsigneeCityName() + dto.getConsigneeDistrictName());
			dto.setEstimatedDeliveryTime(DateRdcUtils.timeSplicing(dto.getEstimatedDeliveryStartTime(), dto.getEstimatedDeliveryEndTime()));
			// 行号自增长
			id++;

			List<ContainerTypeDTO>  containerTypeDTOS = getContainerTypes(dto.getContainerIds());
			if (ToolKits.isNotEmpty(containerTypeDTOS)) {
				dto.setContainerTypeDTOS(containerTypeDTOS);
				dto.setContainerId(containerTypeDTOS.stream().map(ContainerTypeDTO::getContainerId).collect(Collectors.joining(",")));
				dto.setContainerCode(containerTypeDTOS.stream().map(ContainerTypeDTO::getContainerCode).collect(Collectors.joining(",")));
				dto.setContainerName(containerTypeDTOS.stream().map(ContainerTypeDTO::getContainerName).collect(Collectors.joining(",")));
			}
		}

		return PageUtils.getPage(waitPickUpGoodsQueryTypeByReceiverDTOS);
	}

	/**
	 * 配载运单查询
	 * 
	 * @param waitPickUpGoodsReceiverGetShipbillVO
	 * @return
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<WaitPickUpGoodsReceiverGetShipbillDTO> receiverGetShipbillData(WaitPickUpGoodsReceiverGetShipbillVO waitPickUpGoodsReceiverGetShipbillVO) {
		ToolKits.isParamNull(waitPickUpGoodsReceiverGetShipbillVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsReceiverGetShipbillVO.getPageSize(), "每页条数不为空");
		ToolKits.isParamNull(waitPickUpGoodsReceiverGetShipbillVO.getShipbillIds(), "运单ID不为空");

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

		if (!user.getUserType().equals(BussinessConstant.USER_TYPE_ZY) && !user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			ToolKits.isParamNull(user, "当前人员没有操作权限");
		}

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<SignconfigPopDTO> data8 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}
		// 标记配置
		SignconfigPopVO signconfigPopVO = new SignconfigPopVO();
		RestMessage<List<SignconfigPopDTO>> restMessage8 = maindataTmsResource.getSignConfig(signconfigPopVO);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("标记配置查询失败!");
		} else {
			data8 = restMessage8.getData();
		}

		List<SysRefdatadModel> dicData = convertorUtil.getDictionary(new String[] { DataDictionaryConstant.SHIPBILL_STATUS, // 运单状态
				DataDictionaryConstant.TRANSPORT_STATUS, // 运输状态
				DataDictionaryConstant.ABNORMAL_STATUS, // 异常状态
				DataDictionaryConstant.SCAN_STATUS, // 扫描状态
				DataDictionaryConstant.LINE_CARRIER_TYPE // 承运方类型
		});

		// 封装运单明细
		Criteria criteria = Criteria.forClass(TmsLoadingBillDetailModel.class);
		Restriction r1 = Restrictions.in("shipbillId", waitPickUpGoodsReceiverGetShipbillVO.getShipbillIds().toArray());
		criteria.setRestriction(r1);
		criteria.setOrder(Order.newInstance().asc(new String[] { "shippingOrder" }));

		PageUtils.startPage(waitPickUpGoodsReceiverGetShipbillVO.getPageNum(), waitPickUpGoodsReceiverGetShipbillVO.getPageSize());
		List<TmsLoadingBillDetailModel> tmsLoadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteria);

		// 明细集合
		List<WaitPickUpGoodsReceiverGetShipbillDTO> list = Lists.newArrayList();

		for (TmsLoadingBillDetailModel model : tmsLoadingBillDetailModels) {

			WaitPickUpGoodsReceiverGetShipbillDTO waitPickUpGoodsReceiverGetShipbillDTO = new WaitPickUpGoodsReceiverGetShipbillDTO();
			BeanUtils.copyProperties(model, waitPickUpGoodsReceiverGetShipbillDTO);

			// 查询调度单
			TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(model.getLoadingBillId(), TmsLoadingBillHeaderModel.class);
			ToolKits.isParamNull(tmsLoadingBillHeaderModel, "装车单【" + model.getLoadingBillId() + "】不存在");
			waitPickUpGoodsReceiverGetShipbillDTO.setDeliverymanName(tmsLoadingBillHeaderModel.getDeliverymanName());
			waitPickUpGoodsReceiverGetShipbillDTO.setVehiclePlateNumber(tmsLoadingBillHeaderModel.getVehiclePlateNumber());

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(model.getConsigneeLongitude()) && ToolKits.isNotEmpty(model.getConsigneeLatitude())) {
				waitPickUpGoodsReceiverGetShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsReceiverGetShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(model.getShipperLongitude()) && ToolKits.isNotEmpty(model.getShipperLatitude())) {
				waitPickUpGoodsReceiverGetShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsReceiverGetShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}

			StringBuffer consigneeProvinceCityDistrict = new StringBuffer();
			// 目的地
			consigneeProvinceCityDistrict.append(model.getConsigneeProvinceName());
			consigneeProvinceCityDistrict.append(model.getConsigneeCityName());
			consigneeProvinceCityDistrict.append(model.getConsigneeDistrictName());
			waitPickUpGoodsReceiverGetShipbillDTO.setConsigneeProvinceCityDistrict(consigneeProvinceCityDistrict.toString());
			// 始发地
			StringBuffer shipperProvinceCityDistrict = new StringBuffer();
			shipperProvinceCityDistrict.append(model.getShipperProvinceName());
			shipperProvinceCityDistrict.append(model.getShipperCityName());
			shipperProvinceCityDistrict.append(model.getShipperDistrictName());
			waitPickUpGoodsReceiverGetShipbillDTO.setShipperProvinceCityDistrict(shipperProvinceCityDistrict.toString());

			// 类型翻译
			waitPickUpGoodsReceiverGetShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(model.getOrderType())));
			waitPickUpGoodsReceiverGetShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(model.getOrderBusinessType())));
			waitPickUpGoodsReceiverGetShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(model.getDeliveryMethodType())));
			waitPickUpGoodsReceiverGetShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(model.getTransportType())));
			waitPickUpGoodsReceiverGetShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(model.getTemperatureRequirement())));
			waitPickUpGoodsReceiverGetShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(model.getShipperType())));
			waitPickUpGoodsReceiverGetShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(model.getConsigneeType())));

			waitPickUpGoodsReceiverGetShipbillDTO.setStatusName(ConvertorUtil.getName(dicData, DataDictionaryConstant.SHIPBILL_STATUS, String.valueOf(model.getStatus())));
			waitPickUpGoodsReceiverGetShipbillDTO.setTransportStatusName(ConvertorUtil.getName(dicData, DataDictionaryConstant.TRANSPORT_STATUS, String.valueOf(model.getTransportStatus())));
			waitPickUpGoodsReceiverGetShipbillDTO.setAbnormalStatusName(ConvertorUtil.getName(dicData, DataDictionaryConstant.ABNORMAL_STATUS, String.valueOf(model.getAbnormalStatus())));
			waitPickUpGoodsReceiverGetShipbillDTO.setScanStatusName(ConvertorUtil.getName(dicData, DataDictionaryConstant.SCAN_STATUS, String.valueOf(model.getScanStatus())));
			waitPickUpGoodsReceiverGetShipbillDTO.setCarrierTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.LINE_CARRIER_TYPE, String.valueOf(model.getCarrierType())));

			// 获取背景颜色和字体颜色
			Signconfig: for (SignconfigPopDTO signconfigPopDTO : data8) {
				// 标记类型匹配
				switch (signconfigPopDTO.getType()) {
				case DataDictionaryConstant.SIGNCONFIG_TYPE_DDLX: // 订单类型
					if (ToolKits.isNotEmpty(signconfigPopDTO.getMatching())) {
						// 判断是否匹配
						if (PublicMethods.compare(signconfigPopDTO.getMatching(), ToolKits.isNotEmpty(signconfigPopDTO.getStoredValue()) ? signconfigPopDTO.getStoredValue() : "", ToolKits.isNotEmpty(waitPickUpGoodsReceiverGetShipbillDTO.getOrderTypeName()) ? waitPickUpGoodsReceiverGetShipbillDTO.getOrderTypeName() : "")) {
							waitPickUpGoodsReceiverGetShipbillDTO.setBackground(ToolKits.isEmpty(signconfigPopDTO.getBackground()) ? "" : signconfigPopDTO.getBackground());
							waitPickUpGoodsReceiverGetShipbillDTO.setColor(ToolKits.isEmpty(signconfigPopDTO.getColor()) ? "" : signconfigPopDTO.getColor());

							waitPickUpGoodsReceiverGetShipbillDTO.setSignConfigId(signconfigPopDTO.getId());

							// 匹配上结束循环
							break Signconfig;
						}
					}
					break;
				case DataDictionaryConstant.SIGNCONFIG_TYPE_YWLX: // 业务类型
					if (ToolKits.isNotEmpty(signconfigPopDTO.getMatching())) {
						if (PublicMethods.compare(signconfigPopDTO.getMatching(), ToolKits.isNotEmpty(signconfigPopDTO.getStoredValue()) ? signconfigPopDTO.getStoredValue() : "", ToolKits.isNotEmpty(waitPickUpGoodsReceiverGetShipbillDTO.getOrderBusinessTypeName()) ? waitPickUpGoodsReceiverGetShipbillDTO.getOrderBusinessTypeName() : "")) {
							waitPickUpGoodsReceiverGetShipbillDTO.setBackground(ToolKits.isEmpty(signconfigPopDTO.getBackground()) ? "" : signconfigPopDTO.getBackground());
							waitPickUpGoodsReceiverGetShipbillDTO.setColor(ToolKits.isEmpty(signconfigPopDTO.getColor()) ? "" : signconfigPopDTO.getColor());

							waitPickUpGoodsReceiverGetShipbillDTO.setSignConfigId(signconfigPopDTO.getId());

							break Signconfig;
						}
					}
					break;
				case DataDictionaryConstant.SIGNCONFIG_TYPE_WDYQ: // 温度要求
					if (ToolKits.isNotEmpty(signconfigPopDTO.getMatching())) {
						if (PublicMethods.compare(signconfigPopDTO.getMatching(), ToolKits.isNotEmpty(signconfigPopDTO.getStoredValue()) ? signconfigPopDTO.getStoredValue() : "", ToolKits.isNotEmpty(waitPickUpGoodsReceiverGetShipbillDTO.getTemperatureRequirementName()) ? waitPickUpGoodsReceiverGetShipbillDTO.getTemperatureRequirementName() : "")) {
							waitPickUpGoodsReceiverGetShipbillDTO.setBackground(ToolKits.isEmpty(signconfigPopDTO.getBackground()) ? "" : signconfigPopDTO.getBackground());
							waitPickUpGoodsReceiverGetShipbillDTO.setColor(ToolKits.isEmpty(signconfigPopDTO.getColor()) ? "" : signconfigPopDTO.getColor());

							waitPickUpGoodsReceiverGetShipbillDTO.setSignConfigId(signconfigPopDTO.getId());

							break Signconfig;
						}
					}
					break;
				case DataDictionaryConstant.SIGNCONFIG_TYPE_PSFS: // 配送方式
					if (ToolKits.isNotEmpty(signconfigPopDTO.getMatching())) {
						if (PublicMethods.compare(signconfigPopDTO.getMatching(), ToolKits.isNotEmpty(signconfigPopDTO.getStoredValue()) ? signconfigPopDTO.getStoredValue() : "", ToolKits.isNotEmpty(waitPickUpGoodsReceiverGetShipbillDTO.getDeliveryMethodTypeName()) ? waitPickUpGoodsReceiverGetShipbillDTO.getDeliveryMethodTypeName() : "")) {
							waitPickUpGoodsReceiverGetShipbillDTO.setBackground(ToolKits.isEmpty(signconfigPopDTO.getBackground()) ? "" : signconfigPopDTO.getBackground());
							waitPickUpGoodsReceiverGetShipbillDTO.setColor(ToolKits.isEmpty(signconfigPopDTO.getColor()) ? "" : signconfigPopDTO.getColor());

							waitPickUpGoodsReceiverGetShipbillDTO.setSignConfigId(signconfigPopDTO.getId());

							break Signconfig;
						}
					}
					break;
				case DataDictionaryConstant.SIGNCONFIG_TYPE_DDBZ: // 订单备注
					if (ToolKits.isNotEmpty(signconfigPopDTO.getMatching())) {
						if (PublicMethods.compare(signconfigPopDTO.getMatching(), ToolKits.isNotEmpty(signconfigPopDTO.getStoredValue()) ? signconfigPopDTO.getStoredValue() : "", ToolKits.isNotEmpty(waitPickUpGoodsReceiverGetShipbillDTO.getMemo()) ? waitPickUpGoodsReceiverGetShipbillDTO.getMemo() : "")) {
							waitPickUpGoodsReceiverGetShipbillDTO.setBackground(ToolKits.isEmpty(signconfigPopDTO.getBackground()) ? "" : signconfigPopDTO.getBackground());
							waitPickUpGoodsReceiverGetShipbillDTO.setColor(ToolKits.isEmpty(signconfigPopDTO.getColor()) ? "" : signconfigPopDTO.getColor());

							waitPickUpGoodsReceiverGetShipbillDTO.setSignConfigId(signconfigPopDTO.getId());

							break Signconfig;
						}
					}
					break;
				}
			}

			list.add(waitPickUpGoodsReceiverGetShipbillDTO);
		}

		// 分页重组
		Page<WaitPickUpGoodsReceiverGetShipbillDTO> page = PageUtils.getPage(list);
		if (tmsLoadingBillDetailModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsLoadingBillDetailModel> p0 = (com.github.pagehelper.Page<TmsLoadingBillDetailModel>) tmsLoadingBillDetailModels;
			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 waitPickUpGoodsItemDetailVO
	 * @return
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<WaitPickUpGoodsItemDetailDTO> itemDetailData(WaitPickUpGoodsItemDetailVO waitPickUpGoodsItemDetailVO) {
		ToolKits.isParamNull(waitPickUpGoodsItemDetailVO.getShipbillIds(), "运单ID不为空");
		ToolKits.isParamNull(waitPickUpGoodsItemDetailVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsItemDetailVO.getPageSize(), "每页条数不为空");

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

		if (!user.getUserType().equals(BussinessConstant.USER_TYPE_ZY) && !user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			ToolKits.isParamNull(user, "当前人员没有操作权限");
		}

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();

		// 包装类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.PACK_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 货物温层
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CARGO_THERMOSPHERE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("货物温层翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}

		// 根据运单ID查询明细数据
		Criteria criteria = Criteria.forClass(TmsShipbillDetailModel.class);
		Restriction r1 = Restrictions.in("shipbillId", waitPickUpGoodsItemDetailVO.getShipbillIds().toArray());
		criteria.setRestriction(r1);

		PageUtils.startPage(waitPickUpGoodsItemDetailVO.getPageNum(), waitPickUpGoodsItemDetailVO.getPageSize());
		List<TmsShipbillDetailModel> tmsShipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteria);

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

		for (TmsShipbillDetailModel tmsShipbillDetailModel : tmsShipbillDetailModels) {
			WaitPickUpGoodsItemDetailDTO dto = new WaitPickUpGoodsItemDetailDTO();
			BeanUtils.copyProperties(tmsShipbillDetailModel, dto);

			// 数据字典翻译
			dto.setPackTypeName(PublicMethods.change(data1, String.valueOf(dto.getPackType())));
			dto.setCargoThermosphereName(PublicMethods.change(data2, String.valueOf(dto.getCargoThermosphere())));

			dto.setWeight(NumberUtil.mul(tmsShipbillDetailModel.getPcs(), tmsShipbillDetailModel.getUnitWeight()));
			dto.setVolume(NumberUtil.mul(tmsShipbillDetailModel.getPcs(), tmsShipbillDetailModel.getUnitVolume()));

			list.add(dto);
		}

		// 分页重组
		Page<WaitPickUpGoodsItemDetailDTO> page = PageUtils.getPage(list);
		if (tmsShipbillDetailModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsShipbillDetailModel> p0 = (com.github.pagehelper.Page<TmsShipbillDetailModel>) tmsShipbillDetailModels;
			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 waitPickUpGoodsPackageDetailVO
	 * @return
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<WaitPickUpGoodsPackageDetailDTO> packageDetailData(WaitPickUpGoodsPackageDetailVO waitPickUpGoodsPackageDetailVO) {
		ToolKits.isParamNull(waitPickUpGoodsPackageDetailVO.getShipbillIds(), "运单ID不为空");
		ToolKits.isParamNull(waitPickUpGoodsPackageDetailVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsPackageDetailVO.getPageSize(), "每页条数不为空");

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

		if (!user.getUserType().equals(BussinessConstant.USER_TYPE_ZY) && !user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			ToolKits.isParamNull(user, "当前人员没有操作权限");
		}

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();

		// 包裹类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.PACKAGE_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("包裹类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 根据运单ID查询明细数据
		Criteria criteria = Criteria.forClass(TmsShipbillPackageModel.class);
		Restriction r1 = Restrictions.in("shipbillId", waitPickUpGoodsPackageDetailVO.getShipbillIds().toArray());
		criteria.setRestriction(r1);

		PageUtils.startPage(waitPickUpGoodsPackageDetailVO.getPageNum(), waitPickUpGoodsPackageDetailVO.getPageSize());
		List<TmsShipbillPackageModel> tmsShipbillPackageModels = tmsShipbillPackageMapper.findByCriteria(criteria);

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

		for (TmsShipbillPackageModel tmsShipbillPackageModel : tmsShipbillPackageModels) {
			WaitPickUpGoodsPackageDetailDTO dto = new WaitPickUpGoodsPackageDetailDTO();
			BeanUtils.copyProperties(tmsShipbillPackageModel, dto);

			// 数据字典翻译
			dto.setPackageTypeName(PublicMethods.change(data1, String.valueOf(dto.getPackageType())));

			// 设备类型翻译
			if (ToolKits.isNotEmpty(tmsShipbillPackageModel.getDeviceId())) {
				RestMessage<DeviceByOneDTO> deviceByOneDTORestMessage = maindataTmsResource.deviceGetOne(tmsShipbillPackageModel.getDeviceId());
				if (!deviceByOneDTORestMessage.isSuccess()) {
					throw new RuntimeException("获取设备失败!");
				}
				DeviceByOneDTO data = deviceByOneDTORestMessage.getData();
				ToolKits.isParamNull(data, "获取设备为空");

				dto.setDeviceTypeName(data.getTypeName());
			}

			list.add(dto);
		}

		// 分页重组
		Page<WaitPickUpGoodsPackageDetailDTO> page = PageUtils.getPage(list);
		if (tmsShipbillPackageModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<TmsShipbillPackageModel> p0 = (com.github.pagehelper.Page<TmsShipbillPackageModel>) tmsShipbillPackageModels;
			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 waitPickUpGoodsExportAllVO
	 * @return
	 */
	@Override
	public List<WaitPickUpGoodsExportShipbillDTO> exportAllShipbillData(WaitPickUpGoodsExportAllVO waitPickUpGoodsExportAllVO) {
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}

		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}

		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}

		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}

		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}

		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

		// 权限控制
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 判断是否是部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				waitPickUpGoodsExportAllVO.setIsDept(StatusConstant.IS_DEPT_YES);
				waitPickUpGoodsExportAllVO.setDepts(user.getDepts().toArray(new String[] {}));
			} else {
				waitPickUpGoodsExportAllVO.setIsDept(StatusConstant.IS_DEPT_NO);
				// 设置部门权限
				waitPickUpGoodsExportAllVO.setDepts(user.getDepts().toArray(new String[] {}));
				// 设置数据权限
				waitPickUpGoodsExportAllVO.setConsignors(user.getConsignors().toArray(new Long[] {}));
				waitPickUpGoodsExportAllVO.setWsarehouses(user.getWarehouses().toArray(new Long[] {}));
				waitPickUpGoodsExportAllVO.setCustomers(user.getCustomers().toArray(new Long[] {}));
				waitPickUpGoodsExportAllVO.setSuppliers(user.getSuppliers().toArray(new Long[] {}));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			waitPickUpGoodsExportAllVO.setUnitId(Long.valueOf(user.getLoginUserCompanyInfo().getId()));
		} else {
			throw new PrologException("当前人员没有操作权限");
		}
		waitPickUpGoodsExportAllVO.setUserType(user.getUserType());
		waitPickUpGoodsExportAllVO.setEnterpriseId(user.getEnterpriseId());

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

		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsExportAllShipbillData(waitPickUpGoodsExportAllVO);

		for (WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO : waitPickUpGoodsQueryByShipbillDTOS) {

			WaitPickUpGoodsExportShipbillDTO waitPickUpGoodsExportShipbillDTO = new WaitPickUpGoodsExportShipbillDTO();
			BeanUtils.copyProperties(waitPickUpGoodsQueryByShipbillDTO, waitPickUpGoodsExportShipbillDTO);

			// 类型翻译
			waitPickUpGoodsExportShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
			waitPickUpGoodsExportShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
			waitPickUpGoodsExportShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
			waitPickUpGoodsExportShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
			waitPickUpGoodsExportShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
			waitPickUpGoodsExportShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
			waitPickUpGoodsExportShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
			waitPickUpGoodsExportShipbillDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
			waitPickUpGoodsExportShipbillDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
			waitPickUpGoodsExportShipbillDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
			waitPickUpGoodsExportShipbillDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
			waitPickUpGoodsExportShipbillDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

			StringBuffer consigneeProvinceCityDistrict = new StringBuffer();
			// 目的地
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeProvinceName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeCityName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeDistrictName());
			waitPickUpGoodsExportShipbillDTO.setConsigneeProvinceCity(consigneeProvinceCityDistrict.toString());

			// 始发地
			StringBuffer shipperProvinceCityDistrict = new StringBuffer();
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperProvinceName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperCityName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperDistrictName());
			waitPickUpGoodsExportShipbillDTO.setShipperProvinceCity(shipperProvinceCityDistrict.toString());

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}

			if (ObjectUtil.equal(DataDictionaryConstant.LINE_CARRIER_TYPE_SJ, waitPickUpGoodsQueryByShipbillDTO.getCarrierType())) {// 承运方类型为司机时展示司机姓名
				waitPickUpGoodsExportShipbillDTO.setCarrierName(waitPickUpGoodsQueryByShipbillDTO.getDriverName());
				waitPickUpGoodsExportShipbillDTO.setCarrierPhoneNumber(waitPickUpGoodsQueryByShipbillDTO.getDriverPhoneNumber());
			}

			list.add(waitPickUpGoodsExportShipbillDTO);
		}
		return list;
	}

	/**
	 * 导出当前页数据
	 *
	 * @param waitPickUpGoodsExportPageVO
	 * @return
	 */
	@SuppressWarnings("resource")
	@Override
	public List<WaitPickUpGoodsExportShipbillDTO> exportPageShipbill(WaitPickUpGoodsExportPageVO waitPickUpGoodsExportPageVO) {
		ToolKits.isParamNull(waitPickUpGoodsExportPageVO.getPageNum(), "当前页码不为空");
		ToolKits.isParamNull(waitPickUpGoodsExportPageVO.getPageSize(), "每页条数不为空");
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}

		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}

		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}

		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}

		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}

		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

		// 权限控制
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 判断是否是部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				waitPickUpGoodsExportPageVO.setIsDept(StatusConstant.IS_DEPT_YES);
				waitPickUpGoodsExportPageVO.setDepts(user.getDepts().toArray(new String[] {}));
			} else {
				waitPickUpGoodsExportPageVO.setIsDept(StatusConstant.IS_DEPT_NO);
				// 设置部门权限
				waitPickUpGoodsExportPageVO.setDepts(user.getDepts().toArray(new String[] {}));
				// 设置数据权限
				waitPickUpGoodsExportPageVO.setConsignors(user.getConsignors().toArray(new Long[] {}));
				waitPickUpGoodsExportPageVO.setWsarehouses(user.getWarehouses().toArray(new Long[] {}));
				waitPickUpGoodsExportPageVO.setCustomers(user.getCustomers().toArray(new Long[] {}));
				waitPickUpGoodsExportPageVO.setSuppliers(user.getSuppliers().toArray(new Long[] {}));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			waitPickUpGoodsExportPageVO.setUnitId(Long.valueOf(user.getLoginUserCompanyInfo().getId()));
		} else {
			throw new PrologException("当前人员没有操作权限");
		}
		waitPickUpGoodsExportPageVO.setUserType(user.getUserType());
		waitPickUpGoodsExportPageVO.setEnterpriseId(user.getEnterpriseId());

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

		PageUtils.startPage(waitPickUpGoodsExportPageVO.getPageNum(), waitPickUpGoodsExportPageVO.getPageSize());
		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsExportPageShipbillData(waitPickUpGoodsExportPageVO);

		for (WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO : waitPickUpGoodsQueryByShipbillDTOS) {

			WaitPickUpGoodsExportShipbillDTO waitPickUpGoodsExportShipbillDTO = new WaitPickUpGoodsExportShipbillDTO();
			BeanUtils.copyProperties(waitPickUpGoodsQueryByShipbillDTO, waitPickUpGoodsExportShipbillDTO);

			// 类型翻译
			waitPickUpGoodsExportShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
			waitPickUpGoodsExportShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
			waitPickUpGoodsExportShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
			waitPickUpGoodsExportShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
			waitPickUpGoodsExportShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
			waitPickUpGoodsExportShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
			waitPickUpGoodsExportShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
			waitPickUpGoodsExportShipbillDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
			waitPickUpGoodsExportShipbillDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
			waitPickUpGoodsExportShipbillDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
			waitPickUpGoodsExportShipbillDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
			waitPickUpGoodsExportShipbillDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

			StringBuffer consigneeProvinceCityDistrict = new StringBuffer();
			// 目的地
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeProvinceName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeCityName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeDistrictName());
			waitPickUpGoodsExportShipbillDTO.setConsigneeProvinceCity(consigneeProvinceCityDistrict.toString());

			// 始发地
			StringBuffer shipperProvinceCityDistrict = new StringBuffer();
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperProvinceName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperCityName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperDistrictName());
			waitPickUpGoodsExportShipbillDTO.setShipperProvinceCity(shipperProvinceCityDistrict.toString());

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}

			if (ObjectUtil.equal(DataDictionaryConstant.LINE_CARRIER_TYPE_SJ, waitPickUpGoodsQueryByShipbillDTO.getCarrierType())) {// 承运方类型为司机时展示司机姓名
				waitPickUpGoodsExportShipbillDTO.setCarrierName(waitPickUpGoodsQueryByShipbillDTO.getDriverName());
				waitPickUpGoodsExportShipbillDTO.setCarrierPhoneNumber(waitPickUpGoodsQueryByShipbillDTO.getDriverPhoneNumber());
			}

			list.add(waitPickUpGoodsExportShipbillDTO);
		}

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

	/**
	 * 导出选择行数据
	 *
	 * @param shipbillIds
	 * @return
	 */
	@Override
	public List<WaitPickUpGoodsExportShipbillDTO> exportSelectLineShipbillData(List<String> shipbillIds) {
		ToolKits.isParamNull(shipbillIds, "运单ID不为空");

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

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}
		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}
		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}
		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}
		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}
		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

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

		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsExportSelectLineShipbillData(shipbillIds.toArray(new String[] {}));

		for (WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO : waitPickUpGoodsQueryByShipbillDTOS) {

			WaitPickUpGoodsExportShipbillDTO waitPickUpGoodsExportShipbillDTO = new WaitPickUpGoodsExportShipbillDTO();
			BeanUtils.copyProperties(waitPickUpGoodsQueryByShipbillDTO, waitPickUpGoodsExportShipbillDTO);

			// 类型翻译
			waitPickUpGoodsExportShipbillDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
			waitPickUpGoodsExportShipbillDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
			waitPickUpGoodsExportShipbillDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
			waitPickUpGoodsExportShipbillDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
			waitPickUpGoodsExportShipbillDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
			waitPickUpGoodsExportShipbillDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
			waitPickUpGoodsExportShipbillDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
			waitPickUpGoodsExportShipbillDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
			waitPickUpGoodsExportShipbillDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
			waitPickUpGoodsExportShipbillDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
			waitPickUpGoodsExportShipbillDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
			waitPickUpGoodsExportShipbillDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

			StringBuffer consigneeProvinceCityDistrict = new StringBuffer();
			// 目的地
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeProvinceName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeCityName());
			consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeDistrictName());
			waitPickUpGoodsExportShipbillDTO.setConsigneeProvinceCity(consigneeProvinceCityDistrict.toString());

			// 始发地
			StringBuffer shipperProvinceCityDistrict = new StringBuffer();
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperProvinceName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperCityName());
			shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperDistrictName());
			waitPickUpGoodsExportShipbillDTO.setShipperProvinceCity(shipperProvinceCityDistrict.toString());

			// 收货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
			}
			// 发货方位置(经纬度判断)
			if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
			} else {
				waitPickUpGoodsExportShipbillDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
			}

			if (ObjectUtil.equal(DataDictionaryConstant.LINE_CARRIER_TYPE_SJ, waitPickUpGoodsQueryByShipbillDTO.getCarrierType())) {// 承运方类型为司机时展示司机姓名
				waitPickUpGoodsExportShipbillDTO.setCarrierName(waitPickUpGoodsQueryByShipbillDTO.getDriverName());
				waitPickUpGoodsExportShipbillDTO.setCarrierPhoneNumber(waitPickUpGoodsQueryByShipbillDTO.getDriverPhoneNumber());
			}

			list.add(waitPickUpGoodsExportShipbillDTO);
		}
		return list;
	}

	/**
	 * 启运登记
	 *
	 * @param waitPickUpGoodsStartShipmentVO
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void startShipmentData(WaitPickUpGoodsStartShipmentVO waitPickUpGoodsStartShipmentVO) {
		ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getShipbillIds(), "运单ID不能为空");
		ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getDepartureTime(), "启运时间不能为空");

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

		if (!user.getUserType().equals(BussinessConstant.USER_TYPE_ZY) && !user.getUserType().equals(BussinessConstant.USER_TYPE_CYS)) {
			ToolKits.isParamNull(user, "当前人员没有操作权限");
		}

		RestMessage<SysParamConfigModel> restMessageShipbillId = maindataTmsResource.getValue(DataDictionaryConstant.PICKUP_HANDLE_TYPE);
		if (!restMessageShipbillId.isSuccess()) {
			throw new RuntimeException("获取待提货处理方式的系统参数失败:" + restMessageShipbillId.getMessage());
		}

		/*String pickUpCheckDtlSystem = mainDataProxy.getSystemParamByCode(DataDictionaryConstant.PICK_UP_CHECK_DETAIL_SWITCH);
		if (DataDictionaryConstant.WHETHER_YES.toString().equals(pickUpCheckDtlSystem)
				&& ToolKits.isEmpty(waitPickUpGoodsStartShipmentVO.getCheckDetails())) {
			throw new BizException("启运登记检查清单不为空");
		}*/

		SysParamConfigModel sysParamConfigModel = restMessageShipbillId.getData();
		List<PickUpShipbillDetailVO> shipbillDetails = waitPickUpGoodsStartShipmentVO.getShipbillDetails();
		/*List<String> detailLogStr = Lists.newArrayList();
		if (DataDictionaryConstant.PICKUP_HANDLE_TYPE_INPUT.equals(sysParamConfigModel.getValue())) {
			if (ToolKits.isEmpty(shipbillDetails)) {
				throw new PrologException("请按运单明细输入提货件数");
			}
			List<PickUpShipbillDetailVO> noPickUpPcs = shipbillDetails.stream().filter(s -> ToolKits.isEmpty(s.getPickUpPcs())).collect(Collectors.toList());
			if (ToolKits.isNotEmpty(noPickUpPcs)) {
				throw new PrologException("请按运单明细输入提货件数");
			}
			shipbillDetails.forEach(detail -> {
				detailLogStr.add("商品【" + detail.getItemName() + "】,计划提货件数:" + NumberUtil.null2Zero(detail.getPlanDeliveryPcs()) + "件,实际提货件数:" + detail.getPickUpPcs() + "件");
			});

		}*/
		//Map<String, PickUpShipbillDetailVO> detailVOMap = shipbillDetails.stream().collect(Collectors.toMap(t1 -> t1.getId(), t2 -> t2, (t1, t2) -> t2));

		// 当前时间
		Date date = DateUtils.nowDate();
		// 货物图片
		String departurePhoto = "";

		StringBuffer nodeEvent = new StringBuffer();
		nodeEvent.append("启运登记 备注:");
		nodeEvent.append(waitPickUpGoodsStartShipmentVO.getDepartureMemo());

		List<TmsShipbillHeaderModel> tmsShipbillHeaderMapperByIds = tmsShipbillHeaderMapper.findByIds(TmsShipbillHeaderModel.class, waitPickUpGoodsStartShipmentVO.getShipbillIds().toArray(), null);

		List<TmsShipbillHeaderModel> tmsShipbillHeaderModels = tmsShipbillHeaderMapperByIds.stream().filter(o -> StatusConstant.WHETHER_YES.equals(o.getShipperPickUpSign())).collect(Collectors.toList());
		if (ToolKits.isNotEmpty(tmsShipbillHeaderModels)) {
			ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getDepartureSignTime(), "签到时间不能为空");
		}
		List<TmsShipbillHeaderModel> tmsShipbillHeaderModels2 = tmsShipbillHeaderMapperByIds.stream().filter(o -> StatusConstant.WHETHER_YES.equals(o.getShipperPickUpPicture())).collect(Collectors.toList());
		if (ToolKits.isNotEmpty(tmsShipbillHeaderModels2)) {
			ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getDeparturePhoto(), "货物图片不能为空");
			departurePhoto = waitPickUpGoodsStartShipmentVO.getDeparturePhoto();
		}

		Criteria criteriaTransport = Criteria.forClass(TmsShipbillTransLogModel.class);
		Map<String, Object> mapTransportLogUpdate = Maps.newHashMap();
		mapTransportLogUpdate.put("updateperson", user.getNickname());
		mapTransportLogUpdate.put("updatetime", date);
		// 启运时间
		mapTransportLogUpdate.put("departureTime", waitPickUpGoodsStartShipmentVO.getDepartureTime());
		// 签到时间
		if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getDepartureSignTime())) {
			mapTransportLogUpdate.put("departureSignTime", waitPickUpGoodsStartShipmentVO.getDepartureSignTime());
		}
		// 备注
		if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getDepartureMemo())) {
			mapTransportLogUpdate.put("departureMemo", waitPickUpGoodsStartShipmentVO.getDepartureMemo());
		}
		List<KD100VO> subscribeVOS = Lists.newArrayList();
		List<AMapVO> aMapVOS = Lists.newArrayList();
		List<ShipbillRouteDataModel> routeDataModels = Lists.newArrayList();
		//String relationThirdSystem = mainDataProxy.getSystemParamByCode(RelationThirdSystemEnum.ENUM_NAME);
		for (TmsShipbillHeaderModel tmsShipbillHeaderModel : tmsShipbillHeaderMapperByIds) {
			/*if (!DataDictionaryConstant.TEMPERATURE_REQUIREMENT_CW.equals(tmsShipbillHeaderModel.getTemperatureRequirement())) {
				if (Boolean.TRUE.equals(waitPickUpGoodsStartShipmentVO.getShowDepartureTemperature())) {
					if (CollectionUtil.isEmpty(waitPickUpGoodsStartShipmentVO.getTemperatureVOList())) {
						throw new BizException("容器温度集合不存在");
					}
					waitPickUpGoodsStartShipmentVO.getTemperatureVOList().forEach(vo -> {
						if (ObjectUtil.isNull(vo.getTemperature())) {
							throw new BizException("容器" + vo.getContainerName() + "温度为空");
						}
					});

					updateTmsShipbillContainer(waitPickUpGoodsStartShipmentVO.getTemperatureVOList(),tmsShipbillHeaderModel.getShipbillId(),user);
				}
				if (!DataDictionaryConstant.VEHICLE_TYPE_CATEGORY_CLOUD.equals(tmsShipbillHeaderModel.getVehicleTypeCategory())) {
					if (relationThirdSystem.contains(RelationThirdSystemEnum.GPS.getCode())) {
						if (StrUtil.isBlank(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId())) {
							throw new BizException("运单" + tmsShipbillHeaderModel.getShipbillId() + "未绑定设备，请先输入设备号");
						}
					}
					if(relationThirdSystem.contains(RelationThirdSystemEnum.TEMPERATURE.getCode()) || relationThirdSystem.contains(RelationThirdSystemEnum.CONTAINER.getCode())){
						if (StrUtil.isBlank(waitPickUpGoodsStartShipmentVO.getContainerId())) {
							throw new BizException("运单" + tmsShipbillHeaderModel.getShipbillId() + "未绑定保温箱，请先选择容器号");
						}
					}
				}
			}*/

			if (DataDictionaryConstant.PICKUP_HANDLE_TYPE_INPUT.equals(sysParamConfigModel.getValue())) {
				if (shipbillDetails.stream().anyMatch(detailVO -> NumberUtil.isGreater(detailVO.getPlanDeliveryPcs(), detailVO.getPickUpPcs()))) {
					TmsShipbillHeaderTempModel tempModel = BeanUtil.copyProperties(tmsShipbillHeaderModel, TmsShipbillHeaderTempModel.class);
					tempModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
					tempModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
					tempModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
					tempModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
					tempModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
					tempModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
					tempModel.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
					tempModel.setDepartureTemperature(waitPickUpGoodsStartShipmentVO.getDepartureTemperature());
					tempModel.setMemo(waitPickUpGoodsStartShipmentVO.getDeparturePhoto());
					tmsShipbillHeaderTempMapper.save(tempModel);
					tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QYSH);
					tmsShipbillHeaderModel.setUpdateperson(user.getNickname());
					tmsShipbillHeaderModel.setUpdatetime(date);
					tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);

					Criteria criteria = Criteria.forClass(TmsLoadingBillDetailModel.class);
					Restriction r1 = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
					Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
					criteria.setRestriction(Restrictions.and(r1, r2));
					criteria.setOrder(Order.newInstance().desc(TmsLoadingBillDetailModel::getCreatetime));
					List<TmsLoadingBillDetailModel> loadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteria);
					ToolKits.isParamNull(loadingBillDetailModels, "未找到对应的调度单明细");
					TmsLoadingBillDetailModel loadingBillDetailModel = loadingBillDetailModels.get(0);
					loadingBillDetailModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QYSH);
					loadingBillDetailModel.setUpdateperson(user.getNickname());
					loadingBillDetailModel.setUpdatetime(date);
					tmsLoadingBillDetailMapper.update(loadingBillDetailModel);

					// 声明节点实体
					ShipbillNodeTrackingSaveNewVO shipbillNodeTrackingSaveNewVO = new ShipbillNodeTrackingSaveNewVO();
					// 声明日志实体
					ShipbillOperateLogSaveNewVO shipbillOperateLogSaveNewVO = new ShipbillOperateLogSaveNewVO();
					// 节点保存
					shipbillNodeTrackingSaveNewVO.setNodeEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QYSH);
					shipbillNodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QYSH);
					shipbillNodeTrackingSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
					shipbillNodeTrackingSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
					shipbillNodeTrackingSaveNewVO.setNodeDate(date);
					shipbillNodeTrackingSaveNewVO.setUserId(user.getUserid());
					shipbillNodeTrackingSaveNewVO.setUserName(user.getNickname());
					shipbillNodeTrackingSaveNewVO.setEnterpriseId(user.getEnterpriseId());
					shipbillNodeTrackingSaveNewVO.setEnterpriseName(user.getEnterpriseName());
					shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

					shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QYSH);
					shipbillOperateLogSaveNewVO.setOldStatus(tmsShipbillHeaderModel.getStatus());
					shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_QYSH);
					shipbillOperateLogSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
					shipbillOperateLogSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
					shipbillOperateLogSaveNewVO.setUserId(user.getUserid());
					shipbillOperateLogSaveNewVO.setUserName(user.getNickname());
					shipbillOperateLogSaveNewVO.setEnterpriseId(user.getEnterpriseId());
					shipbillOperateLogSaveNewVO.setEnterpriseName(user.getEnterpriseName());
					shipbillOperateLogSaveNewVO.setOperateDate(date);
					shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);
					List<TmsShipbillDetailModel> tmsShipbillDetailModelList = tmsShipbillDetailMapper.findByIds(TmsShipbillDetailModel.class, shipbillDetails.stream().map(PickUpShipbillDetailVO::getId).toArray(), null);
					tmsShipbillDetailModelList.forEach(detailModel -> {
						TmsShipbillDetailTempModel tempModel2 = BeanUtil.copyProperties(detailModel, TmsShipbillDetailTempModel.class);
						/*PickUpShipbillDetailVO detailVO = detailVOMap.get(detailModel.getId());
						if (ObjectUtil.isNotNull(detailVO)) {
							tempModel2.setPickUpPcs(detailVO.getPickUpPcs());
						}*/
						tmsShipbillDetailTempMapper.save(tempModel2);
					});

					// 封装判断所需数据
					ApprovalOpenVO approvalOpenVO = new ApprovalOpenVO();
					approvalOpenVO.setApprovalFlowType(DataDictionaryConstant.APPROVAL_FLOW_TYPE_START_SHIP);
					approvalOpenVO.setApprovalObjectId(tmsShipbillHeaderModel.getShipbillId());
					approvalOpenVO.setApprovalObjectCode(tmsShipbillHeaderModel.getShipbillId());
					approvalOpenVO.setApprovalObjectName(tmsShipbillHeaderModel.getShipbillId());
					approvalOpenVO.setInitiatedUserId(user.getUserid());
					approvalOpenVO.setInitiatedUserName(user.getNickname());
					approvalOpenVO.setDeliveryMethodType(tmsShipbillHeaderModel.getDeliveryMethodType());
					approvalOpenVO.setShipperType(tmsShipbillHeaderModel.getShipperType());
					approvalOpenVO.setShipperUnitId(tmsShipbillHeaderModel.getShipperUnitId());
					approvalOpenVO.setConsigneeType(tmsShipbillHeaderModel.getConsigneeType());
					approvalOpenVO.setConsigneeUnitId(tmsShipbillHeaderModel.getConsigneeUnitId());
					approvalOpenVO.setOrderType(tmsShipbillHeaderModel.getOrderType());
					approvalOpenVO.setOrderBusinessType(tmsShipbillHeaderModel.getOrderBusinessType());
					approvalOpenVO.setTransportType(tmsShipbillHeaderModel.getTransportType());
					approvalOpenVO.setTemperatureRequirement(tmsShipbillHeaderModel.getTemperatureRequirement());
					approvalOpenVO.setCargoOwnerId(tmsShipbillHeaderModel.getCargoOwnerId());
					approvalOpenVO.setDepartmentId(tmsShipbillHeaderModel.getDepartmentId());
					RestMessage<Boolean> restMessage1 = maindataTmsResource.openExecute(approvalOpenVO);
					if (!restMessage1.isSuccess()) {
						throw new BizException("调用maindata服务是否开启审批流接口失败:" + restMessage1.getMessage());
					}
					if (restMessage1.getData()) {
						return;
					}
				}
			}

			// 修改运单明细的商品信息
			Criteria criteriaShipbillDetail = Criteria.forClass(TmsShipbillDetailModel.class);
			Restriction r11 = Restrictions.eq(TmsShipbillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
			Restriction r12 = Restrictions.eq(TmsShipbillDetailModel::getEnterpriseId, user.getEnterpriseId());
			Restriction r13 = Restrictions.ge(TmsShipbillDetailModel::getPcs, BigDecimal.ZERO);
			criteriaShipbillDetail.setRestriction(Restrictions.and(r11, r12, r13));
			List<TmsShipbillDetailModel> shipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteriaShipbillDetail);
			BigDecimal totalDeliveryPcs = new BigDecimal(0);
			BigDecimal totalDeliveryVolume = new BigDecimal(0);
			BigDecimal totalDeliveryWeight = new BigDecimal(0);

			if (ToolKits.isNotEmpty(shipbillDetailModels)) {
				for (TmsShipbillDetailModel shipbillDetailModel : shipbillDetailModels) {
					ItemCheckVO itemCheckVO = new ItemCheckVO();
					itemCheckVO.setItemId(shipbillDetailModel.getItemId());
					RestMessage<ItemCheckDTO> restMessage3 = maindataTmsResource.getItem(itemCheckVO);
					if (!restMessage3.isSuccess()) {
						throw new RuntimeException("取商品资料信息失败:" + restMessage3.getMessage());
					}
					ItemCheckDTO rsItemInfo = restMessage3.getData();
					if (DataDictionaryConstant.PICKUP_HANDLE_TYPE_INPUT.equals(sysParamConfigModel.getValue())) {
						// 输入的提货件数
						List<PickUpShipbillDetailVO> shipbillDetail = shipbillDetails.stream().filter(s -> s.getId().equals(shipbillDetailModel.getId())).collect(Collectors.toList());
						if (ToolKits.isEmpty(shipbillDetail.get(0).getPickUpPcs())) {
							throw new PrologException("运单【" + shipbillDetailModel.getShipbillNo() + "】的商品【" + shipbillDetailModel.getItemName() + "】提货件数为空");
						}
						shipbillDetailModel.setPickUpPcs(shipbillDetail.get(0).getPickUpPcs());
						shipbillDetailModel.setPcs(NumberUtil.sub(shipbillDetailModel.getPcs(), shipbillDetailModel.getPickUpPcs()));
						shipbillDetailModel.setDeliveryPcs(shipbillDetailModel.getPickUpPcs());
						shipbillDetailModel.setVolume(NumberUtil.mul(shipbillDetailModel.getPcs(), rsItemInfo.getVolume()));
						shipbillDetailModel.setWeight(NumberUtil.mul(shipbillDetailModel.getPcs(), rsItemInfo.getWeight()));
					} else {
						shipbillDetailModel.setDeliveryPcs(shipbillDetailModel.getPcs());
						shipbillDetailModel.setPickUpPcs(shipbillDetailModel.getPcs());
						shipbillDetailModel.setPcs(new BigDecimal(0));
						shipbillDetailModel.setVolume(new BigDecimal(0));
						shipbillDetailModel.setWeight(new BigDecimal(0));
					}
					tmsShipbillDetailMapper.update(shipbillDetailModel);
					BigDecimal fatherDeliveryPcs = new BigDecimal(0);

					fatherDeliveryPcs = fatherDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());

					totalDeliveryPcs = totalDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());
					totalDeliveryVolume = totalDeliveryVolume.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getVolume()));
					totalDeliveryWeight = totalDeliveryWeight.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getWeight()));

					// 拆分主单对应的运单明细
					String fatherShipbillIdForDetail = tmsShipbillHeaderModel.getShipbillId();
					while (ToolKits.isNotEmpty(fatherShipbillIdForDetail)) {
						fatherShipbillIdForDetail = updateFatherShipbillDetail(fatherShipbillIdForDetail, shipbillDetailModel, fatherDeliveryPcs, date, user, rsItemInfo);
					}
				}
			}
			// 修改运单
			tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
			tmsShipbillHeaderModel.setUpdateperson(user.getNickname());
			tmsShipbillHeaderModel.setUpdatetime(date);
			tmsShipbillHeaderModel.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);

			tmsShipbillHeaderModel.setTotalDeliveryPcs(totalDeliveryPcs);
			tmsShipbillHeaderModel.setTotalDeliveryWeight(totalDeliveryWeight);
			tmsShipbillHeaderModel.setTotalDeliveryVolume(totalDeliveryVolume);

			tmsShipbillHeaderModel.setTotalPcs(tmsShipbillHeaderModel.getTotalPcs().subtract(totalDeliveryPcs));
			tmsShipbillHeaderModel.setTotalVolume(tmsShipbillHeaderModel.getTotalVolume().subtract(totalDeliveryVolume));
			tmsShipbillHeaderModel.setTotalWeight(tmsShipbillHeaderModel.getTotalWeight().subtract(totalDeliveryWeight));
			tmsShipbillHeaderModel.setActualTotalPcs(tmsShipbillHeaderModel.getTotalPcs());
			tmsShipbillHeaderModel.setActualTotalVolume(tmsShipbillHeaderModel.getTotalVolume());
			tmsShipbillHeaderModel.setActualTotalWeight(tmsShipbillHeaderModel.getTotalWeight());

			if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
				tmsShipbillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
				tmsShipbillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
				tmsShipbillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
			}
			tmsShipbillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
			tmsShipbillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
			tmsShipbillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
			tmsShipbillHeaderModel.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
			tmsShipbillHeaderModel.setDepartureTemperature(waitPickUpGoodsStartShipmentVO.getDepartureTemperature());
			tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);

			// 修改派车单明细
			Criteria criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
			Restriction r1 = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
			Restriction r2 = Restrictions.eq(TmsLoadingBillDetailModel::getEnterpriseId, user.getEnterpriseId());
			criteriaDetail.setRestriction(Restrictions.and(r1, r2));
			criteriaDetail.setOrder(Order.newInstance().desc(new String[] { "createtime" }));
			List<TmsLoadingBillDetailModel> tmsLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
			if (ToolKits.isEmpty(tmsLoadingBillDetails)) {
				throw new PrologException("装车单明细【" + tmsShipbillHeaderModel.getShipbillId() + "】查询失败");
			}
			TmsLoadingBillDetailModel tmsLoadingBillDetail = tmsLoadingBillDetails.get(0);

			tmsLoadingBillDetail.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
			tmsLoadingBillDetail.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);
			tmsLoadingBillDetail.setUpdateperson(user.getNickname());
			tmsLoadingBillDetail.setUpdatetime(date);

			tmsLoadingBillDetail.setTotalDeliveryPcs(totalDeliveryPcs);
			tmsLoadingBillDetail.setTotalDeliveryWeight(totalDeliveryWeight);
			tmsLoadingBillDetail.setTotalDeliveryVolume(totalDeliveryVolume);

			tmsLoadingBillDetail.setTotalPcs(tmsLoadingBillDetail.getTotalPcs().subtract(totalDeliveryPcs));
			tmsLoadingBillDetail.setTotalVolume(tmsLoadingBillDetail.getTotalVolume().subtract(totalDeliveryVolume));
			tmsLoadingBillDetail.setTotalWeight(tmsLoadingBillDetail.getTotalWeight().subtract(totalDeliveryWeight));
			tmsLoadingBillDetail.setActualTotalPcs(tmsLoadingBillDetail.getTotalPcs());
			tmsLoadingBillDetail.setActualTotalVolume(tmsLoadingBillDetail.getTotalVolume());
			tmsLoadingBillDetail.setActualTotalWeight(tmsLoadingBillDetail.getTotalWeight());

			if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
				tmsLoadingBillDetail.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
				tmsLoadingBillDetail.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
				tmsLoadingBillDetail.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
			}
			tmsLoadingBillDetail.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
			tmsLoadingBillDetail.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
			tmsLoadingBillDetail.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
			tmsLoadingBillDetail.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
			tmsLoadingBillDetail.setDepartureTemperature(waitPickUpGoodsStartShipmentVO.getDepartureTemperature());
			tmsLoadingBillDetailMapper.update(tmsLoadingBillDetail);

			Restriction eq = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
			criteriaTransport.setRestriction(eq);
			// 更新订单运输记录表
			tmsShipbillTransportLogMapper.updateMapByCriteria(mapTransportLogUpdate, criteriaTransport);

			// 签到时间是否为空
			boolean departureSignTime = false;

			ShipbillNodeTrackingSaveNewVO shipbillNodeTrackingSaveNewVO = new ShipbillNodeTrackingSaveNewVO();
			ShipbillOperateLogSaveNewVO shipbillOperateLogSaveNewVO = new ShipbillOperateLogSaveNewVO();
			if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getDepartureSignTime())) {
				// 运单节点保存
				shipbillNodeTrackingSaveNewVO.setNodeDate(date);
				shipbillNodeTrackingSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
				shipbillNodeTrackingSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
				shipbillNodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				shipbillNodeTrackingSaveNewVO.setNodeEvent(nodeEvent.toString());
				shipbillNodeTrackingSaveNewVO.setUserId(user.getUserid());
				shipbillNodeTrackingSaveNewVO.setUserName(user.getNickname());
				shipbillNodeTrackingSaveNewVO.setEnterpriseId(user.getEnterpriseId());
				shipbillNodeTrackingSaveNewVO.setEnterpriseName(user.getEnterpriseName());
				shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

				// 运单日志保存
				shipbillOperateLogSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
				shipbillOperateLogSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
				shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QYQD);
				shipbillOperateLogSaveNewVO.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_ZX_CONFIRM);
				shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				shipbillOperateLogSaveNewVO.setOperateDate(date);
				shipbillOperateLogSaveNewVO.setEnterpriseId(user.getEnterpriseId());
				shipbillOperateLogSaveNewVO.setEnterpriseName(user.getEnterpriseName());
				shipbillOperateLogSaveNewVO.setUserId(user.getUserid());
				shipbillOperateLogSaveNewVO.setUserName(user.getNickname());
				shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);

				departureSignTime = true;
			}

			// 运单节点保存
			shipbillNodeTrackingSaveNewVO.setNodeDate(date);
			shipbillNodeTrackingSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
			shipbillNodeTrackingSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
			shipbillNodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
			shipbillNodeTrackingSaveNewVO.setNodeEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QY);
			shipbillNodeTrackingSaveNewVO.setUserId(user.getUserid());
			shipbillNodeTrackingSaveNewVO.setUserName(user.getNickname());
			shipbillNodeTrackingSaveNewVO.setEnterpriseId(user.getEnterpriseId());
			shipbillNodeTrackingSaveNewVO.setEnterpriseName(user.getEnterpriseName());
			shipbillNodeTrackingSaveNewVO.setPicUrl(waitPickUpGoodsStartShipmentVO.getDeparturePhoto());
			shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

			// 运单日志保存
			shipbillOperateLogSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
			shipbillOperateLogSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
			shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QY);
			shipbillOperateLogSaveNewVO.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_ZX_CONFIRM);
			shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
			shipbillOperateLogSaveNewVO.setOperateDate(date);
			shipbillOperateLogSaveNewVO.setEnterpriseId(user.getEnterpriseId());
			shipbillOperateLogSaveNewVO.setEnterpriseName(user.getEnterpriseName());
			shipbillOperateLogSaveNewVO.setUserId(user.getUserid());
			shipbillOperateLogSaveNewVO.setUserName(user.getNickname());
			shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);

			// 父运单的同步启运
			String fatherShipbillId = tmsShipbillHeaderModel.getShipbillId();
			while (ToolKits.isNotEmpty(fatherShipbillId)) {
				fatherShipbillId = fatherStartShipment(fatherShipbillId, date, user, departureSignTime, shipbillNodeTrackingSaveNewVO, mapTransportLogUpdate);
				departureSignTime = false;
			}
			// 更新调度单状态
			Restriction r3 = Restrictions.eq("loadingBillId", tmsLoadingBillDetail.getLoadingBillId());
			Restriction r4 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
			criteriaDetail.setRestriction(Restrictions.and(r3, r4));
			List<TmsLoadingBillDetailModel> tmsLoadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
			int cnt = 0;
			if (ToolKits.isNotEmpty(tmsLoadingBillDetailModels)) {
				TmsLoadingBillHeaderModel secondLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);

				// 运单，第一次调度，调度给承运商，第二次调度，承运商调度给司机或者承运商时，根据第二调度单，查询第一次的调度单
				criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
				r1 = Restrictions.eq(TmsLoadingBillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
				r2 = Restrictions.eq(TmsLoadingBillDetailModel::getEnterpriseId, user.getEnterpriseId());
				r3 = Restrictions.ne(TmsLoadingBillDetailModel::getLoadingBillId, tmsLoadingBillDetail.getLoadingBillId());
				criteriaDetail.setRestriction(Restrictions.and(r1, r2, r3));
				List<TmsLoadingBillDetailModel> firstLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);

				cnt = tmsLoadingBillDetailModels.stream().filter(t -> t.getStatus().intValue() < DataDictionaryConstant.SHIPBILL_STATUS_SD.intValue()).collect(Collectors.toList()).size();
				if (cnt == 0) {
					// 更新状态为启运
					secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);
					loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
					tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
					// 第一次调度单状态更新
					if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
						TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
						firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);

						if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
							firstLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
							firstLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
							firstLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
						}
						firstLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
						firstLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
						firstLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
						loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
						tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
					}
				} else {
					// 更新状态为部分启运
					if (!secondLoadingBillHeaderModel.getStatus().equals(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART)) {
						if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
							secondLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
							secondLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
							secondLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
						}
						secondLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
						secondLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
						secondLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
						secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);
						loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
						tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
						// 第一次调度单状态更新
						if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
							TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
							firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);

							if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
								firstLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
								firstLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
								firstLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
							}
							firstLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
							firstLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
							firstLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
							loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
							tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
						}
					}
				}
			}

			TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);
			if (StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceId()) && StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceCode())) {
				String deviceId = tmsLoadingBillHeaderModel.getVehicleDeviceId().split(",")[0];
				try {
					RestMessage<DeviceByOneDTO> restMessage = maindataTmsResource.deviceGetOne(Long.valueOf(deviceId));
					DeviceByOneDTO deviceByOneDTO = restMessage.getData();
					if (BussinessConstant.E6.equals(deviceByOneDTO.getCompanyName())) {
						redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_E6_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
						log.info("易流 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
					} else if (BussinessConstant.G7.equals(deviceByOneDTO.getCompanyName())) {
						redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_G7_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
						log.info("g7 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
					}
				} catch (Exception e) {
					log.error("增加redis队列错误", e);
				}
			}

			Assert.isTrue(ToolKits.isNotEmpty(tmsShipbillHeaderModel.getExpressNumber()), "运单【" + tmsShipbillHeaderModel.getShipbillId() + "】包裹号为空");
			List<String> expressNumbers = Arrays.stream(tmsShipbillHeaderModel.getExpressNumber().split(",")).collect(Collectors.toList());
			expressNumbers.stream().forEach(expressNo -> {
				if (DataDictionaryConstant.CARRIERS_TYPE_EXPRESS.equals(tmsShipbillHeaderModel.getCarriersType())) {
					KD100VO kd100VO = new KD100VO();
					kd100VO.setCarriersCode(tmsShipbillHeaderModel.getCarriersCode());
					kd100VO.setExpressNumber(expressNo);
					kd100VO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
					kd100VO.setPhone(getPhone(tmsShipbillHeaderModel));
					subscribeVOS.add(kd100VO);
				} else if (DataDictionaryConstant.CARRIERS_TYPE_LOG.equals(tmsShipbillHeaderModel.getCarriersType())) {
					AMapVO aMapVO = new AMapVO();
					aMapVO.setCarriersCode(tmsShipbillHeaderModel.getCarriersCode());
					aMapVO.setExpressNumber(expressNo);
					aMapVO.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
					aMapVO.setShipperLongitude(tmsShipbillHeaderModel.getShipperLongitude());
					aMapVO.setShipperLatitude(tmsShipbillHeaderModel.getShipperLatitude());
					aMapVO.setConsigneeLongitude(tmsShipbillHeaderModel.getConsigneeLongitude());
					aMapVO.setConsigneeLatitude(tmsShipbillHeaderModel.getConsigneeLatitude());
					aMapVOS.add(aMapVO);
				}
			});

			if (ObjectUtil.isNotEmpty(expressNumbers)) {
				List<ShipbillRouteDataModel> dataModels = getInitRote(expressNumbers,tmsShipbillHeaderModel.getCarriersType(),tmsShipbillHeaderModel.getCarriersCode());
				if (ObjectUtil.isNotEmpty(dataModels)) {
					routeDataModels.addAll(dataModels);
				}
			}

			MessageUtil.addMessage(new SendMessageDTO(MessageOrderTypeEnum.SHIP_NO.getCode(), MessageTypeEnum.START_SHIP.getCode(), Lists.newArrayList(tmsShipbillHeaderModel.getShipbillId())));
		}
		if (ToolKits.isNotEmpty(subscribeVOS)) {
			log.info("订阅数据{}", JSONObject.toJSONString(subscribeVOS));
			try {
				kd100Service.pickUpSubscribe(subscribeVOS);
				kd100Service.saveGps(routeDataModels);
			} catch (Exception e) {
				throw new PluginException("订阅失败 " + e.getMessage());
			}
		} else if (ToolKits.isNotEmpty(aMapVOS)) {
			log.info("虚拟坐标生成数据{}", JSONObject.toJSONString(aMapVOS));
			kd100Service.saveGps(routeDataModels);
			aMapService.getDrivingRouting(aMapVOS);
		}
	}

	private String getPhone(TmsShipbillHeaderModel model) {
		if (ToolKits.isNotEmpty(model.getShipperPhoneNumber())) {
			return model.getShipperPhoneNumber();
		} else if (ToolKits.isNotEmpty(model.getShipperLandlineNumber())) {
			return model.getShipperLandlineNumber();
		} else if (ToolKits.isNotEmpty(model.getConsigneePhoneNumber())) {
			return model.getConsigneePhoneNumber();
		} else if (ToolKits.isNotEmpty(model.getConsigneeLandlineNumber())) {
			return model.getConsigneeLandlineNumber();
		}
		List<String> companys= Lists.newArrayList();
		companys.add("shunfeng");
		companys.add("shunfengkuaiyun");
		if (companys.contains(model.getCarriersCode())) {
			log.info("顺丰{}的快递单{}没有联系电话,不能订阅",model.getCarriersCode(),model.getExpressNumber());
			throw new PrologException("顺丰的快递单没有联系电话,不能订阅");
		}
		return null;
	}

	/**
	 * 同步更新父运单商品明细
	 *
	 * @param shipbillId
	 * @param date
	 * @param user
	 * @return
	 */
	public String updateFatherShipbillDetail(String shipbillId, TmsShipbillDetailModel subShipbillDetailModel, BigDecimal totalDeliveryPcs, Date date, UserEntity user, ItemCheckDTO rsItemInfo) {
		// 查询运单
		TmsShipbillHeaderModel tmsShipbillHeaderModel = tmsShipbillHeaderMapper.findById(shipbillId, TmsShipbillHeaderModel.class);
		// 判断是否为原始单号
		if (ToolKits.isNotEmpty(tmsShipbillHeaderModel.getFatherShipbillId()) && !tmsShipbillHeaderModel.getFatherShipbillId().equals(shipbillId)) {
			// 查找父级单号
			TmsShipbillHeaderModel fatherShipbillHeaderModel = tmsShipbillHeaderMapper.findById(tmsShipbillHeaderModel.getFatherShipbillId(), TmsShipbillHeaderModel.class);

			Criteria criteriaShipbillDetail = Criteria.forClass(TmsShipbillDetailModel.class);
			Restriction r11 = Restrictions.eq(TmsShipbillDetailModel::getShipbillId, fatherShipbillHeaderModel.getShipbillId());
			Restriction r12 = Restrictions.eq(TmsShipbillDetailModel::getEnterpriseId, user.getEnterpriseId());
			Restriction r13 = Restrictions.eq(TmsShipbillDetailModel::getItemId, subShipbillDetailModel.getItemId());
			Restriction r14 = Restrictions.gt(TmsShipbillDetailModel::getPcs, BigDecimal.valueOf(0));
			criteriaShipbillDetail.setRestriction(Restrictions.and(r11, r12, r13, r14));
			List<TmsShipbillDetailModel> shipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteriaShipbillDetail);

			if (ToolKits.isEmpty(shipbillDetailModels)) {
				throw new PrologException("运单【" + shipbillId + "】的父运单的运单商品明细【" + subShipbillDetailModel.getItemName() + "】不存在");
			}
			BigDecimal detailDeliveryPcs = totalDeliveryPcs;
			for (TmsShipbillDetailModel fatherShipbillDetailModel : shipbillDetailModels) {
				if (detailDeliveryPcs.intValue() <= 0) {
					break;
				}
				if (fatherShipbillDetailModel.getPcs().intValue() >= detailDeliveryPcs.intValue()) {
					fatherShipbillDetailModel.setDeliveryPcs(fatherShipbillDetailModel.getDeliveryPcs().add(detailDeliveryPcs));
					fatherShipbillDetailModel.setPickUpPcs(NumberUtil.add(fatherShipbillDetailModel.getPickUpPcs(), subShipbillDetailModel.getPickUpPcs()));
					// 剩余件数
					fatherShipbillDetailModel.setUpdateperson(user.getNickname());
					fatherShipbillDetailModel.setUpdatetime(date);
					fatherShipbillDetailModel.setPcs(fatherShipbillDetailModel.getOrigPcs().subtract(fatherShipbillDetailModel.getClosingPcs()).subtract(fatherShipbillDetailModel.getDeliveryPcs()));
					fatherShipbillDetailModel.setVolume(fatherShipbillDetailModel.getPcs().multiply(rsItemInfo.getVolume()));
					fatherShipbillDetailModel.setWeight(fatherShipbillDetailModel.getPcs().multiply(rsItemInfo.getWeight()));

					tmsShipbillDetailMapper.update(fatherShipbillDetailModel);
					detailDeliveryPcs = BigDecimal.valueOf(0);
					break;
				} else {
					fatherShipbillDetailModel.setDeliveryPcs(fatherShipbillDetailModel.getDeliveryPcs().add(fatherShipbillDetailModel.getDeliveryPcs()));
					fatherShipbillDetailModel.setPickUpPcs(NumberUtil.add(fatherShipbillDetailModel.getPickUpPcs(), subShipbillDetailModel.getPickUpPcs()));
					detailDeliveryPcs = detailDeliveryPcs.subtract(fatherShipbillDetailModel.getPcs());

					// 剩余件数
					fatherShipbillDetailModel.setUpdateperson(user.getNickname());
					fatherShipbillDetailModel.setUpdatetime(date);
					fatherShipbillDetailModel.setPcs(fatherShipbillDetailModel.getOrigPcs().subtract(fatherShipbillDetailModel.getClosingPcs()).subtract(fatherShipbillDetailModel.getDeliveryPcs()));
					fatherShipbillDetailModel.setVolume(fatherShipbillDetailModel.getPcs().multiply(rsItemInfo.getVolume()));
					fatherShipbillDetailModel.setWeight(fatherShipbillDetailModel.getPcs().multiply(rsItemInfo.getWeight()));

					tmsShipbillDetailMapper.update(fatherShipbillDetailModel);
				}
			}
			if (detailDeliveryPcs.intValue() > 0) {
				throw new PrologException("运单【" + shipbillId + "】的商品【" + subShipbillDetailModel.getItemName() + "】的件数>父运单的件数");
			}

			// 更新运单
			if (ToolKits.isEmpty(fatherShipbillHeaderModel.getTotalDeliveryPcs())) {
				fatherShipbillHeaderModel.setTotalDeliveryPcs(totalDeliveryPcs);
			} else {
				fatherShipbillHeaderModel.setTotalDeliveryPcs(fatherShipbillHeaderModel.getTotalDeliveryPcs().add(totalDeliveryPcs));
			}

			fatherShipbillHeaderModel.setTotalDeliveryVolume(fatherShipbillHeaderModel.getTotalDeliveryPcs().multiply(rsItemInfo.getVolume()));
			fatherShipbillHeaderModel.setTotalDeliveryWeight(fatherShipbillHeaderModel.getTotalDeliveryPcs().multiply(rsItemInfo.getWeight()));

			if (ToolKits.isEmpty(fatherShipbillHeaderModel.getDepartureTime())) {
				fatherShipbillHeaderModel.setDepartureTime(new Date());
			}

			fatherShipbillHeaderModel.setTotalPcs(fatherShipbillHeaderModel.getTotalPcs().subtract(totalDeliveryPcs));
			fatherShipbillHeaderModel.setTotalVolume(fatherShipbillHeaderModel.getTotalPcs().multiply(rsItemInfo.getVolume()));
			fatherShipbillHeaderModel.setTotalWeight(fatherShipbillHeaderModel.getTotalPcs().multiply(rsItemInfo.getWeight()));
			fatherShipbillHeaderModel.setActualTotalPcs(fatherShipbillHeaderModel.getTotalPcs());
			fatherShipbillHeaderModel.setActualTotalVolume(fatherShipbillHeaderModel.getTotalVolume());
			fatherShipbillHeaderModel.setActualTotalWeight(fatherShipbillHeaderModel.getTotalWeight());

			fatherShipbillHeaderModel.setUpdateperson(user.getNickname());
			fatherShipbillHeaderModel.setUpdatetime(date);
			tmsShipbillHeaderMapper.update(fatherShipbillHeaderModel);

			return fatherShipbillHeaderModel.getShipbillId();
		}
		return null;
	}

	/**
	 * 父运单启运确认
	 *
	 * @param shipbillId
	 * @param date
	 * @param user
	 * @return
	 */
	public String fatherStartShipment(String shipbillId, Date date, UserEntity user, boolean whether, ShipbillNodeTrackingSaveNewVO shipbillNodeTrackingSaveNewVO, Map<String, Object> mapTransportLogUpdate) {
		// 查询运单
		TmsShipbillHeaderModel tmsShipbillHeaderModel = tmsShipbillHeaderMapper.findById(shipbillId, TmsShipbillHeaderModel.class);
		// 判断是否为原始单号
		if (ToolKits.isNotEmpty(tmsShipbillHeaderModel.getFatherShipbillId()) && !tmsShipbillHeaderModel.getFatherShipbillId().equals(shipbillId)) {
			// 查找父级单号
			TmsShipbillHeaderModel fatherShipbillHeaderModel = tmsShipbillHeaderMapper.findById(tmsShipbillHeaderModel.getFatherShipbillId(), TmsShipbillHeaderModel.class);

			// 判断父级单号的状态是否为开始启运
			if (fatherShipbillHeaderModel.getStatus() != DataDictionaryConstant.SHIPBILL_STATUS_SD) {
				// 修改父级运单状态
				fatherShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				fatherShipbillHeaderModel.setUpdatetime(date);
				fatherShipbillHeaderModel.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);
				fatherShipbillHeaderModel.setUpdateperson(user.getNickname());
				tmsShipbillHeaderMapper.update(fatherShipbillHeaderModel);

				// 修改父级运单运输记录表
				Criteria criteriaTransport = Criteria.forClass(TmsShipbillTransLogModel.class);
				Restriction r1 = Restrictions.eq("shipbillId", fatherShipbillHeaderModel.getShipbillId());
				criteriaTransport.setRestriction(r1);
				// 更新订单运输记录表
				tmsShipbillTransportLogMapper.updateMapByCriteria(mapTransportLogUpdate, criteriaTransport);

				// 运单日志信息
				ShipbillOperateLogSaveNewVO shipbillOperateLogSaveNewVO = new ShipbillOperateLogSaveNewVO();
				shipbillOperateLogSaveNewVO.setShipbillId(fatherShipbillHeaderModel.getShipbillId());
				shipbillOperateLogSaveNewVO.setShipbillNo(fatherShipbillHeaderModel.getShipbillId());
				shipbillOperateLogSaveNewVO.setOperateDate(date);
				shipbillOperateLogSaveNewVO.setEnterpriseId(user.getEnterpriseId());
				shipbillOperateLogSaveNewVO.setEnterpriseName(user.getEnterpriseName());
				shipbillOperateLogSaveNewVO.setUserId(user.getUserid());
				shipbillOperateLogSaveNewVO.setUserName(user.getNickname());

				// 判断第一个子单是否有签到时间
				if (whether) {
					// 运单节点信息
					ShipbillNodeTrackingSaveNewVO nodeTrackingSaveNewVO = new ShipbillNodeTrackingSaveNewVO();
					nodeTrackingSaveNewVO.setNodeDate(date);
					nodeTrackingSaveNewVO.setShipbillId(fatherShipbillHeaderModel.getShipbillId());
					nodeTrackingSaveNewVO.setShipbillNo(fatherShipbillHeaderModel.getShipbillId());
					nodeTrackingSaveNewVO.setUserId(user.getUserid());
					nodeTrackingSaveNewVO.setUserName(user.getNickname());
					nodeTrackingSaveNewVO.setEnterpriseId(user.getEnterpriseId());
					nodeTrackingSaveNewVO.setEnterpriseName(user.getEnterpriseName());
					nodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
					nodeTrackingSaveNewVO.setNodeEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QYQD);
					shipbillNodeTrackingService.addShipbillNodeTrackingNewData(nodeTrackingSaveNewVO);

					// 运单日志保存
					shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QYQD);
					shipbillOperateLogSaveNewVO.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_ZX_CONFIRM);
					shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
					shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);
				}
				// 运单节点保存

				shipbillNodeTrackingSaveNewVO.setShipbillId(fatherShipbillHeaderModel.getShipbillId());
				shipbillNodeTrackingSaveNewVO.setShipbillNo(fatherShipbillHeaderModel.getShipbillId());
				shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

				// 运单日志保存
				shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QY);
				shipbillOperateLogSaveNewVO.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_ZX_CONFIRM);
				shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
				shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);

				return fatherShipbillHeaderModel.getShipbillId();
			}
		}
		return null;
	}

	/**
	 * 待提货打印
	 *
	 * @param shipbillId
	 * @return
	 */
	@Override
	public Map<String, Object> printShipbillData(String shipbillId) {
		ToolKits.isParamNull(shipbillId, "运单ID不为空");

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

		// 数据字典翻译数据集合
		List<Map<String, Object>> data1 = Lists.newArrayList();
		List<Map<String, Object>> data2 = Lists.newArrayList();
		List<Map<String, Object>> data3 = Lists.newArrayList();
		List<Map<String, Object>> data4 = Lists.newArrayList();
		List<Map<String, Object>> data5 = Lists.newArrayList();
		List<Map<String, Object>> data6 = Lists.newArrayList();
		List<Map<String, Object>> data7 = Lists.newArrayList();
		List<Map<String, Object>> data8 = Lists.newArrayList();
		List<Map<String, Object>> data9 = Lists.newArrayList();
		List<Map<String, Object>> data10 = Lists.newArrayList();
		List<Map<String, Object>> data11 = Lists.newArrayList();
		List<Map<String, Object>> data12 = Lists.newArrayList();
		List<Map<String, Object>> data13 = Lists.newArrayList();
		List<Map<String, Object>> data14 = Lists.newArrayList();

		// 订单类型
		RestMessage<List<Map<String, Object>>> restMessage1 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_TYPE, null, null, null);
		if (!restMessage1.isSuccess()) {
			throw new RuntimeException("订单类型翻译失败!");
		} else {
			data1 = restMessage1.getData();
		}
		// 订单业务类型
		RestMessage<List<Map<String, Object>>> restMessage2 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ORDER_BUSINESS_TYPE, null, null, null);
		if (!restMessage2.isSuccess()) {
			throw new RuntimeException("订单业务类型翻译失败!");
		} else {
			data2 = restMessage2.getData();
		}
		// 配送方式
		RestMessage<List<Map<String, Object>>> restMessage3 = maindataTmsResource.getDropDownById(DataDictionaryConstant.DELIVERY_METHOD_TYPE, null, null, null);
		if (!restMessage3.isSuccess()) {
			throw new RuntimeException("配送方式翻译失败!");
		} else {
			data3 = restMessage3.getData();
		}
		// 运输类型(运输模式)
		RestMessage<List<Map<String, Object>>> restMessage4 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_TYPE, null, null, null);
		if (!restMessage4.isSuccess()) {
			throw new RuntimeException("运输类型(运输模式)翻译失败!");
		} else {
			data4 = restMessage4.getData();
		}
		// 温度要求
		RestMessage<List<Map<String, Object>>> restMessage5 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TEMPERATURE_REQUIREMENT, null, null, null);
		if (!restMessage5.isSuccess()) {
			throw new RuntimeException("温度要求翻译失败!");
		} else {
			data5 = restMessage5.getData();
		}
		// 发货方类型
		RestMessage<List<Map<String, Object>>> restMessage6 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPPER_TYPE, null, null, null);
		if (!restMessage6.isSuccess()) {
			throw new RuntimeException("发货方类型翻译失败!");
		} else {
			data6 = restMessage6.getData();
		}
		// 收货方类型
		RestMessage<List<Map<String, Object>>> restMessage7 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CONSIGNEE_TYPE, null, null, null);
		if (!restMessage7.isSuccess()) {
			throw new RuntimeException("收货方类型翻译失败!");
		} else {
			data7 = restMessage7.getData();
		}
		// 运单状态
		RestMessage<List<Map<String, Object>>> restMessage8 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SHIPBILL_STATUS, null, null, null);
		if (!restMessage8.isSuccess()) {
			throw new RuntimeException("运单状态翻译失败!");
		} else {
			data8 = restMessage8.getData();
		}
		// 承运方类型
		RestMessage<List<Map<String, Object>>> restMessage9 = maindataTmsResource.getDropDownById(DataDictionaryConstant.LINE_CARRIER_TYPE, null, null, null);
		if (!restMessage9.isSuccess()) {
			throw new RuntimeException("承运方类型翻译失败!");
		} else {
			data9 = restMessage9.getData();
		}
		// 运输状态
		RestMessage<List<Map<String, Object>>> restMessage10 = maindataTmsResource.getDropDownById(DataDictionaryConstant.TRANSPORT_STATUS, null, null, null);
		if (!restMessage10.isSuccess()) {
			throw new RuntimeException("运输状态翻译失败!");
		} else {
			data10 = restMessage10.getData();
		}
		// 异常状态
		RestMessage<List<Map<String, Object>>> restMessage11 = maindataTmsResource.getDropDownById(DataDictionaryConstant.ABNORMAL_STATUS, null, null, null);
		if (!restMessage11.isSuccess()) {
			throw new RuntimeException("异常状态翻译失败!");
		} else {
			data11 = restMessage11.getData();
		}
		// 扫描状态
		RestMessage<List<Map<String, Object>>> restMessage12 = maindataTmsResource.getDropDownById(DataDictionaryConstant.SCAN_STATUS, null, null, null);
		if (!restMessage12.isSuccess()) {
			throw new RuntimeException("扫描状态翻译失败!");
		} else {
			data12 = restMessage12.getData();
		}

		// 包装类型
		RestMessage<List<Map<String, Object>>> restMessage13 = maindataTmsResource.getDropDownById(DataDictionaryConstant.PACK_TYPE, null, null, null);
		if (!restMessage13.isSuccess()) {
			throw new RuntimeException("包装类型翻译失败!");
		} else {
			data13 = restMessage13.getData();
		}
		// 货物温层
		RestMessage<List<Map<String, Object>>> restMessage14 = maindataTmsResource.getDropDownById(DataDictionaryConstant.CARGO_THERMOSPHERE, null, null, null);
		if (!restMessage14.isSuccess()) {
			throw new RuntimeException("货物温层翻译失败!");
		} else {
			data14 = restMessage14.getData();
		}

		// 查询条件
		String[] shipbillIds = new String[] { shipbillId };

		List<WaitPickUpGoodsQueryByShipbillDTO> waitPickUpGoodsQueryByShipbillDTOS = tmsLoadingBillHeaderMapper.waitPickUpGoodsExportSelectLineShipbillData(shipbillIds);
		ToolKits.isParamNull(waitPickUpGoodsQueryByShipbillDTOS, "运单ID[" + shipbillId + "]有误,查询为空!");

		WaitPickUpGoodsPrintHeadDTO waitPickUpGoodsPrintHeadDTO = new WaitPickUpGoodsPrintHeadDTO();
		WaitPickUpGoodsQueryByShipbillDTO waitPickUpGoodsQueryByShipbillDTO = waitPickUpGoodsQueryByShipbillDTOS.get(0);
		BeanUtils.copyProperties(waitPickUpGoodsQueryByShipbillDTO, waitPickUpGoodsPrintHeadDTO);

		// 收货方位置(经纬度判断)
		if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getConsigneeLatitude())) {
			waitPickUpGoodsPrintHeadDTO.setConsigneePositioning(StatusConstant.POSITIONING_YDW);
		} else {
			waitPickUpGoodsPrintHeadDTO.setConsigneePositioning(StatusConstant.POSITIONING_WDW);
		}
		// 发货方位置(经纬度判断)
		if (ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLongitude()) && ToolKits.isNotEmpty(waitPickUpGoodsQueryByShipbillDTO.getShipperLatitude())) {
			waitPickUpGoodsPrintHeadDTO.setShipperPositioning(StatusConstant.POSITIONING_YDW);
		} else {
			waitPickUpGoodsPrintHeadDTO.setShipperPositioning(StatusConstant.POSITIONING_WDW);
		}

		StringBuffer consigneeProvinceCityDistrict = new StringBuffer();
		// 目的地
		consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeProvinceName());
		consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeCityName());
		consigneeProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getConsigneeDistrictName());
		waitPickUpGoodsPrintHeadDTO.setConsigneeProvinceCityDistrict(consigneeProvinceCityDistrict.toString());
		// 始发地
		StringBuffer shipperProvinceCityDistrict = new StringBuffer();
		shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperProvinceName());
		shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperCityName());
		shipperProvinceCityDistrict.append(waitPickUpGoodsQueryByShipbillDTO.getShipperDistrictName());
		waitPickUpGoodsPrintHeadDTO.setShipperProvinceCityDistrict(shipperProvinceCityDistrict.toString());

		// 类型翻译
		waitPickUpGoodsPrintHeadDTO.setOrderTypeName(PublicMethods.change(data1, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderType())));
		waitPickUpGoodsPrintHeadDTO.setOrderBusinessTypeName(PublicMethods.change(data2, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getOrderBusinessType())));
		waitPickUpGoodsPrintHeadDTO.setDeliveryMethodTypeName(PublicMethods.change(data3, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getDeliveryMethodType())));
		waitPickUpGoodsPrintHeadDTO.setTransportTypeName(PublicMethods.change(data4, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportType())));
		waitPickUpGoodsPrintHeadDTO.setTemperatureRequirementName(PublicMethods.change(data5, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTemperatureRequirement())));
		waitPickUpGoodsPrintHeadDTO.setShipperTypeName(PublicMethods.change(data6, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getShipperType())));
		waitPickUpGoodsPrintHeadDTO.setConsigneeTypeName(PublicMethods.change(data7, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getConsigneeType())));
		waitPickUpGoodsPrintHeadDTO.setStatusName(PublicMethods.change(data8, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getStatus())));
		waitPickUpGoodsPrintHeadDTO.setCarrierTypeName(PublicMethods.change(data9, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getCarrierType())));
		waitPickUpGoodsPrintHeadDTO.setTransportStatusName(PublicMethods.change(data10, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getTransportStatus())));
		waitPickUpGoodsPrintHeadDTO.setAbnormalStatusName(PublicMethods.change(data11, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getAbnormalStatus())));
		waitPickUpGoodsPrintHeadDTO.setScanStatusName(PublicMethods.change(data12, String.valueOf(waitPickUpGoodsQueryByShipbillDTO.getScanStatus())));

		// 查询运单明细
		Criteria criteria = Criteria.forClass(TmsShipbillDetailModel.class);
		Restriction r1 = Restrictions.eq("shipbillId", shipbillId);
		criteria.setRestriction(r1);
		List<TmsShipbillDetailModel> tmsShipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteria);

		List<WaitPickUpGoodsPrintDetailDTO> waitPickUpGoodsPrintDetailDTOS = new ArrayList<>();

		for (TmsShipbillDetailModel detail : tmsShipbillDetailModels) {
			WaitPickUpGoodsPrintDetailDTO dto = new WaitPickUpGoodsPrintDetailDTO();
			BeanUtils.copyProperties(detail, dto);
			dto.setPackTypeName(PublicMethods.change(data13, String.valueOf(detail.getPackType())));
			dto.setCargoThermosphereName(PublicMethods.change(data14, String.valueOf(detail.getCargoThermosphere())));
			waitPickUpGoodsPrintDetailDTOS.add(dto);
		}

		// TODO print

		return null;
	}

	@Override
	public ApprovalInfoDTO getApprovalInfo(ApprovalVO vo) {
		ToolKits.isParamNull(vo.getApprovalObjectId(), "审批对象Id不为空");
		ToolKits.isParamNull(vo.getApprovalBusinessId(), "审批业务Id不为空");
		ToolKits.isParamNull(vo.getStatus(), "审批状态不为空");
		List<String> shipBillIdList = Arrays.stream(vo.getApprovalObjectId().split(",")).collect(Collectors.toList());
		List<TmsShipbillHeaderTempModel> tmsShipbillHeaderTempModelList = tmsShipbillHeaderTempMapper.findByIds(TmsShipbillHeaderTempModel.class, shipBillIdList.toArray(), null);
		Criteria criteria = Criteria.forClass(TmsShipbillDetailTempModel.class);
		Restriction r1 = Restrictions.in("shipbillId", shipBillIdList.toArray());
		criteria.setRestriction(r1);
		List<TmsShipbillDetailTempModel> tmsShipbillDetailTempModelList = tmsShipbillDetailTempMapper.findByCriteria(criteria);
		if (DataDictionaryConstant.NODE_APPROVAL_RESULT_SUCCESS.equals(vo.getStatus()) || DataDictionaryConstant.NODE_APPROVAL_RESULT_INVALID.equals(vo.getStatus())) {
			List<TmsShipbillHeaderModel> tmsShipbillHeaderModelList = tmsShipbillHeaderMapper.findByIds(TmsShipbillHeaderModel.class, shipBillIdList.toArray(), null);
			if (CollectionUtil.isNotEmpty(tmsShipbillHeaderModelList)) {
				tmsShipbillHeaderTempModelList = tmsShipbillHeaderModelList.stream().map(tmsShipbillHeaderModel -> BeanUtil.copyProperties(tmsShipbillHeaderModel, TmsShipbillHeaderTempModel.class)).collect(Collectors.toList());
			}
			criteria = Criteria.forClass(TmsShipbillDetailModel.class);
			r1 = Restrictions.in("shipbillId", shipBillIdList.toArray());
			criteria.setRestriction(r1);
			List<TmsShipbillDetailModel> tmsShipbillDetailModelList = tmsShipbillDetailMapper.findByCriteria(criteria);
			tmsShipbillDetailTempModelList = tmsShipbillDetailModelList.stream().map(tmsShipbillDetailModel -> BeanUtil.copyProperties(tmsShipbillDetailModel, TmsShipbillDetailTempModel.class)).collect(Collectors.toList());
		}
		Map<String, List<TmsShipbillDetailTempModel>> listMap = tmsShipbillDetailTempModelList.stream().collect(Collectors.groupingBy(TmsShipbillDetailTempModel::getShipbillId));
		List<SysRefdatadModel> dicData = convertorUtil.getDictionary(new String[] { DataDictionaryConstant.SHIPBILL_STATUS, // 运单状态
				DataDictionaryConstant.TRANSPORT_STATUS, // 运输状态
				DataDictionaryConstant.ABNORMAL_STATUS, // 异常状态
				DataDictionaryConstant.SCAN_STATUS, // 扫描状态
				DataDictionaryConstant.LINE_CARRIER_TYPE, // 承运方类型
				DataDictionaryConstant.DELIVERY_METHOD_TYPE, // 配送方式
				DataDictionaryConstant.TRANSPORT_TYPE, // 运输类型(运输模式)
				DataDictionaryConstant.TEMPERATURE_REQUIREMENT, // 温度要求
				DataDictionaryConstant.SHIPPER_TYPE, // 发货方类型
				DataDictionaryConstant.CONSIGNEE_TYPE, // 收货方类型
				DataDictionaryConstant.ORDER_TYPE, // 订单类型
				DataDictionaryConstant.ORDER_BUSINESS_TYPE // 订单业务类型
		});
		List<ShipbillViewDTO> shipbillInfoDTOList = tmsShipbillHeaderTempModelList.stream().map(tmsShipbillHeaderTempModel -> {
			ShipbillViewDTO shipbillViewDTO = BeanUtil.copyProperties(tmsShipbillHeaderTempModel, ShipbillViewDTO.class);
			shipbillViewDTO.setOrderTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.ORDER_TYPE, String.valueOf(shipbillViewDTO.getOrderType())));
			shipbillViewDTO.setOrderBusinessTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.ORDER_BUSINESS_TYPE, String.valueOf(shipbillViewDTO.getOrderBusinessType())));
			shipbillViewDTO.setDeliveryMethodTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.DELIVERY_METHOD_TYPE, String.valueOf(shipbillViewDTO.getDeliveryMethodType())));
			shipbillViewDTO.setTransportTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.TRANSPORT_TYPE, String.valueOf(shipbillViewDTO.getTransportType())));
			shipbillViewDTO.setTemperatureRequirementName(ConvertorUtil.getName(dicData, DataDictionaryConstant.TEMPERATURE_REQUIREMENT, String.valueOf(shipbillViewDTO.getTemperatureRequirement())));
			shipbillViewDTO.setShipperTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.SHIPPER_TYPE, String.valueOf(shipbillViewDTO.getShipperType())));
			shipbillViewDTO.setConsigneeTypeName(ConvertorUtil.getName(dicData, DataDictionaryConstant.CONSIGNEE_TYPE, String.valueOf(shipbillViewDTO.getConsigneeType())));
			List<TmsShipbillDetailTempModel> detailTempModelList = listMap.get(tmsShipbillHeaderTempModel.getShipbillId());
			if (CollectionUtil.isNotEmpty(detailTempModelList)) {
				shipbillViewDTO.setShipbillDetailViewDTOS(detailTempModelList.stream().map(detailTempModel -> BeanUtil.copyProperties(detailTempModel, ShipbillDetailViewDTO.class)).collect(Collectors.toList()));
			}
			return shipbillViewDTO;
		}).collect(Collectors.toList());

		ApprovalInfoDTO dto = new ApprovalInfoDTO();
		dto.setShipbillInfoDTOList(shipbillInfoDTOList);
		RestMessage<List<ApprovalLogDTO>> resourceBusLog = maindataTmsResource.getBusLog(vo.getApprovalBusinessId().toString());
		if (!resourceBusLog.isSuccess()) {
			throw new PrologException("调用审批日志服务失败!");
		}
		dto.setShipbillApprovalLogDTOList(resourceBusLog.getData());

		RestMessage<List<ApprovalNodeSelDTO>> resourceBusDetail = maindataTmsResource.getBusDetail(vo.getApprovalBusinessId().toString());
		if (!resourceBusLog.isSuccess()) {
			throw new PrologException("调用审批节点服务失败!");
		}
		dto.setShipbillApprovalNodeDTOList(resourceBusDetail.getData());
		return dto;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void invalidApproval(ApprovalVO vo) {
		ToolKits.isParamNull(vo.getApprovalObjectId(), "审批对象Id不为空");
		ToolKits.isParamNull(vo.getApprovalBusinessId(), "审批业务ID不为空");
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

		List<String> shipBillIdList = Arrays.stream(vo.getApprovalObjectId().split(",")).collect(Collectors.toList());
		List<TmsShipbillHeaderTempModel> tmsShipbillHeaderTempModelList = tmsShipbillHeaderTempMapper.findByIds(TmsShipbillHeaderTempModel.class, shipBillIdList.toArray(), null);
		Map<String, TmsShipbillHeaderTempModel> tempModelMap = tmsShipbillHeaderTempModelList.stream().collect(Collectors.toMap(t1 -> t1.getShipbillId(), t2 -> t2, (t1, t2) -> t2));
		List<TmsShipbillHeaderModel> tmsShipbillHeaderModelList = tmsShipbillHeaderMapper.findByIds(TmsShipbillHeaderModel.class, shipBillIdList.toArray(), null);
		tmsShipbillHeaderModelList.forEach(tmsShipbillHeaderModel -> {
			TmsShipbillHeaderTempModel tempModel = tempModelMap.get(tmsShipbillHeaderModel.getShipbillId());
			if (ObjectUtil.isNotNull(tempModel)) {
				tmsShipbillHeaderModel.setStatus(tempModel.getStatus());
				tmsShipbillHeaderModel.setUpdateperson(user.getNickname());
				tmsShipbillHeaderModel.setUpdatetime(new Date());
				tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);

				Criteria criteria = Criteria.forClass(TmsLoadingBillDetailModel.class);
				Restriction r1 = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
				Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
				criteria.setRestriction(Restrictions.and(r1, r2));
				criteria.setOrder(Order.newInstance().desc(TmsLoadingBillDetailModel::getCreatetime));
				List<TmsLoadingBillDetailModel> loadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteria);
				ToolKits.isParamNull(loadingBillDetailModels, "未找到对应的调度单明细");
				TmsLoadingBillDetailModel loadingBillDetailModel = loadingBillDetailModels.get(0);
				loadingBillDetailModel.setStatus(tempModel.getStatus());
				loadingBillDetailModel.setUpdateperson(user.getNickname());
				loadingBillDetailModel.setUpdatetime(new Date());
				tmsLoadingBillDetailMapper.update(loadingBillDetailModel);
			}
		});
		tmsShipbillHeaderTempMapper.deleteByIds(shipBillIdList.toArray(), TmsShipbillHeaderTempModel.class);
		Criteria criteria = Criteria.forClass(TmsShipbillDetailTempModel.class);
		Restriction r1 = Restrictions.in("shipbillId", shipBillIdList.toArray());
		criteria.setRestriction(r1);
		tmsShipbillDetailTempMapper.deleteByCriteria(criteria);
		criteria = Criteria.forClass(TmsVehicleGpsModel.class);
		r1 = Restrictions.in("realShipbillId", shipBillIdList.toArray());
		criteria.setRestriction(r1);
		tmsVehicleGpsMapper.deleteByCriteria(criteria);
		// 审核业务作废
		RestMessage<Object> restMessage = maindataTmsResource.approvalInvalidExecute(vo.getApprovalBusinessId().toString());
		if (!restMessage.isSuccess()) {
			throw new BizException("调用审核作废失败");
		}
	}

	@Override
	public void retractApproval(ApprovalVO vo) {
		ToolKits.isParamNull(vo.getApprovalBusinessId(), "审批业务ID不为空");
		// 提交当前审批
		RestMessage<Object> restMessage1 = maindataTmsResource.approvalRetractExecute(vo.getApprovalBusinessId().toString());
		if (!restMessage1.isSuccess()) {
			throw new BizException("调用审核撤回失败");
		}
	}

	@Override
	public void submitApproval(ApprovalVO vo) {
		ToolKits.isParamNull(vo.getApprovalBusinessId(), "审批业务ID不为空");
		// 提交当前审批
		RestMessage<Object> restMessage1 = maindataTmsResource.approvalSubmitExecute(vo.getApprovalBusinessId().toString());
		if (!restMessage1.isSuccess()) {
			throw new BizException("调用审批提交失败");
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void reviewApproval(ApprovalVO vo) {
		ToolKits.isParamNull(vo.getApprovalObjectId(), "运单ID不为空");
		ToolKits.isParamNull(vo.getApprovalBusinessId(), "审批业务ID不为空");
		ToolKits.isParamNull(vo.getApprovalObjectName(), "审批对象名称不为空");
		ToolKits.isParamNull(vo.getApprovalId(), "审批流程ID不为空");
		ToolKits.isParamNull(vo.getNextApproverNodeId(), "下一审批节点ID不为空");
		ToolKits.isParamNull(vo.getNextApprovalOrder(), "下一节点顺序不为空");
		ToolKits.isParamNull(vo.getResult(), "审批结果不为空");
		if (!vo.getResult().equals(DataDictionaryConstant.NODE_APPROVAL_RESULT_PASS)) {
			ToolKits.isParamNull(vo.getApprovalOpinion(), "驳回意见不为空");
		}
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");
		// 当前时间
		Date date = DateUtils.nowDate();
		// 封装审核所需数据
		ApprovalBusinessNodeVO approvalBusinessNodeVO = new ApprovalBusinessNodeVO();
		approvalBusinessNodeVO.setApprovalObjectName(vo.getApprovalObjectName());
		approvalBusinessNodeVO.setApprovalBusinessId(vo.getApprovalBusinessId());
		approvalBusinessNodeVO.setApprovalId(vo.getApprovalId());
		approvalBusinessNodeVO.setNextApprovalNodeId(vo.getNextApproverNodeId());
		approvalBusinessNodeVO.setNextApprovalOrder(vo.getNextApprovalOrder());
		approvalBusinessNodeVO.setNextApproverRoleId(vo.getNextApproverRoleId());
		approvalBusinessNodeVO.setNextApproverRoleName(vo.getNextApproverRoleName());
		approvalBusinessNodeVO.setNextApproverUserId(vo.getNextApproverUserId());
		approvalBusinessNodeVO.setNextApproverUserName(vo.getNextApproverUserName());
		approvalBusinessNodeVO.setApproverPersonId(user.getUserid());
		approvalBusinessNodeVO.setApproverPersonName(user.getNickname());
		approvalBusinessNodeVO.setApprovalOpinion(ToolKits.isEmpty(vo.getApprovalOpinion()) ? "" : vo.getApprovalOpinion());
		approvalBusinessNodeVO.setApprovalTime(date);
		approvalBusinessNodeVO.setResult(vo.getResult());
		if (CollectionUtil.isNotEmpty(user.getRoles())) {
			approvalBusinessNodeVO.setApproverPersonRoleId(user.getRoles().stream().map(role -> String.valueOf(role)).collect(Collectors.joining(",")));
		}
		approvalBusinessNodeVO.setApproverPersonRoleName("");
		// 节点审批者类型 数据字典 NODE_APPROVER_TYPE 1 角色 2 用户
		approvalBusinessNodeVO.setNodeApproverType(vo.getNodeApproverType());
		// 审批方式 数据字典 NODE_APPROVAL_TYPE: 1 会签 2 或签
		approvalBusinessNodeVO.setNodeApprovalType(vo.getNodeApprovalType());
		// 流程节点审批
		RestMessage<Boolean> restMessage1 = maindataTmsResource.nodeApprovalExecute(approvalBusinessNodeVO);
		if (!restMessage1.isSuccess()) {
			throw new BizException("调用审核失败");
		}
		Boolean finish = restMessage1.getData();
		if (finish) {
			List<String> shipBillIdList = Arrays.stream(vo.getApprovalObjectId().split(",")).collect(Collectors.toList());
			List<TmsShipbillHeaderTempModel> tmsShipbillHeaderTempModelList = tmsShipbillHeaderTempMapper.findByIds(TmsShipbillHeaderTempModel.class, shipBillIdList.toArray(), null);
			List<TmsShipbillHeaderModel> tmsShipbillHeaderModelList = tmsShipbillHeaderMapper.findByIds(TmsShipbillHeaderModel.class, shipBillIdList.toArray(), null);
			Map<String, TmsShipbillHeaderModel> headerModelMap = tmsShipbillHeaderModelList.stream().collect(Collectors.toMap(t1 -> t1.getShipbillId(), t2 -> t2, (t1, t2) -> t2));
			Criteria criteria = Criteria.forClass(TmsShipbillDetailTempModel.class);
			Restriction restriction = Restrictions.in("shipbillId", shipBillIdList.toArray());
			criteria.setRestriction(restriction);
			List<TmsShipbillDetailTempModel> tmsShipbillDetailTempModelList = tmsShipbillDetailTempMapper.findByCriteria(criteria);
			Map<String, TmsShipbillDetailTempModel> detailModelMap = tmsShipbillDetailTempModelList.stream().collect(Collectors.toMap(t1 -> t1.getId(), t2 -> t2, (t1, t2) -> t2));

			tmsShipbillHeaderTempModelList.forEach(tmsShipbillHeaderTempModel -> {
				String departurePhoto = tmsShipbillHeaderTempModel.getMemo();
				TmsShipbillHeaderModel tmsShipbillHeaderModel = BeanUtil.copyProperties(tmsShipbillHeaderTempModel, TmsShipbillHeaderModel.class);
				TmsShipbillHeaderModel dbHeaderModel = headerModelMap.get(tmsShipbillHeaderModel.getShipbillId());
				tmsShipbillHeaderModel.setMemo(dbHeaderModel.getMemo());
				// STD-BUG20220823 lhb 启运登记修改运单明细发货件数 20220920 start
				// 修改运单明细的商品信息
				Criteria criteriaShipbillDetail = Criteria.forClass(TmsShipbillDetailModel.class);
				Restriction r11 = Restrictions.eq(TmsShipbillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
				Restriction r12 = Restrictions.eq(TmsShipbillDetailModel::getEnterpriseId, user.getEnterpriseId());
				Restriction r13 = Restrictions.ge(TmsShipbillDetailModel::getPcs, BigDecimal.ZERO);
				criteriaShipbillDetail.setRestriction(Restrictions.and(r11, r12, r13));
				List<TmsShipbillDetailModel> shipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteriaShipbillDetail);
				BigDecimal totalDeliveryPcs = BigDecimal.ZERO;
				BigDecimal totalDeliveryVolume = BigDecimal.ZERO;
				BigDecimal totalDeliveryWeight = BigDecimal.ZERO;

				if (ToolKits.isNotEmpty(shipbillDetailModels)) {
					for (TmsShipbillDetailModel shipbillDetailModel : shipbillDetailModels) {
						ItemCheckVO itemCheckVO = new ItemCheckVO();
						itemCheckVO.setItemId(shipbillDetailModel.getItemId());
						RestMessage<ItemCheckDTO> restMessage3 = maindataTmsResource.getItem(itemCheckVO);
						if (!restMessage3.isSuccess()) {
							throw new BizException("取商品资料信息失败:" + restMessage3.getMessage());
						}
						ItemCheckDTO rsItemInfo = restMessage3.getData();
						shipbillDetailModel.setUpdateperson(user.getNickname());
						shipbillDetailModel.setUpdatetime(new Date());
						TmsShipbillDetailTempModel detailTempModel = detailModelMap.get(shipbillDetailModel.getId());
						if (ObjectUtil.isNotNull(detailTempModel)) {
							shipbillDetailModel.setPickUpPcs(detailTempModel.getPickUpPcs());
							shipbillDetailModel.setPcs(NumberUtil.sub(shipbillDetailModel.getPcs(), detailTempModel.getPickUpPcs()));
							shipbillDetailModel.setDeliveryPcs(detailTempModel.getPickUpPcs());
							shipbillDetailModel.setVolume(NumberUtil.mul(shipbillDetailModel.getPcs(), rsItemInfo.getVolume()));
							shipbillDetailModel.setWeight(NumberUtil.mul(shipbillDetailModel.getPcs(), rsItemInfo.getWeight()));
						} else {
							shipbillDetailModel.setDeliveryPcs(shipbillDetailModel.getPcs());
							shipbillDetailModel.setPickUpPcs(shipbillDetailModel.getPcs());
							shipbillDetailModel.setPcs(BigDecimal.ZERO);
							shipbillDetailModel.setVolume(BigDecimal.ZERO);
							shipbillDetailModel.setWeight(BigDecimal.ZERO);
						}
						tmsShipbillDetailMapper.update(shipbillDetailModel);
						BigDecimal fatherDeliveryPcs = BigDecimal.ZERO;
						fatherDeliveryPcs = fatherDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());
						totalDeliveryPcs = totalDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());
						totalDeliveryVolume = totalDeliveryVolume.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getVolume()));
						totalDeliveryWeight = totalDeliveryWeight.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getWeight()));
						// 拆分主单对应的运单明细
						String fatherShipbillIdForDetail = tmsShipbillHeaderModel.getShipbillId();
						while (ToolKits.isNotEmpty(fatherShipbillIdForDetail)) {
							fatherShipbillIdForDetail = updateFatherShipbillDetail(fatherShipbillIdForDetail, shipbillDetailModel, fatherDeliveryPcs, date, user, rsItemInfo);
						}
					}
				}
				// STD-BUG20220823 lhb 启运登记修改运单明细发货件数 20220920 end

				// 修改运单
				tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				tmsShipbillHeaderModel.setUpdateperson(user.getNickname());
				tmsShipbillHeaderModel.setUpdatetime(date);
				tmsShipbillHeaderModel.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);

				tmsShipbillHeaderModel.setTotalDeliveryPcs(totalDeliveryPcs);
				tmsShipbillHeaderModel.setTotalDeliveryWeight(totalDeliveryWeight);
				tmsShipbillHeaderModel.setTotalDeliveryVolume(totalDeliveryVolume);

				tmsShipbillHeaderModel.setTotalPcs(tmsShipbillHeaderModel.getTotalPcs().subtract(totalDeliveryPcs));
				tmsShipbillHeaderModel.setTotalVolume(tmsShipbillHeaderModel.getTotalVolume().subtract(totalDeliveryVolume));
				tmsShipbillHeaderModel.setTotalWeight(tmsShipbillHeaderModel.getTotalWeight().subtract(totalDeliveryWeight));
				tmsShipbillHeaderModel.setActualTotalPcs(tmsShipbillHeaderModel.getTotalPcs());
				tmsShipbillHeaderModel.setActualTotalVolume(tmsShipbillHeaderModel.getTotalVolume());
				tmsShipbillHeaderModel.setActualTotalWeight(tmsShipbillHeaderModel.getTotalWeight());
				tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);

				// 修改派车单明细
				Criteria criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
				Restriction r1 = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
				Restriction r2 = Restrictions.eq(TmsLoadingBillDetailModel::getEnterpriseId, user.getEnterpriseId());
				criteriaDetail.setRestriction(Restrictions.and(r1, r2));
				criteriaDetail.setOrder(Order.newInstance().desc(new String[] { "createtime" }));
				List<TmsLoadingBillDetailModel> tmsLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
				if (ToolKits.isEmpty(tmsLoadingBillDetails)) {
					throw new BizException("装车单明细【" + tmsShipbillHeaderModel.getShipbillId() + "】查询失败");
				}
				TmsLoadingBillDetailModel tmsLoadingBillDetail = tmsLoadingBillDetails.get(0);

				tmsLoadingBillDetail.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				tmsLoadingBillDetail.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);
				tmsLoadingBillDetail.setUpdateperson(user.getNickname());
				tmsLoadingBillDetail.setUpdatetime(date);

				tmsLoadingBillDetail.setTotalDeliveryPcs(totalDeliveryPcs);
				tmsLoadingBillDetail.setTotalDeliveryWeight(totalDeliveryWeight);
				tmsLoadingBillDetail.setTotalDeliveryVolume(totalDeliveryVolume);

				tmsLoadingBillDetail.setTotalPcs(tmsLoadingBillDetail.getTotalPcs().subtract(totalDeliveryPcs));
				tmsLoadingBillDetail.setTotalVolume(tmsLoadingBillDetail.getTotalVolume().subtract(totalDeliveryVolume));
				tmsLoadingBillDetail.setTotalWeight(tmsLoadingBillDetail.getTotalWeight().subtract(totalDeliveryWeight));
				tmsLoadingBillDetail.setActualTotalPcs(tmsLoadingBillDetail.getTotalPcs());
				tmsLoadingBillDetail.setActualTotalVolume(tmsLoadingBillDetail.getTotalVolume());
				tmsLoadingBillDetail.setActualTotalWeight(tmsLoadingBillDetail.getTotalWeight());
				tmsLoadingBillDetail.setVehicleDeviceId(tmsShipbillHeaderModel.getVehicleDeviceId());
				tmsLoadingBillDetail.setVehicleDeviceCode(tmsShipbillHeaderModel.getVehicleDeviceCode());
				tmsLoadingBillDetail.setVehicleDeviceName(tmsShipbillHeaderModel.getVehicleDeviceName());
				tmsLoadingBillDetail.setDepartureTemperature(tmsShipbillHeaderModel.getDepartureTemperature());
				tmsLoadingBillDetail.setContainerId(tmsShipbillHeaderModel.getContainerId());
				tmsLoadingBillDetail.setContainerCode(tmsShipbillHeaderModel.getContainerCode());
				tmsLoadingBillDetail.setContainerName(tmsShipbillHeaderModel.getContainerName());
				tmsLoadingBillDetailMapper.update(tmsLoadingBillDetail);

				Criteria criteriaTransport = Criteria.forClass(TmsShipbillTransLogModel.class);

				Map<String, Object> mapTransportLogUpdate = Maps.newHashMap();
				mapTransportLogUpdate.put("updateperson", user.getNickname());
				mapTransportLogUpdate.put("updatetime", date);
				// 启运时间
				mapTransportLogUpdate.put("departureTime", tmsShipbillHeaderTempModel.getDepartureTime());
				Restriction eq = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
				criteriaTransport.setRestriction(eq);
				// 更新订单运输记录表
				tmsShipbillTransportLogMapper.updateMapByCriteria(mapTransportLogUpdate, criteriaTransport);
				String memo = StrUtil.EMPTY;
				if (CollectionUtil.isNotEmpty(shipbillDetailModels)) {
					memo = shipbillDetailModels.stream().map(detailModel -> detailModel.getItemName() + ",计划提货件数:" + NumberUtil.null2Zero(detailModel.getPlanDeliveryPcs()).stripTrailingZeros().toPlainString() + "件,实际提货件数:" + detailModel.getPickUpPcs().stripTrailingZeros().toPlainString() + "件").collect(Collectors.joining(" "));
				}
				// 声明节点实体
				ShipbillNodeTrackingSaveNewVO shipbillNodeTrackingSaveNewVO = new ShipbillNodeTrackingSaveNewVO();
				// 声明日志实体
				ShipbillOperateLogSaveNewVO shipbillOperateLogSaveNewVO = new ShipbillOperateLogSaveNewVO();
				// 节点保存
				shipbillNodeTrackingSaveNewVO.setNodeEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QY + " " + memo);
				shipbillNodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
				shipbillNodeTrackingSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
				shipbillNodeTrackingSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
				shipbillNodeTrackingSaveNewVO.setPicUrl(departurePhoto);
				shipbillNodeTrackingSaveNewVO.setNodeDate(date);
				shipbillNodeTrackingSaveNewVO.setUserId(user.getUserid());
				shipbillNodeTrackingSaveNewVO.setUserName(user.getNickname());
				shipbillNodeTrackingSaveNewVO.setEnterpriseId(user.getEnterpriseId());
				shipbillNodeTrackingSaveNewVO.setEnterpriseName(user.getEnterpriseName());
				shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

				shipbillOperateLogSaveNewVO.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_QY + " " + memo);
				shipbillOperateLogSaveNewVO.setOldStatus(tmsShipbillHeaderModel.getStatus());
				shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
				shipbillOperateLogSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
				shipbillOperateLogSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
				shipbillOperateLogSaveNewVO.setUserId(user.getUserid());
				shipbillOperateLogSaveNewVO.setUserName(user.getNickname());
				shipbillOperateLogSaveNewVO.setEnterpriseId(user.getEnterpriseId());
				shipbillOperateLogSaveNewVO.setEnterpriseName(user.getEnterpriseName());
				shipbillOperateLogSaveNewVO.setOperateDate(date);
				shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);

				// 父运单的同步启运
				String fatherShipbillId = tmsShipbillHeaderModel.getShipbillId();
				while (ToolKits.isNotEmpty(fatherShipbillId)) {
					fatherShipbillId = fatherStartShipment(fatherShipbillId, date, user, false, shipbillNodeTrackingSaveNewVO, mapTransportLogUpdate);
				}

				// STD-BUG20220823 lhb 4649启运登记、送达确认 需要同步回写 派车单的状态 20220915 start
				// 更新调度单状态
				Restriction r3 = Restrictions.eq("loadingBillId", tmsLoadingBillDetail.getLoadingBillId());
				Restriction r4 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
				criteriaDetail.setRestriction(Restrictions.and(r3, r4));
				List<TmsLoadingBillDetailModel> tmsLoadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
				int cnt = 0;
				if (ToolKits.isNotEmpty(tmsLoadingBillDetailModels)) {
					TmsLoadingBillHeaderModel secondLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);

					// 运单，第一次调度，调度给承运商，第二次调度，承运商调度给司机或者承运商时，根据第二调度单，查询第一次的调度单
					criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
					r1 = Restrictions.eq(TmsLoadingBillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
					r2 = Restrictions.eq(TmsLoadingBillDetailModel::getEnterpriseId, user.getEnterpriseId());
					r3 = Restrictions.ne(TmsLoadingBillDetailModel::getLoadingBillId, tmsLoadingBillDetail.getLoadingBillId());
					criteriaDetail.setRestriction(Restrictions.and(r1, r2, r3));
					List<TmsLoadingBillDetailModel> firstLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);

					cnt = tmsLoadingBillDetailModels.stream().filter(t -> t.getStatus().intValue() < DataDictionaryConstant.SHIPBILL_STATUS_SD.intValue()).collect(Collectors.toList()).size();
					if (cnt == 0) {
						// 更新状态为启运
						secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);
						loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
						tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
						// 第一次调度单状态更新
						if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
							TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
							firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);
							firstLoadingBillHeaderModel.setVehicleDeviceId(tmsShipbillHeaderModel.getVehicleDeviceId());
							firstLoadingBillHeaderModel.setVehicleDeviceCode(tmsShipbillHeaderModel.getVehicleDeviceCode());
							firstLoadingBillHeaderModel.setVehicleDeviceName(tmsShipbillHeaderModel.getVehicleDeviceName());
							firstLoadingBillHeaderModel.setContainerId(tmsShipbillHeaderModel.getContainerId());
							firstLoadingBillHeaderModel.setContainerCode(tmsShipbillHeaderModel.getContainerCode());
							firstLoadingBillHeaderModel.setContainerName(tmsShipbillHeaderModel.getContainerName());
							loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
							tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
						}
					} else {
						// 更新状态为部分启运
						if (!secondLoadingBillHeaderModel.getStatus().equals(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART)) {
							secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);
							secondLoadingBillHeaderModel.setVehicleDeviceId(tmsShipbillHeaderModel.getVehicleDeviceId());
							secondLoadingBillHeaderModel.setVehicleDeviceCode(tmsShipbillHeaderModel.getVehicleDeviceCode());
							secondLoadingBillHeaderModel.setVehicleDeviceName(tmsShipbillHeaderModel.getVehicleDeviceName());
							secondLoadingBillHeaderModel.setContainerId(tmsShipbillHeaderModel.getContainerId());
							secondLoadingBillHeaderModel.setContainerCode(tmsShipbillHeaderModel.getContainerCode());
							secondLoadingBillHeaderModel.setContainerName(tmsShipbillHeaderModel.getContainerName());
							loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
							tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
							// 第一次调度单状态更新
							if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
								TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
								firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);
								firstLoadingBillHeaderModel.setVehicleDeviceId(tmsShipbillHeaderModel.getVehicleDeviceId());
								firstLoadingBillHeaderModel.setVehicleDeviceCode(tmsShipbillHeaderModel.getVehicleDeviceCode());
								firstLoadingBillHeaderModel.setVehicleDeviceName(tmsShipbillHeaderModel.getVehicleDeviceName());
								firstLoadingBillHeaderModel.setContainerId(tmsShipbillHeaderModel.getContainerId());
								firstLoadingBillHeaderModel.setContainerCode(tmsShipbillHeaderModel.getContainerCode());
								firstLoadingBillHeaderModel.setContainerName(tmsShipbillHeaderModel.getContainerName());
								loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
								tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
							}
						}
					}
				}

				TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);
				if (StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceId()) && StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceCode())) {
					String deviceId = tmsLoadingBillHeaderModel.getVehicleDeviceId().split(",")[0];
					try {
						RestMessage<DeviceByOneDTO> restMessage = maindataTmsResource.deviceGetOne(Long.valueOf(deviceId));
						DeviceByOneDTO deviceByOneDTO = restMessage.getData();
						if (BussinessConstant.E6.equals(deviceByOneDTO.getCompanyName())) {
							redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_E6_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
							log.info("易流 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
						} else if (BussinessConstant.G7.equals(deviceByOneDTO.getCompanyName())) {
							redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_G7_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
							log.info("g7 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
						}
					} catch (Exception e) {
						log.error("增加redis队列错误", e);
					}
				}

				// STD-BUG20220823 lhb 4649启运登记、送达确认 需要同步回写 派车单的状态 20220915 end
				MessageUtil.addMessage(new SendMessageDTO(MessageOrderTypeEnum.SHIP_NO.getCode(), MessageTypeEnum.START_SHIP.getCode(), Lists.newArrayList(tmsShipbillHeaderModel.getShipbillId())));
			});
			tmsShipbillHeaderTempMapper.deleteByIds(shipBillIdList.toArray(), TmsShipbillHeaderTempModel.class);
			criteria = Criteria.forClass(TmsShipbillDetailTempModel.class);
			restriction = Restrictions.in("shipbillId", shipBillIdList.toArray());
			criteria.setRestriction(restriction);
			tmsShipbillDetailTempMapper.deleteByCriteria(criteria);
		}
	}

	public void updateTmsShipbillContainer (List<ContainerTemperatureVO> temperatureVOList, String shipbillId, UserEntity user) {
		Criteria criteria = Criteria.forClass(TmsShipbillContainerTemp.class);
		Restriction r1 = Restrictions.eq(TmsShipbillContainerTemp::getEnterpriseId, user.getEnterpriseId());
		Restriction r2 = Restrictions.eq(TmsShipbillContainerTemp::getShipbillId, shipbillId);
		criteria.setRestriction(Restrictions.and(r1, r2));
		shipbillContainerTempMapper.deleteByCriteria(criteria);
		temperatureVOList.forEach(temperatureVO -> {
			TmsShipbillContainerTemp temp = new TmsShipbillContainerTemp();
			temp.setId(mainDataProxy.getCodeNumberByCode(SeriaNnumberConstant.TMS_SHIPBILL_CONTAINER_TEMP_ID));
			temp.setShipbillId(shipbillId);
			temp.setContainerId(Long.valueOf(temperatureVO.getContainerId()));
			temp.setContainerCode(temperatureVO.getContainerCode());
			temp.setContainerName(temperatureVO.getContainerName());
			temp.setDepartureTemp(temperatureVO.getTemperature());
			temp.setDepartureTempTime(DateUtil.date());
			temp.setCreatetime(DateUtil.date());
			temp.setCreateperson(user.getNickname());
			temp.setUpdatetime(DateUtil.date());
			temp.setUpdateperson(user.getNickname());
			temp.setEnterpriseId(user.getEnterpriseId());
			temp.setEnterpriseName(user.getEnterpriseName());
			shipbillContainerTempMapper.save(temp);
		});
	}

	@Override
	//@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
	public void autoStartShipmentData(WaitPickUpGoodsStartShipmentVO waitPickUpGoodsStartShipmentVO) {
		ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getShipbillIds(), "运单ID不能为空");
		ToolKits.isParamNull(waitPickUpGoodsStartShipmentVO.getDepartureTime(), "启运时间不能为空");
		log.info("运单{}自动启运开始...", JSONObject.toJSONString(waitPickUpGoodsStartShipmentVO.getShipbillIds()));
		// 当前时间
		Date date = DateUtils.nowDate();

		StringBuffer nodeEvent = new StringBuffer();
		nodeEvent.append("启运登记 备注:");
		nodeEvent.append(waitPickUpGoodsStartShipmentVO.getDepartureMemo());

		List<TmsShipbillHeaderModel> tmsShipbillHeaderMapperByIds = tmsShipbillHeaderMapper.findByIds(TmsShipbillHeaderModel.class, waitPickUpGoodsStartShipmentVO.getShipbillIds().toArray(), null);
		if (ToolKits.isEmpty(tmsShipbillHeaderMapperByIds)) {
			return;
		}
		if (tmsShipbillHeaderMapperByIds.stream().anyMatch(h->NumberUtil.isGreater(BigDecimal.valueOf(h.getStatus().intValue()), BigDecimal.valueOf(DataDictionaryConstant.SHIPBILL_STATUS_QY.intValue())))) {
			throw new PrologException("运单已启运");
		}

		Criteria criteriaTransport = Criteria.forClass(TmsShipbillTransLogModel.class);
		Map<String, Object> mapTransportLogUpdate = Maps.newHashMap();
		mapTransportLogUpdate.put("updatetime", date);
		// 启运时间
		mapTransportLogUpdate.put("departureTime", waitPickUpGoodsStartShipmentVO.getDepartureTime());
		// 签到时间
		if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getDepartureSignTime())) {
			mapTransportLogUpdate.put("departureSignTime", waitPickUpGoodsStartShipmentVO.getDepartureSignTime());
		}
		// 备注
		if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getDepartureMemo())) {
			mapTransportLogUpdate.put("departureMemo", waitPickUpGoodsStartShipmentVO.getDepartureMemo());
		}
		List<KD100VO> subscribeVOS = Lists.newArrayList();
		List<AMapVO> aMapVOS = Lists.newArrayList();
		List<ShipbillRouteDataModel> routeDataModels = Lists.newArrayList();
		UserDTO userDTO = userProxy.getUserInfo(systemUsername);
		UserEntity user = new UserEntity();
		user.setNickname(userDTO.getNickname());
		user.setUserid(Long.valueOf(userDTO.getId()));
		user.setEnterpriseId(Long.valueOf(userDTO.getEnterpriseId()));
		user.setEnterpriseName(userDTO.getEnterpriseName());
		for (TmsShipbillHeaderModel tmsShipbillHeaderModel : tmsShipbillHeaderMapperByIds) {
			// 修改运单明细的商品信息
			Criteria criteriaShipbillDetail = Criteria.forClass(TmsShipbillDetailModel.class);
			Restriction r11 = Restrictions.eq(TmsShipbillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
			Restriction r13 = Restrictions.ge(TmsShipbillDetailModel::getPcs, BigDecimal.ZERO);
			criteriaShipbillDetail.setRestriction(Restrictions.and(r11, r13));
			List<TmsShipbillDetailModel> shipbillDetailModels = tmsShipbillDetailMapper.findByCriteria(criteriaShipbillDetail);
			BigDecimal totalDeliveryPcs = new BigDecimal(0);
			BigDecimal totalDeliveryVolume = new BigDecimal(0);
			BigDecimal totalDeliveryWeight = new BigDecimal(0);

			if (ToolKits.isNotEmpty(shipbillDetailModels)) {
				for (TmsShipbillDetailModel shipbillDetailModel : shipbillDetailModels) {
					ItemCheckVO itemCheckVO = new ItemCheckVO();
					itemCheckVO.setItemId(shipbillDetailModel.getItemId());
					RestMessage<ItemCheckDTO> restMessage3 = maindataTmsResource.getItem(itemCheckVO);
					if (!restMessage3.isSuccess()) {
						throw new RuntimeException("取商品资料信息失败:" + restMessage3.getMessage());
					}
					ItemCheckDTO rsItemInfo = restMessage3.getData();

					shipbillDetailModel.setDeliveryPcs(shipbillDetailModel.getPcs());
					shipbillDetailModel.setPickUpPcs(shipbillDetailModel.getPcs());
					shipbillDetailModel.setPcs(new BigDecimal(0));
					shipbillDetailModel.setVolume(new BigDecimal(0));
					shipbillDetailModel.setWeight(new BigDecimal(0));
					tmsShipbillDetailMapper.update(shipbillDetailModel);
					BigDecimal fatherDeliveryPcs = new BigDecimal(0);

					fatherDeliveryPcs = fatherDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());

					totalDeliveryPcs = totalDeliveryPcs.add(shipbillDetailModel.getDeliveryPcs());
					totalDeliveryVolume = totalDeliveryVolume.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getVolume()));
					totalDeliveryWeight = totalDeliveryWeight.add(shipbillDetailModel.getDeliveryPcs().multiply(rsItemInfo.getWeight()));

					// 拆分主单对应的运单明细
					String fatherShipbillIdForDetail = tmsShipbillHeaderModel.getShipbillId();
					while (ToolKits.isNotEmpty(fatherShipbillIdForDetail)) {
						fatherShipbillIdForDetail = updateFatherShipbillDetail(fatherShipbillIdForDetail, shipbillDetailModel, fatherDeliveryPcs, date, user,rsItemInfo);
					}
				}
			}

			// 修改运单
			tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
			tmsShipbillHeaderModel.setUpdatetime(date);
			tmsShipbillHeaderModel.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);

			tmsShipbillHeaderModel.setTotalDeliveryPcs(totalDeliveryPcs);
			tmsShipbillHeaderModel.setTotalDeliveryWeight(totalDeliveryWeight);
			tmsShipbillHeaderModel.setTotalDeliveryVolume(totalDeliveryVolume);

			tmsShipbillHeaderModel.setTotalPcs(tmsShipbillHeaderModel.getTotalPcs().subtract(totalDeliveryPcs));
			tmsShipbillHeaderModel.setTotalVolume(tmsShipbillHeaderModel.getTotalVolume().subtract(totalDeliveryVolume));
			tmsShipbillHeaderModel.setTotalWeight(tmsShipbillHeaderModel.getTotalWeight().subtract(totalDeliveryWeight));
			tmsShipbillHeaderModel.setActualTotalPcs(tmsShipbillHeaderModel.getTotalPcs());
			tmsShipbillHeaderModel.setActualTotalVolume(tmsShipbillHeaderModel.getTotalVolume());
			tmsShipbillHeaderModel.setActualTotalWeight(tmsShipbillHeaderModel.getTotalWeight());

			if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
				tmsShipbillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
				tmsShipbillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
				tmsShipbillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
			}
			tmsShipbillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
			tmsShipbillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
			tmsShipbillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
			tmsShipbillHeaderModel.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
			tmsShipbillHeaderModel.setDepartureTemperature(waitPickUpGoodsStartShipmentVO.getDepartureTemperature());
			tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);

			// 修改派车单明细
			Criteria criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
			Restriction r1 = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
			criteriaDetail.setRestriction(Restrictions.and(r1));
			criteriaDetail.setOrder(Order.newInstance().desc(new String[] { "createtime" }));
			List<TmsLoadingBillDetailModel> tmsLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
			if (ToolKits.isEmpty(tmsLoadingBillDetails)) {
				log.info("运单{}的派车单明细不存在",tmsShipbillHeaderModel.getShipbillId());
				throw new PrologException("装车单明细【" + tmsShipbillHeaderModel.getShipbillId() + "】查询失败");
			}
			TmsLoadingBillDetailModel tmsLoadingBillDetail = tmsLoadingBillDetails.get(0);

			tmsLoadingBillDetail.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_SD);
			tmsLoadingBillDetail.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_SHIPPING);
			tmsLoadingBillDetail.setUpdatetime(date);

			tmsLoadingBillDetail.setTotalDeliveryPcs(totalDeliveryPcs);
			tmsLoadingBillDetail.setTotalDeliveryWeight(totalDeliveryWeight);
			tmsLoadingBillDetail.setTotalDeliveryVolume(totalDeliveryVolume);

			tmsLoadingBillDetail.setTotalPcs(tmsLoadingBillDetail.getTotalPcs().subtract(totalDeliveryPcs));
			tmsLoadingBillDetail.setTotalVolume(tmsLoadingBillDetail.getTotalVolume().subtract(totalDeliveryVolume));
			tmsLoadingBillDetail.setTotalWeight(tmsLoadingBillDetail.getTotalWeight().subtract(totalDeliveryWeight));
			tmsLoadingBillDetail.setActualTotalPcs(tmsLoadingBillDetail.getTotalPcs());
			tmsLoadingBillDetail.setActualTotalVolume(tmsLoadingBillDetail.getTotalVolume());
			tmsLoadingBillDetail.setActualTotalWeight(tmsLoadingBillDetail.getTotalWeight());

			if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
				tmsLoadingBillDetail.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
				tmsLoadingBillDetail.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
				tmsLoadingBillDetail.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
			}
			tmsLoadingBillDetail.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
			tmsLoadingBillDetail.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
			tmsLoadingBillDetail.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
			tmsLoadingBillDetail.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
			tmsLoadingBillDetail.setDepartureTemperature(waitPickUpGoodsStartShipmentVO.getDepartureTemperature());

			tmsLoadingBillDetailMapper.update(tmsLoadingBillDetail);

			Restriction eq = Restrictions.eq("shipbillId", tmsShipbillHeaderModel.getShipbillId());
			criteriaTransport.setRestriction(eq);
			// 更新订单运输记录表
			tmsShipbillTransportLogMapper.updateMapByCriteria(mapTransportLogUpdate, criteriaTransport);

			ShipbillNodeTrackingSaveNewVO shipbillNodeTrackingSaveNewVO = new ShipbillNodeTrackingSaveNewVO();
			ShipbillOperateLogSaveNewVO shipbillOperateLogSaveNewVO = new ShipbillOperateLogSaveNewVO();

			// 运单节点保存
			shipbillNodeTrackingSaveNewVO.setNodeDate(date);
			shipbillNodeTrackingSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
			shipbillNodeTrackingSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
			shipbillNodeTrackingSaveNewVO.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
			shipbillNodeTrackingSaveNewVO.setNodeEvent(nodeEvent.toString());
			shipbillNodeTrackingSaveNewVO.setUserId(Long.valueOf(userDTO.getId()));
			shipbillNodeTrackingSaveNewVO.setUserName(userDTO.getUsername());
			shipbillNodeTrackingSaveNewVO.setEnterpriseId(tmsLoadingBillDetail.getEnterpriseId());
			shipbillNodeTrackingSaveNewVO.setEnterpriseName(tmsLoadingBillDetail.getEnterpriseName());
			shipbillNodeTrackingSaveNewVO.setPicUrl(waitPickUpGoodsStartShipmentVO.getDeparturePhoto());
			shipbillNodeTrackingService.addShipbillNodeTrackingNewData(shipbillNodeTrackingSaveNewVO);

			// 运单日志保存
			shipbillOperateLogSaveNewVO.setShipbillId(tmsShipbillHeaderModel.getShipbillId());
			shipbillOperateLogSaveNewVO.setShipbillNo(tmsShipbillHeaderModel.getShipbillId());
			shipbillOperateLogSaveNewVO.setOperateEvent(nodeEvent.toString() );
			shipbillOperateLogSaveNewVO.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_ZX_CONFIRM);
			shipbillOperateLogSaveNewVO.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_QY);
			shipbillOperateLogSaveNewVO.setOperateDate(date);

			shipbillOperateLogSaveNewVO.setUserId(Long.valueOf(userDTO.getId()));
			shipbillOperateLogSaveNewVO.setUserName(userDTO.getUsername());
			shipbillOperateLogSaveNewVO.setEnterpriseId(tmsLoadingBillDetail.getEnterpriseId());
			shipbillOperateLogSaveNewVO.setEnterpriseName(tmsLoadingBillDetail.getEnterpriseName());
			shipbillOperateLogService.addShipbillOperateLogNewData(shipbillOperateLogSaveNewVO);

			// 父运单的同步启运
			String fatherShipbillId = tmsShipbillHeaderModel.getShipbillId();
			while (ToolKits.isNotEmpty(fatherShipbillId)) {
				fatherShipbillId = fatherStartShipment(fatherShipbillId, date, user, false, shipbillNodeTrackingSaveNewVO, mapTransportLogUpdate);
			}

			// 更新调度单状态
			Restriction r3 = Restrictions.eq("loadingBillId", tmsLoadingBillDetail.getLoadingBillId());
			criteriaDetail.setRestriction(Restrictions.and(r3));
			List<TmsLoadingBillDetailModel> tmsLoadingBillDetailModels = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);
			int cnt = 0;
			if (ToolKits.isNotEmpty(tmsLoadingBillDetailModels)) {
				TmsLoadingBillHeaderModel secondLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);

				// 运单，第一次调度，调度给承运商，第二次调度，承运商调度给司机或者承运商时，根据第二调度单，查询第一次的调度单
				criteriaDetail = Criteria.forClass(TmsLoadingBillDetailModel.class);
				r1 = Restrictions.eq(TmsLoadingBillDetailModel::getShipbillId, tmsShipbillHeaderModel.getShipbillId());
				r3 = Restrictions.ne(TmsLoadingBillDetailModel::getLoadingBillId, tmsLoadingBillDetail.getLoadingBillId());
				criteriaDetail.setRestriction(Restrictions.and(r1, r3));
				List<TmsLoadingBillDetailModel> firstLoadingBillDetails = tmsLoadingBillDetailMapper.findByCriteria(criteriaDetail);

				cnt = tmsLoadingBillDetailModels.stream().filter(t -> t.getStatus().intValue() < DataDictionaryConstant.SHIPBILL_STATUS_SD.intValue()).collect(Collectors.toList()).size();
				if (cnt == 0) {
					// 更新状态为启运
					secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);
					loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
					tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
					// 第一次调度单状态更新
					if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
						TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
						firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY);

						if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
							firstLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
							firstLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
							firstLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
						}
						firstLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
						firstLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
						firstLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
						loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
						tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
					}
				} else {
					// 更新状态为部分启运
					if (!secondLoadingBillHeaderModel.getStatus().equals(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART)) {
						if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
							secondLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
							secondLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
							secondLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
						}
						secondLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
						secondLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
						secondLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
						secondLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);
						loadingBillService.setLoadingBillDelivery(secondLoadingBillHeaderModel);
						tmsLoadingBillHeaderMapper.update(secondLoadingBillHeaderModel);
						// 第一次调度单状态更新
						if (ToolKits.isNotEmpty(firstLoadingBillDetails)) {
							TmsLoadingBillHeaderModel firstLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(firstLoadingBillDetails.get(0).getLoadingBillId(), TmsLoadingBillHeaderModel.class);
							firstLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_QY_PART);

							if (ToolKits.isNotEmpty(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName())) {
								firstLoadingBillHeaderModel.setVehicleDeviceId(waitPickUpGoodsStartShipmentVO.getVehicleDeviceId());
								firstLoadingBillHeaderModel.setVehicleDeviceCode(waitPickUpGoodsStartShipmentVO.getVehicleDeviceCode());
								firstLoadingBillHeaderModel.setVehicleDeviceName(waitPickUpGoodsStartShipmentVO.getVehicleDeviceName());
							}
							firstLoadingBillHeaderModel.setContainerId(waitPickUpGoodsStartShipmentVO.getContainerId());
							firstLoadingBillHeaderModel.setContainerCode(waitPickUpGoodsStartShipmentVO.getContainerCode());
							firstLoadingBillHeaderModel.setContainerName(waitPickUpGoodsStartShipmentVO.getContainerName());
							loadingBillService.setLoadingBillDelivery(firstLoadingBillHeaderModel);
							tmsLoadingBillHeaderMapper.update(firstLoadingBillHeaderModel);
						}
					}
				}
			}

			TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = tmsLoadingBillHeaderMapper.findById(tmsLoadingBillDetail.getLoadingBillId(), TmsLoadingBillHeaderModel.class);
			if (StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceId()) && StrUtil.isNotBlank(tmsLoadingBillHeaderModel.getVehicleDeviceCode())) {
				String deviceId = tmsLoadingBillHeaderModel.getVehicleDeviceId().split(",")[0];
				try {
					RestMessage<DeviceByOneDTO> restMessage = maindataTmsResource.deviceGetOne(Long.valueOf(deviceId));
					DeviceByOneDTO deviceByOneDTO = restMessage.getData();
					if (BussinessConstant.E6.equals(deviceByOneDTO.getCompanyName())) {
						redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_E6_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
						log.info("易流 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
					} else if (BussinessConstant.G7.equals(deviceByOneDTO.getCompanyName())) {
						redisTemplate.opsForSet().add(RedisConstant.PULL_GPS_DEVICE_G7_KEY, tmsLoadingBillHeaderModel.getVehicleDeviceCode());
						log.info("g7 add loadingBillId={},vehicle={},deviceCode={}", tmsLoadingBillDetail.getLoadingBillId(), tmsLoadingBillHeaderModel.getVehiclePlateNumber(), deviceByOneDTO.getCode());
					}
				} catch (Exception e) {
					log.error("增加redis队列错误", e);
				}
			}
			List<String> expressNumbers = Arrays.stream(tmsShipbillHeaderModel.getExpressNumber().split(",")).collect(Collectors.toList());
			expressNumbers.stream().forEach(expressNo -> {
				if (DataDictionaryConstant.CARRIERS_TYPE_EXPRESS.equals(tmsShipbillHeaderModel.getCarriersType())) {
					KD100VO kd100VO = new KD100VO();
					kd100VO.setCarriersCode(tmsShipbillHeaderModel.getCarriersCode());
					kd100VO.setExpressNumber(expressNo);
					kd100VO.setShipbillNo(tmsShipbillHeaderModel.getShipbillNo());
					kd100VO.setPhone(getPhone(tmsShipbillHeaderModel));
					subscribeVOS.add(kd100VO);
				} else if (DataDictionaryConstant.CARRIERS_TYPE_LOG.equals(tmsShipbillHeaderModel.getCarriersType())) {
					AMapVO aMapVO = new AMapVO();
					aMapVO.setCarriersCode(tmsShipbillHeaderModel.getCarriersCode());
					aMapVO.setExpressNumber(expressNo);
					aMapVO.setDepartureTime(waitPickUpGoodsStartShipmentVO.getDepartureTime());
					aMapVO.setShipperLongitude(tmsShipbillHeaderModel.getShipperLongitude());
					aMapVO.setShipperLatitude(tmsShipbillHeaderModel.getShipperLatitude());
					aMapVO.setConsigneeLongitude(tmsShipbillHeaderModel.getConsigneeLongitude());
					aMapVO.setConsigneeLatitude(tmsShipbillHeaderModel.getConsigneeLatitude());
					aMapVOS.add(aMapVO);
				}
			});
			if (ObjectUtil.isNotEmpty(expressNumbers)) {
				List<ShipbillRouteDataModel> dataModels = getInitRote(expressNumbers,tmsShipbillHeaderModel.getCarriersType(),tmsShipbillHeaderModel.getCarriersCode());
				if (ObjectUtil.isNotEmpty(dataModels)) {
					routeDataModels.addAll(dataModels);
				}
			}

		}
		if (ToolKits.isNotEmpty(subscribeVOS)) {
			log.info("订阅数据{}", JSONObject.toJSONString(subscribeVOS));
			try {
				kd100Service.pickUpSubscribe(subscribeVOS);
				kd100Service.saveGps(routeDataModels);
			} catch (Exception e) {
				throw new PluginException("订阅失败 " + e.getMessage());
			}
		} else if (ToolKits.isNotEmpty(aMapVOS)) {
			log.info("虚拟坐标生成数据{}", JSONObject.toJSONString(aMapVOS));
			kd100Service.saveGps(routeDataModels);
			aMapService.getDrivingRouting(aMapVOS);
		}
	}

	private List<ShipbillRouteDataModel> getInitRote(List<String> expressNumbers,Integer carriersType,String carriersCode) {
		List<ShipbillRouteDataModel> dataModels = Lists.newArrayList();
		for (String expressNumber:expressNumbers) {
			ShipbillRouteDataModel routeDataModel = new ShipbillRouteDataModel();
			RestMessage<String> restMessageDetailId = maindataTmsResource.getCodeNumberByCode(SeriaNnumberConstant.SHIPBILL_ROUTE_DATA_ID, "L");
			if (!restMessageDetailId.isSuccess()) {
				continue;
			}
			Date date = DateUtil.date();
			String id = restMessageDetailId.getData();
			routeDataModel.setId(id);
			routeDataModel.setIscheck("0");
			routeDataModel.setLatitude(init_latitude);
			routeDataModel.setLongitude(init_longitude);
			routeDataModel.setState("0");
			routeDataModel.setAreaName("江西青牛医药有限公司");
			routeDataModel.setCarriersCode(carriersCode);
			routeDataModel.setExpressNumber(expressNumber);
			routeDataModel.setCarriersType(carriersType);
			routeDataModel.setRouteDate(DateUtil.format(date, DatePattern.NORM_DATETIME_PATTERN));
			routeDataModel.setRouteTime(date);
			routeDataModel.setRouteContext("江西青牛医药有限公司");
			routeDataModel.setCreatetime(DateUtil.date());
			dataModels.add(routeDataModel);
		}
		return dataModels;
	}
}
