|
|
|
@ -407,6 +407,29 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void deleteHsCode(EcssHsCodeData data) { |
|
|
|
if (StringUtils.isBlank(data.getHsCodeDesc()) || StringUtils.isBlank(data.getBuNo())) { |
|
|
|
throw new RuntimeException("品名或BU不能为空。"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(data.getSite())) { |
|
|
|
data.setSite(coDelMapper.getSiteByBu(data.getBuNo())); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(data.getBrand())) { |
|
|
|
data.setBrand("无"); |
|
|
|
} |
|
|
|
// 删除前按工厂+BU+品名+品牌校验物料绑定;有引用则禁止删除,避免物料 HS 品名悬空 |
|
|
|
List<String> boundPartNos = coDelMapper.listPartNosBoundByHsCode(data); |
|
|
|
if (boundPartNos != null && !boundPartNos.isEmpty()) { |
|
|
|
int total = boundPartNos.size(); |
|
|
|
int displayLimit = 30; |
|
|
|
List<String> displayList = total > displayLimit ? boundPartNos.subList(0, displayLimit) : boundPartNos; |
|
|
|
String partNoText = String.join("、", displayList); |
|
|
|
String suffix = total > displayLimit ? " 等,共" + total + "个" : ""; |
|
|
|
log.warn("删除HS品名失败,存在物料绑定. site={}, buNo={}, hsCodeDesc={}, brand={}, partCount={}", |
|
|
|
data.getSite(), data.getBuNo(), data.getHsCodeDesc(), data.getBrand(), total); |
|
|
|
throw new RuntimeException("品名【" + data.getHsCodeDesc() + "】品牌【" + data.getBrand() |
|
|
|
+ "】已被物料(" + partNoText + suffix+")绑定,不能删除。"); |
|
|
|
} |
|
|
|
|
|
|
|
PartSubPropertiesValueData propertiesData = new PartSubPropertiesValueData(); |
|
|
|
propertiesData.setSite(data.getSite()); |
|
|
|
propertiesData.setBuNo(data.getBuNo()); |
|
|
|
|