This commit is contained in:
wuweihua
2026-10-28 18:10:14 +08:00
19 changed files with 159 additions and 948 deletions
@@ -1,117 +0,0 @@
package com.bms.web.controller.data;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bms.common.annotation.Log;
import com.bms.common.core.controller.BaseController;
import com.bms.common.core.domain.AjaxResult;
import com.bms.common.core.page.TableDataInfo;
import com.bms.common.enums.BusinessType;
import com.bms.common.utils.poi.ExcelUtil;
import com.bms.system.domain.BmsSupplierType;
import com.bms.system.service.IBmsSupplierTypeService;
/**
* 数据管理:供应商类型
*
* @author bms
*/
@RestController
@RequestMapping("/data/supplierType")
public class BmsSupplierTypeController extends BaseController
{
@Autowired
private IBmsSupplierTypeService supplierTypeService;
/**
* 分页查询。名称模糊、状态精确。
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:list')")
@GetMapping("/list")
public TableDataInfo list(BmsSupplierType query)
{
startPage();
List<BmsSupplierType> list = supplierTypeService.selectList(query);
return getDataTable(list);
}
/**
* 按当前查询条件导出
*/
@Log(title = "供应商类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('data:supplierType:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, BmsSupplierType query)
{
List<BmsSupplierType> list = supplierTypeService.selectList(query);
ExcelUtil<BmsSupplierType> util = new ExcelUtil<BmsSupplierType>(BmsSupplierType.class);
util.exportExcel(response, list, "供应商类型");
}
/**
* 查询详情
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:query')")
@GetMapping("/{typeId}")
public AjaxResult getInfo(@PathVariable Long typeId)
{
return success(supplierTypeService.selectById(typeId));
}
/**
* 新增
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:add')")
@Log(title = "供应商类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BmsSupplierType row)
{
row.setCreateBy(getUsername());
return toAjax(supplierTypeService.insert(row));
}
/**
* 修改
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:edit')")
@Log(title = "供应商类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BmsSupplierType row)
{
row.setUpdateBy(getUsername());
return toAjax(supplierTypeService.update(row));
}
/**
* 启用或停用
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:changeStatus')")
@Log(title = "供应商类型", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody BmsSupplierType row)
{
row.setUpdateBy(getUsername());
return toAjax(supplierTypeService.changeStatus(row));
}
/**
* 删除
*/
@PreAuthorize("@ss.hasPermi('data:supplierType:remove')")
@Log(title = "供应商类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{typeIds}")
public AjaxResult remove(@PathVariable Long[] typeIds)
{
return toAjax(supplierTypeService.deleteByIds(typeIds));
}
}
@@ -46,8 +46,8 @@ public class BmsSupplier extends BaseEntity
@Excel(name = "统一社会信用代码") @Excel(name = "统一社会信用代码")
private String creditCode; private String creditCode;
/** 供应商类型(1卡车行 2航司代理 3报关行 4清关行 5尾派服务商 6报关代理) */ /** 供应商类型(字典 bms_supplier_type) */
@Excel(name = "供应商类型", readConverterExp = "1=卡车行,2=航司代理,3=报关行,4=清关行,5=尾派服务商,6=报关代理") @Excel(name = "供应商类型", dictType = "bms_supplier_type")
private String supplierType; private String supplierType;
/** 开票类型(1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票) */ /** 开票类型(1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票) */
@@ -127,11 +127,6 @@ public class BmsSupplier extends BaseEntity
@Excel(name = "合作开始日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "合作开始日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date cooperationStartDate; private Date cooperationStartDate;
/** 合同开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "合同开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date contractStartDate;
/** 合同结束时间 */ /** 合同结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "合同结束时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "合同结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@@ -5,15 +5,18 @@ import java.util.List;
import com.bms.common.annotation.DataScope; import com.bms.common.annotation.DataScope;
import com.bms.common.exception.ServiceException; import com.bms.common.exception.ServiceException;
import com.bms.common.core.domain.entity.SysDictData;
import com.bms.common.core.domain.entity.SysUser; import com.bms.common.core.domain.entity.SysUser;
import com.bms.common.utils.DateUtils; import com.bms.common.utils.DateUtils;
import com.bms.common.utils.SecurityUtils; import com.bms.common.utils.SecurityUtils;
import com.bms.common.utils.StringUtils;
import com.bms.customer.supplierinfo.domain.BmsSupplier; import com.bms.customer.supplierinfo.domain.BmsSupplier;
import com.bms.customer.supplierinfo.domain.BmsSupplierAttachment; import com.bms.customer.supplierinfo.domain.BmsSupplierAttachment;
import com.bms.customer.supplierinfo.domain.BmsSupplierCompany; import com.bms.customer.supplierinfo.domain.BmsSupplierCompany;
import com.bms.customer.supplierinfo.domain.BmsSupplierContact; import com.bms.customer.supplierinfo.domain.BmsSupplierContact;
import com.bms.customer.supplierinfo.mapper.BmsSupplierMapper; import com.bms.customer.supplierinfo.mapper.BmsSupplierMapper;
import com.bms.customer.supplierinfo.service.IBmsSupplierService; import com.bms.customer.supplierinfo.service.IBmsSupplierService;
import com.bms.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -27,9 +30,15 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class BmsSupplierServiceImpl implements IBmsSupplierService public class BmsSupplierServiceImpl implements IBmsSupplierService
{ {
/** 供应商类型只认系统字典,不另建类型表 */
private static final String DICT_SUPPLIER_TYPE = "bms_supplier_type";
@Autowired @Autowired
private BmsSupplierMapper bmsSupplierMapper; private BmsSupplierMapper bmsSupplierMapper;
@Autowired
private ISysDictTypeService dictTypeService;
@Override @Override
public BmsSupplier selectBmsSupplierBySupplierId(Long supplierId) public BmsSupplier selectBmsSupplierBySupplierId(Long supplierId)
{ {
@@ -252,7 +261,8 @@ public class BmsSupplierServiceImpl implements IBmsSupplierService
@Override @Override
public int insertBmsSupplier(BmsSupplier bmsSupplier) public int insertBmsSupplier(BmsSupplier bmsSupplier)
{ {
checkContractDate(bmsSupplier.getContractStartDate(), bmsSupplier.getContractEndDate()); checkContractDate(bmsSupplier.getCooperationStartDate(), bmsSupplier.getContractEndDate());
checkSupplierType(bmsSupplier);
SysUser user = SecurityUtils.getLoginUser().getUser(); SysUser user = SecurityUtils.getLoginUser().getUser();
bmsSupplier.setCreateTime(DateUtils.getNowDate()); bmsSupplier.setCreateTime(DateUtils.getNowDate());
bmsSupplier.setCreateBy(user.getUserName()); bmsSupplier.setCreateBy(user.getUserName());
@@ -270,7 +280,8 @@ public class BmsSupplierServiceImpl implements IBmsSupplierService
@Override @Override
public int updateBmsSupplier(BmsSupplier bmsSupplier) public int updateBmsSupplier(BmsSupplier bmsSupplier)
{ {
checkContractDate(bmsSupplier.getContractStartDate(), bmsSupplier.getContractEndDate()); checkContractDate(bmsSupplier.getCooperationStartDate(), bmsSupplier.getContractEndDate());
checkSupplierType(bmsSupplier);
SysUser user = SecurityUtils.getLoginUser().getUser(); SysUser user = SecurityUtils.getLoginUser().getUser();
bmsSupplier.setUpdateTime(DateUtils.getNowDate()); bmsSupplier.setUpdateTime(DateUtils.getNowDate());
bmsSupplier.setUpdateBy(user.getUserName()); bmsSupplier.setUpdateBy(user.getUserName());
@@ -319,7 +330,30 @@ public class BmsSupplierServiceImpl implements IBmsSupplierService
{ {
if (start != null && end != null && end.before(start)) if (start != null && end != null && end.before(start))
{ {
throw new ServiceException("合同结束时间不能早于开始时间"); throw new ServiceException("合同结束时间不能早于合作开始日期");
}
}
/**
* 供应商类型允许为空;有值时必须是字典 bms_supplier_type 中启用的键值。
*/
private void checkSupplierType(BmsSupplier bmsSupplier)
{
if (bmsSupplier.getSupplierType() == null)
{
return;
}
String supplierType = bmsSupplier.getSupplierType().trim();
bmsSupplier.setSupplierType(supplierType);
if (StringUtils.isEmpty(supplierType))
{
return;
}
List<SysDictData> datas = dictTypeService.selectDictDataByType(DICT_SUPPLIER_TYPE);
boolean exists = datas != null && datas.stream().anyMatch(d -> supplierType.equals(d.getDictValue()));
if (!exists)
{
throw new ServiceException("供应商类型不存在或已停用");
} }
} }
} }
@@ -1,6 +1,7 @@
package com.bms.customer.supplierinfo.sync; package com.bms.customer.supplierinfo.sync;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -12,8 +13,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bms.common.core.domain.entity.SysDictData;
import com.bms.common.utils.StringUtils;
import com.bms.customer.supplierinfo.domain.BmsSupplier; import com.bms.customer.supplierinfo.domain.BmsSupplier;
import com.bms.customer.supplierinfo.mapper.SupplierSyncMapper; import com.bms.customer.supplierinfo.mapper.SupplierSyncMapper;
import com.bms.system.service.ISysDictTypeService;
/** /**
* 老系统 Oracle 服务商数据 -> sup_supplier 每日同步。 * 老系统 Oracle 服务商数据 -> sup_supplier 每日同步。
@@ -35,11 +39,17 @@ public class SupplierSyncService
/** 写库人标记,便于事后甄别同步数据 */ /** 写库人标记,便于事后甄别同步数据 */
public static final String SYNC_MARKER = "oracle-sync"; public static final String SYNC_MARKER = "oracle-sync";
/** 源中文服务商类型 -> sup_supplier.supplier_type 字典码(4清关行 5尾派服务商) */ /** 供应商类型字典。老系统中文与字典标签不一致时,先折成标签再取键值 */
private static final String TYPE_QINGGUAN = "清关"; private static final String DICT_SUPPLIER_TYPE = "bms_supplier_type";
private static final String TYPE_WEICHENG = "尾程渠道"; private static final Map<String, String> SOURCE_TYPE_LABEL;
private static final String CODE_QINGGUAN_HANG = "4";
private static final String CODE_WEIPAI = "5"; static
{
Map<String, String> labels = new LinkedHashMap<>();
labels.put("尾程渠道", "尾派服务商");
labels.put("清关", "清关行");
SOURCE_TYPE_LABEL = Collections.unmodifiableMap(labels);
}
/** sup_supplier 字符串列长度 */ /** sup_supplier 字符串列长度 */
private static final int LEN_CODE = 50; private static final int LEN_CODE = 50;
@@ -59,6 +69,9 @@ public class SupplierSyncService
@Autowired @Autowired
private SupplierSyncMapper supplierSyncMapper; private SupplierSyncMapper supplierSyncMapper;
@Autowired
private ISysDictTypeService dictTypeService;
/** /**
* 执行一次全量同步。 * 执行一次全量同步。
* *
@@ -84,6 +97,11 @@ public class SupplierSyncService
} }
Set<String> existingCodes = new HashSet<>(supplierSyncMapper.selectExistingCodes()); Set<String> existingCodes = new HashSet<>(supplierSyncMapper.selectExistingCodes());
List<SysDictData> supplierTypes = dictTypeService.selectDictDataByType(DICT_SUPPLIER_TYPE);
if (supplierTypes == null)
{
supplierTypes = Collections.emptyList();
}
List<BmsSupplier> inserts = new ArrayList<>(); List<BmsSupplier> inserts = new ArrayList<>();
List<BmsSupplier> updates = new ArrayList<>(); List<BmsSupplier> updates = new ArrayList<>();
@@ -120,7 +138,7 @@ public class SupplierSyncService
} }
LinkedHashSet<String> channels = channelMap.getOrDefault(code, new LinkedHashSet<>()); LinkedHashSet<String> channels = channelMap.getOrDefault(code, new LinkedHashSet<>());
BmsSupplier s = mapRow(row, code, name, channels, warnings); BmsSupplier s = mapRow(row, code, name, channels, supplierTypes, warnings);
if (existingCodes.contains(code)) if (existingCodes.contains(code))
{ {
s.setUpdateBy(SYNC_MARKER); s.setUpdateBy(SYNC_MARKER);
@@ -159,14 +177,15 @@ public class SupplierSyncService
* 单行映射 * 单行映射
*/ */
private BmsSupplier mapRow(Map<String, Object> row, String code, String name, private BmsSupplier mapRow(Map<String, Object> row, String code, String name,
LinkedHashSet<String> channels, List<String> warnings) LinkedHashSet<String> channels, List<SysDictData> supplierTypes,
List<String> warnings)
{ {
BmsSupplier s = new BmsSupplier(); BmsSupplier s = new BmsSupplier();
s.setSupplierCode(truncate(code, LEN_CODE, code, "supplier_code", warnings)); s.setSupplierCode(truncate(code, LEN_CODE, code, "supplier_code", warnings));
s.setSupplierName(truncate(name, LEN_NAME, code, "supplier_name", warnings)); s.setSupplierName(truncate(name, LEN_NAME, code, "supplier_name", warnings));
s.setDelFlag("0"); s.setDelFlag("0");
s.setSupplierType(mapServiceType(getStr(row, "SERVICE_TYPE"), code, warnings)); s.setSupplierType(mapServiceType(getStr(row, "SERVICE_TYPE"), code, supplierTypes, warnings));
s.setIsEnable(mapEnable(getStr(row, "BL_OPEN"))); s.setIsEnable(mapEnable(getStr(row, "BL_OPEN")));
s.setRemark(truncate(getStr(row, "REMARK"), LEN_REMARK, code, "remark", warnings)); s.setRemark(truncate(getStr(row, "REMARK"), LEN_REMARK, code, "remark", warnings));
@@ -178,25 +197,35 @@ public class SupplierSyncService
} }
/** /**
* 源 SERVICE_TYPE 为中文:尾程渠道 -> 5(尾派服务商),清关 -> 4(清关行); * 源 SERVICE_TYPE 按字典 bms_supplier_type 解析。
* 其他/空值置空并告警,由业务人员手工选择。 * 老系统「尾程渠道」「清关」先折成字典标签,再取启用项的键值;对不上则置空。
*/ */
private static String mapServiceType(String raw, String supplierCode, List<String> warnings) private static String mapServiceType(String raw, String supplierCode, List<SysDictData> supplierTypes,
List<String> warnings)
{ {
String v = clean(raw); String v = clean(raw);
if (v == null) if (v == null)
{ {
return null; return null;
} }
if (TYPE_WEICHENG.equals(v)) if (supplierTypes == null || supplierTypes.isEmpty())
{ {
return CODE_WEIPAI; warnings.add(supplierCode + ": 字典 " + DICT_SUPPLIER_TYPE + " 无可用数据,类型置空");
return null;
} }
if (TYPE_QINGGUAN.equals(v)) String label = SOURCE_TYPE_LABEL.getOrDefault(v, v);
for (SysDictData dict : supplierTypes)
{ {
return CODE_QINGGUAN_HANG; if (dict == null || StringUtils.isEmpty(dict.getDictValue()))
{
continue;
}
if (label.equals(dict.getDictLabel()) || v.equals(dict.getDictLabel()) || v.equals(dict.getDictValue()))
{
return dict.getDictValue();
}
} }
warnings.add(supplierCode + ": 未知服务商类型 " + v + ",类型置空"); warnings.add(supplierCode + ": 服务商类型「" + v + "」不在字典 " + DICT_SUPPLIER_TYPE + " 中,类型置空");
return null; return null;
} }
@@ -1,112 +0,0 @@
package com.bms.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.bms.common.annotation.Excel;
import com.bms.common.core.domain.BaseEntity;
/**
* 供应商类型 bms_supplier_type
* 类型编码与字典 bms_supplier_type 的字典键值一致,供供应商档案引用。
*
* @author bms
*/
public class BmsSupplierType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 类型ID */
private Long typeId;
/** 类型编码(字典键值) */
@Excel(name = "类型编码")
private String typeCode;
/** 类型名称 */
@Excel(name = "类型名称")
private String typeName;
/** 显示排序 */
@Excel(name = "显示排序")
private Integer typeSort;
/** 状态(0正常 1停用) */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标记(0存在 1删除) */
private String delFlag;
public Long getTypeId()
{
return typeId;
}
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public String getTypeCode()
{
return typeCode;
}
public void setTypeCode(String typeCode)
{
this.typeCode = typeCode;
}
public String getTypeName()
{
return typeName;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public Integer getTypeSort()
{
return typeSort;
}
public void setTypeSort(Integer typeSort)
{
this.typeSort = typeSort;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
@Override
public String toString()
{
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("typeId", getTypeId())
.append("typeCode", getTypeCode())
.append("typeName", getTypeName())
.append("typeSort", getTypeSort())
.append("status", getStatus())
.append("remark", getRemark())
.toString();
}
}
@@ -1,112 +0,0 @@
package com.bms.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.bms.system.domain.BmsSupplierType;
/**
* 供应商类型数据层
*
* @author bms
*/
public interface BmsSupplierTypeMapper
{
/**
* 按名称、状态查询供应商类型
*
* @param query 查询条件
* @return 类型列表
*/
List<BmsSupplierType> selectList(BmsSupplierType query);
/**
* 按主键查询未删除的类型
*
* @param typeId 类型ID
* @return 类型
*/
BmsSupplierType selectById(Long typeId);
/**
* 统计未删除的同编码数量
*
* @param typeCode 类型编码
* @param excludeId 排除的类型ID,新增时为空
* @return 数量
*/
int countByTypeCode(@Param("typeCode") String typeCode, @Param("excludeId") Long excludeId);
/**
* 统计未删除的同名称数量
*
* @param typeName 类型名称
* @param excludeId 排除的类型ID,新增时为空
* @return 数量
*/
int countByTypeName(@Param("typeName") String typeName, @Param("excludeId") Long excludeId);
/**
* 新增供应商类型
*
* @param row 类型
* @return 影响行数
*/
int insert(BmsSupplierType row);
/**
* 修改供应商类型(不改编码,避免已引用的供应商失联)
*
* @param row 类型
* @return 影响行数
*/
int update(BmsSupplierType row);
/**
* 只更新启用状态
*
* @param row 含 typeId、status、updateBy
* @return 影响行数
*/
int updateStatus(BmsSupplierType row);
/**
* 逻辑删除
*
* @param typeIds 类型ID
* @return 影响行数
*/
int deleteByIds(Long[] typeIds);
/**
* 按字典类型和键值取字典编码
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典编码,不存在时为空
*/
Long selectDictCode(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
/**
* 写入字典数据
*
* @param row 类型,字典类型由调用方放入 remark 以外的固定值,见 XML
* @return 影响行数
*/
int insertDict(BmsSupplierType row);
/**
* 按类型编码更新字典标签、排序和状态
*
* @param row 类型
* @return 影响行数
*/
int updateDict(BmsSupplierType row);
/**
* 按类型编码删除字典数据
*
* @param typeCode 类型编码
* @return 影响行数
*/
int deleteDictByCode(String typeCode);
}
@@ -1,60 +0,0 @@
package com.bms.system.service;
import java.util.List;
import com.bms.system.domain.BmsSupplierType;
/**
* 供应商类型服务
*
* @author bms
*/
public interface IBmsSupplierTypeService
{
/**
* 分页前的条件查询,分页由调用方开启
*
* @param query 名称、状态
* @return 类型列表
*/
List<BmsSupplierType> selectList(BmsSupplierType query);
/**
* 查询单个类型
*
* @param typeId 类型ID
* @return 类型
*/
BmsSupplierType selectById(Long typeId);
/**
* 新增类型,并同步字典 bms_supplier_type
*
* @param row 类型
* @return 影响行数
*/
int insert(BmsSupplierType row);
/**
* 修改类型名称、排序、状态、备注,并同步字典
*
* @param row 类型
* @return 影响行数
*/
int update(BmsSupplierType row);
/**
* 启用或停用,并同步字典状态
*
* @param row 含 typeId 与 status
* @return 影响行数
*/
int changeStatus(BmsSupplierType row);
/**
* 逻辑删除,并从字典中移除对应键值
*
* @param typeIds 类型ID
* @return 影响行数
*/
int deleteByIds(Long[] typeIds);
}
@@ -1,232 +0,0 @@
package com.bms.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bms.common.core.domain.entity.SysDictData;
import com.bms.common.exception.ServiceException;
import com.bms.common.utils.DictUtils;
import com.bms.common.utils.StringUtils;
import com.bms.system.domain.BmsSupplierType;
import com.bms.system.mapper.BmsSupplierTypeMapper;
import com.bms.system.mapper.SysDictDataMapper;
import com.bms.system.service.IBmsSupplierTypeService;
/**
* 供应商类型服务实现。
* 供应商类型服务实现。_DETAIL
*
* @author bms
*/
@Service
public class BmsSupplierTypeServiceImpl implements IBmsSupplierTypeService
{
/** 字典类型,与系统字典管理中的类型编码一致 */
public static final String DICT_TYPE = "bms_supplier_type";
@Autowired
private BmsSupplierTypeMapper supplierTypeMapper;
@Autowired
private SysDictDataMapper dictDataMapper;
@Override
public List<BmsSupplierType> selectList(BmsSupplierType query)
{
return supplierTypeMapper.selectList(query);
}
@Override
public BmsSupplierType selectById(Long typeId)
{
return supplierTypeMapper.selectById(typeId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int insert(BmsSupplierType row)
{
normalize(row);
validate(row, null);
if (row.getTypeSort() == null)
{
row.setTypeSort(0);
}
if (StringUtils.isEmpty(row.getStatus()))
{
row.setStatus("0");
}
int rows = supplierTypeMapper.insert(row);
syncDict(row);
return rows;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int update(BmsSupplierType row)
{
if (row.getTypeId() == null)
{
throw new ServiceException("类型ID不能为空");
}
BmsSupplierType existing = requireActive(row.getTypeId());
normalize(row);
if (StringUtils.isEmpty(row.getTypeName()))
{
row.setTypeName(existing.getTypeName());
}
if (row.getTypeSort() == null)
{
row.setTypeSort(existing.getTypeSort());
}
if (StringUtils.isEmpty(row.getStatus()))
{
row.setStatus(existing.getStatus());
}
validateNameAndStatus(row, row.getTypeId());
row.setTypeCode(existing.getTypeCode());
int rows = supplierTypeMapper.update(row);
syncDict(row);
return rows;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int changeStatus(BmsSupplierType row)
{
if (row.getTypeId() == null)
{
throw new ServiceException("类型ID不能为空");
}
if (!"0".equals(row.getStatus()) && !"1".equals(row.getStatus()))
{
throw new ServiceException("状态只能是正常或停用");
}
BmsSupplierType existing = requireActive(row.getTypeId());
existing.setStatus(row.getStatus());
existing.setUpdateBy(row.getUpdateBy());
int rows = supplierTypeMapper.updateStatus(existing);
syncDict(existing);
return rows;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteByIds(Long[] typeIds)
{
if (typeIds == null || typeIds.length == 0)
{
return 0;
}
for (Long typeId : typeIds)
{
BmsSupplierType existing = supplierTypeMapper.selectById(typeId);
if (existing != null && StringUtils.isNotEmpty(existing.getTypeCode()))
{
supplierTypeMapper.deleteDictByCode(existing.getTypeCode());
}
}
int rows = supplierTypeMapper.deleteByIds(typeIds);
refreshDictCache();
return rows;
}
/**
* 校验编码、名称唯一,并整理状态
*/
private void validate(BmsSupplierType row, Long excludeId)
{
if (StringUtils.isEmpty(row.getTypeCode()))
{
throw new ServiceException("类型编码不能为空");
}
if (!row.getTypeCode().matches("[0-9A-Za-z_-]{1,32}"))
{
throw new ServiceException("类型编码只能是字母、数字、下划线或中划线,最长32位");
}
if (supplierTypeMapper.countByTypeCode(row.getTypeCode(), excludeId) > 0)
{
throw new ServiceException("类型编码已存在:" + row.getTypeCode());
}
validateNameAndStatus(row, excludeId);
}
private void validateNameAndStatus(BmsSupplierType row, Long excludeId)
{
if (StringUtils.isEmpty(row.getTypeName()))
{
throw new ServiceException("类型名称不能为空");
}
if (row.getTypeName().length() > 100)
{
throw new ServiceException("类型名称不能超过100个字符");
}
if (supplierTypeMapper.countByTypeName(row.getTypeName(), excludeId) > 0)
{
throw new ServiceException("类型名称已存在:" + row.getTypeName());
}
if (StringUtils.isNotEmpty(row.getStatus())
&& !"0".equals(row.getStatus()) && !"1".equals(row.getStatus()))
{
throw new ServiceException("状态只能是正常或停用");
}
}
private BmsSupplierType requireActive(Long typeId)
{
BmsSupplierType existing = supplierTypeMapper.selectById(typeId);
if (existing == null)
{
throw new ServiceException("供应商类型不存在或已删除");
}
return existing;
}
private void normalize(BmsSupplierType row)
{
if (row.getTypeCode() != null)
{
row.setTypeCode(row.getTypeCode().trim());
}
if (row.getTypeName() != null)
{
row.setTypeName(row.getTypeName().trim());
}
if (row.getRemark() != null)
{
row.setRemark(row.getRemark().trim());
}
}
/**
* 按类型编码新增或更新字典项,并刷新该字典缓存
*/
private void syncDict(BmsSupplierType row)
{
Long dictCode = supplierTypeMapper.selectDictCode(DICT_TYPE, row.getTypeCode());
if (dictCode == null)
{
if (StringUtils.isEmpty(row.getCreateBy()))
{
row.setCreateBy(row.getUpdateBy());
}
supplierTypeMapper.insertDict(row);
}
else
{
supplierTypeMapper.updateDict(row);
}
refreshDictCache();
}
/**
* 只缓存正常状态的字典项,停用后下拉不再出现
*/
private void refreshDictCache()
{
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(DICT_TYPE);
DictUtils.setDictCache(DICT_TYPE, dictDatas == null ? new ArrayList<SysDictData>() : dictDatas);
}
}
@@ -30,7 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="weightThreshold" column="weight_threshold" /> <result property="weightThreshold" column="weight_threshold" />
<result property="throwRatio" column="throw_ratio" /> <result property="throwRatio" column="throw_ratio" />
<result property="cooperationStartDate" column="cooperation_start_date" /> <result property="cooperationStartDate" column="cooperation_start_date" />
<result property="contractStartDate" column="contract_start_date" />
<result property="contractEndDate" column="contract_end_date" /> <result property="contractEndDate" column="contract_end_date" />
<result property="cooperationStatus" column="cooperation_status" /> <result property="cooperationStatus" column="cooperation_status" />
<result property="channelIds" column="channel_ids" /> <result property="channelIds" column="channel_ids" />
@@ -48,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
s.is_enable, s.purchaser_user_id, s.purchaser_user, s.settlement_user_id, s.settlement_user, s.is_enable, s.purchaser_user_id, s.purchaser_user, s.settlement_user_id, s.settlement_user,
s.service_user_id, s.service_user, s.ed, s.zq, s.settlement_type, s.temp_ed, s.account_balance, s.service_user_id, s.service_user, s.ed, s.zq, s.settlement_type, s.temp_ed, s.account_balance,
s.foreign_currency_balance, s.credit_ed, s.weight_threshold, s.throw_ratio, s.cooperation_start_date, s.foreign_currency_balance, s.credit_ed, s.weight_threshold, s.throw_ratio, s.cooperation_start_date,
s.contract_start_date, s.contract_end_date, s.cooperation_status, s.channel_ids, s.remark, s.contract_end_date, s.cooperation_status, s.channel_ids, s.remark,
s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag
from sup_supplier s from sup_supplier s
<!-- 数据权限:采购/销售(仅本人 s.purchaser_user_id)/部门经理(本部门 su.dept_id); <!-- 数据权限:采购/销售(仅本人 s.purchaser_user_id)/部门经理(本部门 su.dept_id);
@@ -123,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="weightThreshold != null">weight_threshold,</if> <if test="weightThreshold != null">weight_threshold,</if>
<if test="throwRatio != null">throw_ratio,</if> <if test="throwRatio != null">throw_ratio,</if>
<if test="cooperationStartDate != null">cooperation_start_date,</if> <if test="cooperationStartDate != null">cooperation_start_date,</if>
<if test="contractStartDate != null">contract_start_date,</if>
<if test="contractEndDate != null">contract_end_date,</if> <if test="contractEndDate != null">contract_end_date,</if>
<if test="cooperationStatus != null">cooperation_status,</if> <if test="cooperationStatus != null">cooperation_status,</if>
<if test="channelIds != null">channel_ids,</if> <if test="channelIds != null">channel_ids,</if>
@@ -157,7 +155,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="weightThreshold != null">#{weightThreshold},</if> <if test="weightThreshold != null">#{weightThreshold},</if>
<if test="throwRatio != null">#{throwRatio},</if> <if test="throwRatio != null">#{throwRatio},</if>
<if test="cooperationStartDate != null">#{cooperationStartDate},</if> <if test="cooperationStartDate != null">#{cooperationStartDate},</if>
<if test="contractStartDate != null">#{contractStartDate},</if>
<if test="contractEndDate != null">#{contractEndDate},</if> <if test="contractEndDate != null">#{contractEndDate},</if>
<if test="cooperationStatus != null">#{cooperationStatus},</if> <if test="cooperationStatus != null">#{cooperationStatus},</if>
<if test="channelIds != null">#{channelIds},</if> <if test="channelIds != null">#{channelIds},</if>
@@ -195,7 +192,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="weightThreshold != null">weight_threshold = #{weightThreshold},</if> <if test="weightThreshold != null">weight_threshold = #{weightThreshold},</if>
<if test="throwRatio != null">throw_ratio = #{throwRatio},</if> <if test="throwRatio != null">throw_ratio = #{throwRatio},</if>
<if test="cooperationStartDate != null">cooperation_start_date = #{cooperationStartDate},</if> <if test="cooperationStartDate != null">cooperation_start_date = #{cooperationStartDate},</if>
contract_start_date = #{contractStartDate},
contract_end_date = #{contractEndDate}, contract_end_date = #{contractEndDate},
<if test="cooperationStatus != null">cooperation_status = #{cooperationStatus},</if> <if test="cooperationStatus != null">cooperation_status = #{cooperationStatus},</if>
<if test="channelIds != null">channel_ids = #{channelIds},</if> <if test="channelIds != null">channel_ids = #{channelIds},</if>
@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bms.customer.supplierinfo.mapper.OracleSupplierSyncMapper"> <mapper namespace="com.bms.customer.supplierinfo.mapper.OracleSupplierSyncMapper">
<!-- 服务商(供应商)主数据:TAB_SERVICE_INFO(2026-10-10 起替代取数错误的 TAB_SUPPLIER) <!-- 服务商(供应商)主数据:TAB_SERVICE_INFO(2026-10-10 起替代取数错误的 TAB_SUPPLIER)
SERVICE_TYPE 为中文口径:尾程渠道 -> 供应商类型 5(尾派服务商),清关 -> 4(清关行); SERVICE_TYPE 为中文口径,同步时按字典 bms_supplier_type 解析:尾程渠道 -> 尾派服务商,清关 -> 清关行;
BL_OPEN:1 启用,其余停用 --> BL_OPEN:1 启用,其余停用 -->
<select id="selectAllServiceInfo" resultType="java.util.HashMap" fetchSize="500"> <select id="selectAllServiceInfo" resultType="java.util.HashMap" fetchSize="500">
SELECT SERVICE_CODE, SERVICE_NAME, SERVICE_TYPE, BL_OPEN, REMARK, CREATE_DATE SELECT SERVICE_CODE, SERVICE_NAME, SERVICE_TYPE, BL_OPEN, REMARK, CREATE_DATE
@@ -25,12 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
<!-- 同步源(TAB_SERVICE_INFO/CHANNEL)无开票类型、卡车行类型、额度、账期, <!-- 同步源(TAB_SERVICE_INFO/CHANNEL)无开票类型、卡车行类型、额度、账期,
更新时这些列一律不动,保留库内维护值;supplier_type/channel_ids 以源为准 --> 更新时这些列一律不动。supplier_type 仅在解析到字典键值时回写,源为空或对不上字典时保留原值 -->
<update id="updateSyncSupplierByCode" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplier"> <update id="updateSyncSupplierByCode" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplier">
UPDATE sup_supplier UPDATE sup_supplier
SET supplier_name = #{supplierName} SET supplier_name = #{supplierName}
, is_enable = #{isEnable} , is_enable = #{isEnable}
, supplier_type = #{supplierType} <if test="supplierType != null">, supplier_type = #{supplierType}</if>
, channel_ids = #{channelIds} , channel_ids = #{channelIds}
<if test="remark != null">, remark = #{remark}</if> <if test="remark != null">, remark = #{remark}</if>
, update_by = #{updateBy} , update_by = #{updateBy}
@@ -1,130 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bms.system.mapper.BmsSupplierTypeMapper">
<resultMap type="BmsSupplierType" id="BmsSupplierTypeResult">
<id property="typeId" column="type_id" />
<result property="typeCode" column="type_code" />
<result property="typeName" column="type_name" />
<result property="typeSort" column="type_sort" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectVo">
select type_id, type_code, type_name, type_sort, status, remark,
create_by, create_time, update_by, update_time, del_flag
from bms_supplier_type
</sql>
<select id="selectList" parameterType="BmsSupplierType" resultMap="BmsSupplierTypeResult">
<include refid="selectVo"/>
<where>
del_flag = '0'
<if test="typeName != null and typeName != ''">
and type_name like concat('%', #{typeName}, '%')
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
</where>
order by type_sort asc, type_id asc
</select>
<select id="selectById" parameterType="Long" resultMap="BmsSupplierTypeResult">
<include refid="selectVo"/>
where type_id = #{typeId} and del_flag = '0'
</select>
<select id="countByTypeCode" resultType="int">
select count(1) from bms_supplier_type
where del_flag = '0' and type_code = #{typeCode}
<if test="excludeId != null">and type_id != #{excludeId}</if>
</select>
<select id="countByTypeName" resultType="int">
select count(1) from bms_supplier_type
where del_flag = '0' and type_name = #{typeName}
<if test="excludeId != null">and type_id != #{excludeId}</if>
</select>
<insert id="insert" parameterType="BmsSupplierType" useGeneratedKeys="true" keyProperty="typeId">
insert into bms_supplier_type (
type_code, type_name, type_sort, status, remark, create_by, create_time, del_flag
) values (
#{typeCode}, #{typeName}, #{typeSort}, #{status}, #{remark}, #{createBy}, sysdate(), '0'
)
</insert>
<update id="update" parameterType="BmsSupplierType">
update bms_supplier_type
<set>
<if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
<if test="typeSort != null">type_sort = #{typeSort},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where type_id = #{typeId} and del_flag = '0'
</update>
<update id="updateStatus" parameterType="BmsSupplierType">
update bms_supplier_type
set status = #{status},
update_by = #{updateBy},
update_time = sysdate()
where type_id = #{typeId} and del_flag = '0'
</update>
<update id="deleteByIds" parameterType="Long">
update bms_supplier_type
set del_flag = '1',
type_code = concat(type_code, '#', type_id),
type_name = concat(type_name, '#', type_id),
update_time = sysdate()
where del_flag = '0' and type_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectDictCode" resultType="java.lang.Long">
select dict_code from sys_dict_data
where dict_type = #{dictType} and dict_value = #{dictValue}
limit 1
</select>
<insert id="insertDict" parameterType="BmsSupplierType">
insert into sys_dict_data (
dict_sort, dict_label, dict_value, dict_type, css_class, list_class,
is_default, status, create_by, create_time, remark
) values (
#{typeSort}, #{typeName}, #{typeCode}, 'bms_supplier_type', '', 'primary',
'N', #{status}, #{createBy}, sysdate(), #{remark}
)
</insert>
<update id="updateDict" parameterType="BmsSupplierType">
update sys_dict_data
set dict_sort = #{typeSort},
dict_label = #{typeName},
status = #{status},
remark = #{remark},
update_by = #{updateBy},
update_time = sysdate()
where dict_type = 'bms_supplier_type' and dict_value = #{typeCode}
</update>
<delete id="deleteDictByCode">
delete from sys_dict_data
where dict_type = 'bms_supplier_type' and dict_value = #{typeCode}
</delete>
</mapper>
+1 -2
View File
@@ -1767,7 +1767,7 @@ CREATE TABLE `sup_supplier` (
`supplier_name` varchar(100) NOT NULL COMMENT '供应商名称', `supplier_name` varchar(100) NOT NULL COMMENT '供应商名称',
`supplier_code_dw` varchar(50) DEFAULT '' COMMENT '对外代码', `supplier_code_dw` varchar(50) DEFAULT '' COMMENT '对外代码',
`credit_code` varchar(18) DEFAULT '' COMMENT '统一社会信用代码', `credit_code` varchar(18) DEFAULT '' COMMENT '统一社会信用代码',
`supplier_type` char(1) DEFAULT NULL COMMENT '供应商类型(1卡车行 2航司代理 3报关行 4清关行 5尾派服务商 6报关代理)', `supplier_type` varchar(32) DEFAULT NULL COMMENT '供应商类型(字典 bms_supplier_type)',
`invoice_type` char(1) DEFAULT NULL COMMENT '开票类型(1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票)', `invoice_type` char(1) DEFAULT NULL COMMENT '开票类型(1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票)',
`kache_type` char(1) DEFAULT NULL COMMENT '卡车行类型(0国内 1国外)', `kache_type` char(1) DEFAULT NULL COMMENT '卡车行类型(0国内 1国外)',
`is_enable` char(1) DEFAULT '0' COMMENT '启用状态(0正常 1停用)', `is_enable` char(1) DEFAULT '0' COMMENT '启用状态(0正常 1停用)',
@@ -1787,7 +1787,6 @@ CREATE TABLE `sup_supplier` (
`weight_threshold` decimal(15,2) DEFAULT '0.00' COMMENT '重量阈值(kg)', `weight_threshold` decimal(15,2) DEFAULT '0.00' COMMENT '重量阈值(kg)',
`throw_ratio` decimal(15,2) DEFAULT '0.00' COMMENT '抛比(%)', `throw_ratio` decimal(15,2) DEFAULT '0.00' COMMENT '抛比(%)',
`cooperation_start_date` date DEFAULT NULL COMMENT '合作开始日期', `cooperation_start_date` date DEFAULT NULL COMMENT '合作开始日期',
`contract_start_date` date DEFAULT NULL COMMENT '合同开始时间',
`contract_end_date` date DEFAULT NULL COMMENT '合同结束时间', `contract_end_date` date DEFAULT NULL COMMENT '合同结束时间',
`cooperation_status` char(1) DEFAULT '0' COMMENT '合作状态(0正常 1暂停 2终止)', `cooperation_status` char(1) DEFAULT '0' COMMENT '合作状态(0正常 1暂停 2终止)',
`channel_ids` varchar(1000) DEFAULT NULL COMMENT '绑定的渠道/服务ID(多个用逗号分隔)', `channel_ids` varchar(1000) DEFAULT NULL COMMENT '绑定的渠道/服务ID(多个用逗号分隔)',
@@ -2,14 +2,14 @@
-- 供应商 Oracle(TAB_SUPPLIER) 定时同步 —— sup_supplier 三个类型字段对齐 -- 供应商 Oracle(TAB_SUPPLIER) 定时同步 —— sup_supplier 三个类型字段对齐
-- 日期:2026-09-29 -- 日期:2026-09-29
-- 字典口径以老系统 TAB_SUPPLIER 为准: -- 字典口径以老系统 TAB_SUPPLIER 为准:
-- supplier_type 供应商类型(已有列,改口径):1卡车行 2航司代理 3报关行 4清关行 5尾派服务商 6报关代理 -- supplier_type 供应商类型(已有列,改口径):字典 bms_supplier_type
-- invoice_type 开票类型(新增列):1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票 -- invoice_type 开票类型(新增列):1增值税普通发票 2增值税专用发票 3增值税电子普通发票 4其他普通发票
-- kache_type 卡车行类型(新增列):0国内 1国外 -- kache_type 卡车行类型(新增列):0国内 1国外
-- ============================================================ -- ============================================================
-- 1. supplier_type:旧口径(0生产商 1代理商 2个人 3物流商 4其他)废弃,默认值放开为 NULL -- 1. supplier_type:旧口径(0生产商 1代理商 2个人 3物流商 4其他)废弃,默认值放开为 NULL
ALTER TABLE `sup_supplier` ALTER TABLE `sup_supplier`
MODIFY COLUMN `supplier_type` char(1) DEFAULT NULL COMMENT '供应商类型(1卡车行 2航司代理 3报关行 4清关行 5尾派服务商 6报关代理)'; MODIFY COLUMN `supplier_type` varchar(32) DEFAULT NULL COMMENT '供应商类型(字典 bms_supplier_type)';
-- 2. invoice_type 开票类型(新增) -- 2. invoice_type 开票类型(新增)
ALTER TABLE `sup_supplier` ALTER TABLE `sup_supplier`
+31 -81
View File
@@ -1,47 +1,43 @@
-- 数据管理:供应商类型 -- 供应商类型只维护在数据字典 bms_supplier_type
-- 业务表与字典 bms_supplier_type 使用同一套编码,初始数据与现有供应商档案口径一致 -- 供应商档案下拉、列表、导出都读该字典;不再使用业务表和独立菜单
SET NAMES utf8mb4; SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS bms_supplier_type ( -- 已执行过旧脚本时,拆掉供应商类型业务表和「数据管理 / 供应商类型」菜单
type_id bigint(20) NOT NULL AUTO_INCREMENT COMMENT '类型ID', DROP TABLE IF EXISTS bms_supplier_type;
type_code varchar(32) NOT NULL COMMENT '类型编码(字典键值)',
type_name varchar(100) NOT NULL COMMENT '类型名称',
type_sort int(4) NOT NULL DEFAULT 0 COMMENT '显示排序',
status char(1) NOT NULL DEFAULT '0' COMMENT '状态(0正常 1停用)',
remark varchar(500) DEFAULT NULL COMMENT '备注',
create_by varchar(64) DEFAULT '' COMMENT '创建者',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) DEFAULT '' COMMENT '更新者',
update_time datetime DEFAULT NULL COMMENT '更新时间',
del_flag char(1) DEFAULT '0' COMMENT '删除标记(0存在 1删除)',
PRIMARY KEY (type_id),
UNIQUE KEY uk_bms_supplier_type_code (type_code),
UNIQUE KEY uk_bms_supplier_type_name (type_name),
KEY idx_bms_supplier_type_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='供应商类型';
-- 已有供应商档案的类型列只有 1 位,放宽后才能保存新编码 DELETE rm FROM sys_role_menu rm
INNER JOIN sys_menu m ON rm.menu_id = m.menu_id
INNER JOIN sys_menu p ON m.parent_id = p.menu_id
WHERE m.menu_type = 'F'
AND (p.perms = 'data:supplierType:list' OR p.component = 'data/supplierType/index');
DELETE m FROM sys_menu m
INNER JOIN sys_menu p ON m.parent_id = p.menu_id
WHERE m.menu_type = 'F'
AND (p.perms = 'data:supplierType:list' OR p.component = 'data/supplierType/index');
DELETE rm FROM sys_role_menu rm
INNER JOIN sys_menu m ON rm.menu_id = m.menu_id
WHERE m.perms LIKE 'data:supplierType:%'
OR m.component = 'data/supplierType/index';
DELETE FROM sys_menu
WHERE perms LIKE 'data:supplierType:%'
OR component = 'data/supplierType/index';
-- 类型编码不再限制为 1 位,与字典键值对齐
ALTER TABLE sup_supplier ALTER TABLE sup_supplier
MODIFY COLUMN supplier_type varchar(32) DEFAULT NULL COMMENT '供应商类型(字典 bms_supplier_type)'; MODIFY COLUMN supplier_type varchar(32) DEFAULT NULL COMMENT '供应商类型(字典 bms_supplier_type)';
INSERT INTO bms_supplier_type (type_code, type_name, type_sort, status, remark, create_by, create_time, del_flag)
SELECT v.type_code, v.type_name, v.type_sort, '0', v.remark, 'admin', sysdate(), '0'
FROM (
SELECT '1' AS type_code, '卡车行' AS type_name, 1 AS type_sort, '原供应商档案口径' AS remark
UNION ALL SELECT '2', '航司代理', 2, '原供应商档案口径'
UNION ALL SELECT '3', '报关行', 3, '原供应商档案口径'
UNION ALL SELECT '4', '清关行', 4, '原供应商档案口径'
UNION ALL SELECT '5', '尾派服务商', 5, '原供应商档案口径'
UNION ALL SELECT '6', '报关代理', 6, '原供应商档案口径'
) v
WHERE NOT EXISTS (
SELECT 1 FROM bms_supplier_type t WHERE t.type_code = v.type_code OR t.type_name = v.type_name
);
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark) INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
SELECT '供应商类型', 'bms_supplier_type', '0', 'admin', sysdate(), '供应商档案使用的类型,与供应商类型管理保持一致' SELECT '供应商类型', 'bms_supplier_type', '0', 'admin', sysdate(), '供应商档案使用的类型,在系统字典中维护'
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_supplier_type'); FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_supplier_type');
UPDATE sys_dict_type
SET dict_name = '供应商类型',
remark = '供应商档案使用的类型,在系统字典中维护'
WHERE dict_type = 'bms_supplier_type';
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark)
SELECT v.type_sort, v.type_name, v.type_code, 'bms_supplier_type', '', 'primary', 'N', '0', 'admin', sysdate(), v.remark SELECT v.type_sort, v.type_name, v.type_code, 'bms_supplier_type', '', 'primary', 'N', '0', 'admin', sysdate(), v.remark
FROM ( FROM (
@@ -55,49 +51,3 @@ FROM (
WHERE NOT EXISTS ( WHERE NOT EXISTS (
SELECT 1 FROM sys_dict_data d WHERE d.dict_type = 'bms_supplier_type' AND d.dict_value = v.type_code SELECT 1 FROM sys_dict_data d WHERE d.dict_type = 'bms_supplier_type' AND d.dict_value = v.type_code
); );
SET @parentId := (
SELECT menu_id FROM sys_menu
WHERE path = 'data' AND menu_type = 'M'
ORDER BY menu_id ASC LIMIT 1
);
SET @parentId := IFNULL(@parentId, (
SELECT parent_id FROM sys_menu
WHERE perms = 'data:region:list' OR component = 'data/region/index' OR component = 'data/exchangerate/index'
ORDER BY menu_id ASC LIMIT 1
));
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT 2490, '供应商类型', @parentId, 40, 'supplierType', 'data/supplierType/index', '', 'SupplierType', 1, 0, 'C', '0', '0', 'data:supplierType:list', 'tree', 'admin', sysdate(), '供应商类型维护,并同步字典 bms_supplier_type'
FROM DUAL WHERE @parentId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2490 OR perms = 'data:supplierType:list');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2491, '查询', 2490, 1, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:query', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2491);
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2492, '新增', 2490, 2, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:add', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2492);
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2493, '修改', 2490, 3, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:edit', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2493);
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2494, '删除', 2490, 4, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:remove', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2494);
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2495, '导出', 2490, 5, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:export', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2495);
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
SELECT 2496, '启停', 2490, 6, '', NULL, 1, 0, 'F', '0', '0', 'data:supplierType:changeStatus', '#', 'admin', sysdate()
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2496);
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, m.menu_id FROM (
SELECT 2490 AS menu_id UNION SELECT 2491 UNION SELECT 2492 UNION SELECT 2493
UNION SELECT 2494 UNION SELECT 2495 UNION SELECT 2496
) m
WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu rm WHERE rm.role_id = 1 AND rm.menu_id = m.menu_id);
@@ -1,11 +1,40 @@
-- 客户、供应商主表增加合同开始时间、合同结束时间 -- 客户主表增加合同开始时间、合同结束时间
-- 已存在的库执行本脚本;列已存在时不要重复执行 -- 供应商只增加合同结束时间;合同开始时间与原有合作开始日期重复,已有列则删除
-- 客户列已存在时不要重复执行前面的 ALTER
SET NAMES utf8mb4; SET NAMES utf8mb4;
-- 先去掉供应商上后加的合同开始时间,避免后续语句失败时这一列还留着
SET @has_supplier_contract_start := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'sup_supplier'
AND COLUMN_NAME = 'contract_start_date'
);
SET @drop_supplier_contract_start := IF(
@has_supplier_contract_start > 0,
'ALTER TABLE sup_supplier DROP COLUMN contract_start_date',
'SELECT 1'
);
PREPARE drop_supplier_contract_start_stmt FROM @drop_supplier_contract_start;
EXECUTE drop_supplier_contract_start_stmt;
DEALLOCATE PREPARE drop_supplier_contract_start_stmt;
ALTER TABLE ctr_customer ALTER TABLE ctr_customer
ADD COLUMN contract_start_date date DEFAULT NULL COMMENT '合同开始时间' AFTER credit_ed, ADD COLUMN contract_start_date date DEFAULT NULL COMMENT '合同开始时间' AFTER credit_ed,
ADD COLUMN contract_end_date date DEFAULT NULL COMMENT '合同结束时间' AFTER contract_start_date; ADD COLUMN contract_end_date date DEFAULT NULL COMMENT '合同结束时间' AFTER contract_start_date;
ALTER TABLE sup_supplier -- 供应商原有合作开始日期,只补合同结束时间(已有则跳过)
ADD COLUMN contract_start_date date DEFAULT NULL COMMENT '合同开始时间' AFTER cooperation_start_date, SET @has_supplier_contract_end := (
ADD COLUMN contract_end_date date DEFAULT NULL COMMENT '合同结束时间' AFTER contract_start_date; SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'sup_supplier'
AND COLUMN_NAME = 'contract_end_date'
);
SET @add_supplier_contract_end := IF(
@has_supplier_contract_end = 0,
'ALTER TABLE sup_supplier ADD COLUMN contract_end_date date DEFAULT NULL COMMENT ''合同结束时间'' AFTER cooperation_start_date',
'SELECT 1'
);
PREPARE add_supplier_contract_end_stmt FROM @add_supplier_contract_end;
EXECUTE add_supplier_contract_end_stmt;
DEALLOCATE PREPARE add_supplier_contract_end_stmt;
-47
View File
@@ -1,47 +0,0 @@
import request from '@/utils/request'
export function listSupplierType(query) {
return request({
url: '/data/supplierType/list',
method: 'get',
params: query
})
}
export function getSupplierType(typeId) {
return request({
url: '/data/supplierType/' + typeId,
method: 'get'
})
}
export function addSupplierType(data) {
return request({
url: '/data/supplierType',
method: 'post',
data
})
}
export function updateSupplierType(data) {
return request({
url: '/data/supplierType',
method: 'put',
data
})
}
export function changeSupplierTypeStatus(data) {
return request({
url: '/data/supplierType/changeStatus',
method: 'put',
data
})
}
export function delSupplierType(typeIds) {
return request({
url: '/data/supplierType/' + typeIds,
method: 'delete'
})
}
@@ -166,9 +166,6 @@
<el-table-column v-if="isColVisible('cooperationStartDate')" label="合作开始日期" align="center" prop="cooperationStartDate"> <el-table-column v-if="isColVisible('cooperationStartDate')" label="合作开始日期" align="center" prop="cooperationStartDate">
<template #default="scope">{{ formatDateOnly(scope.row.cooperationStartDate) }}</template> <template #default="scope">{{ formatDateOnly(scope.row.cooperationStartDate) }}</template>
</el-table-column> </el-table-column>
<el-table-column v-if="isColVisible('contractStartDate')" label="合同开始时间" align="center" prop="contractStartDate" width="120">
<template #default="scope">{{ formatDateOnly(scope.row.contractStartDate) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('contractEndDate')" label="合同结束时间" align="center" prop="contractEndDate" width="120"> <el-table-column v-if="isColVisible('contractEndDate')" label="合同结束时间" align="center" prop="contractEndDate" width="120">
<template #default="scope">{{ formatDateOnly(scope.row.contractEndDate) }}</template> <template #default="scope">{{ formatDateOnly(scope.row.contractEndDate) }}</template>
</el-table-column> </el-table-column>
@@ -246,7 +243,6 @@ const columnDefs = [
{ key: 'weightThreshold', label: '重量阈值' }, { key: 'weightThreshold', label: '重量阈值' },
{ key: 'throwRatio', label: '抛比' }, { key: 'throwRatio', label: '抛比' },
{ key: 'cooperationStartDate', label: '合作开始日期' }, { key: 'cooperationStartDate', label: '合作开始日期' },
{ key: 'contractStartDate', label: '合同开始时间' },
{ key: 'contractEndDate', label: '合同结束时间' }, { key: 'contractEndDate', label: '合同结束时间' },
{ key: 'cooperationStatus', label: '合作状态' }, { key: 'cooperationStatus', label: '合作状态' },
{ key: 'channelIds', label: '绑定渠道' }, { key: 'channelIds', label: '绑定渠道' },
@@ -320,7 +316,6 @@ const copyColumns = computed(() => [
{ key: 'weightThreshold', label: '重量阈值', get: r => (r.weightThreshold === null || r.weightThreshold === undefined ? '' : r.weightThreshold) }, { key: 'weightThreshold', label: '重量阈值', get: r => (r.weightThreshold === null || r.weightThreshold === undefined ? '' : r.weightThreshold) },
{ key: 'throwRatio', label: '抛比', get: r => (r.throwRatio === null || r.throwRatio === undefined ? '' : r.throwRatio) }, { key: 'throwRatio', label: '抛比', get: r => (r.throwRatio === null || r.throwRatio === undefined ? '' : r.throwRatio) },
{ key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) }, { key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) },
{ key: 'contractStartDate', label: '合同开始时间', get: r => formatDateOnly(r.contractStartDate) },
{ key: 'contractEndDate', label: '合同结束时间', get: r => formatDateOnly(r.contractEndDate) }, { key: 'contractEndDate', label: '合同结束时间', get: r => formatDateOnly(r.contractEndDate) },
{ key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) }, { key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) },
{ key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) }, { key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) },
@@ -161,11 +161,6 @@
<el-date-picker v-model="form.cooperationStartDate" type="date" value-format="YYYY-MM-DD" placeholder="选择合作开始日期" style="width: 100%;" /> <el-date-picker v-model="form.cooperationStartDate" type="date" value-format="YYYY-MM-DD" placeholder="选择合作开始日期" style="width: 100%;" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="合同开始时间" prop="contractStartDate">
<el-date-picker v-model="form.contractStartDate" type="date" value-format="YYYY-MM-DD" placeholder="选择合同开始时间" style="width: 100%;" />
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="合同结束时间" prop="contractEndDate"> <el-form-item label="合同结束时间" prop="contractEndDate">
<el-date-picker v-model="form.contractEndDate" type="date" value-format="YYYY-MM-DD" placeholder="选择合同结束时间" style="width: 100%;" /> <el-date-picker v-model="form.contractEndDate" type="date" value-format="YYYY-MM-DD" placeholder="选择合同结束时间" style="width: 100%;" />
@@ -695,7 +690,6 @@ function buildEmptyForm() {
throwRatio: null, throwRatio: null,
creditEd: null, creditEd: null,
cooperationStartDate: null, cooperationStartDate: null,
contractStartDate: null,
contractEndDate: null, contractEndDate: null,
cooperationStatus: null, cooperationStatus: null,
channelIds: null, channelIds: null,
@@ -1033,8 +1027,8 @@ function submitForm() {
activeTab.value = 'base' activeTab.value = 'base'
return return
} }
if (form.value.contractStartDate && form.value.contractEndDate && form.value.contractEndDate < form.value.contractStartDate) { if (form.value.cooperationStartDate && form.value.contractEndDate && form.value.contractEndDate < form.value.cooperationStartDate) {
proxy.$modal.msgError('合同结束时间不能早于开始时间') proxy.$modal.msgError('合同结束时间不能早于合作开始日期')
activeTab.value = 'base' activeTab.value = 'base'
return return
} }
@@ -1047,7 +1041,7 @@ function submitForm() {
settlementUser: nullIfEmpty(form.value.settlementUser), settlementUser: nullIfEmpty(form.value.settlementUser),
serviceUserId: nullIfEmpty(form.value.serviceUserId), serviceUserId: nullIfEmpty(form.value.serviceUserId),
serviceUser: nullIfEmpty(form.value.serviceUser), serviceUser: nullIfEmpty(form.value.serviceUser),
contractStartDate: nullIfEmpty(form.value.contractStartDate), cooperationStartDate: nullIfEmpty(form.value.cooperationStartDate),
contractEndDate: nullIfEmpty(form.value.contractEndDate) contractEndDate: nullIfEmpty(form.value.contractEndDate)
} }
saving.value = true saving.value = true