Implement product Excel file import functionality, including new service methods for handling Excel attachments. Update the ProductController to list imported Excel files by product code. Enhance BmsProduct and related entities to store references to the imported Excel files. Update front-end components to support displaying and managing Excel file attachments for products.
This commit is contained in:
@@ -33,6 +33,8 @@ public class BmsProduct extends BaseEntity
|
||||
public static final String STATUS_EXPIRED = "2";
|
||||
private String status;
|
||||
private String sourceSheet;
|
||||
/** FK prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
private Long tmsId;
|
||||
private Integer countryCount;
|
||||
private Integer surchargeCount;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment: prc_price_excel_file
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcPriceExcelFile extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String TYPE_PRODUCT = "PRODUCT";
|
||||
public static final String TYPE_REDLINE = "REDLINE";
|
||||
public static final String TYPE_SALES = "SALES";
|
||||
|
||||
private Long pefId;
|
||||
/** PRODUCT / REDLINE / SALES */
|
||||
private String excelType;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date effectiveTime;
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private Long fileSize;
|
||||
private String contentType;
|
||||
private String fileExtension;
|
||||
private String ossId;
|
||||
/** Comma-separated sheet names (optional) */
|
||||
private String sheetNames;
|
||||
}
|
||||
@@ -48,4 +48,9 @@ public class PrcPriceSet extends BaseEntity
|
||||
private String pullFromLibrary;
|
||||
/** Y: even if version already has details, delete+re-pull from library */
|
||||
private String forcePullLibrary;
|
||||
/**
|
||||
* Request-only: stamp this Excel attachment id onto prc_price_set_product.pef_id
|
||||
* when saving IMPORT details (not a column on prc_price_set).
|
||||
*/
|
||||
private Long pefId;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public class PrcPriceSetProduct implements Serializable
|
||||
private Long sourceProductId;
|
||||
/** 来源Excel sheet */
|
||||
private String sourceSheet;
|
||||
/** 关联导入价表Excel附件 prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment mapper
|
||||
*/
|
||||
public interface PrcPriceExcelFileMapper
|
||||
{
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId);
|
||||
|
||||
public List<PrcPriceExcelFile> selectPrcPriceExcelFileList(PrcPriceExcelFile query);
|
||||
|
||||
/** Distinct PRODUCT excel files linked by product.pef_id for this product_code */
|
||||
public List<PrcPriceExcelFile> selectByProductCode(@Param("productCode") String productCode);
|
||||
|
||||
public int insertPrcPriceExcelFile(PrcPriceExcelFile row);
|
||||
|
||||
public int updatePrcPriceExcelFile(PrcPriceExcelFile row);
|
||||
|
||||
public int deletePrcPriceExcelFileByIds(Long[] pefIds);
|
||||
}
|
||||
@@ -34,4 +34,8 @@ public interface PrcPriceSetProductMapper
|
||||
|
||||
/** Bind detail.psp_id from set product by psv + product_code. */
|
||||
public int bindDetailPspByPsvId(@Param("psvId") Long psvId);
|
||||
|
||||
/** Stamp Excel attachment id on set products under this version (optional code filter). */
|
||||
public int updatePefIdByPsvId(@Param("psvId") Long psvId, @Param("pefId") Long pefId,
|
||||
@Param("productCodes") List<String> productCodes);
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment service
|
||||
*/
|
||||
public interface IPrcPriceExcelFileService
|
||||
{
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId);
|
||||
|
||||
/** Import Excel attachments linked to this product_code via product.pef_id */
|
||||
public List<PrcPriceExcelFile> selectByProductCode(String productCode);
|
||||
|
||||
/**
|
||||
* Persist uploaded Excel under upload/price/excel and insert metadata row.
|
||||
*
|
||||
* @param excelType PRODUCT / REDLINE / SALES
|
||||
* @return inserted row with pefId
|
||||
*/
|
||||
public PrcPriceExcelFile saveImportExcel(String excelType, Date effectiveTime, byte[] bytes,
|
||||
String filename, String operName) throws Exception;
|
||||
}
|
||||
+30
@@ -41,7 +41,9 @@ import com.bms.price.domain.PrcZone;
|
||||
import com.bms.price.mapper.BmsProductCountryMapper;
|
||||
import com.bms.price.mapper.BmsProductMapper;
|
||||
import com.bms.price.mapper.PrcZoneMapper;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
import com.bms.price.service.IPrcSurchargeRelService;
|
||||
import com.bms.price.task.BmsProductImportAsyncRunner;
|
||||
import com.bms.price.util.ZoneCodeAbbrevs;
|
||||
@@ -94,6 +96,9 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
@Autowired
|
||||
private BmsProductImportAsyncRunner importAsyncRunner;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@Override
|
||||
public BmsProduct selectBmsProductById(Long productId)
|
||||
{
|
||||
@@ -313,6 +318,10 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
assertImportProductsNoDupCountryWeight(workbook, products, regionByNameCn, euRegions,
|
||||
zoneByCountryAndCode);
|
||||
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_PRODUCT, forcedEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int successNum = 0;
|
||||
int skipNum = 0;
|
||||
int countryNum = 0;
|
||||
@@ -331,6 +340,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
try
|
||||
{
|
||||
product.setEffectiveDate(forcedEff);
|
||||
product.setPefId(pefId);
|
||||
int[] nums = importOneProduct(workbook, product, operName, regionByNameCn, euRegions,
|
||||
zoneByCountryAndCode, unmatchedCountries, forcedEff);
|
||||
transactionManager.commit(tx);
|
||||
@@ -431,6 +441,10 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
// Pre-check all products: reject whole import before any write if any is earlier than prev version
|
||||
assertImportProductsEffectiveNotBeforePrev(products, forcedEff);
|
||||
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_PRODUCT, forcedEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int successNum = 0;
|
||||
int skipNum = 0;
|
||||
int countryNum = 0;
|
||||
@@ -458,6 +472,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
product.setDestRegion(countryLabel);
|
||||
product.setSourceSheet(block.sheetName);
|
||||
product.setEffectiveDate(forcedEff);
|
||||
product.setPefId(pefId);
|
||||
if (StringUtils.isEmpty(product.getTaxMode()))
|
||||
{
|
||||
product.setTaxMode(resolveTaxMode(product.getProductName()));
|
||||
@@ -649,6 +664,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
if (existing != null)
|
||||
{
|
||||
product.setProductId(existing.getProductId());
|
||||
patchProductPefId(product, operName);
|
||||
int countryRows = saveCountries(product, countries);
|
||||
return new int[] { 0, 1, countryRows };
|
||||
}
|
||||
@@ -672,6 +688,19 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
return new int[] { 1, 0, countryRows };
|
||||
}
|
||||
|
||||
private void patchProductPefId(BmsProduct product, String operName)
|
||||
{
|
||||
if (product == null || product.getProductId() == null || product.getPefId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BmsProduct pefPatch = new BmsProduct();
|
||||
pefPatch.setProductId(product.getProductId());
|
||||
pefPatch.setPefId(product.getPefId());
|
||||
pefPatch.setUpdateBy(operName);
|
||||
productMapper.updateBmsProduct(pefPatch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save country rows by effective_date.
|
||||
@@ -2159,6 +2188,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
if (existing != null)
|
||||
{
|
||||
product.setProductId(existing.getProductId());
|
||||
patchProductPefId(product, operName);
|
||||
int countryRows = saveCountries(product, countries);
|
||||
return new int[] { 0, 1, countryRows };
|
||||
}
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.bms.price.service.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bms.common.config.BmsConfig;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.file.FileUploadUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.mapper.PrcPriceExcelFileMapper;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
|
||||
/**
|
||||
* Persist import Excel bytes and metadata
|
||||
*/
|
||||
@Service
|
||||
public class PrcPriceExcelFileServiceImpl implements IPrcPriceExcelFileService
|
||||
{
|
||||
private static final String SUB_DIR = "price/excel";
|
||||
|
||||
@Autowired
|
||||
private PrcPriceExcelFileMapper excelFileMapper;
|
||||
|
||||
@Override
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId)
|
||||
{
|
||||
return excelFileMapper.selectPrcPriceExcelFileById(pefId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcPriceExcelFile> selectByProductCode(String productCode)
|
||||
{
|
||||
if (StringUtils.isEmpty(productCode))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PrcPriceExcelFile> list = excelFileMapper.selectByProductCode(productCode.trim());
|
||||
return list == null ? Collections.emptyList() : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrcPriceExcelFile saveImportExcel(String excelType, Date effectiveTime, byte[] bytes,
|
||||
String filename, String operName) throws Exception
|
||||
{
|
||||
if (StringUtils.isEmpty(excelType))
|
||||
{
|
||||
throw new ServiceException("excelType required");
|
||||
}
|
||||
if (bytes == null || bytes.length == 0)
|
||||
{
|
||||
throw new ServiceException("excel empty");
|
||||
}
|
||||
if (effectiveTime == null)
|
||||
{
|
||||
effectiveTime = new Date();
|
||||
}
|
||||
String originalName = StringUtils.isNotEmpty(filename) ? filename : "import.xlsx";
|
||||
String ext = FilenameUtils.getExtension(originalName);
|
||||
if (StringUtils.isEmpty(ext))
|
||||
{
|
||||
ext = "xlsx";
|
||||
}
|
||||
ext = ext.toLowerCase(Locale.ROOT);
|
||||
|
||||
String uploadDir = BmsConfig.getUploadPath() + File.separator + SUB_DIR;
|
||||
String pathName = DateUtils.datePath() + "/" + IdUtils.fastSimpleUUID() + "." + ext;
|
||||
File dest = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
|
||||
FileOutputStream fos = null;
|
||||
try
|
||||
{
|
||||
fos = new FileOutputStream(dest);
|
||||
fos.write(bytes);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.close(fos);
|
||||
}
|
||||
String storedPath = FileUploadUtils.getPathFileName(uploadDir, pathName);
|
||||
|
||||
PrcPriceExcelFile row = new PrcPriceExcelFile();
|
||||
row.setExcelType(excelType.trim().toUpperCase(Locale.ROOT));
|
||||
row.setEffectiveTime(effectiveTime);
|
||||
row.setFileName(originalName);
|
||||
row.setFilePath(storedPath);
|
||||
row.setFileSize(Long.valueOf(bytes.length));
|
||||
row.setContentType(resolveContentType(ext));
|
||||
row.setFileExtension(ext);
|
||||
row.setCreateBy(operName);
|
||||
excelFileMapper.insertPrcPriceExcelFile(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
private static String resolveContentType(String ext)
|
||||
{
|
||||
if ("xls".equals(ext))
|
||||
{
|
||||
return "application/vnd.ms-excel";
|
||||
}
|
||||
if ("xlsx".equals(ext))
|
||||
{
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+66
-2
@@ -22,10 +22,12 @@ import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.price.domain.BmsProduct;
|
||||
import com.bms.price.domain.BmsProductCountry;
|
||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||
import com.bms.price.domain.PrcPriceSetDetail;
|
||||
@@ -46,6 +48,7 @@ import com.bms.price.mapper.PrcPriceSetVersionSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
import com.bms.price.service.IPrcPriceSetService;
|
||||
import com.bms.price.task.PrcPriceSetSaveAsyncRunner;
|
||||
|
||||
@@ -117,6 +120,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
@Autowired
|
||||
private PrcPriceSetSaveAsyncRunner saveAsyncRunner;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@Override
|
||||
public PrcPriceSet selectPrcPriceSetById(Long priceSetId)
|
||||
{
|
||||
@@ -1071,6 +1077,18 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
assertUpdateOnlyWeightBandsMatch(byProduct, detailIndex);
|
||||
}
|
||||
String operName = null;
|
||||
try
|
||||
{
|
||||
operName = SecurityUtils.getUsername();
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
operName = null;
|
||||
}
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_SALES, new Date(), bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
Map<String, PrcPriceSetProduct> productMap = new LinkedHashMap<String, PrcPriceSetProduct>();
|
||||
int updated = 0;
|
||||
@@ -1172,9 +1190,20 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
throw new ServiceException(MessageUtils.message("price.set.import.noDetailWritten"));
|
||||
}
|
||||
|
||||
if (pefId != null)
|
||||
{
|
||||
for (PrcPriceSetProduct sp : productMap.values())
|
||||
{
|
||||
if (sp != null)
|
||||
{
|
||||
sp.setPefId(pefId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("products", new ArrayList<PrcPriceSetProduct>(productMap.values()));
|
||||
result.put("details", details);
|
||||
result.put("pefId", pefId);
|
||||
if (updateOnly)
|
||||
{
|
||||
result.put("message", MessageUtils.message("price.set.import.updateSuccess",
|
||||
@@ -1291,6 +1320,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
assertUpdateOnlyWeightBandsMatch(byProduct, detailIndex);
|
||||
}
|
||||
PrcPriceSetVersion verForFile = versionMapper.selectPrcPriceSetVersionById(psvId);
|
||||
Date excelEff = verForFile != null && verForFile.getEffectiveTime() != null
|
||||
? verForFile.getEffectiveTime() : new Date();
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_SALES, excelEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int updated = 0;
|
||||
int inserted = 0;
|
||||
@@ -1321,7 +1356,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
Long pspId = null;
|
||||
if (!updateOnly)
|
||||
{
|
||||
pspId = ensureSetProduct(priceSetId, psvId, productCode, productName);
|
||||
pspId = ensureSetProduct(priceSetId, psvId, productCode, productName, pefId);
|
||||
}
|
||||
for (BmsProductCountry row : e.getValue())
|
||||
{
|
||||
@@ -1385,6 +1420,11 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
setProductMapper.bindDetailPspByPsvId(psvId);
|
||||
}
|
||||
if (pefId != null && (inserted > 0 || updated > 0))
|
||||
{
|
||||
List<String> codes = new ArrayList<String>(byProduct.keySet());
|
||||
setProductMapper.updatePefIdByPsvId(psvId, pefId, codes);
|
||||
}
|
||||
reportImportProgress(taskId, priceSetId, 95, "finishing");
|
||||
if (inserted == 0 && updated == 0)
|
||||
{
|
||||
@@ -2935,7 +2975,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
d.setPriceSetId(set.getPriceSetId());
|
||||
d.setPsvId(version.getPsvId());
|
||||
Long pspId = ensureSetProduct(set.getPriceSetId(), version.getPsvId(),
|
||||
d.getProductCode(), d.getProductName());
|
||||
d.getProductCode(), d.getProductName(), set.getPefId());
|
||||
if (pspId != null)
|
||||
{
|
||||
d.setPspId(pspId);
|
||||
@@ -3059,6 +3099,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
* Uses request-scoped cache during bulk upsert to avoid N selects on same code.
|
||||
*/
|
||||
private Long ensureSetProduct(Long priceSetId, Long psvId, String productCode, String productNameHint)
|
||||
{
|
||||
return ensureSetProduct(priceSetId, psvId, productCode, productNameHint, null);
|
||||
}
|
||||
|
||||
private Long ensureSetProduct(Long priceSetId, Long psvId, String productCode, String productNameHint,
|
||||
Long pefId)
|
||||
{
|
||||
if (psvId == null || StringUtils.isEmpty(productCode))
|
||||
{
|
||||
@@ -3069,15 +3115,32 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
Map<String, Long> cache = setProductCacheTl.get();
|
||||
if (cache != null && cache.containsKey(key))
|
||||
{
|
||||
if (pefId != null)
|
||||
{
|
||||
PrcPriceSetProduct pefPatch = new PrcPriceSetProduct();
|
||||
pefPatch.setPspId(cache.get(key));
|
||||
pefPatch.setPefId(pefId);
|
||||
setProductMapper.updatePrcPriceSetProduct(pefPatch);
|
||||
}
|
||||
return cache.get(key);
|
||||
}
|
||||
PrcPriceSetProduct existing = setProductMapper.selectByPsvIdAndCode(psvId, code);
|
||||
if (existing != null)
|
||||
{
|
||||
boolean needUpdate = false;
|
||||
if (StringUtils.isEmpty(existing.getProductName()) && StringUtils.isNotEmpty(productNameHint)
|
||||
&& !code.equals(productNameHint))
|
||||
{
|
||||
existing.setProductName(productNameHint);
|
||||
needUpdate = true;
|
||||
}
|
||||
if (pefId != null && (existing.getPefId() == null || !pefId.equals(existing.getPefId())))
|
||||
{
|
||||
existing.setPefId(pefId);
|
||||
needUpdate = true;
|
||||
}
|
||||
if (needUpdate)
|
||||
{
|
||||
setProductMapper.updatePrcPriceSetProduct(existing);
|
||||
}
|
||||
if (cache != null)
|
||||
@@ -3090,6 +3153,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
row.setPriceSetId(priceSetId);
|
||||
row.setPsvId(psvId);
|
||||
row.setProductCode(code);
|
||||
row.setPefId(pefId);
|
||||
BmsProduct lib = null;
|
||||
try
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
<result property="createBy" column="created_by" />
|
||||
@@ -30,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<sql id="selectBmsProductVo">
|
||||
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
|
||||
p.source_sheet, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
(select count(distinct c.country_name) from product_country c
|
||||
where c.product_id = p.product_id
|
||||
or (c.product_id is null and c.product_code = p.product_code
|
||||
@@ -139,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="expireDate != null">expire_date,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="sourceSheet != null">source_sheet,</if>
|
||||
<if test="pefId != null">pef_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="tmsId != null">tms_id,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
@@ -155,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="expireDate != null">#{expireDate},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="sourceSheet != null">#{sourceSheet},</if>
|
||||
<if test="pefId != null">#{pefId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="tmsId != null">#{tmsId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
@@ -176,6 +179,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
expire_date = #{expireDate},
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
|
||||
<if test="pefId != null">pef_id = #{pefId},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="tmsId != null">tms_id = #{tmsId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PrcPriceExcelFileMapper">
|
||||
|
||||
<resultMap type="PrcPriceExcelFile" id="PrcPriceExcelFileResult">
|
||||
<id property="pefId" column="pef_id" />
|
||||
<result property="excelType" column="excel_type" />
|
||||
<result property="effectiveTime" column="effective_time" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="filePath" column="file_path" />
|
||||
<result property="fileSize" column="file_size" />
|
||||
<result property="contentType" column="content_type" />
|
||||
<result property="fileExtension" column="file_extension" />
|
||||
<result property="ossId" column="oss_id" />
|
||||
<result property="sheetNames" column="sheet_names" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcPriceExcelFileVo">
|
||||
select pef_id, excel_type, effective_time, file_name, file_path, file_size, content_type,
|
||||
file_extension, oss_id, sheet_names, remark, created_by, create_time, updated_by, update_time
|
||||
from prc_price_excel_file
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcPriceExcelFileById" parameterType="Long" resultMap="PrcPriceExcelFileResult">
|
||||
<include refid="selectPrcPriceExcelFileVo"/>
|
||||
where pef_id = #{pefId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcPriceExcelFileList" parameterType="PrcPriceExcelFile" resultMap="PrcPriceExcelFileResult">
|
||||
<include refid="selectPrcPriceExcelFileVo"/>
|
||||
<where>
|
||||
<if test="excelType != null and excelType != ''">
|
||||
AND excel_type = #{excelType}
|
||||
</if>
|
||||
<if test="fileName != null and fileName != ''">
|
||||
AND file_name like concat('%', #{fileName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by pef_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectByProductCode" resultMap="PrcPriceExcelFileResult">
|
||||
select distinct f.pef_id, f.excel_type, f.effective_time, f.file_name, f.file_path, f.file_size,
|
||||
f.content_type, f.file_extension, f.oss_id, f.sheet_names, f.remark,
|
||||
f.created_by, f.create_time, f.updated_by, f.update_time
|
||||
from prc_price_excel_file f
|
||||
inner join product p on p.pef_id = f.pef_id
|
||||
where p.product_code = #{productCode}
|
||||
and p.pef_id is not null
|
||||
order by f.effective_time desc, f.pef_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceExcelFile" parameterType="PrcPriceExcelFile" useGeneratedKeys="true" keyProperty="pefId">
|
||||
insert into prc_price_excel_file (
|
||||
<if test="excelType != null and excelType != ''">excel_type,</if>
|
||||
<if test="effectiveTime != null">effective_time,</if>
|
||||
<if test="fileName != null and fileName != ''">file_name,</if>
|
||||
<if test="filePath != null and filePath != ''">file_path,</if>
|
||||
<if test="fileSize != null">file_size,</if>
|
||||
<if test="contentType != null">content_type,</if>
|
||||
<if test="fileExtension != null">file_extension,</if>
|
||||
<if test="ossId != null">oss_id,</if>
|
||||
<if test="sheetNames != null">sheet_names,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="excelType != null and excelType != ''">#{excelType},</if>
|
||||
<if test="effectiveTime != null">#{effectiveTime},</if>
|
||||
<if test="fileName != null and fileName != ''">#{fileName},</if>
|
||||
<if test="filePath != null and filePath != ''">#{filePath},</if>
|
||||
<if test="fileSize != null">#{fileSize},</if>
|
||||
<if test="contentType != null">#{contentType},</if>
|
||||
<if test="fileExtension != null">#{fileExtension},</if>
|
||||
<if test="ossId != null">#{ossId},</if>
|
||||
<if test="sheetNames != null">#{sheetNames},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcPriceExcelFile" parameterType="PrcPriceExcelFile">
|
||||
update prc_price_excel_file
|
||||
<set>
|
||||
<if test="excelType != null and excelType != ''">excel_type = #{excelType},</if>
|
||||
<if test="effectiveTime != null">effective_time = #{effectiveTime},</if>
|
||||
<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
|
||||
<if test="filePath != null and filePath != ''">file_path = #{filePath},</if>
|
||||
<if test="fileSize != null">file_size = #{fileSize},</if>
|
||||
<if test="contentType != null">content_type = #{contentType},</if>
|
||||
<if test="fileExtension != null">file_extension = #{fileExtension},</if>
|
||||
<if test="ossId != null">oss_id = #{ossId},</if>
|
||||
<if test="sheetNames != null">sheet_names = #{sheetNames},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where pef_id = #{pefId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrcPriceExcelFileByIds" parameterType="Long">
|
||||
delete from prc_price_excel_file where pef_id in
|
||||
<foreach item="pefId" collection="array" open="(" separator="," close=")">
|
||||
#{pefId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -17,13 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="taxMode" column="tax_mode" />
|
||||
<result property="sourceProductId" column="source_product_id" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectVo">
|
||||
select psp_id, price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time, update_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id,
|
||||
create_time, update_time
|
||||
from prc_price_set_product
|
||||
</sql>
|
||||
|
||||
@@ -52,10 +54,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertPrcPriceSetProduct" parameterType="PrcPriceSetProduct" useGeneratedKeys="true" keyProperty="pspId">
|
||||
insert into prc_price_set_product (
|
||||
price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, create_time
|
||||
) values (
|
||||
#{priceSetId}, #{psvId}, #{productCode}, #{productName}, #{serviceLevel}, #{cargoAttr},
|
||||
#{destRegion}, #{updateNote}, #{taxMode}, #{sourceProductId}, #{sourceSheet}, sysdate()
|
||||
#{destRegion}, #{updateNote}, #{taxMode}, #{sourceProductId}, #{sourceSheet}, #{pefId}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="taxMode != null and taxMode != ''">tax_mode = #{taxMode},</if>
|
||||
<if test="sourceProductId != null">source_product_id = #{sourceProductId},</if>
|
||||
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
|
||||
<if test="pefId != null">pef_id = #{pefId},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where psp_id = #{pspId}
|
||||
@@ -88,11 +91,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="copyFromVersion">
|
||||
insert into prc_price_set_product (
|
||||
price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, create_time
|
||||
)
|
||||
select
|
||||
price_set_id, #{newPsvId}, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, sysdate()
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, sysdate()
|
||||
from prc_price_set_product
|
||||
where psv_id = #{srcPsvId}
|
||||
order by psp_id asc
|
||||
@@ -159,4 +162,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and (d.psp_id is null or d.psp_id <> sp.psp_id)
|
||||
</update>
|
||||
|
||||
<update id="updatePefIdByPsvId">
|
||||
update prc_price_set_product
|
||||
set pef_id = #{pefId}, update_time = sysdate()
|
||||
where psv_id = #{psvId}
|
||||
<if test="productCodes != null and productCodes.size() > 0">
|
||||
and product_code in
|
||||
<foreach item="code" collection="productCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user