Browse Source

BUG终于算是完了。

cangku
wangfukang 2 years ago
parent
commit
0a778ee413
  1. 26
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiPurchaseThread.java
  2. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/config/thread/AiSaleThread.java
  3. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java
  4. 43
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  5. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java
  6. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  7. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
  8. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/operatingarea/vo/OperatingAreaPageVO.java
  9. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductAttributeOfAddVo.java
  10. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductCategoryVo.java
  11. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java
  12. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNoWorkerVO.java
  13. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductCategoryService.java
  14. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java
  15. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java
  16. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
  17. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java
  18. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java
  19. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  20. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
  21. 36
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
  22. 48
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  23. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  24. 79
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java
  25. 2
      hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml
  26. 3
      hiver-modules/hiver-mall/src/main/resources/mapper/ProblemFeedbackMapper.xml
  27. 20
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml
  28. 13
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
  29. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

26
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<PurchaseOcrPicture> 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);
}
}

4
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);
}
}

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java

@ -339,12 +339,15 @@ public class ReturnSaleController {
public Result<List<ReturnSale>> queryAll(@RequestBody SaleComVO saleComVO) {
final QueryWrapper<ReturnSale> 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("取消配送成功");
}

43
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");

7
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<Product> {
@ -42,7 +43,7 @@ public interface ProductMapper extends BaseMapper<Product> {
List<Product> getProductListOfShop(String shopId);
List<Product> getByProductSn(@Param("productSn")String productSn,@Param("shopId") String shopId);
CopyOnWriteArrayList<Product> 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<Product> {
List<Product> getByBarcode(@Param("barcode")String barcode,@Param("shopId") String shopId);
List<Product> getProductByProductSnList(@Param("productSnList") List<String> productSnList,@Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getProductByProductSnList(@Param("productSnList") List<String> productSnList, @Param("shopId") String shopId);
List<Product> getProductByProductNameList(@Param("productNameList") List<String> productNameList,@Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getProductByProductNameList(@Param("productNameList") List<String> productNameList,@Param("shopId") String shopId);
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java

@ -80,5 +80,6 @@ public interface SaleMapper extends BaseMapper<Sale> {
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);
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java

@ -40,4 +40,6 @@ public interface StockMapper extends BaseMapper<Stock> {
List<ProductCategoryStockVo> getlistByAttributeList(@Param("id")String id, @Param("shopId")String shopId, @Param("attributeList")String attributeList);
List<Stock> getTailWarnProduct(@Param("stockPageQuery") StockPageQuery stockPageQuery);
List<Stock> getProductStock(@Param("productId")String productId);
}

3
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;
}

4
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<ProductAttributeValueVo> productAttributeValueVoList;
private CopyOnWriteArrayList<ProductAttributeValueVo> productAttributeValueVoList;
}

4
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<ProductAttributeOfAddVo> productAttributeOfAddVos;
private CopyOnWriteArrayList<ProductAttributeOfAddVo> productAttributeOfAddVos;
}

4
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<PurchaseOcrDetailVo> attributeList;
private CopyOnWriteArrayList<PurchaseOcrDetailVo> attributeList;
}

3
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;

3
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<ProductCategory> {
boolean batchSaveCategoryAndAttribute(ProductCategoryVo productCategoryVo);
@ -19,5 +20,5 @@ public interface ProductCategoryService extends IService<ProductCategory> {
*/
boolean batchSaveCategoryAndAttributeOfAi(List<ProductCategoryAiVo> productCategoryVoList);
List<ProductCategoryVo> getShopCategory(List<String> categoryIdList);
CopyOnWriteArrayList<ProductCategoryVo> getShopCategory(List<String> categoryIdList);
}

11
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<Product> {
@ -15,18 +16,20 @@ public interface ProductService extends IService<Product> {
List<Product> getProductList(List<String> productIdList);
List<Product> getProductByProductSnList(List<String> productSnList,String shopId);
List<Product> getProductByProductNameList(List<String> productNameList,String shopId);
CopyOnWriteArrayList<Product> getProductByProductSnList(List<String> productSnList, String shopId);
CopyOnWriteArrayList<Product> getProductByProductNameList(List<String> productNameList, String shopId);
/**
* 获取店铺中商品信息
*
* @return List<Product>
* @author 王富康
* @date 2023/11/21
* @return List<Product>
*/
List<Product> getProductListOfShop();
List<Product> getByProductSn(String productSn, String shopId);
CopyOnWriteArrayList<Product> getByProductSn(String productSn, String shopId);
ProductLastBuyVo getByUserIdAndProductId(String userId, String productId);

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java

@ -55,5 +55,7 @@ public interface SaleService extends IService<Sale> {
List<SaleDetailDTO> buyAi(String aiMsg);
void updateAiFlag(String id, Integer status);
void updateStatus(String id, Integer status);
}

9
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java

@ -48,4 +48,13 @@ public interface StockService extends IService<Stock> {
List<StockProductVo> getTailWarnProduct(StockPageQuery stockPageQuery);
Result putInPriceOfAi(PurchaseVo purchaseVo);
/**
* 根据商品id获取该商品所有规格的库存信息
* @author 王富康
* @date 2024/4/17
* @param productId 商品id
* @return List<Stock>
*/
List<Stock> getProductStock(String productId);
}

2
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();

9
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<ProductCategoryMappe
}
@Override
public List<ProductCategoryVo> getShopCategory(List<String> categoryIdList) {
public CopyOnWriteArrayList<ProductCategoryVo> getShopCategory(List<String> categoryIdList) {
// 先查询分类信息
List<ProductCategoryVo> productCategories = new ArrayList<>();
if (categoryIdList.isEmpty()) {
@ -223,7 +224,7 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
final ProductAttributeOfAddVo productAttributeOfAddVo = productAttributeOfAddVoMap.get(attributeId);
final List<ProductAttributeValueVo> productAttributeValueVoList = productAttributeOfAddVo.getProductAttributeValueVoList();
if (productAttributeValueVoList == null || productAttributeValueVoList.isEmpty()) {
final List<ProductAttributeValueVo> productAttributeValueVoListGet = new ArrayList<>();
final CopyOnWriteArrayList<ProductAttributeValueVo> productAttributeValueVoListGet = new CopyOnWriteArrayList<>();
productAttributeValueVoListGet.add(productAttributeValueVo);
productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoListGet);
} else {
@ -238,13 +239,13 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
final ProductCategoryVo productCategoryVo = productCategoryMap.get(categoryId);
final List<ProductAttributeOfAddVo> attributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos();
if (attributeOfAddVos == null || attributeOfAddVos.isEmpty()) {
final List<ProductAttributeOfAddVo> attributeOfAddVoList = new ArrayList<>();
final CopyOnWriteArrayList<ProductAttributeOfAddVo> attributeOfAddVoList = new CopyOnWriteArrayList<>();
attributeOfAddVoList.add(productAttributeOfAddVo);
productCategoryVo.setProductAttributeOfAddVos(attributeOfAddVoList);
} else {
attributeOfAddVos.add(productAttributeOfAddVo);
}
}
return new ArrayList<>(productCategoryMap.values());
return new CopyOnWriteArrayList<>(productCategoryMap.values());
}
}

7
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<ProductMapper, Product> implements ProductService {
@ -35,12 +36,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
}
@Override
public List<Product> getProductByProductSnList(List<String> productSnList,String shopId) {
public CopyOnWriteArrayList<Product> getProductByProductSnList(List<String> productSnList, String shopId) {
return baseMapper.getProductByProductSnList(productSnList, shopId);
}
@Override
public List<Product> getProductByProductNameList(List<String> productNameList,String shopId) {
public CopyOnWriteArrayList<Product> getProductByProductNameList(List<String> productNameList,String shopId) {
return baseMapper.getProductByProductNameList(productNameList, shopId);
}
@ -58,7 +59,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
}
@Override
public List<Product> getByProductSn(String productSn,String shopId) {
public CopyOnWriteArrayList<Product> getByProductSn(String productSn,String shopId) {
return baseMapper.getByProductSn(productSn,shopId);
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java

@ -47,6 +47,10 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailMapper,
final Integer newProductCount = purchaseDetail.getProductCount() == null ? 0 : purchaseDetail.getProductCount();
oldPurchaseDetail.setProductCount(oldProductCount + newProductCount);
updatePurchaseDetails.add(oldPurchaseDetail);
// 修改子表id
for (StockLog stockLog : purchaseDetail.getStockLogList1()) {
stockLog.setDetailId(oldPurchaseDetail.getId());
}
} else {
addPurchaseDetails.add(purchaseDetail);
}

36
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java

@ -350,10 +350,29 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
}
final Map<String, List<StockLog>> stockLogMap = new HashMap<>();
// 封装规格属性,AI开单,可能存在商品id不存在的情况,id不存在,根据商品货号分组,货号不存在根据商品名称分组
// 将商品信息封装到map中
final Map<String, PurchaseDetail> 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<PurchaseMapper, Purchase> 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<PurchaseMapper, Purchase> i
for (Map.Entry<String, List<PurchaseDetail>> 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));
}

48
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java

@ -166,9 +166,9 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
queryWrapper.eq("product_id", productId);
// 供应商名称
final List<Stock> stockList = stockService.list(queryWrapper);
final Map<String,Integer> attributeMap = new HashMap<>();
final Map<String, Integer> 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<SaleMapper, Sale> 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<SaleMapper, Sale> 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<SaleMapper, Sale> implements Sa
final List<SaleAiMsg> 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<SaleMapper, Sale> 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<SaleMapper, Sale> implements Sa
final JSONObject object = json.getJSONObject(i);
final String productSn = object.getString("productSn");
// 根据货号去查询商品,如果
final List<Product> byProductSn = productService.getByProductSn(productSn,shopId);
final List<Product> byProductSn = productService.getByProductSn(productSn, shopId);
if (byProductSn != null && !byProductSn.isEmpty()) {
// 原则上一个店铺一个货号对应一个商品,这里如果查到了,直接拿第一个。
final Product product = byProductSn.get(0);
final String productId = product.getId();
// 查询商品所有的库存
final List<Stock> stockList = stockService.getProductStock(productId);
final Map<String, Integer> 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<SaleMapper, Sale> 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<SaleMapper, Sale> 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<SaleMapper, Sale> 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<SaleMapper, Sale> 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<SaleMapper, Sale> 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);

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java

@ -930,4 +930,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
return ResultUtil.error("添加入库单信息失败");
}
}
@Override
public List<Stock> getProductStock(String productId) {
return stockMapper.getProductStock(productId);
}
}

