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

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

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

import com.google.common.collect.Lists;
import com.prolog.common.util.DateUtils;
import com.prolog.common.util.ToolKits;
import com.prolog.framework.core.exception.ParameterException;
import com.prolog.framework.core.exception.PrologException;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.core.restriction.Criteria;
import com.prolog.framework.core.restriction.Order;
import com.prolog.framework.core.restriction.Restriction;
import com.prolog.framework.core.restriction.Restrictions;
import com.prolog.framework.dao.util.PageUtils;
import com.prolog.product.core.framework.entity.UserEntity;
import com.prolog.product.core.framework.util.PlgFxUsrUtils;
import com.prolog.rdc.tms.constant.BussinessConstant;
import com.prolog.rdc.tms.constant.DataDictionaryConstant;
import com.prolog.rdc.tms.constant.SeriaNnumberConstant;
import com.prolog.rdc.tms.constant.StatusConstant;
import com.prolog.rdc.tms.dao.mapper.TmsApprovalBusinessMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseCargoOwnerMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseCargoOwnerTempMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseCustomerMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseItemMapper;
import com.prolog.rdc.tms.dao.mapper.TmsBaseProviderMapper;
import com.prolog.rdc.tms.model.dto.IntfErrorLogDTO;
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.CargoOwnerApprovalQueryDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerByEncodingNameDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerByIdsDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerCheckDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerDetailForApprovalDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerPagingQueryDTO;
import com.prolog.rdc.tms.model.dto.basicData.CargoOwnerPopupDTO;
import com.prolog.rdc.tms.model.dto.basicData.UserCargoOwnerPopupDTO;
import com.prolog.rdc.tms.model.entity.line.TmsApprovalBusinessModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseCargoOwnerModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseCargoOwnerTempModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseCustomerModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseItemModel;
import com.prolog.rdc.tms.model.entity.line.TmsBaseProviderModel;
import com.prolog.rdc.tms.model.vo.ApprovalBusinessNodeVO;
import com.prolog.rdc.tms.model.vo.IntfCargoOwnerSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ApprovalOpenVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerAddVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerApprovalQueryVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerApprovalVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerBatchDeleteVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerByCargoOwnerIdVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerByEncodingNameVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerByIdVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerByIdsVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerCheckVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerCopyVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerGeocodingVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerModifyVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerPagingQueryVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerPopupVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerProcessApprovalVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerSummitApprovalVO;
import com.prolog.rdc.tms.model.vo.basicData.CargoOwnerWhetherEnableVO;
import com.prolog.rdc.tms.model.vo.basicData.UserCargoOwnerPopupVO;
import com.prolog.rdc.tms.service.ApprovalBusinessService;
import com.prolog.rdc.tms.service.SysCodeengineService;
import com.prolog.rdc.tms.service.SysRefdatadService;
import com.prolog.rdc.tms.service.basicData.CargoOwnerService;
import com.prolog.rdc.tms.util.PublicMethods;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * 基础数据-货主管理实现层
 *
 * @author :fanzw
 * @version :1.0.0
 * @className :BaseCargoOwnerServiceImpl
 * @creationTime :2022/02/25
 * @description :
 * @modifier :fanzw
 * @modifyTime :2022/02/25
 * @reviseRemarks:
 */
@Slf4j
@Service
public class CargoOwnerServiceImpl implements CargoOwnerService {

	@Autowired
	private TmsBaseCargoOwnerMapper tmsBaseCargoOwnerMapper;

	@Autowired
	private SysCodeengineService sysCodeengineService;

	@Autowired
	private SysRefdatadService sysRefdatadService;

	@Autowired
	private TmsBaseItemMapper tmsBaseItemMapper;

	@Autowired
	private TmsBaseCustomerMapper tmsBaseCustomerMapper;

	@Autowired
	private TmsBaseProviderMapper tmsBaseProviderMapper;

	@Autowired
	private TmsApprovalBusinessMapper tmsApprovalBussinessMapper;

	@Autowired
	private ApprovalBusinessService approvalBusinessService;

	@Autowired
	private TmsBaseCargoOwnerTempMapper tmsBaseCargoOwnerTempMapper;

	/**
	 * 货主资料分页查询
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<CargoOwnerPagingQueryDTO> pageCargoOwnerData(CargoOwnerPagingQueryVO cargoOwnerPagingQueryVO) {
		ToolKits.isParamNull(cargoOwnerPagingQueryVO, "货主资料查询请求不为空");
		ToolKits.isParamNull(cargoOwnerPagingQueryVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(cargoOwnerPagingQueryVO.getPageSize(), "页数不为空");

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

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

		// 货主状态
		List<Map<String, Object>> restMessage = sysRefdatadService.getDropDownById(DataDictionaryConstant.MAINDATA_STATUS, null, null, null);
		// 开户行
		List<Map<String, Object>> restMessage2 = sysRefdatadService.getDropDownById(DataDictionaryConstant.BANK, null, null, null);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		cargoOwnerPagingQueryVO.setEnterpriseId(user.getEnterpriseId());
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				cargoOwnerPagingQueryVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerPagingQueryVO.setIsDept("Y");
				cargoOwnerPagingQueryVO.setIsData("N");
			} else {
				cargoOwnerPagingQueryVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerPagingQueryVO.setCargoOwnerIds(user.getConsignors().stream().toArray(Long[]::new));
				cargoOwnerPagingQueryVO.setIsDept("N");
				cargoOwnerPagingQueryVO.setIsData("Y");
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			cargoOwnerPagingQueryVO.setCargoOwnerIds(cargoOwners);
			cargoOwnerPagingQueryVO.setIsDept(null);
			cargoOwnerPagingQueryVO.setIsData("Y");
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		PageUtils.startPage(cargoOwnerPagingQueryVO.getPageNum(), cargoOwnerPagingQueryVO.getPageSize());
		List<CargoOwnerPagingQueryDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.pageCargoOwnerData(cargoOwnerPagingQueryVO);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end
		for (CargoOwnerPagingQueryDTO tmsBaseCargoOwnerModel : tmsBaseCargoOwnerModels) {
			// 响应对象
			CargoOwnerPagingQueryDTO cargoOwnerPagingQueryDTO = new CargoOwnerPagingQueryDTO();
			BeanUtils.copyProperties(tmsBaseCargoOwnerModel, cargoOwnerPagingQueryDTO);
			cargoOwnerPagingQueryDTO.setStatusName(PublicMethods.change(restMessage, String.valueOf(cargoOwnerPagingQueryDTO.getStatus())));
			cargoOwnerPagingQueryDTO.setBankName(PublicMethods.change(restMessage2, String.valueOf(cargoOwnerPagingQueryDTO.getBank())));
			cargoOwnerPagingQueryDTOs.add(cargoOwnerPagingQueryDTO);
		}
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		Page<CargoOwnerPagingQueryDTO> page = PageUtils.getPage(cargoOwnerPagingQueryDTOs);
		if (tmsBaseCargoOwnerModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<CargoOwnerPagingQueryDTO> p0 = (com.github.pagehelper.Page<CargoOwnerPagingQueryDTO>) tmsBaseCargoOwnerModels;
			page.setPageCount(p0.getPages());
			page.setPageNum(p0.getPageNum());
			page.setPageSize(p0.getPageSize());
			page.setTotalCount(p0.getTotal());
			page.setStartRow(p0.getStartRow());
			page.setEndRow(p0.getEndRow());
		}
		return page;
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end
	}

	/**
	 * 货主资料查看
	 */
	@Override
	public CargoOwnerCheckDTO getCargoOwnerData(CargoOwnerCheckVO cargoOwnerCheckVO) {
		ToolKits.isParamNull(cargoOwnerCheckVO, "货主资料查看请求不为空");
		ToolKits.isParamNull(cargoOwnerCheckVO.getCargoOwnerId(), "货主ID不为空");

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

		// 货主状态
		List<Map<String, Object>> restMessage = sysRefdatadService.getDropDownById(DataDictionaryConstant.MAINDATA_STATUS, null, null, null);

		Criteria criteria = Criteria.forClass(TmsBaseCargoOwnerModel.class);
		Restriction r1 = Restrictions.eq("cargoOwnerId", cargoOwnerCheckVO.getCargoOwnerId());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseCargoOwnerModel> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.findByCriteria(criteria);

		Assert.isTrue(tmsBaseCargoOwnerModels.size() == 1, "货主ID【" + cargoOwnerCheckVO.getCargoOwnerId() + "】存在重复数据，查询失败");

		// 货主资料对象
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerModels.get(0);

		// 响应对象
		CargoOwnerCheckDTO cargoOwnerCheckDTO = new CargoOwnerCheckDTO();
		BeanUtils.copyProperties(tmsBaseCargoOwnerModel, cargoOwnerCheckDTO);
		cargoOwnerCheckDTO.setStatusName(PublicMethods.change(restMessage, String.valueOf(cargoOwnerCheckDTO.getStatus())));

		return cargoOwnerCheckDTO;
	}

