From d39e4f7d839167c16425086dfa2f8747bccfdff9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 十一月 2026 17:39:01 +0800
Subject: [PATCH] feat: 打通销售采购财务闭环并完成累计业务优化
---
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 322 insertions(+), 36 deletions(-)
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
index fe7fe1a..a7e42c9 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
@@ -1,32 +1,44 @@
package cn.iocoder.yudao.module.srm.service.supplier;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierPageReqVO;
-import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierSaveReqVO;
-import cn.iocoder.yudao.module.srm.dal.dataobject.*;
-import cn.iocoder.yudao.module.srm.dal.mysql.SrmBidAwardMapper;
-import cn.iocoder.yudao.module.srm.dal.mysql.SrmBidEvaluationMapper;
-import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierApplyMapper;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
+import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.*;
+import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierBankDO;
+import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierContactDO;
+import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO;
+import cn.iocoder.yudao.module.erp.api.purchase.ErpSupplierReferenceApi;
+import cn.iocoder.yudao.module.srm.dal.mysql.SrmBidBondMapper;
+import cn.iocoder.yudao.module.srm.dal.mysql.SrmInquiryOrderMapper;
+import cn.iocoder.yudao.module.srm.dal.mysql.SrmInquiryQuoteMapper;
+import cn.iocoder.yudao.module.srm.dal.mysql.SrmInquirySupplierMapper;
+import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierBankMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierCategoryMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierContactMapper;
-import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierCertificateMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierMapper;
-import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderBidMapper;
import cn.iocoder.yudao.module.srm.enums.ErrorCodeConstants;
-import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
+import cn.iocoder.yudao.module.srm.enums.SupplierTypeEnum;
+import com.mzt.logapi.starter.annotation.LogRecord;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
-import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
-import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
-
-import cn.hutool.core.collection.CollUtil;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Objects;
+
+import static cn.iocoder.yudao.module.srm.enums.LogRecordConstants.*;
@Service
@Validated
@@ -39,34 +51,43 @@
private SrmSupplierContactMapper supplierContactMapper;
@Resource
+ private SrmSupplierBankMapper supplierBankMapper;
+
+ @Resource
private SrmSupplierCategoryMapper supplierCategoryMapper;
@Resource
- private SrmSupplierApplyMapper supplierApplyMapper;
+ private SrmInquirySupplierMapper inquirySupplierMapper;
@Resource
- private SrmSupplierCertificateMapper supplierCertificateMapper;
+ private SrmInquiryQuoteMapper inquiryQuoteMapper;
@Resource
- private SrmTenderBidMapper tenderBidMapper;
+ private SrmInquiryOrderMapper inquiryOrderMapper;
@Resource
- private SrmBidEvaluationMapper bidEvaluationMapper;
+ private SrmBidBondMapper bidBondMapper;
@Resource
- private SrmBidAwardMapper bidAwardMapper;
+ private ErpSupplierReferenceApi erpSupplierReferenceApi;
@Override
+ @Transactional(rollbackFor = Exception.class)
public Long createSupplier(SrmSupplierSaveReqVO createReqVO) {
// 鏍¢獙渚涘簲鍟嗙紪鐮佸敮涓�鎬�
validateCodeUnique(createReqVO.getCode(), null);
// 鎻掑叆
SrmSupplierDO supplier = BeanUtils.toBean(createReqVO, SrmSupplierDO.class);
+ fillDefaultContactAndBankFromFlatFields(createReqVO);
supplierMapper.insert(supplier);
+ saveContacts(supplier.getId(), createReqVO.getContacts());
+ saveBanks(supplier.getId(), createReqVO.getBanks());
+ syncSupplierDefaultFields(supplier.getId(), createReqVO.getContacts(), createReqVO.getBanks());
return supplier.getId();
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public void updateSupplier(SrmSupplierSaveReqVO updateReqVO) {
// 鏍¢獙瀛樺湪鎬�
validateSupplierExists(updateReqVO.getId());
@@ -75,17 +96,47 @@
// 鏇存柊
SrmSupplierDO updateObj = BeanUtils.toBean(updateReqVO, SrmSupplierDO.class);
supplierMapper.updateById(updateObj);
+ // 鍒楄〃浼� null 琛ㄧず涓嶄慨鏀癸紱浼犵┖鍒楄〃琛ㄧず娓呯┖
+ if (updateReqVO.getContacts() != null) {
+ saveContacts(updateReqVO.getId(), updateReqVO.getContacts());
+ }
+ if (updateReqVO.getBanks() != null) {
+ saveBanks(updateReqVO.getId(), updateReqVO.getBanks());
+ }
+ syncSupplierDefaultFields(updateReqVO.getId(), updateReqVO.getContacts(), updateReqVO.getBanks());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteSupplier(Long id) {
// 鏍¢獙瀛樺湪鎬�
- validateSupplierExists(id);
- // 鍏宠仈鏁版嵁瀛樺湪鏃讹紝涓嶅厑璁稿垹闄�
- validateNoReference(id);
+ SrmSupplierDO supplier = validateSupplierExists(id);
+ // 鏍¢獙涓氬姟寮曠敤锛氳浠枫�佷繚璇侀噾銆丒RP 閲囪喘/浠樻绛夊崟鎹�
+ List<String> references = new ArrayList<>();
+ if (inquirySupplierMapper.selectCountBySupplierId(id) > 0) {
+ references.add("SRM璇环鍗�");
+ }
+ if (inquiryQuoteMapper.selectCountBySupplierId(id) > 0) {
+ references.add("SRM璇环鎶ヤ环");
+ }
+ if (inquiryOrderMapper.selectCountBySupplierId(id) > 0) {
+ references.add("SRM璇环杞噰璐鍗曡褰�");
+ }
+ if (bidBondMapper.selectCountBySupplierId(id) > 0) {
+ references.add("SRM鎶曟爣淇濊瘉閲�");
+ }
+ List<String> erpSources = erpSupplierReferenceApi.getSupplierReferenceSources(id).getCheckedData();
+ if (CollUtil.isNotEmpty(erpSources)) {
+ references.addAll(erpSources);
+ }
+ if (!references.isEmpty()) {
+ throw new ServiceException(ErrorCodeConstants.SUPPLIER_EXISTS_REFERENCE.getCode(),
+ "渚涘簲鍟嗐��" + supplier.getName() + "銆戝凡琚笟鍔″紩鐢紙" + String.join("銆�", references)
+ + "锛夛紝鏃犳硶鍒犻櫎銆傝鍏堝鐞嗙浉鍏冲崟鎹紝鎴栧皢渚涘簲鍟嗙姸鎬佹敼涓哄仠鐢ㄣ��");
+ }
// 鍙洿鎺ユ竻鐞嗙殑鍏宠仈鏁版嵁
supplierContactMapper.deleteBySupplierId(id);
+ supplierBankMapper.deleteBySupplierId(id);
supplierCategoryMapper.deleteBySupplierId(id);
// 閫昏緫鍒犻櫎
supplierMapper.deleteById(id);
@@ -97,13 +148,81 @@
}
@Override
+ public List<SrmSupplierContactDO> getSupplierContactList(Long supplierId) {
+ return supplierContactMapper.selectListBySupplierId(supplierId);
+ }
+
+ @Override
+ public List<SrmSupplierBankDO> getSupplierBankList(Long supplierId) {
+ return supplierBankMapper.selectListBySupplierId(supplierId);
+ }
+
+ @Override
public PageResult<SrmSupplierDO> getSupplierPage(SrmSupplierPageReqVO pageReqVO) {
return supplierMapper.selectPage(pageReqVO);
}
@Override
+ @Transactional(rollbackFor = Exception.class)
+ @LogRecord(type = LOG_SUPPLIER_TYPE, subType = LOG_SUPPLIER_IMPORT_SUB_TYPE, bizNo = "0",
+ success = LOG_SUPPLIER_IMPORT_SUCCESS)
+ public SrmSupplierImportRespVO importSupplierList(List<SrmSupplierImportExcelVO> importList, Boolean updateSupport) {
+ if (CollUtil.isEmpty(importList)) {
+ throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_IMPORT_LIST_IS_EMPTY);
+ }
+ SrmSupplierImportRespVO respVO = SrmSupplierImportRespVO.builder()
+ .createList(new ArrayList<>())
+ .updateList(new ArrayList<>())
+ .failureList(new LinkedHashMap<>())
+ .build();
+ // 閫愯瀵煎叆锛氬崟琛屽け璐ヨ褰曞埌 failureList锛屼笉褰卞搷鍏跺畠琛�
+ for (SrmSupplierImportExcelVO importVO : importList) {
+ String code = StrUtil.trim(importVO.getCode());
+ String name = StrUtil.trim(importVO.getName());
+ if (StrUtil.isBlank(code) || StrUtil.isBlank(name)) {
+ respVO.getFailureList().put(StrUtil.blankToDefault(name, code), "渚涘簲鍟嗙紪鐮佸拰渚涘簲鍟嗗悕绉颁笉鑳戒负绌�");
+ continue;
+ }
+ SrmSupplierSaveReqVO saveReqVO = toSaveReqVO(importVO);
+ try {
+ SrmSupplierDO existByCode = supplierMapper.selectByCode(code);
+ if (existByCode != null) {
+ if (!Boolean.TRUE.equals(updateSupport)) {
+ respVO.getFailureList().put(name, "渚涘簲鍟嗙紪鐮佸凡瀛樺湪");
+ continue;
+ }
+ saveReqVO.setId(existByCode.getId());
+ updateSupplier(saveReqVO);
+ respVO.getUpdateList().add(name);
+ } else {
+ createSupplier(saveReqVO);
+ respVO.getCreateList().add(name);
+ }
+ } catch (Exception ex) {
+ // 鍗曟潯澶辫触锛岃褰曞苟缁х画
+ String reason = ex instanceof ServiceException ? ((ServiceException) ex).getMessage() : ex.getMessage();
+ respVO.getFailureList().put(name, reason == null ? "瀵煎叆澶辫触" : reason);
+ }
+ }
+ // 璁板綍瀵煎叆缁撴灉姹囨�伙紝渚� @LogRecord 鐨� success 鏂囨寮曠敤
+ OperateLogUtils.putImportSummary(respVO.getCreateList(), respVO.getUpdateList(), respVO.getFailureList());
+ return respVO;
+ }
+
+ @Override
public List<SrmSupplierDO> getSupplierSimpleList() {
- return supplierMapper.selectApprovedList();
+ // 鍑嗗叆鍔熻兘宸茬Щ闄わ紝涓嬫媺閫夋嫨缁熶竴杩斿洖鍚敤鐨勪緵搴斿晢
+ return supplierMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
+ }
+
+ @Override
+ public List<SrmSupplierDO> getSupplierAllList() {
+ return supplierMapper.selectList(new LambdaQueryWrapperX<SrmSupplierDO>()
+ // 杩囨护鍋滅敤渚涘簲鍟嗭紝淇濈暀鏈缃姸鎬佷笌鍚敤鐘舵�佺殑妗f渚涘簲鍟�
+ .and(w -> w.isNull(SrmSupplierDO::getStatus)
+ .or()
+ .ne(SrmSupplierDO::getStatus, CommonStatusEnum.DISABLE.getStatus()))
+ .orderByAsc(SrmSupplierDO::getId));
}
@Override
@@ -114,29 +233,196 @@
return supplierMapper.selectBatchIds(ids);
}
+ // ========== 鑱旂郴浜� / 閾惰璐︽埛 ==========
+
+ /**
+ * 瀵煎叆鍦烘櫙娌℃湁鑱旂郴浜哄垪琛ㄦ椂锛岀敤涓昏〃鎵佸钩瀛楁鐢熸垚涓�鏉¢粯璁よ仈绯讳汉
+ */
+ private void fillDefaultContactAndBankFromFlatFields(SrmSupplierSaveReqVO reqVO) {
+ if (reqVO.getContacts() == null && StrUtil.isNotBlank(reqVO.getContactName())) {
+ SrmSupplierContactSaveReqVO contact = new SrmSupplierContactSaveReqVO();
+ contact.setName(reqVO.getContactName());
+ contact.setMobile(reqVO.getContactMobile());
+ contact.setEmail(reqVO.getContactEmail());
+ contact.setIsDefault(Boolean.TRUE);
+ reqVO.setContacts(Collections.singletonList(contact));
+ }
+ if (reqVO.getBanks() == null
+ && (StrUtil.isNotBlank(reqVO.getBankName()) || StrUtil.isNotBlank(reqVO.getBankAccount()))) {
+ SrmSupplierBankSaveReqVO bank = new SrmSupplierBankSaveReqVO();
+ bank.setBankName(reqVO.getBankName());
+ bank.setBankAccount(reqVO.getBankAccount());
+ bank.setIsDefault(Boolean.TRUE);
+ reqVO.setBanks(Collections.singletonList(bank));
+ }
+ }
+
+ private void saveContacts(Long supplierId, List<SrmSupplierContactSaveReqVO> contacts) {
+ supplierContactMapper.deleteBySupplierId(supplierId);
+ if (CollUtil.isEmpty(contacts)) {
+ return;
+ }
+ for (int i = 0; i < contacts.size(); i++) {
+ SrmSupplierContactSaveReqVO vo = contacts.get(i);
+ if (StrUtil.isBlank(vo.getName())) {
+ throw new ServiceException(ErrorCodeConstants.SUPPLIER_CONTACT_NAME_REQUIRED.getCode(),
+ "绗� " + (i + 1) + " 涓仈绯讳汉鐨勫鍚嶄笉鑳戒负绌猴紝璇峰~鍐欒仈绯讳汉濮撳悕鍚庨噸鏂颁繚瀛�");
+ }
+ }
+ int defaultIndex = resolveDefaultIndex(contacts.size(),
+ contacts.stream().map(SrmSupplierContactSaveReqVO::getIsDefault).toList());
+ for (int i = 0; i < contacts.size(); i++) {
+ SrmSupplierContactDO contact = BeanUtils.toBean(contacts.get(i), SrmSupplierContactDO.class);
+ contact.setId(null);
+ contact.setSupplierId(supplierId);
+ contact.setSort(i);
+ contact.setIsDefault(i == defaultIndex);
+ supplierContactMapper.insert(contact);
+ }
+ }
+
+ private void saveBanks(Long supplierId, List<SrmSupplierBankSaveReqVO> banks) {
+ supplierBankMapper.deleteBySupplierId(supplierId);
+ if (CollUtil.isEmpty(banks)) {
+ return;
+ }
+ for (int i = 0; i < banks.size(); i++) {
+ SrmSupplierBankSaveReqVO vo = banks.get(i);
+ if (StrUtil.isBlank(vo.getBankName()) || StrUtil.isBlank(vo.getBankAccount())) {
+ throw new ServiceException(ErrorCodeConstants.SUPPLIER_BANK_INFO_INCOMPLETE.getCode(),
+ "绗� " + (i + 1) + " 涓摱琛岃处鎴风殑寮�鎴疯鎴栭摱琛岃处鍙蜂负绌猴紝璇疯ˉ鍏ㄥ紑鎴疯鍜岄摱琛岃处鍙峰悗閲嶆柊淇濆瓨");
+ }
+ }
+ int defaultIndex = resolveDefaultIndex(banks.size(),
+ banks.stream().map(SrmSupplierBankSaveReqVO::getIsDefault).toList());
+ for (int i = 0; i < banks.size(); i++) {
+ SrmSupplierBankDO bank = BeanUtils.toBean(banks.get(i), SrmSupplierBankDO.class);
+ bank.setId(null);
+ bank.setSupplierId(supplierId);
+ bank.setSort(i);
+ bank.setIsDefault(i == defaultIndex);
+ supplierBankMapper.insert(bank);
+ }
+ }
+
+ /**
+ * 瑙f瀽榛樿椤癸細浼樺厛鍙栨爣璁颁簡榛樿鐨勭涓�鏉★紝鍚﹀垯鍙栫涓�鏉�
+ */
+ private int resolveDefaultIndex(int size, List<Boolean> defaults) {
+ for (int i = 0; i < size; i++) {
+ if (Boolean.TRUE.equals(defaults.get(i))) {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 鎶婇粯璁よ仈绯讳汉/榛樿閾惰鍥炲啓涓昏〃鎵佸钩瀛楁锛屽吋瀹瑰垪琛ㄣ�佹悳绱笌瀵煎叆瀵煎嚭
+ */
+ private void syncSupplierDefaultFields(Long supplierId, List<SrmSupplierContactSaveReqVO> contacts,
+ List<SrmSupplierBankSaveReqVO> banks) {
+ SrmSupplierDO updateObj = new SrmSupplierDO();
+ updateObj.setId(supplierId);
+ boolean changed = false;
+ if (contacts != null) {
+ SrmSupplierContactSaveReqVO defaultContact = pickDefault(contacts, SrmSupplierContactSaveReqVO::getIsDefault);
+ updateObj.setContactName(defaultContact == null ? null : defaultContact.getName());
+ updateObj.setContactMobile(defaultContact == null ? null : defaultContact.getMobile());
+ updateObj.setContactEmail(defaultContact == null ? null : defaultContact.getEmail());
+ changed = true;
+ }
+ if (banks != null) {
+ SrmSupplierBankSaveReqVO defaultBank = pickDefault(banks, SrmSupplierBankSaveReqVO::getIsDefault);
+ updateObj.setBankName(defaultBank == null ? null : defaultBank.getBankName());
+ updateObj.setBankAccount(defaultBank == null ? null : defaultBank.getBankAccount());
+ changed = true;
+ }
+ if (changed) {
+ supplierMapper.updateById(updateObj);
+ }
+ }
+
+ private <T> T pickDefault(List<T> list, java.util.function.Function<T, Boolean> isDefault) {
+ if (CollUtil.isEmpty(list)) {
+ return null;
+ }
+ return list.stream().filter(item -> Boolean.TRUE.equals(isDefault.apply(item)))
+ .findFirst().orElse(list.get(0));
+ }
+
+ // ========== 瀵煎叆杈呭姪鏂规硶 ==========
+
+ /**
+ * 瀵煎叆 VO -> 淇濆瓨 VO锛屽鐢� create/update 閫昏緫锛�
+ * 绫诲瀷鏀寔涓枃鍚嶇О鎴栫紪鐮侊紙1~4锛夛紝鐘舵�佺暀绌洪粯璁ゅ惎鐢�
+ */
+ private SrmSupplierSaveReqVO toSaveReqVO(SrmSupplierImportExcelVO importVO) {
+ SrmSupplierSaveReqVO saveReqVO = new SrmSupplierSaveReqVO();
+ saveReqVO.setCode(StrUtil.trim(importVO.getCode()));
+ saveReqVO.setName(StrUtil.trim(importVO.getName()));
+ saveReqVO.setShortName(StrUtil.trimToNull(importVO.getShortName()));
+ saveReqVO.setType(parseTypeCode(importVO.getType()));
+ saveReqVO.setCompanyNature(StrUtil.trimToNull(importVO.getCompanyNature()));
+ saveReqVO.setRegisteredCapital(importVO.getRegisteredCapital());
+ saveReqVO.setBusinessLicenseNo(StrUtil.trimToNull(importVO.getBusinessLicenseNo()));
+ saveReqVO.setTaxNo(StrUtil.trimToNull(importVO.getTaxNo()));
+ saveReqVO.setLegalPerson(StrUtil.trimToNull(importVO.getLegalPerson()));
+ saveReqVO.setAddress(StrUtil.trimToNull(importVO.getAddress()));
+ saveReqVO.setWebsite(StrUtil.trimToNull(importVO.getWebsite()));
+ saveReqVO.setContactName(StrUtil.trimToNull(importVO.getContactName()));
+ saveReqVO.setContactMobile(StrUtil.trimToNull(importVO.getContactMobile()));
+ saveReqVO.setContactEmail(StrUtil.trimToNull(importVO.getContactEmail()));
+ saveReqVO.setBankName(StrUtil.trimToNull(importVO.getBankName()));
+ saveReqVO.setBankAccount(StrUtil.trimToNull(importVO.getBankAccount()));
+ saveReqVO.setStatus(importVO.getStatus() != null ? importVO.getStatus() : CommonStatusEnum.ENABLE.getStatus());
+ saveReqVO.setRemark(StrUtil.trimToNull(importVO.getRemark()));
+ return saveReqVO;
+ }
+
+ /**
+ * 渚涘簲鍟嗙被鍨嬭В鏋愶細涓枃鍚嶇О鎴栫紪鐮侊紙1~4锛夊潎杞崲涓虹紪鐮佸瓧绗︿覆锛�
+ * 鏃犳硶璇嗗埆鏃朵繚鐣欏師鍊硷紝閬垮厤瀵煎叆琚樆濉�
+ */
+ private String parseTypeCode(String type) {
+ String t = StrUtil.trimToNull(type);
+ if (t == null) {
+ return null;
+ }
+ for (SupplierTypeEnum e : SupplierTypeEnum.values()) {
+ if (t.equalsIgnoreCase(e.getName()) || t.equals(String.valueOf(e.getCode()))) {
+ return String.valueOf(e.getCode());
+ }
+ }
+ // 鍏煎 Excel 鏁板瓧鍗曞厓鏍艰璇绘垚 "1.0" 绛夊甫灏忔暟褰㈠紡
+ try {
+ BigDecimal bd = new BigDecimal(t);
+ if (bd.stripTrailingZeros().scale() <= 0) {
+ int i = bd.intValueExact();
+ if (i >= 1 && i <= 4) {
+ return String.valueOf(i);
+ }
+ }
+ } catch (NumberFormatException ignored) {
+ // 蹇界暐锛氫繚鎸佸師鍊�
+ }
+ return t;
+ }
+
// ========== 鏍¢獙鏂规硶 ==========
- private void validateSupplierExists(Long id) {
- if (supplierMapper.selectById(id) == null) {
+ private SrmSupplierDO validateSupplierExists(Long id) {
+ SrmSupplierDO supplier = supplierMapper.selectById(id);
+ if (supplier == null) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_NOT_EXISTS);
}
+ return supplier;
}
private void validateCodeUnique(String code, Long id) {
SrmSupplierDO existing = supplierMapper.selectByCode(code);
- if (existing != null && !existing.getId().equals(id)) {
+ if (existing != null && !Objects.equals(existing.getId(), id)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_CODE_EXISTS);
- }
- }
-
- private void validateNoReference(Long id) {
- boolean hasReference = supplierApplyMapper.existsApprovedBySupplierId(id)
- || supplierCertificateMapper.selectCount(SrmSupplierCertificateDO::getSupplierId, id) > 0
- || tenderBidMapper.selectCount(SrmTenderBidDO::getSupplierId, id) > 0
- || bidEvaluationMapper.selectCount(SrmBidEvaluationDO::getSupplierId, id) > 0
- || bidAwardMapper.selectCount(SrmBidAwardDO::getSupplierId, id) > 0;
- if (hasReference) {
- throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_EXISTS_REFERENCE);
}
}
--
Gitblit v1.9.3