|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -29,6 +30,7 @@ import org.dromara.customer.domain.vo.SupplyAreaVo;
|
|
|
import org.dromara.customer.domain.SupplyArea;
|
|
import org.dromara.customer.domain.SupplyArea;
|
|
|
import org.dromara.customer.mapper.SupplyAreaMapper;
|
|
import org.dromara.customer.mapper.SupplyAreaMapper;
|
|
|
import org.dromara.customer.service.ISupplyAreaService;
|
|
import org.dromara.customer.service.ISupplyAreaService;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -91,7 +93,8 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
// 3.3 遍历市级数据,挂载到对应的省级父节点中
|
|
// 3.3 遍历市级数据,挂载到对应的省级父节点中
|
|
|
for (SupplyAreaVo cityVo : cityList) {
|
|
for (SupplyAreaVo cityVo : cityList) {
|
|
|
// 市级的parentCode(上级编码)对应省级的areaCode
|
|
// 市级的parentCode(上级编码)对应省级的areaCode
|
|
|
- String parentAreaCode = cityVo.getParentCode(); // 注意类型转换(根据你的实际字段调整)
|
|
|
|
|
|
|
+ //TODO
|
|
|
|
|
+ Long parentAreaCode = cityVo.getParentId(); // 注意类型转换(根据你的实际字段调整)
|
|
|
|
|
|
|
|
// 找到对应的省级父节点
|
|
// 找到对应的省级父节点
|
|
|
SupplyAreaVo parentProvince = provinceMap.get(parentAreaCode);
|
|
SupplyAreaVo parentProvince = provinceMap.get(parentAreaCode);
|
|
@@ -263,7 +266,7 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
lqw.eq(bo.getSupplierId() != null, SupplyArea::getSupplierId, bo.getSupplierId());
|
|
lqw.eq(bo.getSupplierId() != null, SupplyArea::getSupplierId, bo.getSupplierId());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAreaCode()), SupplyArea::getAreaCode, bo.getAreaCode());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAreaCode()), SupplyArea::getAreaCode, bo.getAreaCode());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getAreaName()), SupplyArea::getAreaName, bo.getAreaName());
|
|
lqw.like(StringUtils.isNotBlank(bo.getAreaName()), SupplyArea::getAreaName, bo.getAreaName());
|
|
|
- lqw.eq(bo.getParentCode()!=null, SupplyArea::getParentCode, bo.getParentCode());
|
|
|
|
|
|
|
+ lqw.eq(bo.getParentId()!=null, SupplyArea::getParentId, bo.getParentId());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLevel()), SupplyArea::getLevel, bo.getLevel());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLevel()), SupplyArea::getLevel, bo.getLevel());
|
|
|
return lqw;
|
|
return lqw;
|
|
|
}
|
|
}
|
|
@@ -275,6 +278,7 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
* @return 是否新增成功
|
|
* @return 是否新增成功
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(SupplyAreaBo bo) {
|
|
public Boolean insertByBo(SupplyAreaBo bo) {
|
|
|
// 1. 校验核心参数(避免空指针)
|
|
// 1. 校验核心参数(避免空指针)
|
|
|
if (bo == null || bo.getSupplierId() == null) {
|
|
if (bo == null || bo.getSupplierId() == null) {
|
|
@@ -330,7 +334,7 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
try {
|
|
try {
|
|
|
areaListJson = objectMapper.writeValueAsString(tableDataInfo);
|
|
areaListJson = objectMapper.writeValueAsString(tableDataInfo);
|
|
|
} catch (JsonProcessingException e) {
|
|
} catch (JsonProcessingException e) {
|
|
|
- throw new RuntimeException("供应商区域数据 JSON 序列化失败,请检查数据格式", e);
|
|
|
|
|
|
|
+ throw new ServiceException("供应商区域数据 JSON 序列化失败,请检查数据格式"+e);
|
|
|
}
|
|
}
|
|
|
// 步骤6:处理临时表(SupplierInfoTemporary)- 查询→新建/更新
|
|
// 步骤6:处理临时表(SupplierInfoTemporary)- 查询→新建/更新
|
|
|
// 6.1 查询该供应商对应的临时表记录(一对一关联,以 supplierId 作为临时表 ID)
|
|
// 6.1 查询该供应商对应的临时表记录(一对一关联,以 supplierId 作为临时表 ID)
|
|
@@ -356,8 +360,6 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 6.3 无论新建/更新,均设置 areaListJson 字段(核心操作)
|
|
// 6.3 无论新建/更新,均设置 areaListJson 字段(核心操作)
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
int update = supplierInfoMapper.update(new LambdaUpdateWrapper<SupplierInfo>()
|
|
int update = supplierInfoMapper.update(new LambdaUpdateWrapper<SupplierInfo>()
|
|
|
.set(SupplierInfo::getSupplyStatus, SupplierStatusEnum.REVIEW_UPDATED.getCode())
|
|
.set(SupplierInfo::getSupplyStatus, SupplierStatusEnum.REVIEW_UPDATED.getCode())
|
|
|
.eq(SupplierInfo::getId, supplierId));
|
|
.eq(SupplierInfo::getId, supplierId));
|
|
@@ -370,7 +372,7 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
operateResult = supplierInfoTemporaryService.saveOrUpdate(tempSupplier);
|
|
operateResult = supplierInfoTemporaryService.saveOrUpdate(tempSupplier);
|
|
|
return operateResult;
|
|
return operateResult;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- throw new RuntimeException("供应商临时表数据操作失败,请联系管理员", e);
|
|
|
|
|
|
|
+ throw new ServiceException("供应商临时表数据操作失败,请联系管理员"+e);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
// 2.1 转换BO为正式库实体SupplyArea
|
|
// 2.1 转换BO为正式库实体SupplyArea
|
|
@@ -397,7 +399,7 @@ public class SupplyAreaServiceImpl extends ServiceImpl<SupplyAreaMapper, Supply
|
|
|
boolean b = baseMapper.insertBatch(supplyAreaOfficialList);
|
|
boolean b = baseMapper.insertBatch(supplyAreaOfficialList);
|
|
|
return b;
|
|
return b;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- throw new RuntimeException("供应商区域正式表数据插入失败,请联系管理员", e);
|
|
|
|
|
|
|
+ throw new ServiceException("供应商区域正式表数据插入失败,请联系管理员"+e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|