	/**
	 * 货主资料弹窗
	 */
	@Override
	public Page<CargoOwnerPopupDTO> popupCargoOwnerData(CargoOwnerPopupVO cargoOwnerPopupVO) {
		ToolKits.isParamNull(cargoOwnerPopupVO, "货主资料弹窗请求不为空");
		ToolKits.isParamNull(cargoOwnerPopupVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(cargoOwnerPopupVO.getPageSize(), "页数不为空");

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

		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		cargoOwnerPopupVO.setEnterpriseId(user.getEnterpriseId());
		cargoOwnerPopupVO.setStatus(StatusConstant.STATUS_ENABLE);
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			cargoOwnerPopupVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				cargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				cargoOwnerPopupVO.setIsData("Y");
				cargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerPopupVO.setCargoOwnerIds(user.getConsignors().stream().toArray(Long[]::new));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			cargoOwnerPopupVO.setIsData("Y");
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			cargoOwnerPopupVO.setCargoOwnerIds(cargoOwners);
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		PageUtils.startPage(cargoOwnerPopupVO.getPageNum(), cargoOwnerPopupVO.getPageSize());
		List<CargoOwnerPopupDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.popupCargoOwnerData(cargoOwnerPopupVO);
		return PageUtils.getPage(tmsBaseCargoOwnerModels);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end
	}

	/**
	 * 货主资料弹窗
	 *
	 * @param cargoOwnerPopupVO
	 * @return
	 */
	public Page<CargoOwnerPopupDTO> popupCargoOwnerDataByName(CargoOwnerPopupVO cargoOwnerPopupVO) {
		ToolKits.isParamNull(cargoOwnerPopupVO, "货主资料弹窗请求不为空");
		ToolKits.isParamNull(cargoOwnerPopupVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(cargoOwnerPopupVO.getPageSize(), "页数不为空");

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

		cargoOwnerPopupVO.setEnterpriseId(user.getEnterpriseId());
		cargoOwnerPopupVO.setStatus(StatusConstant.STATUS_ENABLE);
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			cargoOwnerPopupVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				cargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				cargoOwnerPopupVO.setIsData("Y");
				cargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerPopupVO.setCargoOwnerIds(user.getConsignors().stream().toArray(Long[]::new));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			cargoOwnerPopupVO.setIsData("Y");
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			cargoOwnerPopupVO.setCargoOwnerIds(cargoOwners);
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		PageUtils.startPage(cargoOwnerPopupVO.getPageNum(), cargoOwnerPopupVO.getPageSize());
		List<CargoOwnerPopupDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.popupCargoOwnerDataByName(cargoOwnerPopupVO);
		return PageUtils.getPage(tmsBaseCargoOwnerModels);
	}

	/**
	 * 用户货主资料弹窗
	 */
	@Override
	public Page<UserCargoOwnerPopupDTO> popupUserCargoOwnerData(UserCargoOwnerPopupVO userCargoOwnerPopupVO) {
		ToolKits.isParamNull(userCargoOwnerPopupVO, "货主资料弹窗请求不为空");
		ToolKits.isParamNull(userCargoOwnerPopupVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(userCargoOwnerPopupVO.getPageSize(), "页数不为空");

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

		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		userCargoOwnerPopupVO.setEnterpriseId(user.getEnterpriseId());
		userCargoOwnerPopupVO.setStatus(StatusConstant.STATUS_ENABLE);
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			userCargoOwnerPopupVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				userCargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				userCargoOwnerPopupVO.setIsData("Y");
				userCargoOwnerPopupVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				userCargoOwnerPopupVO.setCargoOwnerIds(user.getConsignors().stream().toArray(Long[]::new));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			userCargoOwnerPopupVO.setCargoOwnerIds(cargoOwners);
			userCargoOwnerPopupVO.setIsData("Y");
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		// 分页
		PageUtils.startPage(userCargoOwnerPopupVO.getPageNum(), userCargoOwnerPopupVO.getPageSize());
		List<UserCargoOwnerPopupDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.popupUserCargoOwnerData(userCargoOwnerPopupVO);
		for (UserCargoOwnerPopupDTO tmsBaseCargoOwnerModel : tmsBaseCargoOwnerModels) {
			// 响应对象
			tmsBaseCargoOwnerModel.setId(tmsBaseCargoOwnerModel.getConsignorId());
		}

		return PageUtils.getPage(tmsBaseCargoOwnerModels);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end
	}

	/**
	 * 根据货主ID集合分页查询
	 */
	@SuppressWarnings("resource")
	@Override
	public Page<CargoOwnerByIdsDTO> pageCargoOwnerByIdsData(CargoOwnerByIdsVO cargoOwnerByIdsVO) {
		ToolKits.isParamNull(cargoOwnerByIdsVO, "根据货主ID集合分页查询请求不为空");
		ToolKits.isParamNull(cargoOwnerByIdsVO.getPageNum(), "页码不为空");
		ToolKits.isParamNull(cargoOwnerByIdsVO.getPageSize(), "页数不为空");

		if (ToolKits.isNotEmpty(cargoOwnerByIdsVO.getCargoOwnerIds())) {
			cargoOwnerByIdsVO.setCargoOwnerIdVOs(cargoOwnerByIdsVO.getCargoOwnerIds().stream().map(CargoOwnerByCargoOwnerIdVO::getCargoOwnerId).toArray(Long[]::new));
		}
		UserEntity user = PlgFxUsrUtils.getUserEntity();
		ToolKits.isParamNull(user, "当前人员没有操作权限");

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

		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		cargoOwnerByIdsVO.setEnterpriseId(user.getEnterpriseId());
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			cargoOwnerByIdsVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				cargoOwnerByIdsVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				cargoOwnerByIdsVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerByIdsVO.setCargoOwnerIdsSql(user.getConsignors().stream().toArray(Long[]::new));
				cargoOwnerByIdsVO.setIsData("Y");
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			cargoOwnerByIdsVO.setCargoOwnerIdsSql(cargoOwners);
			cargoOwnerByIdsVO.setIsData("Y");
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}
		// 分页
		PageUtils.startPage(cargoOwnerByIdsVO.getPageNum(), cargoOwnerByIdsVO.getPageSize());
		List<CargoOwnerByIdsDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.pageCargoOwnerByIdsData(cargoOwnerByIdsVO);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end
		for (CargoOwnerByIdsDTO tmsBaseCargoOwnerModel : tmsBaseCargoOwnerModels) {
			// 响应对象
			CargoOwnerByIdsDTO cargoOwnerByIdsDTO = new CargoOwnerByIdsDTO();
			BeanUtils.copyProperties(tmsBaseCargoOwnerModel, cargoOwnerByIdsDTO);
			cargoOwnerByIdsDTOs.add(cargoOwnerByIdsDTO);
		}

		Page<CargoOwnerByIdsDTO> page = PageUtils.getPage(cargoOwnerByIdsDTOs);
		if (tmsBaseCargoOwnerModels instanceof com.github.pagehelper.Page) {
			com.github.pagehelper.Page<CargoOwnerByIdsDTO> p0 = (com.github.pagehelper.Page<CargoOwnerByIdsDTO>) tmsBaseCargoOwnerModels;
			page.setPageCount(p0.getPages());
			page.setPageNum(p0.getPageNum());
			page.setPageSize(p0.getPageSize());
			page.setTotalCount(p0.getTotal());
			page.setStartRow(p0.getStartRow());
			page.setEndRow(p0.getEndRow());
		}
		return page;
	}

	/**
	 * 货主资料新增
	 */
	@Override
	public void addCargoOwnerData(CargoOwnerAddVO cargoOwnerAddVO) {
		ToolKits.isParamNull(cargoOwnerAddVO, "货主资料新增请求不为空");
		ToolKits.isParamNull(cargoOwnerAddVO.getCargoOwnerCode(), "货主编码不为空");
		ToolKits.isParamNull(cargoOwnerAddVO.getCargoOwnerName(), "货主名称不为空");
		ToolKits.isParamNull(cargoOwnerAddVO.getDepartmentId(), "所属部门ID不为空");
		ToolKits.isParamNull(cargoOwnerAddVO.getDepartmentCode(), "所属部门编码不为空");
		ToolKits.isParamNull(cargoOwnerAddVO.getDepartmentName(), "所属部门名称不为空");

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

		// 判断货主编码是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseCargoOwnerModel.class, "cargoOwnerCode", cargoOwnerAddVO.getCargoOwnerCode(), "enterpriseId", plgFxUser.getEnterpriseId(), tmsBaseCargoOwnerMapper, "货主编码已存在");
		// 判断货主名称是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseCargoOwnerModel.class, "cargoOwnerName", cargoOwnerAddVO.getCargoOwnerName(), "enterpriseId", plgFxUser.getEnterpriseId(), tmsBaseCargoOwnerMapper, "货主名称已存在");

		// 货主ID
		String cargoOwnerId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.CARGO_OWNER_ID, "L");
		ToolKits.isParamNull(cargoOwnerId, "货主ID生成失败");

		// 当前日期
		Date date = DateUtil.date();

		// 货主资料对象
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = new TmsBaseCargoOwnerModel();
		BeanUtils.copyProperties(cargoOwnerAddVO, tmsBaseCargoOwnerModel);
		tmsBaseCargoOwnerModel.setCargoOwnerId(Long.valueOf(cargoOwnerId));
		tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_CREATE);
		tmsBaseCargoOwnerModel.setEnterpriseId(plgFxUser.getEnterpriseId());
		tmsBaseCargoOwnerModel.setEnterpriseName(plgFxUser.getEnterpriseName());
		tmsBaseCargoOwnerModel.setCreateperson(plgFxUser.getNickname());
		tmsBaseCargoOwnerModel.setCreatetime(date);
		tmsBaseCargoOwnerModel.setUpdateperson(plgFxUser.getNickname());
		tmsBaseCargoOwnerModel.setUpdatetime(date);
		tmsBaseCargoOwnerMapper.save(tmsBaseCargoOwnerModel);
	}

