|
|
@@ -229,7 +229,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
|
supplierInfoTemporary.setSupplyStatus(bo.getSupplyStatus());
|
|
|
boolean save = supplierInfoTemporaryService.saveOrUpdate(supplierInfoTemporary);
|
|
|
- return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ baseMapper.updateById(supplierInfoVo);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -237,19 +237,19 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
update.setCooperative(1L);
|
|
|
- return baseMapper.updateById(update) > 0;
|
|
|
+ baseMapper.updateById(update);
|
|
|
}
|
|
|
//待审核 -> 审核未通过
|
|
|
if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- return baseMapper.updateById(update) > 0;
|
|
|
+ baseMapper.updateById(update);
|
|
|
}
|
|
|
|
|
|
//停用 ->正式供应商
|
|
|
if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
update.setCooperative(1L);
|
|
|
- return baseMapper.updateById(update) > 0;
|
|
|
+ baseMapper.updateById(update);
|
|
|
}
|
|
|
//审核未通过 -> 无
|
|
|
|
|
|
@@ -272,7 +272,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
String areaListJson = supplierInfoTemporary.getAreaListJson();
|
|
|
if (areaListJson == null || areaListJson.trim().isEmpty()) {
|
|
|
// 无区域数据,直接更新主表即可
|
|
|
- return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ baseMapper.updateById(supplierInfoVo);
|
|
|
}
|
|
|
try {
|
|
|
// 1. 解析JSON字符串为 TableDataInfo<SupplyAreaVo>(和存储时的类型一致)
|
|
|
@@ -286,7 +286,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
List<SupplyAreaVo> supplyAreaVoList = areaTableData.getRows();
|
|
|
if (supplyAreaVoList == null || supplyAreaVoList.isEmpty()) {
|
|
|
// 无地址数据,直接更新主表即可
|
|
|
- return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ baseMapper.updateById(supplierInfoVo);
|
|
|
}
|
|
|
|
|
|
// 3. 转换 SupplyAreaVo -> SupplyArea(持久化实体)
|
|
|
@@ -2394,4 +2394,128 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
|
|
|
return baseMapper.selectVoList(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将供应商表数据同步到临时表
|
|
|
+ *
|
|
|
+ * @return 是否同步成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean syncToTemporaryTable() {
|
|
|
+ try {
|
|
|
+ // 1. 查询所有供应商信息
|
|
|
+ List<SupplierInfo> supplierList = baseMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
+
|
|
|
+ if (supplierList == null || supplierList.isEmpty()) {
|
|
|
+ log.warn("没有找到需要同步的供应商数据");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 清空临时表数据(可选,根据业务需求决定是否需要先清空)
|
|
|
+ supplierInfoTemporaryService.remove(new LambdaQueryWrapper<>());
|
|
|
+
|
|
|
+ // 3. 转换并批量插入到临时表
|
|
|
+ List<SupplierInfoTemporary> temporaryList = new ArrayList<>();
|
|
|
+ for (SupplierInfo supplier : supplierList) {
|
|
|
+ SupplierInfoTemporary temporary = convertToTemporary(supplier);
|
|
|
+ temporaryList.add(temporary);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 批量保存到临时表
|
|
|
+ boolean result = supplierInfoTemporaryService.saveBatch(temporaryList);
|
|
|
+
|
|
|
+ log.info("成功同步 {} 条供应商数据到临时表", temporaryList.size());
|
|
|
+ return result;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("同步供应商数据到临时表失败", e);
|
|
|
+ throw new ServiceException("同步供应商数据失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将SupplierInfo转换为SupplierInfoTemporary
|
|
|
+ *
|
|
|
+ * @param supplier 供应商信息
|
|
|
+ * @return 临时表实体
|
|
|
+ */
|
|
|
+ private SupplierInfoTemporary convertToTemporary(SupplierInfo supplier) {
|
|
|
+ SupplierInfoTemporary temporary = new SupplierInfoTemporary();
|
|
|
+
|
|
|
+ // 复制基本字段
|
|
|
+ temporary.setSupplierNo(supplier.getSupplierNo());
|
|
|
+ temporary.setSupplierId(supplier.getId());
|
|
|
+ temporary.setEnterpriseName(supplier.getEnterpriseName());
|
|
|
+ temporary.setMembershipSize(supplier.getMembershipSize());
|
|
|
+ temporary.setSupplierType(supplier.getSupplierType());
|
|
|
+ temporary.setCooperationType(supplier.getCooperationType());
|
|
|
+ temporary.setFixedPhone(supplier.getFixedPhone());
|
|
|
+ temporary.setFax(supplier.getFax());
|
|
|
+ temporary.setUrl(supplier.getUrl());
|
|
|
+ temporary.setPostCode(supplier.getPostCode());
|
|
|
+ temporary.setMailbox(supplier.getMailbox());
|
|
|
+ temporary.setOfficeProvince(supplier.getOfficeProvince());
|
|
|
+ temporary.setOfficeCity(supplier.getOfficeCity());
|
|
|
+ temporary.setOfficeCounty(supplier.getOfficeCounty());
|
|
|
+ temporary.setOfficeAddress(supplier.getOfficeAddress());
|
|
|
+ temporary.setBusinessName(supplier.getBusinessName());
|
|
|
+ temporary.setSocialCreditCode(supplier.getSocialCreditCode());
|
|
|
+ temporary.setLegalPersonName(supplier.getLegalPersonName());
|
|
|
+ temporary.setLegalPersonId(supplier.getLegalPersonId());
|
|
|
+ temporary.setRegisteredCapital(supplier.getRegisteredCapital());
|
|
|
+ temporary.setBusinessProvince(supplier.getBusinessProvince());
|
|
|
+ temporary.setBusinessCity(supplier.getBusinessCity());
|
|
|
+ temporary.setBusinessCounty(supplier.getBusinessCounty());
|
|
|
+ temporary.setBusinessAddress(supplier.getBusinessAddress());
|
|
|
+ temporary.setBusinessLicense(supplier.getBusinessLicense());
|
|
|
+ temporary.setInvoiceType(supplier.getInvoiceType());
|
|
|
+ temporary.setInvoiceHeader(supplier.getInvoiceHeader());
|
|
|
+ temporary.setTaxpayerIdentifier(supplier.getTaxpayerIdentifier());
|
|
|
+ temporary.setDepositaryBank(supplier.getDepositaryBank());
|
|
|
+ temporary.setRowNum(supplier.getRowNum());
|
|
|
+ temporary.setBankAccounts(supplier.getBankAccounts());
|
|
|
+ temporary.setInvoiceAddress(supplier.getInvoiceAddress());
|
|
|
+ temporary.setInvoiceLandline(supplier.getInvoiceLandline());
|
|
|
+ temporary.setScopeSupply(supplier.getScopeSupply());
|
|
|
+
|
|
|
+ // 注意:cooperateWay在SupplierInfo中是Long类型,在SupplierInfoTemporary中是String类型
|
|
|
+ if (supplier.getCooperateWay() != null) {
|
|
|
+ temporary.setCooperateWay(String.valueOf(supplier.getCooperateWay()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 注意:cooperateLevel在SupplierInfo中是Long类型,在SupplierInfoTemporary中是String类型
|
|
|
+ if (supplier.getCooperateLevel() != null) {
|
|
|
+ temporary.setCooperateLevel(String.valueOf(supplier.getCooperateLevel()));
|
|
|
+ }
|
|
|
+
|
|
|
+ temporary.setContractEndTime(supplier.getContractEndTime());
|
|
|
+ temporary.setSupplyStatus(supplier.getSupplyStatus());
|
|
|
+ temporary.setSupplyScore(supplier.getSupplyScore());
|
|
|
+ temporary.setYearSales(supplier.getYearSales());
|
|
|
+ temporary.setSupplierName(supplier.getSupplierName());
|
|
|
+ temporary.setSupplierPhone(supplier.getSupplierPhone());
|
|
|
+ temporary.setSupplierPassword(supplier.getSupplierPassword());
|
|
|
+ temporary.setOperatingCategory(supplier.getOperatingCategory());
|
|
|
+ temporary.setOperatingBrand(supplier.getOperatingBrand());
|
|
|
+ temporary.setOtherCustomers(supplier.getOtherCustomers());
|
|
|
+ temporary.setShortName(supplier.getShortName());
|
|
|
+ temporary.setIndustrCategory(supplier.getIndustrCategory());
|
|
|
+ temporary.setType(supplier.getType());
|
|
|
+ temporary.setOwnedCompany(supplier.getOwnedCompany());
|
|
|
+
|
|
|
+ // 注意:pushStatus在SupplierInfo中是Long类型,在SupplierInfoTemporary中是String类型
|
|
|
+ if (supplier.getPushStatus() != null) {
|
|
|
+ temporary.setPushStatus(String.valueOf(supplier.getPushStatus()));
|
|
|
+ }
|
|
|
+
|
|
|
+ temporary.setValidityFromDate(supplier.getValidityFromDate());
|
|
|
+ temporary.setValidityToDate(supplier.getValidityToDate());
|
|
|
+ temporary.setRowNo(supplier.getRowNo());
|
|
|
+ temporary.setPersonImage(supplier.getPersonImage());
|
|
|
+ temporary.setAbutmentNo(supplier.getAbutmentNo());
|
|
|
+ temporary.setCooperative(supplier.getCooperative());
|
|
|
+
|
|
|
+ return temporary;
|
|
|
+ }
|
|
|
}
|