79
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<MultiModalConversationResult> multiModalConversationResults = new ArrayList<>();
final CopyOnWriteArrayList<MultiModalConversationResult> 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<MultiModalConversationMessage> messages = new ArrayList<>();
final CopyOnWriteArrayList<MultiModalConversationMessage> 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<Object>(messages));
param.setMessages(new CopyOnWriteArrayList<Object>(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<String, PurchaseDetail> purchaseDetailMap = getPurchaseDetailMap(productService, orderId, shopId, picturePath, json);
getPurchaseDetailMap(purchaseDetailService,productService, orderId, shopId, picturePath, json);
stopWatch.stop();
// 将map 转为list 进行落库操作
stopWatch.start("批量插入==");
final List<PurchaseDetail> purchaseDetails = new ArrayList<>(purchaseDetailMap.values());
/*stopWatch.start("批量插入==");
final CopyOnWriteArrayList<PurchaseDetail> 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<String, PurchaseDetail> 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<PurchaseOcrVo> purchaseOcrVos = new ArrayList<>();
final CopyOnWriteArrayList<PurchaseOcrVo> purchaseOcrVos = new CopyOnWriteArrayList<>();
// 货号集合
final List<String> productSnList = new ArrayList<>();
final CopyOnWriteArrayList<String> productSnList = new CopyOnWriteArrayList<>();
// 商品名称集合
final List<String> productNameList = new ArrayList<>();
final CopyOnWriteArrayList<String> 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<PurchaseOcrDetailVo> attributeList = new CopyOnWriteArrayList<>();
attributeList.add(purchaseOcrDetailVo);
purchaseOcrVo.setAttributeList(attributeList);
purchaseOcrVos.add(purchaseOcrVo);
// 处理当前识别的货号及名称,现在需要特殊处理的 是货号:去掉“/”,或者是“/"在货号或者名称中间的,需要分隔为货号及名称
@ -223,22 +229,22 @@ public class AliOcrUtil {
purchaseOcrVo.setProductName(productName);
}
// 根据货号集合获取商品信息
final List<Product> productByProductSnList = productService.getProductByProductSnList(productSnList, shopId);
final Map<String, Product> productSnMap = new HashMap<>();
final CopyOnWriteArrayList<Product> productByProductSnList = productService.getProductByProductSnList(productSnList, shopId);
final Map<String, Product> productSnMap = new ConcurrentHashMap<>();
// 将商品信息封装到Map 中,货号作为key,商品作为value
productByProductSnList.forEach(product -> {
productSnMap.put(product.getProductSn(), product);
});
// 根据商品名称获取商品信息
final List<Product> productByProductNameList = productService.getProductByProductNameList(productNameList, shopId);
final Map<String, Product> productNameMap = new HashMap<>();
final CopyOnWriteArrayList<Product> productByProductNameList = productService.getProductByProductNameList(productNameList, shopId);
final Map<String, Product> productNameMap = new ConcurrentHashMap<>();
// 将商品信息封装到Map 中,商品名称作为key,商品作为value
productByProductNameList.forEach(product -> {
productNameMap.put(product.getProductName(), product);
});
// 得到数据之后,开始跟该店铺的商品进行对比。
// orderId
final Map<String, PurchaseDetail> purchaseDetailMap = new HashMap<>();
final Map<String, PurchaseDetail> 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<PurchaseOcrDetailVo> attributeList = purchaseOcrVo.getAttributeList();
final CopyOnWriteArrayList<PurchaseOcrDetailVo> 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<StockLog> stockLogList = new ArrayList<>();
final CopyOnWriteArrayList<StockLog> 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<PurchaseDetail> 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<String> aiNotRecognitionList = new ArrayList<>();
final CopyOnWriteArrayList<String> aiNotRecognitionList = new CopyOnWriteArrayList<>();
// 异步处理的直接入库
final JSONArray json = JSON.parseArray(jsonStr);
final List<SaleDetail> saleDetailList = new ArrayList<>();
final CopyOnWriteArrayList<SaleDetail> 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<Product> byProductSn = productService.getByProductSn(productSn, shopId);
final CopyOnWriteArrayList<Product> 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<String> categoryIdList = new ArrayList<>();
final CopyOnWriteArrayList<String> categoryIdList = new CopyOnWriteArrayList<>();
categoryIdList.add(categoryId);
// 查询该店铺该分类下所有的颜色和尺码,进行对比,有则新增,无,则提醒用户无该规格
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList);
final CopyOnWriteArrayList<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList);
final ProductCategoryVo productCategoryVo = shopCategory.get(0);
final List<ProductAttributeOfAddVo> productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos();
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new HashMap<>();
final CopyOnWriteArrayList<ProductAttributeOfAddVo> productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos();
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new ConcurrentHashMap<>();
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) {
productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeName(), productAttributeOfAddVo);
}
//获取颜色及规格进行拼接
List<ProductAttributeValueVo> colorProductAttributeValueVoList = new ArrayList<>();
List<ProductAttributeValueVo> sizeProductAttributeValueVoList = new ArrayList<>();
CopyOnWriteArrayList<ProductAttributeValueVo> colorProductAttributeValueVoList = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<ProductAttributeValueVo> sizeProductAttributeValueVoList = new CopyOnWriteArrayList<>();
if (productAttributeOfAddVoMap.containsKey("颜色")) {
colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList();
}
// 将所有颜色放到一个集合中
final List<String> colorList = new ArrayList<>();
final CopyOnWriteArrayList<String> colorList = new CopyOnWriteArrayList<>();
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) {
colorList.add(productAttributeValueVo.getValue());
}
@ -487,7 +494,7 @@ public class AliOcrUtil {
sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList();
}
// 将所有尺码放到一个集合中
final List<String> sizeList = new ArrayList<>();
final CopyOnWriteArrayList<String> 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;
}

2
hiver-modules/hiver-mall/src/main/resources/mapper/OperatingAreaMapper.xml

@ -226,7 +226,7 @@
<select id="getOperatingAreaList" resultType="cc.hiver.mall.operatingarea.vo.OperatingAreaPageVO">
select
t.id, t.shipping_type, t.shipping_method, t.shipping_method_id,
t.province, t.city, t.area, t.charging_standard,
t.province, t.city, t.area, t.charging_standard,t.network,
s.mobile,s.rebate_amount
from t_operating_area t
left join

3
hiver-modules/hiver-mall/src/main/resources/mapper/ProblemFeedbackMapper.xml

@ -148,9 +148,6 @@
</if>
</where>
ORDER BY
<if test='queryParams.sortField!=null and queryParams.sortField.trim() neq "" and queryParams.sortField !=null and queryParams.sort.trim() neq ""'>
#{queryParams.sortField} #{queryParams.sort},
</if>
t.create_time desc
</select>
</mapper>

20
hiver-modules/hiver-mall/src/main/resources/mapper/SaleAiMsgMapper.xml

@ -84,15 +84,15 @@
<insert id="batchSave" parameterType="java.util.List">
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
<foreach item="purchaseOcrPicture" collection="purchaseOcrPictureList" index="index" separator=",">
(#{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
<foreach item="saleAiMsg" collection="saleAiMsgs" index="index" separator=",">
(#{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})
</foreach>
</insert>
@ -108,7 +108,7 @@
select
<include refid="Base_Column_List" />
from t_sale_ai_msg
where order_id =#{purchaseId}
where order_id =#{saleId}
</select>
</mapper>

13
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
<select id="getSaleByCompanyId" resultType="cc.hiver.mall.pojo.vo.SaleNoWorkerVO">
SELECT
t.shop_name,concat(m.region,m.shop_area_title,m.shop_address) as shop_address,t.create_by_name,t.create_by_phone,t.create_time,t.user_name,s.phone as user_phone,t.receive_address,t.province,t.city,t.area
t.id as sale_id,t.shop_name,concat(m.region,m.shop_area_title,m.shop_address) as shop_address,t.create_by_name,t.create_by_phone,t.create_time,t.user_name,s.phone as user_phone,t.receive_address,t.province,t.city,t.area
FROM t_sale t left join t_customer s
on t.user_id = s.id
left join t_shop m
@ -871,7 +871,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
<update id="companyGetSale" >
update t_sale
set
status = '9'
status = '4'
where id = #{saleId,jdbcType=VARCHAR}
</update>
@ -882,10 +882,17 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
where id = #{saleId,jdbcType=VARCHAR}
</update>
<update id="updateStatus" >
<update id="updateAiFlag" >
update t_sale
set
ai_flag = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateStatus" >
update t_sale
set
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

12
hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

@ -623,4 +623,16 @@
</if>
order by s.product_name
</select>
<select id="getProductStock" resultMap="BaseResultMap">
SELECT
s.product_id,
s.product_name,
s.product_sn,
s.attribute_list,
s.stock_count
FROM
t_stock s
where s.product_id= #{productId,jdbcType=VARCHAR}
</select>
</mapper>
Loading…
Cancel
Save