	/**
	 * 货主资料复制
	 */
	@Override
	public void copyCargoOwnerData(CargoOwnerCopyVO cargoOwnerCopyVO) {
		ToolKits.isParamNull(cargoOwnerCopyVO, "货主资料复制请求不为空");
		ToolKits.isParamNull(cargoOwnerCopyVO.getCargoOwnerCode(), "货主编码不为空");
		ToolKits.isParamNull(cargoOwnerCopyVO.getCargoOwnerName(), "货主名称不为空");
		ToolKits.isParamNull(cargoOwnerCopyVO.getDepartmentId(), "所属部门ID不为空");
		ToolKits.isParamNull(cargoOwnerCopyVO.getDepartmentCode(), "所属部门编码不为空");
		ToolKits.isParamNull(cargoOwnerCopyVO.getDepartmentName(), "所属部门名称不为空");

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

		// 判断货主编码是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseCargoOwnerModel.class, "cargoOwnerCode", cargoOwnerCopyVO.getCargoOwnerCode(), "enterpriseId", plgFxUser.getEnterpriseId(), tmsBaseCargoOwnerMapper, "货主编码已存在");
		// 判断货主名称是否已存在
		PublicMethods.isThereAnyinformation(TmsBaseCargoOwnerModel.class, "cargoOwnerName", cargoOwnerCopyVO.getCargoOwnerName(), "enterpriseId", plgFxUser.getEnterpriseId(), tmsBaseCargoOwnerMapper, "货主名称已存在");

		// 货主ID
		String cargoOwnerId = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.CARGO_OWNER_ID, "L");
		ToolKits.isParamNull(cargoOwnerId, "货主ID生成失败");

		// 当前日期
		Date date = DateUtil.date();

