新增渠道管理
This commit is contained in:
@@ -2,6 +2,7 @@ package com.bms.masterdata.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bms.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -17,53 +18,98 @@ public class ServiceChannel
|
||||
private String id;
|
||||
|
||||
/** 渠道编码 */
|
||||
@Excel(name = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
/** 渠道名称 */
|
||||
@Excel(name = "渠道名称")
|
||||
private String channelName;
|
||||
|
||||
/** 所属服务商编码 */
|
||||
@Excel(name = "服务商编码")
|
||||
private String serviceCode;
|
||||
|
||||
/** 所属服务商名称 */
|
||||
@Excel(name = "服务商名称")
|
||||
private String serviceName;
|
||||
|
||||
/** 是否启用(1启用 0停用) */
|
||||
@Excel(name = "是否启用", readConverterExp = "1=启用,0=停用")
|
||||
private String blOpen;
|
||||
|
||||
/** 是否支持多票(1是 0否) */
|
||||
@Excel(name = "是否多票", readConverterExp = "1=是,0=否")
|
||||
private String blMultiple;
|
||||
|
||||
@Excel(name = "货物类型")
|
||||
private String cargoType;
|
||||
|
||||
@Excel(name = "付款方式")
|
||||
private String payType;
|
||||
|
||||
@Excel(name = "发货人名称")
|
||||
private String shipperName;
|
||||
|
||||
@Excel(name = "发货人ID")
|
||||
private String shipperId;
|
||||
|
||||
@Excel(name = "轨迹查询类型")
|
||||
private String queryType;
|
||||
|
||||
@Excel(name = "轨迹编码")
|
||||
private String trajectoryCode;
|
||||
|
||||
@Excel(name = "末端服务商")
|
||||
private String finalServiceName;
|
||||
|
||||
@Excel(name = "目的港/目的地区域")
|
||||
private String desPort;
|
||||
|
||||
/** 重量类型 */
|
||||
@Excel(name = "重量类型")
|
||||
private String weightType;
|
||||
|
||||
/** 体积除数(抛货系数) */
|
||||
@Excel(name = "抛货系数")
|
||||
private Long dimDivisor;
|
||||
|
||||
@Excel(name = "计重规则")
|
||||
private String weightRule;
|
||||
|
||||
@Excel(name = "发货类型")
|
||||
private String shipmentType;
|
||||
|
||||
@Excel(name = "数据来源")
|
||||
private String dataFrom;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Excel(name = "创建人")
|
||||
private String createName;
|
||||
|
||||
private String createManCode;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "创建时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDate;
|
||||
|
||||
@Excel(name = "修改人")
|
||||
private String modifier;
|
||||
|
||||
private String modifierCode;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "修改时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date modifyDate;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date gmtCreate;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date gmtModified;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "同步时间", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date syncTime;
|
||||
}
|
||||
|
||||
+43
-2
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
|
||||
/**
|
||||
* 服务渠道镜像表查询(MASTER 数据源)
|
||||
* 服务渠道 srv_service_channel
|
||||
*
|
||||
* @author bms
|
||||
* @date 2026-10-12
|
||||
@@ -12,7 +12,48 @@ import com.bms.masterdata.domain.ServiceChannel;
|
||||
public interface ServiceChannelMapper
|
||||
{
|
||||
/**
|
||||
* 查询服务渠道列表(支持渠道编码/名称/服务商编码/启用状态过滤,非分页)
|
||||
* 查询服务渠道列表。
|
||||
* 渠道名称、服务商名称、目的港/目的地区域、发货人名称为模糊匹配;编码同样按包含匹配,便于列表检索。
|
||||
*/
|
||||
List<ServiceChannel> selectServiceChannelList(ServiceChannel query);
|
||||
|
||||
/**
|
||||
* 按主键查询渠道
|
||||
*/
|
||||
ServiceChannel selectServiceChannelById(String id);
|
||||
|
||||
/**
|
||||
* 按渠道编码精确查询(唯一性校验)
|
||||
*/
|
||||
ServiceChannel selectServiceChannelByCode(String channelCode);
|
||||
|
||||
/**
|
||||
* 产品渠道关系中引用该渠道编码的数量
|
||||
*/
|
||||
int countProductChannelByCode(String channelCode);
|
||||
|
||||
/**
|
||||
* 供应商绑定中引用该渠道编码的数量
|
||||
*/
|
||||
int countSupplierByChannelCode(String channelCode);
|
||||
|
||||
/**
|
||||
* 新增渠道
|
||||
*/
|
||||
int insertServiceChannel(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 修改渠道
|
||||
*/
|
||||
int updateServiceChannel(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 只更新启用状态
|
||||
*/
|
||||
int updateServiceChannelStatus(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 批量删除渠道
|
||||
*/
|
||||
int deleteServiceChannelByIds(String[] ids);
|
||||
}
|
||||
|
||||
+27
-2
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
|
||||
/**
|
||||
* 服务渠道镜像 服务层
|
||||
* 服务渠道 服务层
|
||||
*
|
||||
* @author bms
|
||||
* @date 2026-10-12
|
||||
@@ -12,7 +12,32 @@ import com.bms.masterdata.domain.ServiceChannel;
|
||||
public interface IServiceChannelService
|
||||
{
|
||||
/**
|
||||
* 查询服务渠道列表(非分页,供供应商绑定渠道等下拉选择场景)
|
||||
* 查询服务渠道列表(分页由调用方 startPage 控制;下拉场景不传分页)
|
||||
*/
|
||||
List<ServiceChannel> selectServiceChannelList(ServiceChannel query);
|
||||
|
||||
/**
|
||||
* 查询渠道详情
|
||||
*/
|
||||
ServiceChannel selectServiceChannelById(String id);
|
||||
|
||||
/**
|
||||
* 新增渠道
|
||||
*/
|
||||
int insertServiceChannel(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 修改渠道
|
||||
*/
|
||||
int updateServiceChannel(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 启用或停用渠道(只改 bl_open)
|
||||
*/
|
||||
int updateServiceChannelStatus(ServiceChannel channel);
|
||||
|
||||
/**
|
||||
* 批量删除渠道。已被产品渠道或供应商引用时拒绝删除。
|
||||
*/
|
||||
int deleteServiceChannelByIds(String[] ids);
|
||||
}
|
||||
|
||||
+169
-1
@@ -3,12 +3,15 @@ package com.bms.masterdata.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
||||
import com.bms.masterdata.service.IServiceChannelService;
|
||||
|
||||
/**
|
||||
* 服务渠道镜像 服务实现
|
||||
* 服务渠道 服务实现
|
||||
*
|
||||
* @author bms
|
||||
* @date 2026-10-12
|
||||
@@ -24,4 +27,169 @@ public class ServiceChannelServiceImpl implements IServiceChannelService
|
||||
{
|
||||
return serviceChannelMapper.selectServiceChannelList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceChannel selectServiceChannelById(String id)
|
||||
{
|
||||
return serviceChannelMapper.selectServiceChannelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertServiceChannel(ServiceChannel channel)
|
||||
{
|
||||
prepare(channel, true);
|
||||
assertCodeUnique(channel);
|
||||
channel.setId(IdUtils.fastSimpleUUID());
|
||||
if (StringUtils.isEmpty(channel.getDataFrom()))
|
||||
{
|
||||
channel.setDataFrom("BMS");
|
||||
}
|
||||
return serviceChannelMapper.insertServiceChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateServiceChannel(ServiceChannel channel)
|
||||
{
|
||||
if (channel == null || StringUtils.isEmpty(channel.getId()))
|
||||
{
|
||||
throw new ServiceException("渠道ID不能为空");
|
||||
}
|
||||
ServiceChannel existing = serviceChannelMapper.selectServiceChannelById(channel.getId());
|
||||
if (existing == null)
|
||||
{
|
||||
throw new ServiceException("渠道不存在或已被删除");
|
||||
}
|
||||
prepare(channel, false);
|
||||
assertCodeUnique(channel);
|
||||
if (!StringUtils.equals(existing.getChannelCode(), channel.getChannelCode())
|
||||
&& countUsage(existing.getChannelCode()) > 0)
|
||||
{
|
||||
throw new ServiceException("渠道「" + existing.getChannelName() + "」已被产品渠道或供应商引用,不能修改渠道编码");
|
||||
}
|
||||
return serviceChannelMapper.updateServiceChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateServiceChannelStatus(ServiceChannel channel)
|
||||
{
|
||||
if (channel == null || StringUtils.isEmpty(channel.getId()))
|
||||
{
|
||||
throw new ServiceException("渠道ID不能为空");
|
||||
}
|
||||
if (!"0".equals(channel.getBlOpen()) && !"1".equals(channel.getBlOpen()))
|
||||
{
|
||||
throw new ServiceException("启用状态只能是启用或停用");
|
||||
}
|
||||
ServiceChannel existing = serviceChannelMapper.selectServiceChannelById(channel.getId());
|
||||
if (existing == null)
|
||||
{
|
||||
throw new ServiceException("渠道不存在或已被删除");
|
||||
}
|
||||
return serviceChannelMapper.updateServiceChannelStatus(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteServiceChannelByIds(String[] ids)
|
||||
{
|
||||
if (ids == null || ids.length == 0)
|
||||
{
|
||||
throw new ServiceException("请选择要删除的渠道");
|
||||
}
|
||||
for (String id : ids)
|
||||
{
|
||||
if (StringUtils.isEmpty(id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ServiceChannel existing = serviceChannelMapper.selectServiceChannelById(id);
|
||||
if (existing == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (countUsage(existing.getChannelCode()) > 0)
|
||||
{
|
||||
throw new ServiceException("渠道「" + existing.getChannelName() + "」已被产品渠道或供应商引用,不能删除,请改为停用");
|
||||
}
|
||||
}
|
||||
return serviceChannelMapper.deleteServiceChannelByIds(ids);
|
||||
}
|
||||
|
||||
private void prepare(ServiceChannel channel, boolean creating)
|
||||
{
|
||||
if (channel == null)
|
||||
{
|
||||
throw new ServiceException("渠道信息不能为空");
|
||||
}
|
||||
channel.setChannelCode(StringUtils.trim(channel.getChannelCode()));
|
||||
channel.setChannelName(StringUtils.trim(channel.getChannelName()));
|
||||
channel.setServiceCode(trimToNull(channel.getServiceCode()));
|
||||
channel.setServiceName(trimToNull(channel.getServiceName()));
|
||||
channel.setShipperName(trimToNull(channel.getShipperName()));
|
||||
channel.setDesPort(trimToNull(channel.getDesPort()));
|
||||
if (StringUtils.isEmpty(channel.getChannelCode()))
|
||||
{
|
||||
throw new ServiceException("渠道编码不能为空");
|
||||
}
|
||||
if (channel.getChannelCode().length() > 64)
|
||||
{
|
||||
throw new ServiceException("渠道编码不能超过64个字符");
|
||||
}
|
||||
if (StringUtils.isEmpty(channel.getChannelName()))
|
||||
{
|
||||
throw new ServiceException("渠道名称不能为空");
|
||||
}
|
||||
if (channel.getChannelName().length() > 200)
|
||||
{
|
||||
throw new ServiceException("渠道名称不能超过200个字符");
|
||||
}
|
||||
if (StringUtils.isEmpty(channel.getBlOpen()))
|
||||
{
|
||||
if (creating)
|
||||
{
|
||||
channel.setBlOpen("1");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ServiceException("请选择启用状态");
|
||||
}
|
||||
}
|
||||
if (!"0".equals(channel.getBlOpen()) && !"1".equals(channel.getBlOpen()))
|
||||
{
|
||||
throw new ServiceException("启用状态只能是启用或停用");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(channel.getBlMultiple())
|
||||
&& !"0".equals(channel.getBlMultiple()) && !"1".equals(channel.getBlMultiple()))
|
||||
{
|
||||
throw new ServiceException("是否多票只能是是或否");
|
||||
}
|
||||
if (channel.getDimDivisor() != null && channel.getDimDivisor() < 0)
|
||||
{
|
||||
throw new ServiceException("抛货系数不能为负数");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertCodeUnique(ServiceChannel channel)
|
||||
{
|
||||
ServiceChannel same = serviceChannelMapper.selectServiceChannelByCode(channel.getChannelCode());
|
||||
if (same != null && !StringUtils.equals(same.getId(), channel.getId()))
|
||||
{
|
||||
throw new ServiceException("渠道编码「" + channel.getChannelCode() + "」已存在");
|
||||
}
|
||||
}
|
||||
|
||||
private int countUsage(String channelCode)
|
||||
{
|
||||
if (StringUtils.isEmpty(channelCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return serviceChannelMapper.countProductChannelByCode(channelCode)
|
||||
+ serviceChannelMapper.countSupplierByChannelCode(channelCode);
|
||||
}
|
||||
|
||||
private String trimToNull(String value)
|
||||
{
|
||||
String text = StringUtils.trim(value);
|
||||
return StringUtils.isEmpty(text) ? null : text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user