From ca0ffb9f8032ed31b5cc36efce95a1b7996af093 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 16:59:45 +0800 Subject: [PATCH] =?UTF-8?q?AI=E5=9B=BE=E7=89=87=E5=85=A5=E5=BA=93=E7=9C=9F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=A6=E6=83=85=E5=92=8Cstocklog;=20?= =?UTF-8?q?=E6=92=A4=E9=94=80=E9=87=87=E8=B4=AD=E5=8D=95=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81=EF=BC=8C=E5=8F=AA=E5=9B=9E?= =?UTF-8?q?=E9=80=80=E5=BA=93=E5=AD=98=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiver-admin/test-output/test-report.html | 14 ++--- .../mall/dao/mapper/PurchaseDetailMapper.java | 2 + .../hiver/mall/dao/mapper/StockLogMapper.java | 2 + .../cc/hiver/mall/entity/PurchaseDetail.java | 4 ++ .../cc/hiver/mall/pojo/vo/PurchaseOcrVo.java | 3 ++ .../mybatis/PurchaseDetailService.java | 2 + .../mall/service/mybatis/StockLogService.java | 2 + .../mybatis/PurchaseDetailServiceImpl.java | 5 ++ .../mybatis/PurchaseServiceImpl.java | 54 ++----------------- .../mybatis/StockLogServiceImpl.java | 5 ++ .../serviceimpl/mybatis/StockServiceImpl.java | 6 +-- .../java/cc/hiver/mall/utils/AliOcrUtil.java | 2 + .../resources/mapper/PurchaseDetailMapper.xml | 38 ++++++++++--- .../main/resources/mapper/StockLogMapper.xml | 9 +++- 14 files changed, 79 insertions(+), 69 deletions(-) diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index de2c08d2..a9d737d9 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • -八月 04, 2024 12:12:02 +八月 04, 2024 16:50:15
  • @@ -84,7 +84,7 @@

    passTest

    -

    12:12:02 下午 / 0.016 secs

    +

    16:50:16 下午 / 0.016 secs

    @@ -92,8 +92,8 @@
    #test-id=1
    passTest
    -08.04.2024 12:12:02 -08.04.2024 12:12:02 +08.04.2024 16:50:16 +08.04.2024 16:50:16 0.016 secs
    @@ -104,7 +104,7 @@ Pass - 12:12:02 + 16:50:16 Test passed @@ -128,13 +128,13 @@

    Started

    -

    八月 04, 2024 12:12:02

    +

    八月 04, 2024 16:50:15

    Ended

    -

    八月 04, 2024 12:12:02

    +

    八月 04, 2024 16:50:16

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java index f6a85a52..6d0b3b83 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java @@ -54,4 +54,6 @@ public interface PurchaseDetailMapper extends BaseMapper { * @return List */ List getPurchaseDetailListByProductIds(@Param("productIdList") List productIdList,@Param("id") String id); + + void realDeleteByPurchaseId(@Param("purchaseId") String purchaseId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java index e91c764a..af52e705 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java @@ -45,4 +45,6 @@ public interface StockLogMapper extends BaseMapper { List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList); List getByProductIds(@Param("purchaseId") String purchaseId,@Param("productIdList") List productIdList); + + void realDeleteByPurchaseId(@Param("purchaseId") String purchaseId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java index e974bf6f..5d16139c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java @@ -98,6 +98,10 @@ public class PurchaseDetail extends HiverBaseEntity { @ApiModelProperty(value = "璇嗗埆鍥剧墖id") private String ocrPicturePath; + + @ApiModelProperty(value = "鎺掑簭") + private Integer sort; + @Transient @TableField(exist = false) @ApiModelProperty(value = "鍏ュ簱鍟嗗搧瑙勬牸鏄庣粏琛") 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 11b76a67..f130493a 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 @@ -21,6 +21,9 @@ public class PurchaseOcrVo { @ApiModelProperty(value = "鏁伴噺") private Integer productCount; + @ApiModelProperty(value = "鎺掑簭") + private Integer sort; + @ApiModelProperty(value = "鍗曚綅") private CopyOnWriteArrayList attributeList; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java index 2ed062da..8fcabc44 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java @@ -21,6 +21,8 @@ public interface PurchaseDetailService extends IService { void deleteByPurchaseId(String purchaseId); + void realDeleteByPurchaseId(String purchaseId); + List getPurchaseDetails(List purchaseIdList); /** diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java index d903a5fb..c6eb9390 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java @@ -25,4 +25,6 @@ public interface StockLogService extends IService { * @return List */ List getByProductIds(String purchaseId, String productIds); + + void realDeleteByPurchaseId(String purchaseId); } 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 bd63197f..ac6cc886 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 @@ -82,6 +82,11 @@ public class PurchaseDetailServiceImpl extends ServiceImpl getPurchaseDetails(List purchaseIdList) { return purchaseDetailMapper.getPurchaseDetails(purchaseIdList); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java index 1c615b2e..3d98cd95 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java @@ -436,7 +436,7 @@ public class PurchaseServiceImpl extends ServiceImpl i stockLogMap.put(mapKey, stockLogs); } } - final Map> purchaseDetailMap = new HashMap<>(); + final LinkedHashMap> purchaseDetailMap = new LinkedHashMap<>(); for (PurchaseDetail purchaseDetail : purchaseDetails) { // 杩欓噷瀵筽urchaseDetail鍋氫釜鍚堝苟澶勭悊锛屼紭鍏堟牴鎹晢鍝乮d鍒嗙粍锛屽鏋滃晢鍝乮d涓虹┖锛岄偅灏卞氨鏍规嵁鍟嗗搧璐у彿鍒嗙粍锛屽鏋滃晢鍝佽揣鍙蜂负绌猴紝鍒欐牴鎹晢鍝佸悕绉板垎缁勶紝 // 閲嶅鐨勭洿鎺ヨ鐩栧嵆鍙 @@ -651,7 +651,7 @@ public class PurchaseServiceImpl extends ServiceImpl i for (PurchaseDetail purchaseDetail : byPurchaseIdList) { productIdList.add(purchaseDetail.getProductId()); } - // 鏌ヨ璇ュ晢鍝侀櫎褰撳墠鍏ュ簱鍗曠殑鍏朵粬鐨勫叆搴撹褰 + // 鏌ヨ璇ュ晢鍝侀櫎褰撳墠鍏ュ簱鍗曠殑鍏朵粬鐨勫叆搴撹褰曪紝鐢ㄤ簬璁$畻骞冲潎閲囪喘浠 final List purductPurchaseList = purchaseDetailService.getPurchaseDetailListByProductIds(productIdList, id); // 灏佽涓哄晢鍝乮d涓簁ey,List涓簐alue 鐨刴ap final Map> purductPurchaseMap = new HashMap<>(); @@ -665,59 +665,15 @@ public class PurchaseServiceImpl extends ServiceImpl i purductPurchaseMap.put(productId, purchaseDetails); } } - // 鏌ヨ璇ュ晢鍝佺殑閿鍞褰 - final List purductSaleList = saleDetailService.getSaleDetailListByProductIds(productIdList); - // 灏佽涓哄晢鍝乮d涓簁ey,List涓簐alue 鐨刴ap - final Map> purductSaleMap = new HashMap<>(); - for (SaleDetail saleDetail : purductSaleList) { - final String productId = saleDetail.getProductId(); - if (purductSaleMap.containsKey(productId)) { - purductSaleMap.get(productId).add(saleDetail); - } else { - final List saleDetails = new ArrayList<>(); - saleDetails.add(saleDetail); - purductSaleMap.put(productId, saleDetails); - } - } - // - final StringJoiner needDeleteProductId = new StringJoiner(","); - final StringJoiner needDeleteStockProductId = new StringJoiner(","); - final StringJoiner needReduceStockProductId = new StringJoiner(","); - - for (PurchaseDetail purchaseDetail : byPurchaseIdList) { - final String productId = purchaseDetail.getProductId(); - if (!purductPurchaseMap.containsKey(productId) && !purductSaleMap.containsKey(productId)) { - // 鍙互鍒犻櫎鍟嗗搧鐨勭浉鍏充俊鎭 - needDeleteProductId.add(productId); - // 搴撳瓨鍒犻櫎 - needDeleteStockProductId.add(productId); - } else { - // 鍟嗗搧淇濈暀,搴撳瓨鎵e噺 - needReduceStockProductId.add(productId); - } + final List stockLogList = stockLogService.getByPurchaseId(id); + // 鏍规嵁鍏ュ簱璁板綍鍑忔帀搴撳瓨鏁 + stockService.batchReduceStockByLog(stockLogList); - } - // 鎵ц鍒犻櫎鍟嗗搧 - if (StringUtils.isNotEmpty(needDeleteProductId.toString())) { - productService.batchDeleteProduct(needDeleteProductId.toString()); - } - // 鎵ц鍒犻櫎搴撳瓨 - if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) { - stockService.batchDeleteStockByProductIds(needDeleteStockProductId.toString()); - } - // 鎵ц鎵e噺搴撳瓨 - if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) { - // 鑾峰彇褰撳墠鍏ュ簱鍗曞悇鍟嗗搧鐨勮鏍煎強鏁伴噺淇℃伅 - final List stockLogList = stockLogService.getByProductIds(id, needReduceStockProductId.toString()); - // 鏍规嵁鍏ュ簱璁板綍鍑忔帀搴撳瓨鏁 - stockService.batchReduceStockByLog(stockLogList); - } // 4. 鏍规嵁閲囪喘鍗昳d鍒犻櫎搴撳瓨璁板綍 stockLogService.deleteByPurchaseId(id); // 5. 璁$畻骞冲潎閲囪喘浠 // 鑾峰彇璇ュ晢鍝佺殑鍘嗘鍏ュ簱璁板綍锛屾帓闄ゆ帀鏈鍏ュ簱璁板綍 鍏ュ簱鐨勪环鏍*鍏ュ簱鏁伴噺/鍏ュ簱鎬绘暟閲 - final Map productPurchasePriceMap = new HashMap<>(); final List productList = new ArrayList<>(); for (Map.Entry> stringListEntry : purductPurchaseMap.entrySet()) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java index 3ccab6fe..b81fed99 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java @@ -57,4 +57,9 @@ public class StockLogServiceImpl extends ServiceImpl i return stockLogMapper.getByProductIds(purchaseId, productIdList); } + @Override + public void realDeleteByPurchaseId(String purchaseId) { + stockLogMapper.realDeleteByPurchaseId(purchaseId); + } + } 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 860c67a0..7d2b0e59 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 @@ -736,9 +736,9 @@ public class StockServiceImpl extends ServiceImpl implements insertFlag = false; } - // 鍏堟牴鎹叆搴撳崟id 鍒犻櫎璇︽儏鍙婂簱瀛樺饱鍘嗚〃淇℃伅 - purchaseDetailService.deleteByPurchaseId(purchaseId); - stockLogService.deleteByPurchaseId(purchaseId); + // 鍏堟牴鎹叆搴撳崟id 鍒犻櫎璇︽儏鍙婂簱瀛樺饱鍘嗚〃淇℃伅(鐪熷垹闄) + purchaseDetailService.realDeleteByPurchaseId(purchaseId); + stockLogService.realDeleteByPurchaseId(purchaseId); // 鑾峰彇鍓嶅彴鍏ュ簱鍟嗗搧淇℃伅 final List purchaseDetails = purchaseVo.getPurchaseDetails(); 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 68cf0efd..b23b6d2c 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 @@ -654,6 +654,7 @@ public class AliOcrUtil { } purchaseOcrVo.setAttributeList(attributeList); + purchaseOcrVo.setSort(i); purchaseOcrVos.add(purchaseOcrVo); // 澶勭悊褰撳墠璇嗗埆鐨勮揣鍙峰強鍚嶇О锛岀幇鍦ㄩ渶瑕佺壒娈婂鐞嗙殑 鏄揣鍙凤細鍘绘帀鈥/鈥濓紝鎴栬呮槸鈥/"鍦ㄨ揣鍙锋垨鑰呭悕绉颁腑闂寸殑锛岄渶瑕佸垎闅斾负璐у彿鍙婂悕绉 @@ -809,6 +810,7 @@ public class AliOcrUtil { } stockLogList.add(stockLog); purchaseDetail.setStockLogList1(stockLogList); + purchaseDetail.setSort(purchaseOcrVo.getSort()); // 濡傛灉璐у彿涓虹┖锛岄偅涔堝氨鎷垮晢鍝佸悕绉颁綔涓簁ey purchaseDetailMap.put(StringUtils.isEmpty(productSn) ? productName : productSn, purchaseDetail); } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml index d4119787..3454961b 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml @@ -30,6 +30,7 @@ + @@ -93,7 +94,7 @@ id, create_by, create_time, del_flag, update_by, update_time, purchase_id, product_id, product_name, unit, shop_id, category_id, attribute_list, supplier_id,supplier_name, product_sn, barcode, price, purchase_price, wholesale_price, product_picture, product_video, - product_intro, sales_week, tail_warn, print_barcode, product_count,ocr_picture_path + product_intro, sales_week, tail_warn, print_barcode, product_count,ocr_picture_path,sort @@ -414,6 +421,9 @@ ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}, + + sort = #{record.sort,jdbcType=INTEGER}, + @@ -448,7 +458,8 @@ tail_warn = #{record.tailWarn,jdbcType=INTEGER}, print_barcode = #{record.printBarcode,jdbcType=VARCHAR}, product_count = #{record.productCount,jdbcType=INTEGER}, - ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR} + ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}, + sort = #{record.sort,jdbcType=INTEGER} @@ -537,6 +548,9 @@ ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}, + + sort = #{sort,jdbcType=INTEGER}, + where id = #{id,jdbcType=VARCHAR} @@ -568,7 +582,8 @@ tail_warn = #{tailWarn,jdbcType=INTEGER}, print_barcode = #{printBarcode,jdbcType=VARCHAR}, product_count = #{productCount,jdbcType=INTEGER}, - ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR} + ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} @@ -578,7 +593,7 @@ from t_purchase_detail where purchase_id = #{id,jdbcType=VARCHAR} - order by create_time desc + order by create_time desc ,sort asc select diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml index ddad9cdb..af5803e9 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml @@ -448,10 +448,15 @@ - update t_stock_log set del_flag ='1' - where order_id = #{purchaseId,jdbcType=VARCHAR} + update t_stock_log set del_flag = '1' where order_id = #{purchaseId,jdbcType=VARCHAR} + + + delete from t_stock_log + where order_id = #{purchaseId,jdbcType=VARCHAR} + + update t_stock_log set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null