		// 货主资料对象
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = new TmsBaseCargoOwnerModel();
		BeanUtils.copyProperties(cargoOwnerCopyVO, tmsBaseCargoOwnerModel);
		tmsBaseCargoOwnerModel.setCargoOwnerId(Long.valueOf(cargoOwnerId));
		tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_CREATE);
		tmsBaseCargoOwnerModel.setEnterpriseId(plgFxUser.getEnterpriseId());
		tmsBaseCargoOwnerModel.setEnterpriseName(plgFxUser.getEnterpriseName());
		tmsBaseCargoOwnerModel.setCreateperson(plgFxUser.getNickname());
		tmsBaseCargoOwnerModel.setCreatetime(date);
		tmsBaseCargoOwnerModel.setUpdateperson(plgFxUser.getNickname());
		tmsBaseCargoOwnerModel.setUpdatetime(date);
		tmsBaseCargoOwnerMapper.save(tmsBaseCargoOwnerModel);
	}

	/**
	 * 货主资料修改
	 */
	@Override
	public void modifyCargoOwnerData(CargoOwnerModifyVO cargoOwnerModifyVO) {
		ToolKits.isParamNull(cargoOwnerModifyVO, "货主资料修改请求不为空");
		ToolKits.isParamNull(cargoOwnerModifyVO.getCargoOwnerId(), "货主ID不为空");
		ToolKits.isParamNull(cargoOwnerModifyVO.getDepartmentId(), "所属部门ID不为空");
		ToolKits.isParamNull(cargoOwnerModifyVO.getDepartmentCode(), "所属部门编码不为空");
		ToolKits.isParamNull(cargoOwnerModifyVO.getDepartmentName(), "所属部门名称不为空");

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

		// 根据ID查询货主资料
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerModifyVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主ID【" + cargoOwnerModifyVO.getCargoOwnerId() + "】不存在");

		Assert.isTrue(tmsBaseCargoOwnerModel.getStatus() == StatusConstant.STATUS_ENABLE, "货主已停用不能修改");
		// 货主资料在审核中，不能修改
		Criteria criteria = Criteria.forClass(TmsApprovalBusinessModel.class);
		Restriction r1 = ToolKits.isEmpty(tmsBaseCargoOwnerModel.getCargoOwnerId()) ? null : Restrictions.eq("approvalObjectId", tmsBaseCargoOwnerModel.getCargoOwnerId());
		Restriction r2 = ToolKits.isEmpty(tmsBaseCargoOwnerModel.getCargoOwnerCode()) ? null : Restrictions.eq("approvalObjectCode", tmsBaseCargoOwnerModel.getCargoOwnerCode());
		Restriction r3 = ToolKits.isEmpty(tmsBaseCargoOwnerModel.getCargoOwnerName()) ? null : Restrictions.like("approvalObjectName", "%" + tmsBaseCargoOwnerModel.getCargoOwnerName() + "%");
		Restriction r4 = Restrictions.ne("status", DataDictionaryConstant.APPROVAL_BUSINESS_STATUS_INVALID);
		Restriction r5 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2, r3, r4, r5));
		criteria.setOrder(Order.newInstance().desc(new String[] { "updatetime" }));

		List<TmsApprovalBusinessModel> tmsApprovalBussinessModels = tmsApprovalBussinessMapper.findByCriteria(criteria);
		Assert.isTrue(ToolKits.isEmpty(tmsApprovalBussinessModels) || tmsApprovalBussinessModels.size() == 0, "货主资料审核中，不能修改");

		tmsBaseCargoOwnerModel.setCargoOwnerShortName(cargoOwnerModifyVO.getCargoOwnerShortName());
		tmsBaseCargoOwnerModel.setContact(cargoOwnerModifyVO.getContact());
		tmsBaseCargoOwnerModel.setPhoneNumber(cargoOwnerModifyVO.getPhoneNumber());
		tmsBaseCargoOwnerModel.setLandlineNumber(cargoOwnerModifyVO.getLandlineNumber());
		tmsBaseCargoOwnerModel.setMail(cargoOwnerModifyVO.getMail());
		tmsBaseCargoOwnerModel.setPostCode(cargoOwnerModifyVO.getPostCode());
		tmsBaseCargoOwnerModel.setProvince(cargoOwnerModifyVO.getProvince());
		tmsBaseCargoOwnerModel.setProvinceName(cargoOwnerModifyVO.getProvinceName());
		tmsBaseCargoOwnerModel.setCity(cargoOwnerModifyVO.getCity());
		tmsBaseCargoOwnerModel.setCityName(cargoOwnerModifyVO.getCityName());
		tmsBaseCargoOwnerModel.setDistrict(cargoOwnerModifyVO.getDistrict());
		tmsBaseCargoOwnerModel.setDistrictName(cargoOwnerModifyVO.getDistrictName());
		tmsBaseCargoOwnerModel.setAddress(cargoOwnerModifyVO.getAddress());
		tmsBaseCargoOwnerModel.setLongitude(cargoOwnerModifyVO.getLongitude());
		tmsBaseCargoOwnerModel.setLatitude(cargoOwnerModifyVO.getLatitude());
		tmsBaseCargoOwnerModel.setLegalman(cargoOwnerModifyVO.getLegalman());
		tmsBaseCargoOwnerModel.setInvoice(cargoOwnerModifyVO.getInvoice());
		tmsBaseCargoOwnerModel.setInvoiceTaxNumber(cargoOwnerModifyVO.getInvoiceTaxNumber());
		tmsBaseCargoOwnerModel.setRegisteredCapital(cargoOwnerModifyVO.getRegisteredCapital());
		tmsBaseCargoOwnerModel.setBank(cargoOwnerModifyVO.getBank());
		tmsBaseCargoOwnerModel.setBankAccount(cargoOwnerModifyVO.getBankAccount());
		tmsBaseCargoOwnerModel.setEstablished(cargoOwnerModifyVO.getEstablished());
		tmsBaseCargoOwnerModel.setRegisteredAddress(cargoOwnerModifyVO.getRegisteredAddress());
		tmsBaseCargoOwnerModel.setMemo(cargoOwnerModifyVO.getMemo());
		tmsBaseCargoOwnerModel.setDepartmentId(cargoOwnerModifyVO.getDepartmentId());
		tmsBaseCargoOwnerModel.setDepartmentCode(cargoOwnerModifyVO.getDepartmentCode());
		tmsBaseCargoOwnerModel.setDepartmentName(cargoOwnerModifyVO.getDepartmentName());
		tmsBaseCargoOwnerModel.setUpdateperson(user.getNickname());
		tmsBaseCargoOwnerModel.setUpdatetime(DateUtil.date());
		tmsBaseCargoOwnerModel.setExtStr1(cargoOwnerModifyVO.getExtStr1());
		tmsBaseCargoOwnerModel.setExtStr2(cargoOwnerModifyVO.getExtStr2());
		tmsBaseCargoOwnerModel.setExtStr3(cargoOwnerModifyVO.getExtStr3());
		tmsBaseCargoOwnerModel.setExtStr4(cargoOwnerModifyVO.getExtStr4());
		tmsBaseCargoOwnerModel.setExtStr5(cargoOwnerModifyVO.getExtStr5());
		tmsBaseCargoOwnerModel.setExtNum1(cargoOwnerModifyVO.getExtNum1());
		tmsBaseCargoOwnerModel.setExtNum2(cargoOwnerModifyVO.getExtNum2());
		tmsBaseCargoOwnerModel.setExtNum3(cargoOwnerModifyVO.getExtNum3());
		tmsBaseCargoOwnerModel.setExtNum4(cargoOwnerModifyVO.getExtNum4());
		tmsBaseCargoOwnerModel.setExtNum5(cargoOwnerModifyVO.getExtNum5());
		tmsBaseCargoOwnerModel.setExtDate1(cargoOwnerModifyVO.getExtDate1());
		tmsBaseCargoOwnerModel.setExtDate2(cargoOwnerModifyVO.getExtDate2());
		tmsBaseCargoOwnerModel.setExtDate3(cargoOwnerModifyVO.getExtDate3());
		tmsBaseCargoOwnerModel.setExtDate4(cargoOwnerModifyVO.getExtDate4());
		tmsBaseCargoOwnerModel.setExtDate5(cargoOwnerModifyVO.getExtDate5());
		tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
	}

	/**
	 * 货主资料批量删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchDeleteCargoOwnerData(List<CargoOwnerBatchDeleteVO> cargoOwnerBatchDeleteVOs) {
		ToolKits.isParamNull(cargoOwnerBatchDeleteVOs, "货主资料批量删除请求不为空");

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

		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = new TmsBaseCargoOwnerModel();
		for (CargoOwnerBatchDeleteVO cargoOwnerBatchDeleteVO : cargoOwnerBatchDeleteVOs) {
			ToolKits.isParamNull(cargoOwnerBatchDeleteVO.getCargoOwnerId(), "货主ID不为空");

			tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerBatchDeleteVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);

			// 校验货主是否绑定其他数据
			Criteria itemCriteria = Criteria.forClass(TmsBaseItemModel.class);
			Restriction itemR1 = Restrictions.eq("cargoOwnerId", cargoOwnerBatchDeleteVO.getCargoOwnerId());
			itemCriteria.setRestriction(itemR1);
			long count = tmsBaseItemMapper.findCountByCriteria(itemCriteria);
			if (count > 0) {
				throw new ParameterException("货主【" + tmsBaseCargoOwnerModel.getCargoOwnerName() + "】正在被商品使用，不能删除");
			}

			Criteria customerCriteria = Criteria.forClass(TmsBaseCustomerModel.class);
			Restriction customerR1 = Restrictions.eq("cargoOwnerId", cargoOwnerBatchDeleteVO.getCargoOwnerId());
			customerCriteria.setRestriction(customerR1);
			count = tmsBaseCustomerMapper.findCountByCriteria(customerCriteria);
			if (count > 0) {
				throw new ParameterException("货主【" + tmsBaseCargoOwnerModel.getCargoOwnerName() + "】正在被客户使用，不能删除");
			}

			Criteria providerCriteria = Criteria.forClass(TmsBaseProviderModel.class);
			Restriction providerR1 = Restrictions.eq("cargoOwnerId", cargoOwnerBatchDeleteVO.getCargoOwnerId());
			providerCriteria.setRestriction(providerR1);
			count = tmsBaseProviderMapper.findCountByCriteria(providerCriteria);
			if (count > 0) {
				throw new ParameterException("货主【" + tmsBaseCargoOwnerModel.getCargoOwnerName() + "】正在被供应商使用，不能删除");
			}

			// 删除货主
			tmsBaseCargoOwnerMapper.deleteById(cargoOwnerBatchDeleteVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		}
	}

	/**
	 * 货主资料是否启用
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void whetherEnableCargoOwnerData(CargoOwnerWhetherEnableVO cargoOwnerWhetherEnableVO) {
		ToolKits.isParamNull(cargoOwnerWhetherEnableVO, "货主资料是否启用请求不为空");
		ToolKits.isParamNull(cargoOwnerWhetherEnableVO.getCargoOwnerIds(), "货主ID集不为空");
		ToolKits.isParamNull(cargoOwnerWhetherEnableVO.getStatus(), "状态不为空");

		Assert.isTrue(cargoOwnerWhetherEnableVO.getStatus() == StatusConstant.STATUS_ENABLE || cargoOwnerWhetherEnableVO.getStatus() == StatusConstant.STATUS_DISABLE, "货主状态【" + cargoOwnerWhetherEnableVO.getStatus() + "】错误");

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

		// 当前日期
		Date date = DateUtil.date();

		for (CargoOwnerByIdVO cargoOwnerByIdVO : cargoOwnerWhetherEnableVO.getCargoOwnerIds()) {
			ToolKits.isParamNull(cargoOwnerByIdVO.getCargoOwnerId(), "货主ID不为空");

			// 根据ID查询货主
			TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerByIdVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
			ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主ID【" + cargoOwnerByIdVO.getCargoOwnerId() + "】不存在");

			if (tmsBaseCargoOwnerModel.getStatus().equals(StatusConstant.STATUS_UNDER_REVIEW)) {
				throw new PrologException("货主[" + tmsBaseCargoOwnerModel.getCargoOwnerName() + "]在审核中不可启用");
			}

			if (cargoOwnerWhetherEnableVO.getStatus() == StatusConstant.STATUS_ENABLE) {
				ApprovalOpenVO approvalOpenVO = new ApprovalOpenVO();
				approvalOpenVO.setInitiatedUserId(user.getUserid());
				approvalOpenVO.setInitiatedUserName(user.getNickname());
				approvalOpenVO.setApprovalFlowType(DataDictionaryConstant.APPROVAL_FLOW_TYPE_OWNER);
				approvalOpenVO.setApprovalObjectId(String.valueOf(cargoOwnerByIdVO.getCargoOwnerId()));
				approvalOpenVO.setApprovalObjectCode(tmsBaseCargoOwnerModel.getCargoOwnerCode());
				approvalOpenVO.setApprovalObjectName(tmsBaseCargoOwnerModel.getCargoOwnerName());
				approvalOpenVO.setCargoOwnerId(cargoOwnerByIdVO.getCargoOwnerId());
				boolean isOpen = approvalBusinessService.approvalOpen(approvalOpenVO);
				if (isOpen) {
					tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_UNDER_REVIEW);

					// 临时表的数据作成
					TmsBaseCargoOwnerTempModel tmsBaseCargoOwnerTempModel = new TmsBaseCargoOwnerTempModel();
					BeanUtils.copyProperties(tmsBaseCargoOwnerModel, tmsBaseCargoOwnerTempModel);
					tmsBaseCargoOwnerTempMapper.save(tmsBaseCargoOwnerTempModel);
				} else {
					tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_ENABLE);
				}
			} else {
				tmsBaseCargoOwnerModel.setStatus(cargoOwnerWhetherEnableVO.getStatus());
			}

			tmsBaseCargoOwnerModel.setUpdateperson(user.getNickname());
			tmsBaseCargoOwnerModel.setUpdatetime(date);
			tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
		}
	}

	/**
	 * 货主资料地址解析
	 */
	@Override
	public void geocodingData(CargoOwnerGeocodingVO cargoOwnerGeocodingVO) {
		ToolKits.isParamNull(cargoOwnerGeocodingVO, "货主资料地址解析请求不为空");
		ToolKits.isParamNull(cargoOwnerGeocodingVO.getCargoOwnerId(), "货主ID不为空");
		ToolKits.isParamNull(cargoOwnerGeocodingVO.getLongitude(), "经度不为空");
		ToolKits.isParamNull(cargoOwnerGeocodingVO.getLatitude(), "纬度不为空");
		ToolKits.isParamNull(cargoOwnerGeocodingVO.getAddress(), "详细地址不为空");

		// 根据ID查询货主对象
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerGeocodingVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主信息不存在，经纬度更新失败");

		// 更新经纬度信息
		tmsBaseCargoOwnerModel.setLongitude(cargoOwnerGeocodingVO.getLongitude());
		tmsBaseCargoOwnerModel.setLatitude(cargoOwnerGeocodingVO.getLatitude());
		tmsBaseCargoOwnerModel.setAddress(cargoOwnerGeocodingVO.getAddress());
		tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
	}

	/**
	 * 根据货主编码名称查询货主资料
	 */
	@Override
	public CargoOwnerByEncodingNameDTO getCargoOwnerByEncodingNameData(CargoOwnerByEncodingNameVO cargoOwnerByEncodingNameVO) {
		ToolKits.isParamNull(cargoOwnerByEncodingNameVO, "根据货主编码名称查询货主资料请求不为空");
		// ToolKits.isParamNull(cargoOwnerByEncodingNameVO.getCargoOwnerCode(),
		// "货主编码不为空");
		ToolKits.isParamNull(cargoOwnerByEncodingNameVO.getCargoOwnerName(), "货主名称不为空");

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

		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 start
		cargoOwnerByEncodingNameVO.setEnterpriseId(user.getEnterpriseId());
		// 判断账号类型
		if (user.getUserType().equals(BussinessConstant.USER_TYPE_ZY)) {
			cargoOwnerByEncodingNameVO.setIsDept("Y");
			// 自有账号
			// 判断是否为部门权限
			if (user.getOwnedAllDataAuthFlag().equals(BussinessConstant.USER_DEPARTMENT_AUTH_Y)) {
				cargoOwnerByEncodingNameVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
			} else {
				cargoOwnerByEncodingNameVO.setIsData("Y");
				cargoOwnerByEncodingNameVO.setDepartmentIds(user.getDepts().stream().toArray(String[]::new));
				cargoOwnerByEncodingNameVO.setCargoOwnerIds(user.getConsignors().stream().toArray(Long[]::new));
			}
		} else if (user.getUserType().equals(BussinessConstant.USER_TYPE_HZ)) {
			// 货主账号
			Long[] cargoOwners = { Long.valueOf(user.getLoginUserCompanyInfo().getId()) };
			cargoOwnerByEncodingNameVO.setCargoOwnerIds(cargoOwners);
			cargoOwnerByEncodingNameVO.setIsData("Y");
		} else {
			// 其他账号
			throw new RuntimeException("当前账号没有权限");
		}

		List<CargoOwnerByEncodingNameDTO> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.getCargoOwnerByEncodingNameData(cargoOwnerByEncodingNameVO);
		// STD-DEVELOP20220823 lhb JC-HZ-001货主支持多部门 20220830 end

		Assert.isTrue(tmsBaseCargoOwnerModels.size() > 0, "不存在编码为【" + cargoOwnerByEncodingNameVO.getCargoOwnerCode() + "】,名称为【" + cargoOwnerByEncodingNameVO.getCargoOwnerName() + "】的货主");
		Assert.isTrue(tmsBaseCargoOwnerModels.size() == 1, "编码为【" + cargoOwnerByEncodingNameVO.getCargoOwnerCode() + "】,名称为【" + cargoOwnerByEncodingNameVO.getCargoOwnerName() + "】的货主资料重复");

		// 货主资料对象
		CargoOwnerByEncodingNameDTO tmsBaseCargoOwnerModel = tmsBaseCargoOwnerModels.get(0);
		Assert.isTrue(tmsBaseCargoOwnerModel.getStatus() == StatusConstant.STATUS_ENABLE, "货主【" + cargoOwnerByEncodingNameVO.getCargoOwnerName() + "】未启用");

		// 响应对象
		return tmsBaseCargoOwnerModel;
	}

	/**
	 * 货主流程审批 撤回
	 *
	 * @param cargoOwnerProcessApprovalVO
	 */
	@Override
	public void retractApproval(CargoOwnerProcessApprovalVO cargoOwnerProcessApprovalVO) {
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO, "货主资料审批撤回请求不为空");
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO.getCargoOwnerId(), "货主资料ID不为空");
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO.getApprovalBusinessId(), "审批业务ID不为空");

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

		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerProcessApprovalVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主资料[" + cargoOwnerProcessApprovalVO.getCargoOwnerId() + "]不存在!");

		approvalBusinessService.approvalRetractData(cargoOwnerProcessApprovalVO.getApprovalBusinessId());
	}

	/**
	 * 货主流程审批 作废
	 *
	 * @param cargoOwnerProcessApprovalVO
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void invalidApproval(CargoOwnerProcessApprovalVO cargoOwnerProcessApprovalVO) {
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO, "货主资料审批作废请求不为空");
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO.getCargoOwnerId(), "货主资料ID不为空");
		ToolKits.isParamNull(cargoOwnerProcessApprovalVO.getApprovalBusinessId(), "审批业务ID不为空");

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

		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerProcessApprovalVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主资料[" + cargoOwnerProcessApprovalVO.getCargoOwnerId() + "]不存在!");
		tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_CREATE);
		tmsBaseCargoOwnerModel.setUpdateperson(user.getNickname());
		tmsBaseCargoOwnerModel.setUpdatetime(DateUtil.date());
		tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);

		approvalBusinessService.approvalInvalidData(cargoOwnerProcessApprovalVO.getApprovalBusinessId());
	}

	/**
	 * 货主流程审批 提交
	 *
	 * @param cargoOwnerSummitApprovalVO
	 */
	@Override
	public void summitApproval(CargoOwnerSummitApprovalVO cargoOwnerSummitApprovalVO) {

		ToolKits.isParamNull(cargoOwnerSummitApprovalVO, "货主资料审批提交请求不为空");
		ToolKits.isParamNull(cargoOwnerSummitApprovalVO.getCargoOwnerId(), "货主资料ID不为空");
		ToolKits.isParamNull(cargoOwnerSummitApprovalVO.getApprovalBusinessId(), "审批业务ID不为空");

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

		// 查询临时表数据
		TmsBaseCargoOwnerTempModel tmsBaseCargoOwnerTempModel = tmsBaseCargoOwnerTempMapper.findById(cargoOwnerSummitApprovalVO.getCargoOwnerId(), TmsBaseCargoOwnerTempModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerTempModel, "审核用的临时货主资料[" + cargoOwnerSummitApprovalVO.getCargoOwnerId() + "]不存在");
		// 审批业务提交
		approvalBusinessService.approvalSubmitData(cargoOwnerSummitApprovalVO.getApprovalBusinessId());
		// 修改临时表数据
		BeanUtils.copyProperties(cargoOwnerSummitApprovalVO, tmsBaseCargoOwnerTempModel);
		tmsBaseCargoOwnerTempMapper.update(tmsBaseCargoOwnerTempModel);
	}

	/**
	 * 货主流程审批 审核
	 *
	 * @param cargoOwnerApprovalVO
	 */
	public void approval(CargoOwnerApprovalVO cargoOwnerApprovalVO) {
		ToolKits.isParamNull(cargoOwnerApprovalVO, "货主审核请求不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getCargoOwnerId(), "货主ID不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getApprovalBusinessId(), "审批业务ID不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getApprovalObjectName(), "审批对象名称不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getApprovalId(), "审批流程ID不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApproverNodeId(), "下一审批节点ID不为空");
		ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApprovalOrder(), "下一节点顺序不为空");

		ToolKits.isParamNull(cargoOwnerApprovalVO.getResult(), "审批结果不为空");

		if (cargoOwnerApprovalVO.getNodeApproverType() == DataDictionaryConstant.NODE_APPROVER_TYPE_ROLE) {
			ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApproverRoleId(), "审核角色不为空");
			ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApproverRoleName(), "审核角色不为空");
		} else {
			ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApproverUserId(), "下一审批用户ID不为空");
			ToolKits.isParamNull(cargoOwnerApprovalVO.getNextApproverUserName(), "下一审批用户名称不为空");
		}
		if (cargoOwnerApprovalVO.getResult() != DataDictionaryConstant.NODE_APPROVAL_RESULT_PASS) {
			ToolKits.isParamNull(cargoOwnerApprovalVO.getApprovalOpinion(), "驳回意见不为空");
		}

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

		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerApprovalVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
		ToolKits.isParamNull(tmsBaseCargoOwnerModel, "审核用的临时货主资料[" + cargoOwnerApprovalVO.getCargoOwnerId() + "]不存在!");

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

		// 封装审核所需数据
		ApprovalBusinessNodeVO approvalBusinessNodeVO = new ApprovalBusinessNodeVO();
		approvalBusinessNodeVO.setApprovalObjectName(cargoOwnerApprovalVO.getApprovalObjectName());
		approvalBusinessNodeVO.setApprovalBusinessId(cargoOwnerApprovalVO.getApprovalBusinessId());
		approvalBusinessNodeVO.setApprovalId(cargoOwnerApprovalVO.getApprovalId());
		approvalBusinessNodeVO.setNextApprovalNodeId(cargoOwnerApprovalVO.getNextApproverNodeId());
		approvalBusinessNodeVO.setNextApprovalOrder(cargoOwnerApprovalVO.getNextApprovalOrder());
		approvalBusinessNodeVO.setNextApproverRoleId(cargoOwnerApprovalVO.getNextApproverRoleId());
		approvalBusinessNodeVO.setNextApproverRoleName(cargoOwnerApprovalVO.getNextApproverRoleName());
		approvalBusinessNodeVO.setNextApproverUserId(cargoOwnerApprovalVO.getNextApproverUserId());
		approvalBusinessNodeVO.setNextApproverUserName(cargoOwnerApprovalVO.getNextApproverUserName());
		approvalBusinessNodeVO.setApproverPersonId(user.getUserid());
		approvalBusinessNodeVO.setApproverPersonName(user.getNickname());
		approvalBusinessNodeVO.setApprovalOpinion(ToolKits.isEmpty(cargoOwnerApprovalVO.getApprovalOpinion()) ? "" : cargoOwnerApprovalVO.getApprovalOpinion());
		approvalBusinessNodeVO.setApprovalTime(date);
		approvalBusinessNodeVO.setResult(cargoOwnerApprovalVO.getResult());

		approvalBusinessNodeVO.setApproverPersonRoleId(user.getRoles().stream().map(l -> l.toString()).collect(Collectors.joining(",")));
		approvalBusinessNodeVO.setApproverPersonRoleName("");

		approvalBusinessNodeVO.setNodeApproverType(cargoOwnerApprovalVO.getNodeApproverType());
		approvalBusinessNodeVO.setNodeApprovalType(cargoOwnerApprovalVO.getNodeApprovalType());

		Boolean isFinish = approvalBusinessService.nodeApproval(approvalBusinessNodeVO);

		// 判断是否已结束流程
		if (isFinish) {
			// 流程结束
			// 查询临时表数据
			TmsBaseCargoOwnerTempModel tmsBaseCargoOwnerTempModel = tmsBaseCargoOwnerTempMapper.findById(cargoOwnerApprovalVO.getCargoOwnerId(), TmsBaseCargoOwnerTempModel.class);

			// 判断临时表是否为空
			if (ToolKits.isNotEmpty(tmsBaseCargoOwnerTempModel)) {
				// 修改正式数据
				BeanUtils.copyProperties(tmsBaseCargoOwnerTempModel, tmsBaseCargoOwnerModel);
				tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_ENABLE);
				tmsBaseCargoOwnerModel.setUpdatetime(date);
				tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
			} else {
				tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_ENABLE);
				tmsBaseCargoOwnerModel.setUpdatetime(date);
				tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
			}
			// 删除临时表
			tmsBaseCargoOwnerTempMapper.deleteById(tmsBaseCargoOwnerTempModel.getCargoOwnerId(), TmsBaseCargoOwnerTempModel.class);
		}
	}

	/**
	 * 货主资料和流程审批的查询
	 *
	 * @param cargoOwnerApprovalQueryVO
	 */
	@Override
	public CargoOwnerApprovalQueryDTO approvalQuery(CargoOwnerApprovalQueryVO cargoOwnerApprovalQueryVO) {
		ToolKits.isParamNull(cargoOwnerApprovalQueryVO, "货主资料和流程审批的查询请求不为空");
		ToolKits.isParamNull(cargoOwnerApprovalQueryVO.getCargoOwnerId(), "货主ID不为空");
		ToolKits.isParamNull(cargoOwnerApprovalQueryVO.getApprovalBusinessId(), "审批业务ID不为空");

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

		// 响应对象
		CargoOwnerApprovalQueryDTO rsDto = new CargoOwnerApprovalQueryDTO();

		// 查下临时表数据
		TmsBaseCargoOwnerTempModel tmsBaseCargoOwnerTempModel = tmsBaseCargoOwnerTempMapper.findById(cargoOwnerApprovalQueryVO.getCargoOwnerId(), TmsBaseCargoOwnerTempModel.class);

		// 当临时表数据为空时查正式表
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = null;
		if (ToolKits.isEmpty(tmsBaseCargoOwnerTempModel)) {
			tmsBaseCargoOwnerModel = tmsBaseCargoOwnerMapper.findById(cargoOwnerApprovalQueryVO.getCargoOwnerId(), TmsBaseCargoOwnerModel.class);
			ToolKits.isParamNull(tmsBaseCargoOwnerModel, "货主资料[" + cargoOwnerApprovalQueryVO.getCargoOwnerId() + "]不存在!");
		}

		// 货主资料对象
		CargoOwnerDetailForApprovalDTO cargoOwnerDetailDTO = new CargoOwnerDetailForApprovalDTO();
		BeanUtils.copyProperties(tmsBaseCargoOwnerTempModel == null ? tmsBaseCargoOwnerModel : tmsBaseCargoOwnerTempModel, cargoOwnerDetailDTO);
		rsDto.setCargoOwnerDetailForApprovalDTO(cargoOwnerDetailDTO);
		// 审批历史信息取得
		List<ApprovalLogDTO> logs = approvalBusinessService.getBusLogData(String.valueOf(cargoOwnerApprovalQueryVO.getApprovalBusinessId()));
		rsDto.setApprovalLogDTOList(logs);

		// 审批节点信息取得
		List<ApprovalNodeSelDTO> nodes = approvalBusinessService.getBusDetailData(String.valueOf(cargoOwnerApprovalQueryVO.getApprovalBusinessId()));
		rsDto.setApprovalNodeSelDTOList(nodes);

		return rsDto;
	}

	/**
	 * 货主接口转TMS
	 */
	@Override
	public List<IntfErrorLogDTO> saveCargoOwnerInterfaceData(List<IntfCargoOwnerSaveVO> intfCargoOwnerSaveVOs) {
		// 响应集合
		List<IntfErrorLogDTO> intfErrorLogDTOs = Lists.newArrayList();

		Date date = DateUtil.date();

		// 循环处理
		for (IntfCargoOwnerSaveVO intfCargoOwnerSaveVO : intfCargoOwnerSaveVOs) {
			// 响应对象
			IntfErrorLogDTO intfErrorLogDTO = new IntfErrorLogDTO();

			try {
				// 货主校验
				Criteria criteria = Criteria.forClass(TmsBaseCargoOwnerModel.class);
				Restriction r1 = Restrictions.eq(TmsBaseCargoOwnerModel::getCargoOwnerCode, intfCargoOwnerSaveVO.getCargoOwnerCode());
				Restriction r2 = Restrictions.eq(TmsBaseCargoOwnerModel::getEnterpriseId, intfCargoOwnerSaveVO.getEnterpriseId());
				criteria.setRestriction(Restrictions.and(r1, r2));
				List<TmsBaseCargoOwnerModel> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.findByCriteria(criteria);
				if (tmsBaseCargoOwnerModels.size() > 0) {
					Assert.isTrue(tmsBaseCargoOwnerModels.size() <= 1, "货主编码[" + intfCargoOwnerSaveVO.getCargoOwnerCode() + "]维护重复");

					// 供应商资料对象
					TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerModels.get(0);
					tmsBaseCargoOwnerModel.setCargoOwnerName(intfCargoOwnerSaveVO.getCargoOwnerName());
					tmsBaseCargoOwnerModel.setCargoOwnerShortName(intfCargoOwnerSaveVO.getCargoOwnerShortName());
					tmsBaseCargoOwnerModel.setContact(intfCargoOwnerSaveVO.getContact());
					tmsBaseCargoOwnerModel.setPhoneNumber(intfCargoOwnerSaveVO.getPhoneNumber());
					tmsBaseCargoOwnerModel.setLandlineNumber(intfCargoOwnerSaveVO.getLandlineNumber());
					tmsBaseCargoOwnerModel.setMail(intfCargoOwnerSaveVO.getMail());
					tmsBaseCargoOwnerModel.setPostCode(intfCargoOwnerSaveVO.getPostCode());
					tmsBaseCargoOwnerModel.setProvince(intfCargoOwnerSaveVO.getProvince());
					tmsBaseCargoOwnerModel.setProvinceName(intfCargoOwnerSaveVO.getProvinceName());
					tmsBaseCargoOwnerModel.setCity(intfCargoOwnerSaveVO.getCity());
					tmsBaseCargoOwnerModel.setCityName(intfCargoOwnerSaveVO.getCityName());
					tmsBaseCargoOwnerModel.setDistrict(intfCargoOwnerSaveVO.getDistrict());
					tmsBaseCargoOwnerModel.setDistrictName(intfCargoOwnerSaveVO.getDistrictName());
					tmsBaseCargoOwnerModel.setAddress(intfCargoOwnerSaveVO.getAddress());
					tmsBaseCargoOwnerModel.setLongitude(intfCargoOwnerSaveVO.getLongitude());
					tmsBaseCargoOwnerModel.setLatitude(intfCargoOwnerSaveVO.getLatitude());
					tmsBaseCargoOwnerModel.setLegalman(intfCargoOwnerSaveVO.getLegalman());
					tmsBaseCargoOwnerModel.setInvoice(intfCargoOwnerSaveVO.getInvoice());
					tmsBaseCargoOwnerModel.setInvoiceTaxNumber(intfCargoOwnerSaveVO.getInvoiceTaxNumber());
					tmsBaseCargoOwnerModel.setRegisteredCapital(intfCargoOwnerSaveVO.getRegisteredCapital());
					tmsBaseCargoOwnerModel.setBank(intfCargoOwnerSaveVO.getBank());
					tmsBaseCargoOwnerModel.setBankAccount(intfCargoOwnerSaveVO.getBankAccount());
					tmsBaseCargoOwnerModel.setEstablished(intfCargoOwnerSaveVO.getEstablished());
					tmsBaseCargoOwnerModel.setRegisteredAddress(intfCargoOwnerSaveVO.getRegisteredAddress());
					tmsBaseCargoOwnerModel.setStatus(intfCargoOwnerSaveVO.getStatus());
					tmsBaseCargoOwnerModel.setMemo(intfCargoOwnerSaveVO.getMemo());
					tmsBaseCargoOwnerModel.setEnterpriseId(intfCargoOwnerSaveVO.getEnterpriseId());
					tmsBaseCargoOwnerModel.setEnterpriseName(intfCargoOwnerSaveVO.getEnterpriseName());
					tmsBaseCargoOwnerModel.setDepartmentId(intfCargoOwnerSaveVO.getDepartmentId());
					tmsBaseCargoOwnerModel.setDepartmentCode(intfCargoOwnerSaveVO.getDepartmentCode());
					tmsBaseCargoOwnerModel.setDepartmentName(intfCargoOwnerSaveVO.getDepartmentName());
					tmsBaseCargoOwnerModel.setExtStr1(intfCargoOwnerSaveVO.getExtStr1());
					tmsBaseCargoOwnerModel.setExtStr2(intfCargoOwnerSaveVO.getExtStr2());
					tmsBaseCargoOwnerModel.setExtStr3(intfCargoOwnerSaveVO.getExtStr3());
					tmsBaseCargoOwnerModel.setExtStr4(intfCargoOwnerSaveVO.getExtStr4());
					tmsBaseCargoOwnerModel.setExtStr5(intfCargoOwnerSaveVO.getExtStr5());
					tmsBaseCargoOwnerModel.setExtNum1(intfCargoOwnerSaveVO.getExtNum1());
					tmsBaseCargoOwnerModel.setExtNum2(intfCargoOwnerSaveVO.getExtNum2());
					tmsBaseCargoOwnerModel.setExtNum3(intfCargoOwnerSaveVO.getExtNum3());
					tmsBaseCargoOwnerModel.setExtNum4(intfCargoOwnerSaveVO.getExtNum4());
					tmsBaseCargoOwnerModel.setExtNum5(intfCargoOwnerSaveVO.getExtNum5());
					tmsBaseCargoOwnerModel.setExtDate1(intfCargoOwnerSaveVO.getExtDate1());
					tmsBaseCargoOwnerModel.setExtDate2(intfCargoOwnerSaveVO.getExtDate2());
					tmsBaseCargoOwnerModel.setExtDate3(intfCargoOwnerSaveVO.getExtDate3());
					tmsBaseCargoOwnerModel.setExtDate4(intfCargoOwnerSaveVO.getExtDate4());
					tmsBaseCargoOwnerModel.setExtDate5(intfCargoOwnerSaveVO.getExtDate5());
					tmsBaseCargoOwnerModel.setUpdatetime(date);
					tmsBaseCargoOwnerMapper.update(tmsBaseCargoOwnerModel);
				} else {
					String id = sysCodeengineService.getCodeNumberByCode(SeriaNnumberConstant.CARGO_OWNER_ID, "L");
					Assert.isTrue(ToolKits.isNotEmpty(id), "货主ID生成为空");

					TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = new TmsBaseCargoOwnerModel();
					BeanUtils.copyProperties(intfCargoOwnerSaveVO, tmsBaseCargoOwnerModel);
					tmsBaseCargoOwnerModel.setCargoOwnerId(Long.valueOf(id));
					tmsBaseCargoOwnerModel.setStatus(StatusConstant.STATUS_ENABLE);
					tmsBaseCargoOwnerModel.setCreatetime(date);
					tmsBaseCargoOwnerModel.setUpdatetime(date);
					tmsBaseCargoOwnerMapper.save(tmsBaseCargoOwnerModel);
				}

				// 成功信息
				intfErrorLogDTO.setErrorInfo(null);
				intfErrorLogDTO.setDataId(intfCargoOwnerSaveVO.getCargoOwnerId());
				intfErrorLogDTO.setStatus(true);

				intfErrorLogDTOs.add(intfErrorLogDTO);
			} catch (Exception e) {
				e.printStackTrace();

				log.info("货主资料接口处理失败:{}", e);

				// 错误信息
				intfErrorLogDTO.setErrorInfo(e.getMessage());
				intfErrorLogDTO.setDataId(intfCargoOwnerSaveVO.getCargoOwnerId());
				intfErrorLogDTO.setStatus(false);

				intfErrorLogDTOs.add(intfErrorLogDTO);
			}
		}

		return intfErrorLogDTOs;
	}

	/**
	 * 根据货主名称返回货主资料
	 *
	 * @param cargoOwnerCheckVO
	 * @return
	 */
	public CargoOwnerCheckDTO getCargoOwnerByNameData(CargoOwnerCheckVO cargoOwnerCheckVO) {
		ToolKits.isParamNull(cargoOwnerCheckVO, "货主资料查看请求不为空");
		ToolKits.isParamNull(cargoOwnerCheckVO.getCargoOwnerName(), "货主名称不为空");

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

		// 货主状态
		List<Map<String, Object>> restMessage = sysRefdatadService.getDropDownById(DataDictionaryConstant.MAINDATA_STATUS, null, null, null);

		Criteria criteria = Criteria.forClass(TmsBaseCargoOwnerModel.class);
		Restriction r1 = Restrictions.eq(TmsBaseCargoOwnerModel::getCargoOwnerName, cargoOwnerCheckVO.getCargoOwnerName());
		Restriction r2 = Restrictions.eq("enterpriseId", user.getEnterpriseId());
		criteria.setRestriction(Restrictions.and(r1, r2));
		List<TmsBaseCargoOwnerModel> tmsBaseCargoOwnerModels = tmsBaseCargoOwnerMapper.findByCriteria(criteria);

		Assert.isTrue(tmsBaseCargoOwnerModels.size() == 1, "货主名称【" + cargoOwnerCheckVO.getCargoOwnerName() + "】存在重复数据，查询失败");

		// 货主资料对象
		TmsBaseCargoOwnerModel tmsBaseCargoOwnerModel = tmsBaseCargoOwnerModels.get(0);

		// 响应对象
		CargoOwnerCheckDTO cargoOwnerCheckDTO = new CargoOwnerCheckDTO();
		BeanUtils.copyProperties(tmsBaseCargoOwnerModel, cargoOwnerCheckDTO);
		cargoOwnerCheckDTO.setStatusName(PublicMethods.change(restMessage, String.valueOf(cargoOwnerCheckDTO.getStatus())));

		return cargoOwnerCheckDTO;
	}

}
