修改产品导入

This commit is contained in:
wuweihua
2026-09-29 20:50:01 +08:00
parent 3f8f3a824d
commit 38f371742a
10 changed files with 613 additions and 139 deletions
@@ -1,7 +1,9 @@
package com.bms.web.controller.price;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -20,12 +22,14 @@ import com.bms.common.core.controller.BaseController;
import com.bms.common.core.domain.AjaxResult;
import com.bms.common.core.page.TableDataInfo;
import com.bms.common.enums.BusinessType;
import com.bms.common.utils.MessageUtils;
import com.bms.price.domain.BmsProduct;
import com.bms.price.domain.BmsProductCountry;
import com.bms.price.domain.BmsProductImportTask;
import com.bms.price.service.IBmsProductService;
/**
* 产品列表(含 Excel 导入)
* Product list (async Excel import)
*
* @author bms
*/
@@ -45,6 +49,17 @@ public class ProductController extends BaseController
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('price:product:import')")
@GetMapping("/import/task/{taskId}")
public AjaxResult getImportTask(@PathVariable String taskId)
{
BmsProductImportTask task = productService.getImportTask(taskId);
if (task == null)
{
return error(MessageUtils.message("price.product.import.task.notExists"));
}
return success(task);
}
@PreAuthorize("@ss.hasPermi('price:product:query')")
@GetMapping("/{productCode}/countries")
@@ -64,7 +79,7 @@ public class ProductController extends BaseController
}
@PreAuthorize("@ss.hasPermi('price:product:add')")
@Log(title = "产品列表", businessType = BusinessType.INSERT)
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody BmsProduct product)
{
@@ -73,7 +88,7 @@ public class ProductController extends BaseController
}
@PreAuthorize("@ss.hasPermi('price:product:edit')")
@Log(title = "产品列表", businessType = BusinessType.UPDATE)
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody BmsProduct product)
{
@@ -81,11 +96,8 @@ public class ProductController extends BaseController
return toAjax(productService.updateBmsProduct(product));
}
/**
* 修改产品国家明细行(重量段/运费/挂号费/尺寸/尾程/时效/生效失效日期)
*/
@PreAuthorize("@ss.hasPermi('price:product:edit')")
@Log(title = "产品国家明细", businessType = BusinessType.UPDATE)
@Log(title = "\u4ea7\u54c1\u56fd\u5bb6\u660e\u7ec6", businessType = BusinessType.UPDATE)
@PutMapping("/country")
public AjaxResult editCountry(@RequestBody BmsProductCountry country)
{
@@ -93,7 +105,7 @@ public class ProductController extends BaseController
}
@PreAuthorize("@ss.hasPermi('price:product:remove')")
@Log(title = "产品列表", businessType = BusinessType.DELETE)
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.DELETE)
@DeleteMapping("/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds)
{
@@ -101,26 +113,30 @@ public class ProductController extends BaseController
}
/**
* 导入威狮B2C小包价表.xlsx(产品目录 + 国家服务明细)
* Async import Weishi B2C workbook. Returns taskId; poll /import/task/{taskId}.
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:product:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
String message = productService.importProductExcel(file, updateSupport, getUsername());
return success(message);
String taskId = productService.submitImportProductExcelAsync(file, updateSupport, getUsername());
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("taskId", taskId);
return success(payload);
}
/**
* Import a single-country linehaul cost sheet. countryCode is the destination.
* Async single-country cost-sheet import. Returns taskId; poll /import/task/{taskId}.
*/
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:product:import')")
@PostMapping("/importCountryData")
public AjaxResult importCountryData(MultipartFile file, String countryCode) throws Exception
{
String message = productService.importCountryProductExcel(file, countryCode, getUsername());
return success(message);
String taskId = productService.submitImportCountryProductExcelAsync(file, countryCode, getUsername());
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("taskId", taskId);
return success(payload);
}
}
@@ -127,6 +127,7 @@ price.product.import.countryNotFound=国家不存在或已停用:{0}
price.product.import.countrySheetNotFound=未找到「产品目录」sheet,请上传单国专线成本价表
price.product.import.countryNoPrice=未找到该产品的重量段价格:{0}
price.product.import.countrySuccess=按国家导入成功({0}):新增 {1} 个产品,跳过 {2} 个(同代码同生效日不覆盖主数据);写入重量段 {3} 行。
price.product.import.task.notExists=任务不存在或已过期
# 报价试算 TmsPriceQuote(对外 TMS API 错误码,保持英文契约)
price.quote.postcodeRequired=该国家/产品有分区,请填写目的邮编
price.quote.postcodeZoneNotFound=邮编未匹配到分区,请核对目的邮编