diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiPurchaseThread.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiPurchaseThread.java index 8f9b077b..5992a5ea 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiPurchaseThread.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiPurchaseThread.java @@ -12,7 +12,6 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; import java.util.List; -import java.util.concurrent.Callable; /** * 请详细描述方法 @@ -22,7 +21,7 @@ import java.util.concurrent.Callable; */ @Data @Slf4j -public class AiPurchaseThread implements Callable { +public class AiPurchaseThread implements Runnable { private String purchaseId; private PurchaseOcrPictureService purchaseOcrPictureService; @@ -34,7 +33,7 @@ public class AiPurchaseThread implements Callable { public AiPurchaseThread() { } - public AiPurchaseThread(String purchaseId , PurchaseOcrPicture purchaseOcrPicture, PurchaseOcrPictureService purchaseOcrPictureService, ProductService productService, PurchaseDetailService purchaseDetailService, PurchaseService purchaseService) { + public AiPurchaseThread(String purchaseId, PurchaseOcrPicture purchaseOcrPicture, PurchaseOcrPictureService purchaseOcrPictureService, ProductService productService, PurchaseDetailService purchaseDetailService, PurchaseService purchaseService) { this.purchaseId = purchaseId; this.purchaseOcrPicture = purchaseOcrPicture; this.purchaseOcrPictureService = purchaseOcrPictureService; @@ -58,11 +57,10 @@ public class AiPurchaseThread implements Callable { /** * 每个线程拿到数据后如何去处理 - * - * @return */ @Override - public JSONObject call() { + public void run() { + JSONObject jsonObject = new JSONObject(); try { log.info("当前线程名称:------------>>>>>" + Thread.currentThread().getName()); @@ -74,21 +72,19 @@ public class AiPurchaseThread implements Callable { purchaseOcrPicture.setOcrStatus(PurchaseConstant.OCR_STATUS[1]); purchaseOcrPicture.setOcrCount(Integer.valueOf(jsonObject.getString("ocrCount"))); purchaseOcrPictureService.updateStatus(purchaseOcrPicture); - } catch(Exception e){ + } catch (Exception e) { purchaseOcrPicture.setOcrStatus(PurchaseConstant.OCR_STATUS[2]); purchaseOcrPicture.setOcrMsg(e.getMessage()); purchaseOcrPictureService.updateStatus(purchaseOcrPicture); - jsonObject.put("code",500); - jsonObject.put("msg",e.getMessage()); - throw new RuntimeException(e); + jsonObject.put("code", 500); + jsonObject.put("msg", e.getMessage()); + // throw new RuntimeException(e); } // 尝试更新主表识别状态 updateInStorageStatus(); } catch (Exception e) { log.error("timerThread出错,线程------>" + Thread.currentThread().getName(), e); } - - return jsonObject; } private void updateInStorageStatus() { @@ -97,19 +93,19 @@ public class AiPurchaseThread implements Callable { final List purchaseOcrPictureList = purchaseOcrPictureService.queryAllPictureStatus(purchaseId); // IN_STORAGE_STATUS 默认正在识别;2:正在识别;3:识别成功;4:识别失败 // OCR_STATUS ocr识别状态 0:(未识别)1:(已识别);2:(识别失败) - int inStorageStatus= PurchaseConstant.IN_STORAGE_STATUS[3]; + int inStorageStatus = PurchaseConstant.IN_STORAGE_STATUS[3]; for (PurchaseOcrPicture ocrPicture : purchaseOcrPictureList) { final Integer ocrStatus = ocrPicture.getOcrStatus(); if (ocrStatus == PurchaseConstant.OCR_STATUS[0]) { // 有正在识别的,则判定正在识别 inStorageStatus = PurchaseConstant.IN_STORAGE_STATUS[2]; break; - }else if(ocrStatus == PurchaseConstant.OCR_STATUS[2]){ + } else if (ocrStatus == PurchaseConstant.OCR_STATUS[2]) { // 有识别失败的,则判定识别失败 inStorageStatus = PurchaseConstant.IN_STORAGE_STATUS[4]; break; } } - purchaseService.updateInStorageStatus(purchaseId,inStorageStatus); + purchaseService.updateInStorageStatus(purchaseId, inStorageStatus); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiSaleThread.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiSaleThread.java index 7cda89a8..474713d0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiSaleThread.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiSaleThread.java @@ -52,7 +52,7 @@ public class AiSaleThread implements Runnable { saleAiMsg.setAiResultMsg(jsonObject.getString("resultContent")); saleAiMsg.setAiStatus(SaleAiMsgConstant.AI_STATUS[2]); saleAiMsgService.updateStatus(saleAiMsg); - throw new RuntimeException(e); + // throw new RuntimeException(e); } // 尝试更新主表识别状态 updateSaleAiStatus(); @@ -70,6 +70,6 @@ public class AiSaleThread implements Runnable { break; } } - saleService.updateStatus(saleAiMsg.getOrderId(), status); + saleService.updateAiFlag(saleAiMsg.getOrderId(), status); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java index 3b4e580d..0c63ab56 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java @@ -339,12 +339,15 @@ public class ReturnSaleController { public Result> queryAll(@RequestBody SaleComVO saleComVO) { final QueryWrapper queryWrapper = new QueryWrapper<>(); if (!ObjectUtils.isEmpty(saleComVO)) { - // shopId从缓存中设置 - final String shopId = securityUtil.getShopId(); - queryWrapper.eq("shop_id", shopId); if (!StringUtils.isEmpty(saleComVO.getSaleId())) { + // 根据销售单id,查询该销售单所有的退货信息 queryWrapper.eq("sale_id", saleComVO.getSaleId()); + }else{ + // 如果没有saleId,则说明店铺查询所有的欠款列表。 + // shopId从缓存中设置 + final String shopId = securityUtil.getShopId(); + queryWrapper.eq("shop_id", shopId); } final String remark = saleComVO.getRemark(); if (!StringUtils.isEmpty(remark)) { @@ -380,7 +383,7 @@ public class ReturnSaleController { //非自提查询配送人员信息 final OrderXd orderData = orderService.findByOrderId(id); // 订单的所属拉包工不为空的时候订单中的woker才会有值,所以这里判断所属拉包工id是否为空。 - if(orderData.getWorker() != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())){ + if(orderData != null && orderData.getWorker() != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())){ final String workerName = orderData.getWorker().getWorkerName(); // 查询到之后回填值列表 record.setWorkerName(workerName); @@ -432,7 +435,9 @@ public class ReturnSaleController { final ReturnSale returnSale = returnSaleService.getById(orderId); returnSale.setStatus(SaleConstant.SALE_STATUS[4]); returnSaleService.saveOrUpdate(returnSale); - // 同时取消订单 + // 修改销售单的状态为已完成 + saleService.updateStatus(returnSale.getSaleId(), Integer.valueOf(SaleConstant.SALE_STATUS[4])); + // 同时取消订单, orderService.delete(orderId); return ResultUtil.success("取消配送成功"); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java index 2ab24a3f..ccc1cc56 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java @@ -22,6 +22,7 @@ import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria; import cc.hiver.mall.pojo.vo.*; import cc.hiver.mall.service.*; import cc.hiver.mall.service.mybatis.*; +import cc.hiver.mall.utils.DateUtil; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -277,17 +278,16 @@ public class SaleController { if (!StringUtils.isEmpty(saleVO.getShopId())) { queryWrapper.eq("shop_id", saleVO.getShopId()); } - final SearchDateVo searchDateVo = saleVO.getSearchDateVo(); - if (!ObjectUtils.isEmpty(searchDateVo) && !searchDateVo.isAnyFieldEmpty()) { - final Date endDate = searchDateVo.getEndDate(); - final Date startDate = searchDateVo.getStartDate(); - if (!ObjectUtils.isEmpty(startDate) && !ObjectUtils.isEmpty(endDate)) { - queryWrapper.between("create_time", startDate, endDate); - } else if (!ObjectUtils.isEmpty(startDate)) { - queryWrapper.ge("create_time", startDate); - } else if (!ObjectUtils.isEmpty(endDate)) { - queryWrapper.le("create_time", endDate); - } + String endDate = saleVO.getEndTime(); + final String startDate = saleVO.getStartTime(); + if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) { + endDate = DateUtil.addDay(endDate, 1); + queryWrapper.between("create_time", startDate, endDate); + } else if (StringUtils.isNotEmpty(startDate)) { + queryWrapper.ge("create_time", startDate); + } else if (StringUtils.isNotEmpty(endDate)) { + endDate = DateUtil.addDay(endDate, 1); + queryWrapper.le("create_time", endDate); } //默认加一个时间排序 queryWrapper.orderByDesc("create_time"); @@ -307,17 +307,16 @@ public class SaleController { if (!StringUtils.isEmpty(saleVO.getShopId())) { queryRWrapper.eq("shop_id", saleVO.getShopId()); } - final SearchDateVo searchDateVo = saleVO.getSearchDateVo(); - if (!ObjectUtils.isEmpty(searchDateVo) && !searchDateVo.isAnyFieldEmpty()) { - final Date endDate = searchDateVo.getEndDate(); - final Date startDate = searchDateVo.getStartDate(); - if (!ObjectUtils.isEmpty(startDate) && !ObjectUtils.isEmpty(endDate)) { - queryRWrapper.between("create_time", startDate, endDate); - } else if (!ObjectUtils.isEmpty(startDate)) { - queryRWrapper.ge("create_time", startDate); - } else if (!ObjectUtils.isEmpty(endDate)) { - queryRWrapper.le("create_time", endDate); - } + String endDate = saleVO.getEndTime(); + final String startDate = saleVO.getStartTime(); + if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) { + endDate = DateUtil.addDay(endDate, 1); + queryWrapper.between("create_time", startDate, endDate); + } else if (StringUtils.isNotEmpty(startDate)) { + queryWrapper.ge("create_time", startDate); + } else if (StringUtils.isNotEmpty(endDate)) { + endDate = DateUtil.addDay(endDate, 1); + queryWrapper.le("create_time", endDate); } //默认加一个时间排序 queryRWrapper.orderByDesc("create_time"); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java index c8244e55..3bf0a002 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java @@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Repository public interface ProductMapper extends BaseMapper { @@ -42,7 +43,7 @@ public interface ProductMapper extends BaseMapper { List getProductListOfShop(String shopId); - List getByProductSn(@Param("productSn")String productSn,@Param("shopId") String shopId); + CopyOnWriteArrayList getByProductSn(@Param("productSn")String productSn,@Param("shopId") String shopId); ProductLastBuyVo getByUserIdAndProductId(@Param("userId")String userId, @Param("productId") String productId); @@ -50,7 +51,7 @@ public interface ProductMapper extends BaseMapper { List getByBarcode(@Param("barcode")String barcode,@Param("shopId") String shopId); - List getProductByProductSnList(@Param("productSnList") List productSnList,@Param("shopId") String shopId); + CopyOnWriteArrayList getProductByProductSnList(@Param("productSnList") List productSnList, @Param("shopId") String shopId); - List getProductByProductNameList(@Param("productNameList") List productNameList,@Param("shopId") String shopId); + CopyOnWriteArrayList getProductByProductNameList(@Param("productNameList") List productNameList,@Param("shopId") String shopId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java index 1971923a..efec2f4c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java @@ -80,5 +80,6 @@ public interface SaleMapper extends BaseMapper { void updateAiMsg(@Param("aiMsg") String aiMsg,@Param("saleId") String saleId); - void updateStatus(@Param("id")String id,@Param("status") Integer status); + void updateAiFlag(@Param("id")String id, @Param("status") Integer status); + void updateStatus(@Param("id")String id, @Param("status") Integer status); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java index 08850d99..239faa69 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java @@ -40,4 +40,6 @@ public interface StockMapper extends BaseMapper { List getlistByAttributeList(@Param("id")String id, @Param("shopId")String shopId, @Param("attributeList")String attributeList); List getTailWarnProduct(@Param("stockPageQuery") StockPageQuery stockPageQuery); + + List getProductStock(@Param("productId")String productId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/operatingarea/vo/OperatingAreaPageVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/operatingarea/vo/OperatingAreaPageVO.java index 3b640e09..f2995b37 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/operatingarea/vo/OperatingAreaPageVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/operatingarea/vo/OperatingAreaPageVO.java @@ -66,4 +66,7 @@ public class OperatingAreaPageVO { @ApiModelProperty(value = "是否支持上门取货") private Integer canToDoor; + + @ApiModelProperty(value = "网点") + private String network; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductAttributeOfAddVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductAttributeOfAddVo.java index f2259adf..50e5bf73 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductAttributeOfAddVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductAttributeOfAddVo.java @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Data @ApiModel(value = "商品规格属性") @@ -22,6 +22,6 @@ public class ProductAttributeOfAddVo extends HiverBaseEntity { @ApiModelProperty(value = "属性名称") private String attributeName; - private List productAttributeValueVoList; + private CopyOnWriteArrayList productAttributeValueVoList; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductCategoryVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductCategoryVo.java index 2408e058..2166e4f5 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductCategoryVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductCategoryVo.java @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Data @ApiModel(value = "类别Vo") @@ -23,7 +23,7 @@ public class ProductCategoryVo implements Serializable { private String shopId; @ApiModelProperty(value = "分类列表") - private List productAttributeOfAddVos; + private CopyOnWriteArrayList productAttributeOfAddVos; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java index a27640ef..11b76a67 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java @@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; -import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Data public class PurchaseOcrVo { @@ -22,5 +22,5 @@ public class PurchaseOcrVo { private Integer productCount; @ApiModelProperty(value = "单位") - private List attributeList; + private CopyOnWriteArrayList attributeList; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNoWorkerVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNoWorkerVO.java index 3d6d24cd..3e6ba3b8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNoWorkerVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNoWorkerVO.java @@ -18,6 +18,9 @@ public class SaleNoWorkerVO implements Serializable { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "销售单id") + private String saleId; + @ApiModelProperty(value = "店铺名称") private String shopName; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductCategoryService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductCategoryService.java index 1e98ba6b..8a57248d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductCategoryService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductCategoryService.java @@ -6,6 +6,7 @@ import cc.hiver.mall.pojo.vo.ProductCategoryVo; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public interface ProductCategoryService extends IService { boolean batchSaveCategoryAndAttribute(ProductCategoryVo productCategoryVo); @@ -19,5 +20,5 @@ public interface ProductCategoryService extends IService { */ boolean batchSaveCategoryAndAttributeOfAi(List productCategoryVoList); - List getShopCategory(List categoryIdList); + CopyOnWriteArrayList getShopCategory(List categoryIdList); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java index 8822bd8a..700122a4 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public interface ProductService extends IService { @@ -15,18 +16,20 @@ public interface ProductService extends IService { List getProductList(List productIdList); - List getProductByProductSnList(List productSnList,String shopId); - List getProductByProductNameList(List productNameList,String shopId); + CopyOnWriteArrayList getProductByProductSnList(List productSnList, String shopId); + + CopyOnWriteArrayList getProductByProductNameList(List productNameList, String shopId); /** * 获取店铺中商品信息 + * + * @return List * @author 王富康 * @date 2023/11/21 - * @return List */ List getProductListOfShop(); - List getByProductSn(String productSn, String shopId); + CopyOnWriteArrayList getByProductSn(String productSn, String shopId); ProductLastBuyVo getByUserIdAndProductId(String userId, String productId); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java index 90cdd970..01848f85 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java @@ -55,5 +55,7 @@ public interface SaleService extends IService { List buyAi(String aiMsg); + void updateAiFlag(String id, Integer status); + void updateStatus(String id, Integer status); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java index 23558cc7..841f198d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java @@ -48,4 +48,13 @@ public interface StockService extends IService { List getTailWarnProduct(StockPageQuery stockPageQuery); Result putInPriceOfAi(PurchaseVo purchaseVo); + + /** + * 根据商品id获取该商品所有规格的库存信息 + * @author 王富康 + * @date 2024/4/17 + * @param productId 商品id + * @return List + */ + List getProductStock(String productId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java index 46533e4d..89f5523d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java @@ -486,6 +486,8 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService { sale.setCreateTime(new Date()); sale.setTransCompany(CharSequenceUtil.isNotEmpty(saleQueryDTO.getTransCompany()) ? saleQueryDTO.getTransCompany() : null); + // 获取店铺名称 + sale.setShopName(shopService.findById(sale.getShopId()).getShopName()); saleService.save(sale); final String saleId = sale.getId(); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java index 346cbd1c..9b10a538 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; @Slf4j @Service @@ -189,7 +190,7 @@ public class ProductCategoryServiceImpl extends ServiceImpl getShopCategory(List categoryIdList) { + public CopyOnWriteArrayList getShopCategory(List categoryIdList) { // 先查询分类信息 List productCategories = new ArrayList<>(); if (categoryIdList.isEmpty()) { @@ -223,7 +224,7 @@ public class ProductCategoryServiceImpl extends ServiceImpl productAttributeValueVoList = productAttributeOfAddVo.getProductAttributeValueVoList(); if (productAttributeValueVoList == null || productAttributeValueVoList.isEmpty()) { - final List productAttributeValueVoListGet = new ArrayList<>(); + final CopyOnWriteArrayList productAttributeValueVoListGet = new CopyOnWriteArrayList<>(); productAttributeValueVoListGet.add(productAttributeValueVo); productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoListGet); } else { @@ -238,13 +239,13 @@ public class ProductCategoryServiceImpl extends ServiceImpl attributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos(); if (attributeOfAddVos == null || attributeOfAddVos.isEmpty()) { - final List attributeOfAddVoList = new ArrayList<>(); + final CopyOnWriteArrayList attributeOfAddVoList = new CopyOnWriteArrayList<>(); attributeOfAddVoList.add(productAttributeOfAddVo); productCategoryVo.setProductAttributeOfAddVos(attributeOfAddVoList); } else { attributeOfAddVos.add(productAttributeOfAddVo); } } - return new ArrayList<>(productCategoryMap.values()); + return new CopyOnWriteArrayList<>(productCategoryMap.values()); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java index 6b4a33c1..b2724807 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Service public class ProductServiceImpl extends ServiceImpl implements ProductService { @@ -35,12 +36,12 @@ public class ProductServiceImpl extends ServiceImpl impl } @Override - public List getProductByProductSnList(List productSnList,String shopId) { + public CopyOnWriteArrayList getProductByProductSnList(List productSnList, String shopId) { return baseMapper.getProductByProductSnList(productSnList, shopId); } @Override - public List getProductByProductNameList(List productNameList,String shopId) { + public CopyOnWriteArrayList getProductByProductNameList(List productNameList,String shopId) { return baseMapper.getProductByProductNameList(productNameList, shopId); } @@ -58,7 +59,7 @@ public class ProductServiceImpl extends ServiceImpl impl } @Override - public List getByProductSn(String productSn,String shopId) { + public CopyOnWriteArrayList getByProductSn(String productSn,String shopId) { return baseMapper.getByProductSn(productSn,shopId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java index c1ed357a..ab660349 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java @@ -47,6 +47,10 @@ public class PurchaseDetailServiceImpl extends ServiceImpl i } final Map> stockLogMap = new HashMap<>(); // 封装规格属性,AI开单,可能存在商品id不存在的情况,id不存在,根据商品货号分组,货号不存在根据商品名称分组 + // 将商品信息封装到map中 + final Map purchaseDetailIdDataMap = new HashMap<>(); + for (PurchaseDetail purchaseDetail : purchaseDetails) { + purchaseDetailIdDataMap.put(purchaseDetail.getId(),purchaseDetail); + } for (StockLog stockLog : stockLogList) { + // 20240414 wfk修改这里需要根据detail的商品id或者货号,或者名称作为key,进行合并 + final String productId = stockLog.getProductId(); final String detailId = stockLog.getDetailId(); - final String mapKey = productId == null ? detailId : productId; + final PurchaseDetail purchaseDetail = purchaseDetailIdDataMap.get(detailId); + String purchaseDetailMapKey = ""; + if (StringUtils.isNotEmpty(purchaseDetail.getProductId())) { + purchaseDetailMapKey = purchaseDetail.getProductId(); + } else if (StringUtils.isNotEmpty(purchaseDetail.getProductSn())) { + purchaseDetailMapKey = purchaseDetail.getProductSn(); + } else if (StringUtils.isNotEmpty(purchaseDetail.getProductName())) { + purchaseDetailMapKey = purchaseDetail.getProductName(); + }else{ + purchaseDetailMapKey = purchaseDetail.getId(); + } + + final String mapKey = productId == null ? purchaseDetailMapKey : productId; if (stockLogMap.containsKey(mapKey)) { stockLogMap.get(mapKey).add(stockLog); } else { @@ -373,6 +392,8 @@ public class PurchaseServiceImpl extends ServiceImpl i purchaseDetailMapKey = purchaseDetail.getProductSn(); } else if (StringUtils.isNotEmpty(purchaseDetail.getProductName())) { purchaseDetailMapKey = purchaseDetail.getProductName(); + }else{ + purchaseDetailMapKey = purchaseDetail.getId(); } if (purchaseDetailMap.containsKey(purchaseDetailMapKey)) { purchaseDetailMap.get(purchaseDetailMapKey).add(purchaseDetail); @@ -387,7 +408,18 @@ public class PurchaseServiceImpl extends ServiceImpl i for (Map.Entry> entry : purchaseDetailMap.entrySet()) { final PurchaseDetail purchaseDetail = entry.getValue().get(0); // 拼接规格,如果商品id为空,则根据id去stockLogMap中拿规格数据 - final String getstockLogMapKey = StringUtils.isEmpty(purchaseDetail.getProductId()) ? purchaseDetail.getId() : purchaseDetail.getProductId(); + // final String getstockLogMapKey = StringUtils.isEmpty(purchaseDetail.getProductId()) ? purchaseDetail.getId() : purchaseDetail.getProductId(); + String getstockLogMapKey = ""; + if (StringUtils.isNotEmpty(purchaseDetail.getProductId())) { + getstockLogMapKey = purchaseDetail.getProductId(); + } else if (StringUtils.isNotEmpty(purchaseDetail.getProductSn())) { + getstockLogMapKey = purchaseDetail.getProductSn(); + } else if (StringUtils.isNotEmpty(purchaseDetail.getProductName())) { + getstockLogMapKey = purchaseDetail.getProductName(); + }else{ + getstockLogMapKey = purchaseDetail.getId(); + } + if (stockLogMap.containsKey(getstockLogMapKey)) { purchaseDetail.setStockLogList1(stockLogMap.get(getstockLogMapKey)); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java index 82f8878f..7cb9fb05 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java @@ -166,9 +166,9 @@ public class SaleServiceImpl extends ServiceImpl implements Sa queryWrapper.eq("product_id", productId); // 供应商名称 final List stockList = stockService.list(queryWrapper); - final Map attributeMap = new HashMap<>(); + final Map attributeMap = new HashMap<>(); for (Stock stock : stockList) { - attributeMap.put(stock.getAttributeList(),stock.getStockCount()); + attributeMap.put(stock.getAttributeList(), stock.getStockCount()); } for (SaleDetail saleDetail : saleDetailList) { saleDetailDTO.setProductId(productId); @@ -190,11 +190,11 @@ public class SaleServiceImpl extends ServiceImpl implements Sa final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); saleDetailQueryDTO.setAttributeList(saleDetail.getAttributeList()); saleDetailQueryDTO.setProductCount(saleDetail.getProductCount()); - if(attributeMap.containsKey(saleDetail.getAttributeList())){ + if (attributeMap.containsKey(saleDetail.getAttributeList())) { final Integer stockCount = attributeMap.get(saleDetail.getAttributeList()); saleDetailQueryDTO.setStockCount(stockCount); - }else{ - saleDetailQueryDTO.setStockCount(0); + } else { + saleDetailQueryDTO.setStockCount(null); } saleDetailQueryDTOS.add(saleDetailQueryDTO); } @@ -507,7 +507,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } @Override - public void buyAiSync(String aiMsg,String saleId) { + public void buyAiSync(String aiMsg, String saleId) { // 叉转X 文本纠错 使用正则表达式替换单个或多个连续的“叉”字符 aiMsg = replaceAllX(aiMsg); @@ -520,7 +520,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa final List saleAiMsgs = new ArrayList<>(); for (String s : split) { if (StringUtils.isNotEmpty(s)) { - final String oneAiMsg ="货号:" + s; + final String oneAiMsg = "货号:" + s; // 封装需要新增的ai开单记录表 final SaleAiMsg saleAiMsg = new SaleAiMsg(); saleAiMsg.setCreateBy(user.getId()); @@ -541,7 +541,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa try { AiSaleThread aiSaleThread; for (SaleAiMsg saleAiMsg : saleAiMsgs) { - aiSaleThread = new AiSaleThread(saleAiMsg,saleAiMsgService, productService, productCategoryService,saleService,saleDetailService); + aiSaleThread = new AiSaleThread(saleAiMsg, saleAiMsgService, productService, productCategoryService, saleService, saleDetailService); ThreadPoolUtil.getPool().execute(aiSaleThread); } } catch (Exception e) { @@ -568,13 +568,20 @@ public class SaleServiceImpl extends ServiceImpl implements Sa final JSONObject object = json.getJSONObject(i); final String productSn = object.getString("productSn"); // 根据货号去查询商品,如果 - final List byProductSn = productService.getByProductSn(productSn,shopId); + final List byProductSn = productService.getByProductSn(productSn, shopId); if (byProductSn != null && !byProductSn.isEmpty()) { // 原则上一个店铺一个货号对应一个商品,这里如果查到了,直接拿第一个。 final Product product = byProductSn.get(0); + final String productId = product.getId(); + // 查询商品所有的库存 + final List stockList = stockService.getProductStock(productId); + final Map stockMap = new HashMap<>(); + for (Stock stock : stockList) { + stockMap.put(stock.getAttributeList(), stock.getStockCount()); + } final String categoryId = product.getCategoryId(); final SaleDetailDTO saleDetailDTO = new SaleDetailDTO(); - saleDetailDTO.setProductId(product.getId()); + saleDetailDTO.setProductId(productId); saleDetailDTO.setProductName(product.getProductName()); saleDetailDTO.setShopId(product.getShopId()); saleDetailDTO.setCategoryId(categoryId); @@ -626,8 +633,10 @@ public class SaleServiceImpl extends ServiceImpl implements Sa for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); - saleDetailQueryDTO.setAttributeList("{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"); + final String attribute = "{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"; + saleDetailQueryDTO.setAttributeList(attribute); saleDetailQueryDTO.setProductCount(productCount); + saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); saleDetailQueryDTOS.add(saleDetailQueryDTO); } @@ -653,8 +662,10 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); - saleDetailQueryDTO.setAttributeList("{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + size + "\"}"); + final String attribute = "{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + size + "\"}"; + saleDetailQueryDTO.setAttributeList(attribute); saleDetailQueryDTO.setProductCount(productCount); + saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); saleDetailQueryDTOS.add(saleDetailQueryDTO); } @@ -678,8 +689,10 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); - saleDetailQueryDTO.setAttributeList("{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"); + final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"; + saleDetailQueryDTO.setAttributeList(attribute); saleDetailQueryDTO.setProductCount(productCount); + saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); saleDetailQueryDTOS.add(saleDetailQueryDTO); } @@ -687,8 +700,10 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } // 不包含所有按照获取的拼接 final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); - saleDetailQueryDTO.setAttributeList("{\"颜色\":\"" + color + "\",\"尺码\":\"" + size + "\"}"); + final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + size + "\"}"; + saleDetailQueryDTO.setAttributeList(attribute); saleDetailQueryDTO.setProductCount(productCount); + saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); saleDetailQueryDTOS.add(saleDetailQueryDTO); } @@ -708,6 +723,11 @@ public class SaleServiceImpl extends ServiceImpl implements Sa return saleDetailDTOS; } + @Override + public void updateAiFlag(String id, Integer status) { + saleMapper.updateAiFlag(id, status); + } + @Override public void updateStatus(String id, Integer status) { saleMapper.updateStatus(id, status); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java index e281caf7..1ae0cdd5 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java @@ -930,4 +930,9 @@ public class StockServiceImpl extends ServiceImpl implements return ResultUtil.error("添加入库单信息失败"); } } + + @Override + public List getProductStock(String productId) { + return stockMapper.getProductStock(productId); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java index ca3411ac..fb26c0b9 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java @@ -28,7 +28,12 @@ import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.regex.Pattern; @Slf4j @@ -62,7 +67,7 @@ public class AliOcrUtil { final StopWatch stopWatch = new StopWatch("Ai回答计时"); Constants.apiKey = "sk-bcfa4865b89548acb8225f910f13d682"; - final List multiModalConversationResults = new ArrayList<>(); + final CopyOnWriteArrayList multiModalConversationResults = new CopyOnWriteArrayList<>(); final MultiModalConversation conv = new MultiModalConversation(); final MultiModalMessageItemText systemText = new MultiModalMessageItemText("You are a helpful assistant."); final MultiModalConversationMessage systemMessage = MultiModalConversationMessage.builder() @@ -74,7 +79,7 @@ public class AliOcrUtil { final MultiModalConversationMessage userMessage = MultiModalConversationMessage.builder().role(Role.USER.getValue()) .content(Arrays.asList(userImage, userText)).build(); - final List messages = new ArrayList<>(); + final CopyOnWriteArrayList messages = new CopyOnWriteArrayList<>(); messages.add(systemMessage); messages.add(userMessage); final MultiModalConversationParam param = MultiModalConversationParam.builder() @@ -94,9 +99,9 @@ public class AliOcrUtil { // 根据{}截取数据 final int startIndex = text.indexOf('{'); final int endIndex = text.lastIndexOf('}'); - if(startIndex == -1 || endIndex == -1){ + if (startIndex == -1 || endIndex == -1) { // 没有查询到想要的数据,那么就报错返回 - throw new RuntimeException("识别数据失败,未找到指定标识符:识别结果为:"+text); + throw new RuntimeException("识别数据失败,未找到指定标识符:识别结果为:" + text); } final String jsonStr = '[' + text.substring(startIndex, endIndex + 1) + ']'; JSONArray json = JSON.parseArray(jsonStr); @@ -113,7 +118,7 @@ public class AliOcrUtil { userText = new MultiModalMessageItemText(secondQuestionMsg); messages.add(MultiModalConversationMessage.builder().role(Role.USER.getValue()) .content(Collections.singletonList(userText)).build()); - param.setMessages(new ArrayList(messages)); + param.setMessages(new CopyOnWriteArrayList(messages)); stopWatch.start("二轮会话"); result = conv.call(param); multiModalConversationResults.add(result); @@ -129,13 +134,13 @@ public class AliOcrUtil { log.info(JSON.toJSONString(json)); stopWatch.start("解析结果=="); // 解析结果 - final Map purchaseDetailMap = getPurchaseDetailMap(productService, orderId, shopId, picturePath, json); + getPurchaseDetailMap(purchaseDetailService,productService, orderId, shopId, picturePath, json); stopWatch.stop(); // 将map 转为list 进行落库操作 - stopWatch.start("批量插入=="); - final List purchaseDetails = new ArrayList<>(purchaseDetailMap.values()); + /*stopWatch.start("批量插入=="); + final CopyOnWriteArrayList purchaseDetails = new CopyOnWriteArrayList<>(purchaseDetailMap.values()); purchaseDetailService.batchSavePurchaseList(purchaseDetails); - stopWatch.stop(); + stopWatch.stop();*/ log.info(stopWatch.prettyPrint()); jsonObject.put("resultContent", json); @@ -157,15 +162,14 @@ public class AliOcrUtil { * @author 王富康 * @date 2024/3/31 */ - @NotNull - private static Map getPurchaseDetailMap(ProductService productService, String orderId, String shopId, String ocrPicturePath, JSONArray json) { + private static void getPurchaseDetailMap(PurchaseDetailService purchaseDetailService, ProductService productService, String orderId, String shopId, String ocrPicturePath, JSONArray json) { // 开始解析图片识别的数据,进行入库操作。 // 解析未实体对象 - final List purchaseOcrVos = new ArrayList<>(); + final CopyOnWriteArrayList purchaseOcrVos = new CopyOnWriteArrayList<>(); // 货号集合 - final List productSnList = new ArrayList<>(); + final CopyOnWriteArrayList productSnList = new CopyOnWriteArrayList<>(); // 商品名称集合 - final List productNameList = new ArrayList<>(); + final CopyOnWriteArrayList productNameList = new CopyOnWriteArrayList<>(); for (int i = 0; i < json.size(); i++) { final JSONObject jsonObject = json.getJSONObject(i); final PurchaseOcrVo purchaseOcrVo = new PurchaseOcrVo(); @@ -178,7 +182,9 @@ public class AliOcrUtil { final PurchaseOcrDetailVo purchaseOcrDetailVo = new PurchaseOcrDetailVo(); purchaseOcrDetailVo.setColor(attributeListJson.getString("color")); purchaseOcrDetailVo.setSize(attributeListJson.getString("size")); - purchaseOcrVo.setAttributeList(Collections.singletonList(purchaseOcrDetailVo)); + final CopyOnWriteArrayList attributeList = new CopyOnWriteArrayList<>(); + attributeList.add(purchaseOcrDetailVo); + purchaseOcrVo.setAttributeList(attributeList); purchaseOcrVos.add(purchaseOcrVo); // 处理当前识别的货号及名称,现在需要特殊处理的 是货号:去掉“/”,或者是“/"在货号或者名称中间的,需要分隔为货号及名称 @@ -223,22 +229,22 @@ public class AliOcrUtil { purchaseOcrVo.setProductName(productName); } // 根据货号集合获取商品信息 - final List productByProductSnList = productService.getProductByProductSnList(productSnList, shopId); - final Map productSnMap = new HashMap<>(); + final CopyOnWriteArrayList productByProductSnList = productService.getProductByProductSnList(productSnList, shopId); + final Map productSnMap = new ConcurrentHashMap<>(); // 将商品信息封装到Map 中,货号作为key,商品作为value productByProductSnList.forEach(product -> { productSnMap.put(product.getProductSn(), product); }); // 根据商品名称获取商品信息 - final List productByProductNameList = productService.getProductByProductNameList(productNameList, shopId); - final Map productNameMap = new HashMap<>(); + final CopyOnWriteArrayList productByProductNameList = productService.getProductByProductNameList(productNameList, shopId); + final Map productNameMap = new ConcurrentHashMap<>(); // 将商品信息封装到Map 中,商品名称作为key,商品作为value productByProductNameList.forEach(product -> { productNameMap.put(product.getProductName(), product); }); // 得到数据之后,开始跟该店铺的商品进行对比。 // orderId - final Map purchaseDetailMap = new HashMap<>(); + final Map purchaseDetailMap = new ConcurrentHashMap<>(); for (PurchaseOcrVo purchaseOcrVo : purchaseOcrVos) { String productSn = purchaseOcrVo.getProductSn(); final String productName = purchaseOcrVo.getProductName(); @@ -254,7 +260,7 @@ public class AliOcrUtil { } } // 先将规格信息拼接好,后边肯定会插入这个值 - final List attributeList = purchaseOcrVo.getAttributeList(); + final CopyOnWriteArrayList attributeList = purchaseOcrVo.getAttributeList(); final StringBuilder attributeStr = new StringBuilder(); // 现在的读取方式是一个商品一个规格,attributeList 的长度目前只是1。 for (PurchaseOcrDetailVo purchaseOcrDetailVo : attributeList) { @@ -292,7 +298,7 @@ public class AliOcrUtil { } else { final PurchaseDetail purchaseDetail = new PurchaseDetail(); final StockLog stockLog = new StockLog(); - final List stockLogList = new ArrayList<>(); + final CopyOnWriteArrayList stockLogList = new CopyOnWriteArrayList<>(); purchaseDetail.setPurchaseId(orderId); purchaseDetail.setCreateTime(new Date()); purchaseDetail.setShopId(shopId); @@ -328,7 +334,8 @@ public class AliOcrUtil { purchaseDetailMap.put(StringUtils.isEmpty(productSn) ? productName : productSn, purchaseDetail); } } - return purchaseDetailMap; + final CopyOnWriteArrayList purchaseDetails = new CopyOnWriteArrayList<>(purchaseDetailMap.values()); + purchaseDetailService.batchSavePurchaseList(purchaseDetails); } /** @@ -431,15 +438,15 @@ public class AliOcrUtil { @NotNull private static void getSaleList(String saleId, String jsonStr, String shopId, String createBy, ProductService productService, ProductCategoryService productCategoryService, SaleService saleService, SaleDetailService saleDetailService) { - final List aiNotRecognitionList = new ArrayList<>(); + final CopyOnWriteArrayList aiNotRecognitionList = new CopyOnWriteArrayList<>(); // 异步处理的直接入库 final JSONArray json = JSON.parseArray(jsonStr); - final List saleDetailList = new ArrayList<>(); + final CopyOnWriteArrayList saleDetailList = new CopyOnWriteArrayList<>(); for (int i = 0; i < json.size(); i++) { final JSONObject object = json.getJSONObject(i); final String productSn = object.getString("productSn"); // 根据货号去查询商品,如果 - final List byProductSn = productService.getByProductSn(productSn, shopId); + final CopyOnWriteArrayList byProductSn = productService.getByProductSn(productSn, shopId); if (byProductSn != null && !byProductSn.isEmpty()) { // 原则上一个店铺一个货号对应一个商品,这里如果查到了,直接拿第一个。 final Product product = byProductSn.get(0); @@ -462,24 +469,24 @@ public class AliOcrUtil { } size = size.toUpperCase(); - final List categoryIdList = new ArrayList<>(); + final CopyOnWriteArrayList categoryIdList = new CopyOnWriteArrayList<>(); categoryIdList.add(categoryId); // 查询该店铺该分类下所有的颜色和尺码,进行对比,有则新增,无,则提醒用户无该规格 - final List shopCategory = productCategoryService.getShopCategory(categoryIdList); + final CopyOnWriteArrayList shopCategory = productCategoryService.getShopCategory(categoryIdList); final ProductCategoryVo productCategoryVo = shopCategory.get(0); - final List productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos(); - final Map productAttributeOfAddVoMap = new HashMap<>(); + final CopyOnWriteArrayList productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos(); + final Map productAttributeOfAddVoMap = new ConcurrentHashMap<>(); for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) { productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeName(), productAttributeOfAddVo); } //获取颜色及规格进行拼接 - List colorProductAttributeValueVoList = new ArrayList<>(); - List sizeProductAttributeValueVoList = new ArrayList<>(); + CopyOnWriteArrayList colorProductAttributeValueVoList = new CopyOnWriteArrayList<>(); + CopyOnWriteArrayList sizeProductAttributeValueVoList = new CopyOnWriteArrayList<>(); if (productAttributeOfAddVoMap.containsKey("颜色")) { colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList(); } // 将所有颜色放到一个集合中 - final List colorList = new ArrayList<>(); + final CopyOnWriteArrayList colorList = new CopyOnWriteArrayList<>(); for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { colorList.add(productAttributeValueVo.getValue()); } @@ -487,7 +494,7 @@ public class AliOcrUtil { sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList(); } // 将所有尺码放到一个集合中 - final List sizeList = new ArrayList<>(); + final CopyOnWriteArrayList sizeList = new CopyOnWriteArrayList<>(); for (ProductAttributeValueVo productAttributeValueVo : sizeProductAttributeValueVoList) { sizeList.add(productAttributeValueVo.getValue()); } @@ -619,6 +626,8 @@ public class AliOcrUtil { } } else { // 没查到去找下一个 + final String msg = "货号为:" + productSn + "的商品,不存在"; + aiNotRecognitionList.add(msg); continue; } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml index d5099458..cf85dd8d 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml @@ -226,7 +226,7 @@ \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml index 32181d01..8534c5e2 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml @@ -84,15 +84,15 @@ insert into t_sale_ai_msg (id, create_by, create_by_name, create_time, del_flag, update_by, update_time, order_id, ai_msg, - ai_status, ai_result_msg, shop_id, shop_name,count,ocr_count,parent_picture_path) values - - (#{purchaseOcrPicture.id,jdbcType=VARCHAR},#{purchaseOcrPicture.createBy,jdbcType=VARCHAR}, - #{purchaseOcrPicture.createByName,jdbcType=VARCHAR},#{purchaseOcrPicture.createTime,jdbcType=TIMESTAMP}, - #{purchaseOcrPicture.delFlag,jdbcType=INTEGER},#{purchaseOcrPicture.updateBy,jdbcType=VARCHAR}, - #{purchaseOcrPicture.updateTime,jdbcType=TIMESTAMP},#{purchaseOcrPicture.orderId,jdbcType=VARCHAR}, - #{purchaseOcrPicture.aiMsg,jdbcType=VARCHAR}, - #{purchaseOcrPicture.aiStatus,jdbcType=INTEGER},#{purchaseOcrPicture.aiResultMsg,jdbcType=VARCHAR}, - #{purchaseOcrPicture.shopId,jdbcType=VARCHAR},#{purchaseOcrPicture.shopName,jdbcType=VARCHAR}) + ai_status, ai_result_msg, shop_id, shop_name) values + + (#{saleAiMsg.id,jdbcType=VARCHAR},#{saleAiMsg.createBy,jdbcType=VARCHAR}, + #{saleAiMsg.createByName,jdbcType=VARCHAR},#{saleAiMsg.createTime,jdbcType=TIMESTAMP}, + #{saleAiMsg.delFlag,jdbcType=INTEGER},#{saleAiMsg.updateBy,jdbcType=VARCHAR}, + #{saleAiMsg.updateTime,jdbcType=TIMESTAMP},#{saleAiMsg.orderId,jdbcType=VARCHAR}, + #{saleAiMsg.aiMsg,jdbcType=VARCHAR}, + #{saleAiMsg.aiStatus,jdbcType=INTEGER},#{saleAiMsg.aiResultMsg,jdbcType=VARCHAR}, + #{saleAiMsg.shopId,jdbcType=VARCHAR},#{saleAiMsg.shopName,jdbcType=VARCHAR}) @@ -108,7 +108,7 @@ select from t_sale_ai_msg - where order_id =#{purchaseId} + where order_id =#{saleId} \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml index e3d57882..6f303149 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml @@ -851,7 +851,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr + + \ No newline at end of file