导入修改

This commit is contained in:
秦鸿展
2026-07-22 19:01:18 +08:00
parent 8ea6a82acd
commit effa681709
2 changed files with 36 additions and 20 deletions
@@ -380,11 +380,23 @@ public class UserShipperApplicationService {
if (org.springframework.util.StringUtils.isEmpty(companyName)) continue;
total++;
try {
// 先按公司名称查是否已存在委托方
UserShipperEntity existingShipper = findFirstByShipperEnterpriseNameAcrossOrgs(companyName);
if (existingShipper != null && existingShipper.getShipperId() != null) {
// 已存在:只更新NC客户编码和org_code
appendOrganizationToExistingShipper(existingShipper,
SecurityUtils.getLoginUser().getUserPo().getOrganizationId(),
SecurityUtils.getLoginUser().getUserPo().getOrganizationName(),
userAccount, SecurityUtils.getLoginUser());
success++;
} else {
UserShipperDO shipperDO = new UserShipperDO();
shipperDO.setShipperType(2);
shipperDO.setDataSource(2);
shipperDO.setUserAccount(userAccount);
shipperDO.setShipperEnterpriseName(companyName);
// 登录账号同时作为NC客户编码
shipperDO.setCustomerNcCode(userAccount);
String contactName = getCellStr(row.getCell(2));
String contactPhone = getCellStr(row.getCell(3));
// 联系人 -> user表 user_name + user_shipper表 user_name_shipper
@@ -399,6 +411,7 @@ public class UserShipperApplicationService {
shipperDO.setSettlementCurrency(getCellStr(row.getCell(7)));
addShipper(shipperDO);
success++;
}
} catch (Exception e) {
failed++;
errors.add("" + (i + 1) + "行[" + companyName + "]导入失败:" + e.getMessage());
@@ -250,7 +250,10 @@ public class MaterialBaseInfoApplicationService {
}
}
Long shipperId = materialBaseInfoDO.getShipperId();
String customerCodeNcJson = materialBaseInfoMapper.getCustomerCodeNcJson(shipperId.toString());
String customerCodeNcJson = null;
if (shipperId != null) {
customerCodeNcJson = materialBaseInfoMapper.getCustomerCodeNcJson(shipperId.toString());
}
if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) {
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, Object>> listNc = null;