商品映射新增导出未分配商品功能
This commit is contained in:
parent
3ed0363ef1
commit
f2b7283fa5
@ -83,13 +83,12 @@ public class ProductMapping implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 生成唯一键:productName + storeId + specValue + specUnit
|
||||
* 生成唯一键:productName + productNumber + storeId
|
||||
*/
|
||||
public String getUniqueKey() {
|
||||
return String.format("%s|%d|%s|%s",
|
||||
return String.format("%s|%s|%d",
|
||||
productName,
|
||||
storeId,
|
||||
specValue.stripTrailingZeros().toPlainString(),
|
||||
specUnit);
|
||||
productNumber,
|
||||
storeId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +207,9 @@ public class ProductMappingController extends BaseControllerImpl {
|
||||
*/
|
||||
@ApiOperation(value = "查找为同步的商品数据", notes = "删除查找为同步的商品数据")
|
||||
@RequestMapping(value = "/getSyncBaseMapingProducts", method = RequestMethod.GET)
|
||||
public CommonResult getSyncBaseMapingProducts(Integer storeId) {
|
||||
return productMappingService.getSyncProductUnchecked(storeId);
|
||||
public CommonResult getSyncBaseMapingProducts(@RequestParam Integer storeId,@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
return productMappingService.getSyncProductUnchecked(storeId,pageNum,pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,5 +295,13 @@ public class ProductMappingController extends BaseControllerImpl {
|
||||
return CommonResult.success(syncThirdDataService.importLibProductImg(null));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出未分配商品数据
|
||||
* @param storeId
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportUncheckShopData")
|
||||
public void exportUncheckShopData(@RequestParam(value = "storeId",required = false) Integer storeId, HttpServletResponse response) {
|
||||
productMappingService.exportUncheckShopData(storeId,response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,11 +64,9 @@ public class ProductMappingExcel {
|
||||
* 生成唯一键:productName + storeId + specValue + specUnit
|
||||
*/
|
||||
public String getUniqueKey() {
|
||||
return String.format("%s|%s|%d|%s|%s",
|
||||
return String.format("%s|%s|%d",
|
||||
productName,
|
||||
productNumber,
|
||||
storeId,
|
||||
specValue.stripTrailingZeros().toPlainString(),
|
||||
specUnit);
|
||||
storeId);
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@ public interface ProductMappingService extends IBaseService<ProductMapping> {
|
||||
|
||||
CommonResult syncAllProductMapping(Integer storeId,String isPublish);
|
||||
|
||||
CommonResult getSyncProductUnchecked(Integer storeId);
|
||||
CommonResult getSyncProductUnchecked(Integer storeId,Integer pageNum,Integer pageSize);
|
||||
|
||||
// 下载导入模板
|
||||
void downloadTemplate(HttpServletResponse response);
|
||||
@ -44,4 +44,7 @@ public interface ProductMappingService extends IBaseService<ProductMapping> {
|
||||
// 保存数据
|
||||
CommonResult saveProductMapping(ProductMapping data);
|
||||
|
||||
// 导出未分配商品数据
|
||||
void exportUncheckShopData(Integer storeId, HttpServletResponse response);
|
||||
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult getSyncProductUnchecked(Integer storeId) {
|
||||
public CommonResult getSyncProductUnchecked(Integer storeId,Integer pageNum,Integer pageSize) {
|
||||
if(ObjectUtil.isEmpty(storeId)){
|
||||
storeId= Integer.valueOf(Objects.requireNonNull(ContextUtil.getCurrentUser()).getStore_id());
|
||||
}
|
||||
@ -540,7 +540,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
QueryWrapper<ShopProductBase> queryWrapper= new QueryWrapper<>();
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
return CommonResult.success(shopProductBaseService.list(queryWrapper));
|
||||
return CommonResult.success(shopProductBaseService.lists(queryWrapper,pageNum,pageSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -612,7 +612,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
productMappingService.saveBatch(toInsert,toInsert.size());
|
||||
}
|
||||
if (!toUpdate.isEmpty()) {
|
||||
productMappingService.updateBatchById(toUpdate,toInsert.size());
|
||||
productMappingService.updateBatchById(toUpdate,toUpdate.size());
|
||||
}
|
||||
|
||||
// 5. 生成错误报告(如果有错误)
|
||||
@ -688,7 +688,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
// 构建唯一键查询条件
|
||||
private String buildUniqueKeyCondition(List<String> uniqueKeys) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CONCAT_WS('|', product_name, store_id, TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(spec_value AS CHAR))), spec_unit) IN (");
|
||||
sb.append("CONCAT_WS('|', product_name,product_number, store_id) IN (");
|
||||
|
||||
for (int i = 0; i < uniqueKeys.size(); i++) {
|
||||
if (i > 0) sb.append(",");
|
||||
@ -809,6 +809,43 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
return CommonResult.success(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportUncheckShopData(Integer storeId, HttpServletResponse response) {
|
||||
try {
|
||||
// 设置响应头
|
||||
setExcelResponseHeader(response, EXPORT_NAME);
|
||||
|
||||
if(ObjectUtil.isEmpty(storeId)){
|
||||
storeId= Integer.valueOf(Objects.requireNonNull(ContextUtil.getCurrentUser()).getStore_id());
|
||||
}
|
||||
//找出范围内的规格产品
|
||||
QueryWrapper<ShopProductBase> queryWrapper= new QueryWrapper<>();
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
List<ShopProductBase> shopProductBaseList= shopProductBaseService.lists(queryWrapper,1,5000).getRecords();
|
||||
List<ProductMappingExcel> excelData=new ArrayList<>();
|
||||
shopProductBaseList.forEach(shopBase->{
|
||||
ProductMappingExcel productMappingExcel=new ProductMappingExcel();
|
||||
productMappingExcel.setProductName(shopBase.getProduct_name());
|
||||
productMappingExcel.setStoreId(shopBase.getStore_id());
|
||||
productMappingExcel.setProductNumber(shopBase.getProduct_number());
|
||||
productMappingExcel.setStoreName(shopBase.getStore_name());
|
||||
productMappingExcel.setSortOrder(10);
|
||||
productMappingExcel.setSpecUnit("g");
|
||||
excelData.add(productMappingExcel);
|
||||
});
|
||||
|
||||
// 导出Excel
|
||||
EasyExcel.write(response.getOutputStream(), ProductMappingExcel.class)
|
||||
.sheet("需要映射的商品数据")
|
||||
.registerWriteHandler(new ExportStyleHandler())
|
||||
.doWrite(excelData);
|
||||
} catch (IOException e) {
|
||||
log.error("导出数据失败", e);
|
||||
throw new RuntimeException("导出数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 错误信息类
|
||||
@Data
|
||||
|
||||
Loading…
Reference in New Issue
Block a user