OMS执行单开发

This commit is contained in:
hjx
2026-01-27 19:28:53 +08:00
parent a52984b103
commit 3b9983c68f
16 changed files with 1060 additions and 26 deletions
@@ -13,7 +13,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 【请填写功能名称】对象 business_document_cargo_multi
*
*
* @author gen
* @date 2026-01-26
*/
@@ -63,5 +63,38 @@ public class BusinessDocumentCargoMulti extends BaseVOEntity{
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private BigDecimal cargoWeight;
@ApiModelProperty("货物名称")
private String cargoName;
@ApiModelProperty("货物单位ID")
private String cargoUnitId;
@ApiModelProperty("货物单位名字")
private String cargoUnitName;
@ApiModelProperty(value = "货物数量")
private BigDecimal cargoNum;
private BigDecimal weight;
@ApiModelProperty(value = "重量单位ID")
private String weightUnitId;
@ApiModelProperty(value = "重量单位名称")
private String weightUnit;
@ApiModelProperty(value = "数量单位ID")
private String quantityUnitId;
@ApiModelProperty(value = "数量单位名称")
private String quantityUnit;
@ApiModelProperty("整机表编号")
private String machineCode;
@ApiModelProperty("")
private String materialCode;
@ApiModelProperty("$column.columnComment")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String orderId;
}
@@ -44,4 +44,8 @@ public interface IBusinessDocumentOrderService extends IService<BusinessDocument
public BusinessDocumentOrderPO getInfo(Long id);
public BusinessDocumentOrderPO audit( Long id, Long reviewStatus);
String selectByMakerCodeNc(String salesmanCodeNc);
String selectByMakerCodeNc1(String salesmanCodeNc);
}
@@ -8,7 +8,7 @@ import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocument
import org.apache.ibatis.annotations.Param;
/**
* 【请填写功能名称】Mapper接口
*
*
* @author gen
* @date 2026-01-26
*/
@@ -19,4 +19,8 @@ public interface BusinessDocumentOrderMapper extends BaseMapper<BusinessDocument
*/
public List<BusinessDocumentOrderPO> queryList(BusinessDocumentOrderDO businessDocumentOrderDO);
String selectByMakerCodeNc(@Param("salesmanCodeNc") String salesmanCodeNc);
String selectByMakerCodeNc1(@Param("salesmanCodeNc") String salesmanCodeNc);
}
@@ -141,4 +141,21 @@ public class BusinessDocumentOrderImpl extends ServiceImpl<BusinessDocumentOrder
}
return null;
}
@Override
public String selectByMakerCodeNc(String salesmanCodeNc) {
String makerCodeNc = businessDocumentOrderMapper.selectByMakerCodeNc(salesmanCodeNc);
if (makerCodeNc == null){
return "";
}
return makerCodeNc;
}
@Override
public String selectByMakerCodeNc1(String salesmanCodeNc) {
String makerCodeNc = businessDocumentOrderMapper.selectByMakerCodeNc1(salesmanCodeNc);
if (makerCodeNc == null){
return "";
}
return makerCodeNc;
}
}
@@ -1,6 +1,9 @@
package com.mhd.oms.domain.businessDocumentOrder.repository.todo;
import com.mhd.common.core.annotation.Excel;
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO;
import com.mhd.oms.interfaces.dto.businessDocumentCargoMulti.BusinessDocumentCargoMultiDTO;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -701,4 +704,15 @@ public class BusinessDocumentOrderDO extends BaseVOEntity{
@ApiModelProperty("预约单号")
private String reservationOrderNumber;
@ApiModelProperty("业务单地址集合")
private List<BusinessDocumentAddressMultiDTO> businessDocumentAddressMultiDTOList;
@ApiModelProperty("业务单货物集合")
private List<BusinessDocumentCargoMultiDTO> businessDocumentCargoMultiList;
@ApiModelProperty(value = "装货地址集合")
private List<BusinessDocumentAddressMultiDTO> loadingAddressList;
@ApiModelProperty(value = "卸货地址集合")
private List<BusinessDocumentAddressMultiDTO> unloadAddressList;
}
@@ -1,13 +1,41 @@
package com.mhd.oms.domain.businessDocumentOrder.service;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mhd.common.core.domain.po.UserShipperPo;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.oms.domain.businessDocumentAddressMulti.entity.BusinessDocumentAddressMulti;
import com.mhd.oms.domain.businessDocumentAddressMulti.repository.mapper.BusinessDocumentAddressMultiMapper;
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
import com.mhd.oms.domain.businessDocumentOrder.repository.facade.IBusinessDocumentOrderService;
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
import com.mhd.oms.domain.orderType.entity.OrderType;
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO;
import com.mhd.oms.interfaces.dto.businessDocumentCargoMulti.BusinessDocumentCargoMultiDTO;
import com.mhd.oms.util.DictDataUtils;
import com.mhd.oms.util.DictTypeEnum;
import com.mhd.system.api.domain.SysDictData;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.List;
/**
* 【请填写功能名称】
*
@@ -21,7 +49,14 @@ public class BusinessDocumentOrderDomainService {
@Autowired
private IBusinessDocumentOrderService businessDocumentOrderService;
@Resource
private DictDataUtils dictDataUtils;
@Resource
private BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper;
@Resource
private BusinessDocumentAddressMultiMapper businessDocumentAddressMultiMapper;
/**
* 分页查询【请填写功能名称】列表
*/
@@ -34,17 +69,569 @@ public class BusinessDocumentOrderDomainService {
* 新增【请填写功能名称】
*/
public Boolean insert(BusinessDocumentOrderDO businessDocumentOrderDO) {
if (null!=businessDocumentOrderDO.getGoodsQuantity()){
businessDocumentOrderDO.setGoodsQuantity(BigDecimal.ZERO);
}
return businessDocumentOrderService.insert(businessDocumentOrderDO);
LoginUser u = SecurityUtils.getLoginUser();
//处理费用默认值
handFee(businessDocumentOrderDO);
//组织赋值
Long organizationId = businessDocumentOrderDO.getOrganizationId();
if(ObjectUtil.isNotEmpty(organizationId)){
businessDocumentOrderDO.setOrgId(String.valueOf(organizationId));
businessDocumentOrderDO.setOrgName(businessDocumentOrderDO.getOrganizationName());
}else{
businessDocumentOrderDO.setOrgId(String.valueOf(u.getUserPo().getOrganizationId()));
businessDocumentOrderDO.setOrgName(String.valueOf(u.getUserPo().getOrganizationName()));
}
businessDocumentOrderDO.setTopOrganizationId(u.getUserPo().getTopOrganizationId());
/* String swzlUserId = businessDocumentOrderDO.getAppointShipperId();
// 获取数字物流平台用户Id
String appointShipperId = businessDocumentOrderDO.getAppointShipperId();
if(StringUtils.isBlank(appointShipperId)){
appointShipperId = u.getUserid();
businessDocumentOrderDO.setAppointShipperId(appointShipperId);
}*/
UserShipperPo userShipperPo=u.getUserShipperPo();
if (userShipperPo == null) {
throw new ServiceException("您非货主角色或账号已被删除!");
}
String orderRemark = businessDocumentOrderDO.getRemarks();
businessDocumentOrderDO.setRemarks(orderRemark);
businessDocumentOrderDO.setAppointShipperId(String.valueOf(userShipperPo.getUserId()));
// 分类处理货物列表
List<BusinessDocumentCargoMultiDTO> allCargoList = businessDocumentOrderDO.getBusinessDocumentCargoMultiList();
businessDocumentOrderDO.setReceivableType(2L);
//非企业员工判断个人信息审核状态x
if (userShipperPo.getShipperType() != 2 && userShipperPo.getShipperFill() != 3) {
throw new ServiceException("未提交个人信息认证或认证未通过,请先认证!");
}
//企业员工判断企业货主审核状态
if (userShipperPo.getShipperType() == 2) {
if (userShipperPo.getShipperEnterpriseFill() != 3) {
throw new ServiceException("未提交个人信息认证或认证未通过,请先认证!");
}
}
/**
* 生成货源单信息
*/
BusinessDocumentOrder tmsOrder = new BusinessDocumentOrder();
BeanUtils.copyProperties(businessDocumentOrderDO, tmsOrder, "id");
tmsOrder.setSettlementStatus(1L);//未出账
tmsOrder.setAuditStatus(0L);//未审核
tmsOrder.setSzwlUserId(Long.valueOf(u.getUserid()));
if (tmsOrder.getLoadingDate() != null && tmsOrder.getUnloadingData() != null) {
if (tmsOrder.getUnloadingData().before(tmsOrder.getLoadingDate())) {
throw new ServiceException("装货日期不能大于卸货日期!");
}
}
//赋值信息费收款方信息
if(businessDocumentOrderDO.getOrderShippingType()==3&&businessDocumentOrderDO.getInfoFeePayeeType()!=null){
String infoFeePayee = "";
if(businessDocumentOrderDO.getInfoFeePayeeType()==0){
infoFeePayee = businessDocumentOrderDO.getAppointShipper();//委托方
}else if(businessDocumentOrderDO.getInfoFeePayeeType()==1){
infoFeePayee = businessDocumentOrderDO.getRecipientName();//收货方
}else if(businessDocumentOrderDO.getInfoFeePayeeType()==2){
infoFeePayee = businessDocumentOrderDO.getInfoFeePayee();//第三方
if(StringUtils.isBlank(businessDocumentOrderDO.getInfoFeePayee())){
throw new ServiceException("请填写信息费第三方收款方信息!");
}
}
tmsOrder.setInfoFeePayeeType(businessDocumentOrderDO.getInfoFeePayeeType());
if(infoFeePayee!=""){
tmsOrder.setInfoFeePayee(infoFeePayee);
}
}
//根据货物重量大小赋值
BigDecimal weightMin = new BigDecimal(0);
tmsOrder.setWeightMin(weightMin);
tmsOrder.setUncollectedFreight(tmsOrder.getDeliveryFreight());
//存入对应创建人
tmsOrder.setCreateBy(userShipperPo.getUserId());
if ( 2 == userShipperPo.getShipperType()) {
tmsOrder.setCreateCompanyId(String.valueOf(userShipperPo.getUserId()));
}
tmsOrder.setCreateTime(new Date());
tmsOrder.setCreaterName(u.getUsername());//保存创建人姓名
tmsOrder.setCreaterPhone(u.getUserPo().getUserPhone());//保存创建人电话
tmsOrder.setRealCreateBy(String.valueOf(u.getUserid()));
tmsOrder.setRealCreateName(u.getUsername());
tmsOrder.setAppointShipper(userShipperPo.getShipperEnterpriseName());//20250-07-29修改:订单表委托方保存公司名字,而不是姓名
String salesmanCodeNc = businessDocumentOrderDO.getSalesmanId();
if (salesmanCodeNc != null){
String makerCodeNc = businessDocumentOrderService.selectByMakerCodeNc(salesmanCodeNc);
String makerCodeNc1 = businessDocumentOrderService.selectByMakerCodeNc1(salesmanCodeNc);
tmsOrder.setMakerCodeNc(makerCodeNc);
tmsOrder.setSalesmanCodeNc(makerCodeNc1);
}
List<String> machineNumberList = new ArrayList<>();
List<String> goodsNameList = new ArrayList<>();
if (ObjectUtil.isNotEmpty(allCargoList)&&allCargoList.size()>0) {
BusinessDocumentCargoMultiDTO tmsCargoInfoDTO1 = allCargoList.get(0);
String goodsTypeId = tmsCargoInfoDTO1.getGoodsTypeId();
if (ObjectUtil.isNotEmpty(goodsTypeId)) {
for (BusinessDocumentCargoMultiDTO tmsCargoInfoDTO : allCargoList) {
// 处理货物名称信息
String goodsName = buildCargoNameInfo(tmsCargoInfoDTO, businessDocumentOrderDO);
if (goodsName != null) {
goodsNameList.add(goodsName);
}
// 处理机械编号信息
String machineCode = extractMachineCode(tmsCargoInfoDTO);
if (machineCode != null) {
machineNumberList.add(machineCode);
}
}
}
}
//生成货源单号
tmsOrder.setGoodsNumber(OrderSequence.getOrderCode());
List<BusinessDocumentAddressMultiDTO> loadingAddressList = businessDocumentOrderDO.getLoadingAddressList();//装货地信息集合
List<BusinessDocumentAddressMultiDTO> unloadAddressList = businessDocumentOrderDO.getUnloadAddressList();//卸货地信息集合
String loadCityCounty="",unloadCityCounty="";
//获取第一条装货地址和获取最后一条卸货地址
BusinessDocumentAddressMultiDTO firstAddress = loadingAddressList.get(0);
BusinessDocumentAddressMultiDTO lastAddress = unloadAddressList.get(unloadAddressList.size() - 1);
tmsOrder.setLoadingAreaId(firstAddress.getAreaCode());
tmsOrder.setLoadingName(firstAddress.getAreaCode());
tmsOrder.setLoadingAddress(firstAddress.getAddress());
String area = firstAddress.getAreaCode() + firstAddress.getAddress();
tmsOrder.setLineTitleLeft(firstAddress.getAreaCode());
tmsOrder.setLineTitleRight(lastAddress.getAreaCode());
tmsOrder.setFreighterName(firstAddress.getContactName());
tmsOrder.setLoadingPhone(firstAddress.getContactPhone());
tmsOrder.setLoadingDate(firstAddress.getLayDate());
tmsOrder.setUnloadAreaId(lastAddress.getAreaCode());
tmsOrder.setUnloadName(lastAddress.getAreaCode());
tmsOrder.setUnloadAddress(lastAddress.getAddress());
String unarea = lastAddress.getAreaCode() + lastAddress.getAddress();
tmsOrder.setDischargerName(lastAddress.getContactName());
tmsOrder.setUnloadPhone(lastAddress.getContactPhone());
tmsOrder.setUnloadingData(lastAddress.getLayDate());
tmsOrder.setMachineNumber(String.join(",", machineNumberList));
// 设置货物名称,将所有货物信息用逗号连接
tmsOrder.setGoodsName(String.join(",", goodsNameList));
//服务要求
SysDictData sysDictItem = new SysDictData();
if (StringUtils.isNotBlank(businessDocumentOrderDO.getServiceRequireId())) {
String[] serviceRequireId = businessDocumentOrderDO.getServiceRequireId().split(",");
StringBuilder serviceRequire = new StringBuilder();
tmsOrder.setServiceRequire(findName(serviceRequireId, sysDictItem, serviceRequire));
}
//车长车型
if (StringUtils.isNotEmpty(businessDocumentOrderDO.getCarType())) {
String[] carType = businessDocumentOrderDO.getCarType().split(",");
StringBuilder carTypeName = new StringBuilder();
tmsOrder.setCarTypeName(findName(carType, sysDictItem, carTypeName));
}
if (ObjectUtil.isNotEmpty(allCargoList)&&allCargoList.size()>0) {
BusinessDocumentCargoMultiDTO tmsCargoInfoDTO1 = allCargoList.get(0);
String goodsTypeId = tmsCargoInfoDTO1.getGoodsTypeId();
if (ObjectUtil.isNotEmpty(goodsTypeId)) {
for (BusinessDocumentCargoMultiDTO tmsCargoInfoDTO : allCargoList) {
//货物重量单位id
if (StringUtils.isNotBlank(tmsCargoInfoDTO.getWeightUnitId())) {
SysDictData sysDictItem3 = dictDataUtils.getDictDataByValue(DictTypeEnum.GOODSUNIT.getTypeCode(), tmsCargoInfoDTO.getWeightUnitId());
if (sysDictItem3 != null) {
tmsOrder.setGoodsUntis(sysDictItem3.getDictLabel());
}
} else {
tmsOrder.setGoodsUntisId("1");
tmsOrder.setGoodsUntis("");
}
//货物数量单位id
if (StringUtils.isNotBlank(tmsCargoInfoDTO.getQuantityUnitId())) {
SysDictData sysDictItem33 = dictDataUtils.getDictDataByValue(DictTypeEnum.GOODSUNIT.getTypeCode(), tmsCargoInfoDTO.getQuantityUnitId());
if (sysDictItem33 != null) {
tmsCargoInfoDTO.setQuantityUnit(sysDictItem33.getDictLabel());
}
}
}
}
}
//配载方式名称
if (businessDocumentOrderDO.getTransportationModeId() != null && StringUtils.isNotEmpty(businessDocumentOrderDO.getTransportationModeId() + "")) {
if (businessDocumentOrderDO.getTransportationModeId() == 0) {
tmsOrder.setTransportationName("数量配载");
tmsOrder.setRadioValue(2L);
//wxy 23-12-15日修改,数量配载时不重置需求车次为1
// tmsOrder.setDemandTrainNumber(1);
} else if (businessDocumentOrderDO.getTransportationModeId() == 1) {
tmsOrder.setTransportationName("车次配载");
tmsOrder.setRadioValue(1L);
}
}
if(businessDocumentOrderDO.getOrderShippingType()==3){
tmsOrder.setTransportationName("数量配载");
tmsOrder.setRadioValue(2L);
tmsOrder.setTransportationModeId(0L);
}else{
tmsOrder.setTransportationName("车次配载");
tmsOrder.setRadioValue(1L);
tmsOrder.setTransportationModeId(1L);
}
//货源单保存
tmsOrder.setCreateUserId(String.valueOf(u.getUserid()));
tmsOrder.setOrderStatus(0L);
//保存付款方
if(businessDocumentOrderDO.getPayerType()==0){//委托方
tmsOrder.setPayer(tmsOrder.getAppointShipper());
}else if(businessDocumentOrderDO.getPayerType()==1){//收货方
tmsOrder.setPayer(tmsOrder.getRecipientName());
}
// 设置组织信息
if (businessDocumentOrderDO.getOrganizationId() != null) {
tmsOrder.setOrganizationId(businessDocumentOrderDO.getOrganizationId());
}
if (businessDocumentOrderDO.getOrganizationName() != null) {
tmsOrder.setOrganizationName(businessDocumentOrderDO.getOrganizationName());
}
if (businessDocumentOrderDO.getTopOrganizationId() != null) {
tmsOrder.setTopOrganizationId(businessDocumentOrderDO.getTopOrganizationId());
}
boolean istrue=businessDocumentOrderService.insert(businessDocumentOrderDO);
//保存货物信息及地址信息
saveAddress2CargoInfo(tmsOrder.getId(), allCargoList, loadingAddressList, unloadAddressList);
return istrue;
}
/**
* 修改【请填写功能名称】
*/
public Boolean update(BusinessDocumentOrderDO businessDocumentOrderDO) {
return businessDocumentOrderService.update(businessDocumentOrderDO);
LoginUser u = SecurityUtils.getLoginUser();
UserShipperPo userShipperPo=u.getUserShipperPo();
if (userShipperPo == null) {
throw new ServiceException("您非货主角色或账号已被删除!");
}
BusinessDocumentOrder tmsOrder = businessDocumentOrderService.getById(businessDocumentOrderDO.getId());
if (tmsOrder.getOrderStatus() == 1){
tmsOrder.setOrderStatus(0L);
}
if (tmsOrder == null) {
throw new ServiceException("货源单不存在或已被删除!");
}
if (tmsOrder.getIsSource() == 1) {
throw new ServiceException("运单已被关闭,请确认!");
}
//处理费用默认值
handFee(businessDocumentOrderDO);
//组织赋值
Long organizationId = businessDocumentOrderDO.getOrganizationId();
if(ObjectUtil.isNotEmpty(organizationId)){
businessDocumentOrderDO.setOrgId(String.valueOf(organizationId));
businessDocumentOrderDO.setOrgName(businessDocumentOrderDO.getOrganizationName());
}else{
businessDocumentOrderDO.setOrgId(String.valueOf(u.getUserPo().getOrganizationId()));
businessDocumentOrderDO.setOrgName(String.valueOf(u.getUserPo().getOrganizationName()));
}
businessDocumentOrderDO.setTopOrganizationId(u.getUserPo().getTopOrganizationId());
BigDecimal deliveryFreight=tmsOrder.getDeliveryFreight();
/**
* 生成货源单信息
*/
BeanUtils.copyProperties(businessDocumentOrderDO, tmsOrder);
tmsOrder.setSzwlUserId(Long.valueOf(u.getUserid()));
if (tmsOrder.getLoadingDate() != null && tmsOrder.getUnloadingData() != null) {
if (tmsOrder.getUnloadingData().before(tmsOrder.getLoadingDate())) {
throw new ServiceException("装货日期不能大于卸货日期!");
}
}
//赋值信息费收款方信息
if(businessDocumentOrderDO.getOrderShippingType()==3&&businessDocumentOrderDO.getInfoFeePayeeType()!=null){
String infoFeePayee = "";
if(businessDocumentOrderDO.getInfoFeePayeeType()==0){
infoFeePayee = businessDocumentOrderDO.getAppointShipper();//委托方
}else if(businessDocumentOrderDO.getInfoFeePayeeType()==1){
infoFeePayee = businessDocumentOrderDO.getRecipientName();//收货方
}else if(businessDocumentOrderDO.getInfoFeePayeeType()==2){
infoFeePayee = businessDocumentOrderDO.getInfoFeePayee();//第三方
if(StringUtils.isBlank(businessDocumentOrderDO.getInfoFeePayee())){
throw new ServiceException("请填写信息费第三方收款方信息!");
}
}
tmsOrder.setInfoFeePayeeType(businessDocumentOrderDO.getInfoFeePayeeType());
if(infoFeePayee!=""){
tmsOrder.setInfoFeePayee(infoFeePayee);
}
}
//根据货物重量大小赋值
BigDecimal weightMin = new BigDecimal(0);
tmsOrder.setWeightMin(weightMin);
tmsOrder.setUncollectedFreight(tmsOrder.getDeliveryFreight());
//存入对应创建人
tmsOrder.setCreateBy(userShipperPo.getUserId());
if ( 2 == userShipperPo.getShipperType()) {
tmsOrder.setCreateCompanyId(String.valueOf(userShipperPo.getUserId()));
}
tmsOrder.setCreateTime(new Date());
tmsOrder.setCreaterName(u.getUsername());//保存创建人姓名
tmsOrder.setCreaterPhone(u.getUserPo().getUserPhone());//保存创建人电话
tmsOrder.setRealCreateBy(String.valueOf(u.getUserid()));
tmsOrder.setRealCreateName(u.getUsername());
tmsOrder.setAppointShipper(userShipperPo.getShipperEnterpriseName());//20250-07-29修改:订单表委托方保存公司名字,而不是姓名
String salesmanCodeNc = businessDocumentOrderDO.getSalesmanId();
if (salesmanCodeNc != null){
String makerCodeNc = businessDocumentOrderService.selectByMakerCodeNc(salesmanCodeNc);
String makerCodeNc1 = businessDocumentOrderService.selectByMakerCodeNc1(salesmanCodeNc);
tmsOrder.setMakerCodeNc(makerCodeNc);
tmsOrder.setSalesmanCodeNc(makerCodeNc1);
}
List<String> machineNumberList = new ArrayList<>();
List<String> goodsNameList = new ArrayList<>();
// 分类处理货物列表
List<BusinessDocumentCargoMultiDTO> allCargoList = businessDocumentOrderDO.getBusinessDocumentCargoMultiList();
if (ObjectUtil.isNotEmpty(allCargoList)&&allCargoList.size()>0) {
BusinessDocumentCargoMultiDTO tmsCargoInfoDTO1 = allCargoList.get(0);
String goodsTypeId = tmsCargoInfoDTO1.getGoodsTypeId();
if (ObjectUtil.isNotEmpty(goodsTypeId)) {
for (BusinessDocumentCargoMultiDTO tmsCargoInfoDTO : allCargoList) {
// 处理货物名称信息
String goodsName = buildCargoNameInfo(tmsCargoInfoDTO, businessDocumentOrderDO);
if (goodsName != null) {
goodsNameList.add(goodsName);
}
// 处理机械编号信息
String machineCode = extractMachineCode(tmsCargoInfoDTO);
if (machineCode != null) {
machineNumberList.add(machineCode);
}
}
}
}
//生成货源单号
tmsOrder.setGoodsNumber(OrderSequence.getOrderCode());
List<BusinessDocumentAddressMultiDTO> loadingAddressList = businessDocumentOrderDO.getLoadingAddressList();//装货地信息集合
List<BusinessDocumentAddressMultiDTO> unloadAddressList = businessDocumentOrderDO.getUnloadAddressList();//卸货地信息集合
String loadCityCounty="",unloadCityCounty="";
//获取第一条装货地址和获取最后一条卸货地址
BusinessDocumentAddressMultiDTO firstAddress = loadingAddressList.get(0);
BusinessDocumentAddressMultiDTO lastAddress = unloadAddressList.get(unloadAddressList.size() - 1);
tmsOrder.setLoadingAreaId(firstAddress.getAreaCode());
tmsOrder.setLoadingName(firstAddress.getAreaCode());
tmsOrder.setLoadingAddress(firstAddress.getAddress());
String area = firstAddress.getAreaCode() + firstAddress.getAddress();
tmsOrder.setLineTitleLeft(firstAddress.getAreaCode());
tmsOrder.setLineTitleRight(lastAddress.getAreaCode());
tmsOrder.setFreighterName(firstAddress.getContactName());
tmsOrder.setLoadingPhone(firstAddress.getContactPhone());
tmsOrder.setLoadingDate(firstAddress.getLayDate());
tmsOrder.setUnloadAreaId(lastAddress.getAreaCode());
tmsOrder.setUnloadName(lastAddress.getAreaCode());
tmsOrder.setUnloadAddress(lastAddress.getAddress());
String unarea = lastAddress.getAreaCode() + lastAddress.getAddress();
tmsOrder.setDischargerName(lastAddress.getContactName());
tmsOrder.setUnloadPhone(lastAddress.getContactPhone());
tmsOrder.setUnloadingData(lastAddress.getLayDate());
tmsOrder.setMachineNumber(String.join(",", machineNumberList));
// 设置货物名称,将所有货物信息用逗号连接
tmsOrder.setGoodsName(String.join(",", goodsNameList));
//服务要求
SysDictData sysDictItem = new SysDictData();
if (StringUtils.isNotBlank(businessDocumentOrderDO.getServiceRequireId())) {
String[] serviceRequireId = businessDocumentOrderDO.getServiceRequireId().split(",");
StringBuilder serviceRequire = new StringBuilder();
tmsOrder.setServiceRequire(findName(serviceRequireId, sysDictItem, serviceRequire));
}
//车长车型
if (StringUtils.isNotEmpty(businessDocumentOrderDO.getCarType())) {
String[] carType = businessDocumentOrderDO.getCarType().split(",");
StringBuilder carTypeName = new StringBuilder();
tmsOrder.setCarTypeName(findName(carType, sysDictItem, carTypeName));
}
if (ObjectUtil.isNotEmpty(allCargoList)&&allCargoList.size()>0) {
BusinessDocumentCargoMultiDTO tmsCargoInfoDTO1 = allCargoList.get(0);
String goodsTypeId = tmsCargoInfoDTO1.getGoodsTypeId();
if (ObjectUtil.isNotEmpty(goodsTypeId)) {
for (BusinessDocumentCargoMultiDTO tmsCargoInfoDTO : allCargoList) {
//货物重量单位id
if (StringUtils.isNotBlank(tmsCargoInfoDTO.getWeightUnitId())) {
SysDictData sysDictItem3 = dictDataUtils.getDictDataByValue(DictTypeEnum.GOODSUNIT.getTypeCode(), tmsCargoInfoDTO.getWeightUnitId());
if (sysDictItem3 != null) {
tmsOrder.setGoodsUntis(sysDictItem3.getDictLabel());
}
} else {
tmsOrder.setGoodsUntisId("1");
tmsOrder.setGoodsUntis("");
}
//货物数量单位id
if (StringUtils.isNotBlank(tmsCargoInfoDTO.getQuantityUnitId())) {
SysDictData sysDictItem33 = dictDataUtils.getDictDataByValue(DictTypeEnum.GOODSUNIT.getTypeCode(), tmsCargoInfoDTO.getQuantityUnitId());
if (sysDictItem33 != null) {
tmsCargoInfoDTO.setQuantityUnit(sysDictItem33.getDictLabel());
}
}
}
}
}
//配载方式名称
if (businessDocumentOrderDO.getTransportationModeId() != null && StringUtils.isNotEmpty(businessDocumentOrderDO.getTransportationModeId() + "")) {
if (businessDocumentOrderDO.getTransportationModeId() == 0) {
tmsOrder.setTransportationName("数量配载");
tmsOrder.setRadioValue(2L);
//wxy 23-12-15日修改,数量配载时不重置需求车次为1
// tmsOrder.setDemandTrainNumber(1);
} else if (businessDocumentOrderDO.getTransportationModeId() == 1) {
tmsOrder.setTransportationName("车次配载");
tmsOrder.setRadioValue(1L);
}
}
if(businessDocumentOrderDO.getOrderShippingType()==3){
tmsOrder.setTransportationName("数量配载");
tmsOrder.setRadioValue(2L);
tmsOrder.setTransportationModeId(0L);
}else{
tmsOrder.setTransportationName("车次配载");
tmsOrder.setRadioValue(1L);
tmsOrder.setTransportationModeId(1L);
}
//货源单保存
tmsOrder.setCreateUserId(String.valueOf(u.getUserid()));
tmsOrder.setOrderStatus(0L);
//保存付款方
if(businessDocumentOrderDO.getPayerType()==0){//委托方
tmsOrder.setPayer(tmsOrder.getAppointShipper());
}else if(businessDocumentOrderDO.getPayerType()==1){//收货方
tmsOrder.setPayer(tmsOrder.getRecipientName());
}
// 设置组织信息
if (businessDocumentOrderDO.getOrganizationId() != null) {
tmsOrder.setOrganizationId(businessDocumentOrderDO.getOrganizationId());
}
if (businessDocumentOrderDO.getOrganizationName() != null) {
tmsOrder.setOrganizationName(businessDocumentOrderDO.getOrganizationName());
}
if (businessDocumentOrderDO.getTopOrganizationId() != null) {
tmsOrder.setTopOrganizationId(businessDocumentOrderDO.getTopOrganizationId());
}
boolean istrue=businessDocumentOrderService.update(businessDocumentOrderDO);
//保存货物信息及地址信息
saveAddress2CargoInfo(tmsOrder.getId(), allCargoList, loadingAddressList, unloadAddressList);
return istrue;
}
private void saveAddress2CargoInfo(Long id, List<BusinessDocumentCargoMultiDTO> cargoInfoList, List<BusinessDocumentAddressMultiDTO> loadingAddressList, List<BusinessDocumentAddressMultiDTO> unloadAddressList) {
//根据ID先删除货物、装卸货信息
Snowflake snowflake = IdUtil.createSnowflake(1, 1);
if (ObjectUtil.isNotEmpty(cargoInfoList)&&cargoInfoList.size()>0) {
BusinessDocumentCargoMultiDTO tmsCargoInfoDTO1 = cargoInfoList.get(0);
String goodsTypeId = tmsCargoInfoDTO1.getGoodsTypeId();
if (ObjectUtil.isNotEmpty(goodsTypeId)) {
businessDocumentCargoMultiMapper.delete(new LambdaQueryWrapper<BusinessDocumentCargoMulti>().eq(BusinessDocumentCargoMulti::getOrderId, id));
List<BusinessDocumentCargoMulti> tmsCargoInfoList = new ArrayList<>();
for (BusinessDocumentCargoMultiDTO tmsCargoInfoDTO : cargoInfoList) {
BusinessDocumentCargoMulti tmsCargoInfo = new BusinessDocumentCargoMulti();
BeanUtils.copyProperties(tmsCargoInfoDTO, tmsCargoInfo);
tmsCargoInfo.setCreateTime(new Date());
tmsCargoInfo.setUpdateTime(new Date());
tmsCargoInfo.setOrderId(String.valueOf(id));
tmsCargoInfo.setCargoWeight(tmsCargoInfoDTO.getWeight()==null ? BigDecimal.ZERO: tmsCargoInfoDTO.getWeight());
tmsCargoInfo.setCargoNum(tmsCargoInfoDTO.getCargoNum()==null ? BigDecimal.ZERO: tmsCargoInfoDTO.getCargoNum());
businessDocumentCargoMultiMapper.insert(tmsCargoInfo);
}
}
}
businessDocumentAddressMultiMapper.delete(new LambdaQueryWrapper<BusinessDocumentAddressMulti>().eq(BusinessDocumentAddressMulti::getOrderId, id));
List<BusinessDocumentAddressMulti> addressMultiList = new ArrayList<>();
for (BusinessDocumentAddressMultiDTO addressMultiDTO : loadingAddressList) {
BusinessDocumentAddressMulti tmsAddressMulti = new BusinessDocumentAddressMulti();
BeanUtils.copyProperties(addressMultiDTO, tmsAddressMulti);
tmsAddressMulti.setCreateTime(new Date());
tmsAddressMulti.setUpdateTime(new Date());
tmsAddressMulti.setOrderId(String.valueOf(id));
tmsAddressMulti.setLayType(1L);
tmsAddressMulti.setSort(addressMultiDTO.getSort());
tmsAddressMulti.setShortName(tmsAddressMulti.getAreaName());
businessDocumentAddressMultiMapper.insert(tmsAddressMulti);
}
for (BusinessDocumentAddressMultiDTO addressMultiDTO : unloadAddressList) {
BusinessDocumentAddressMulti tmsAddressMulti = new BusinessDocumentAddressMulti();
BeanUtils.copyProperties(addressMultiDTO, tmsAddressMulti);
tmsAddressMulti.setCreateTime(new Date());
tmsAddressMulti.setUpdateTime(new Date());
tmsAddressMulti.setOrderId(String.valueOf(id));
tmsAddressMulti.setShortName(tmsAddressMulti.getAreaName());
businessDocumentAddressMultiMapper.insert(tmsAddressMulti);
}
}
/**
* 处理前端费用为null的情况
* @param businessDocumentOrderDO
*/
private void handFee(BusinessDocumentOrderDO businessDocumentOrderDO) {
businessDocumentOrderDO.setWeightMin( businessDocumentOrderDO.getWeightMin() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getWeightMin());
businessDocumentOrderDO.setWeightMax( businessDocumentOrderDO.getWeightMax() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getWeightMax());
businessDocumentOrderDO.setDeliveryFreight( businessDocumentOrderDO.getDeliveryFreight() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getDeliveryFreight());
businessDocumentOrderDO.setTransportationUnitPrice( businessDocumentOrderDO.getTransportationUnitPrice() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getTransportationUnitPrice());
//businessDocumentOrderDO.setHighestPrice( businessDocumentOrderDO.getHighestPrice() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getHighestPrice());
// businessDocumentOrderDO.setMaximumBidPrice( businessDocumentOrderDO.getMaximumBidPrice() == null ? BigDecimal.ZERO : businessDocumentOrderDO.getMaximumBidPrice());
}
/**
* 构建货物名称信息
* @param tmsCargoInfoDTO 货物信息
* @param tmsOrderAddDTO 订单信息
* @return 格式化的货物名称字符串,如果货物名称为空则返回null
*/
private String buildCargoNameInfo(BusinessDocumentCargoMultiDTO tmsCargoInfoDTO, BusinessDocumentOrderDO tmsOrderAddDTO) {
// 早期返回:如果货物名称为空,返回null
if (tmsCargoInfoDTO.getCargoName() == null || StringUtils.isEmpty(tmsCargoInfoDTO.getCargoName())) {
return null;
}
StringBuilder goodsInfo = new StringBuilder();
goodsInfo.append(tmsCargoInfoDTO.getCargoName());
// 非罐车运输:使用cargoNum和cargoUnitName
if (tmsCargoInfoDTO.getCargoNum() != null) {
goodsInfo.append("*").append(tmsCargoInfoDTO.getCargoNum());
}
if (tmsCargoInfoDTO.getCargoUnitName() != null && StringUtils.isNotEmpty(tmsCargoInfoDTO.getCargoUnitName())) {
goodsInfo.append(tmsCargoInfoDTO.getCargoUnitName());
}
return goodsInfo.toString();
}
/**
* 提取机械编号信息
* @param tmsCargoInfoDTO 货物信息
* @return 机械编号字符串,如果机械编号为空则返回null
*/
private String extractMachineCode(BusinessDocumentCargoMultiDTO tmsCargoInfoDTO) {
// 早期返回:如果机械编号为空,返回null
if (tmsCargoInfoDTO.getMachineCode() == null || StringUtils.isEmpty(tmsCargoInfoDTO.getMachineCode())) {
return null;
}
return tmsCargoInfoDTO.getMachineCode();
}
/**
* 批量删除【请填写功能名称】
*/
@@ -68,4 +655,44 @@ public class BusinessDocumentOrderDomainService {
public Boolean execute(Long[] ids) {
return businessDocumentOrderService.execute(ids);
}
/**
* 查询编码对应名称
*
* @param serviceRequireId
* @param sysDictItem
* @param serviceRequire
* @return
*/
private String findName(String[] serviceRequireId, SysDictData sysDictItem, StringBuilder serviceRequire) {
List<SysDictData> dictDataList = dictDataUtils.getDictDataList();
Map<String, List<SysDictData>> map = dictDataList.stream().collect(Collectors.groupingBy(SysDictData::getDictType));
List<SysDictData> dictData = new ArrayList<>();
if (map != null){
if (map.get(DictTypeEnum.SERVICE_REQUIREMENT.getTypeCode()) != null){
dictData.addAll(map.get(DictTypeEnum.SERVICE_REQUIREMENT.getTypeCode()));
}
if (map.get(DictTypeEnum.VEHICLE_LENGTH.getTypeCode()) != null){
dictData.addAll(map.get(DictTypeEnum.VEHICLE_LENGTH.getTypeCode()));
}
if (map.get(DictTypeEnum.VEHICLE_TYPE.getTypeCode()) != null){
dictData.addAll(map.get(DictTypeEnum.VEHICLE_TYPE.getTypeCode()));
}
}
if(dictData != null && dictData.size()>0){
for (int i = 0; i < serviceRequireId.length; i++) {
if (serviceRequireId[i].length() > 0) {
sysDictItem = dictDataUtils.getDictData(dictData, serviceRequireId[i]);
if (sysDictItem != null){
serviceRequire.append(sysDictItem.getDictLabel());
if (i < serviceRequireId.length - 1) {
serviceRequire.append(",");
}
}
}
}
}
return serviceRequire.toString();
}
}
@@ -9,7 +9,7 @@ import java.util.List;
/**
* 【请填写功能名称】Service接口
*
*
* @author gen
* @date 2026-01-27
*/
@@ -35,6 +35,8 @@ public interface IExecuteOrderService extends IService<ExecuteOrder>
*/
public Boolean delete(Long[] ids);
public Boolean issueDocuments(Long[] ids);
/**
* 查询【请填写功能名称】
@@ -1,5 +1,6 @@
package com.mhd.oms.domain.executeOrder.repository.persistence;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
import com.mhd.oms.domain.executeOrder.repository.facade.IExecuteOrderService;
@@ -15,7 +16,7 @@ import java.util.List;
/**
* 【请填写功能名称】Service业务层处理
*
*
* @author gen
* @date 2026-01-27
*/
@@ -68,6 +69,23 @@ public class ExecuteOrderImpl extends ServiceImpl<ExecuteOrderMapper, ExecuteOrd
return this.updateBatchById(list);
}
@Override
public Boolean issueDocuments(Long[] ids) {
for (Long id:ids){
ExecuteOrder executeOrder=executeOrderMapper.selectById(id);
if (ObjectUtil.isNotNull(executeOrder)){
}
}
return null;
}
/**
* 修改【请填写功能名称】
*/
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 【请填写功能名称】
*
*
* @author gen
* @date 2026-01-27
*/
@@ -51,6 +51,9 @@ public class ExecuteOrderDomainService {
public Boolean delete(Long[] ids) {
return executeOrderService.delete(ids);
}
public Boolean issueDocuments(Long[] ids) {
return executeOrderService.issueDocuments(ids);
}
/**
* 获取【请填写功能名称】详细信息