From 6f2aa02a57aad5a9fd9530e16b01589eb2470a63 Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Thu, 7 Sep 2023 10:42:26 +0800 Subject: [PATCH 1/3] moveOpPageBufferTimer --- .../api/service/impl/OpOrderServiceImpl.java | 73 ++++++++++++++++++- .../timer/MoveOpPageBufferTimerService.java | 28 +++++++ .../mapper/OpOrderRsyncPageBufferMapper.java | 6 ++ .../mapper/OpOrderRsyncPageQueueMapper.java | 2 +- .../mapper/OpOrderRsyncPageBufferMapper.xml | 23 ++++-- .../mapper/OpOrderRsyncPageQueueMapper.xml | 2 +- .../java/com/ms/web/OrderTestController.java | 8 +- 7 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 ms-biz/src/main/java/com/ms/api/spi/timer/MoveOpPageBufferTimerService.java diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java index 975e16f1..63121f17 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java @@ -99,6 +99,7 @@ import com.ms.dal.entity.OpOrderPhase; import com.ms.dal.entity.OpOrderPriceProtection; import com.ms.dal.entity.OpOrderRsyncInfo; import com.ms.dal.entity.OpOrderRsyncLog; +import com.ms.dal.entity.OpOrderRsyncPageBuffer; import com.ms.dal.entity.OpOrderRsyncPageLog; import com.ms.dal.entity.OpOrderRsyncPageQueue; import com.ms.dal.entity.OpOrderRsyncQueue; @@ -1987,11 +1988,79 @@ public class OpOrderServiceImpl implements OpOrderService { @Override public void moveOpPageBufferToQueue(Map shopIdAndMoveCntMap) { log.info("start moveOpPageBufferToQueue"); - int startBufferId = 0; + Long startBufferId = 0L; int limit = 1000; - for (Map.Entry entry : shopIdAndMoveCntMap.entrySet()) { + while (shopIdAndMoveCntMap.size() > 0) { + List chunkBufferList = opOrderRsyncPageBufferMapper.selectByBufferIdAndLimit(startBufferId, limit); + if (ObjectUtil.isEmpty(chunkBufferList)) { + break; + } + startBufferId = chunkBufferList.stream().map(OpOrderRsyncPageBuffer::getOpOrderRsyncPageBufferId).max(Long::compare).orElse(0L); + startMoveOpPageBufferToQueue(chunkBufferList, shopIdAndMoveCntMap); + shopIdAndMoveCntMap = shopIdAndMoveCntMap.entrySet().stream().filter(r -> r.getValue() > 0) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + log.info("end moveOpPageBufferToQueue"); + } + + private ApiResult startMoveOpPageBufferToQueue(List bufferList, Map shopIdAndMoveCntMap) { + List deleteBufferIds = new ArrayList<>(); + List insertQueueList = new ArrayList<>(); + List deleteShopIds = new ArrayList<>(); + for (OpOrderRsyncPageBuffer buffer : bufferList) { + Long shopId = buffer.getShopId(); + if (!shopIdAndMoveCntMap.containsKey(shopId) || shopIdAndMoveCntMap.get(shopId) < 0) { + continue; + } + Long cnt = shopIdAndMoveCntMap.get(shopId) - 1; + if (cnt < 0) { + deleteShopIds.add(shopId); + } + OpOrderRsyncPageQueue queue = new OpOrderRsyncPageQueue(); + queue.setOpOrderRsyncQueueId(buffer.getOpOrderRsyncQueueId()); + queue.setShopId(shopId); + queue.setGmtStartModified(buffer.getGmtStartModified()); + queue.setGmtEndModified(buffer.getGmtEndModified()); + queue.setPageSize(buffer.getPageSize()); + queue.setPage(buffer.getPage()); + queue.setPageCount(buffer.getPageCount()); + queue.setPreviewTotal(buffer.getPreviewTotal()); + queue.setLocked(0L); + queue.setGmtCreate(new Date()); + queue.setGmtModified(new Date()); + insertQueueList.add(queue); + deleteBufferIds.add(buffer.getOpOrderRsyncPageBufferId()); + } + for (Long id : deleteShopIds) { + shopIdAndMoveCntMap.remove(id); + } + Long startQueueId = null; + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + try { + if (ObjectUtil.isNotEmpty(insertQueueList)) { + opOrderRsyncPageQueueMapper.insertBatch(insertQueueList); + startQueueId = insertQueueList.get(insertQueueList.size() - 1).getOpOrderRsyncPageQueueId(); + } + if (ObjectUtil.isNotEmpty(deleteBufferIds)) { + opOrderRsyncPageBufferMapper.deleteByIdList(deleteBufferIds); + } + dataSourceTransactionManager.commit(transactionStatus); //手动提交 + } catch (Exception e) { + dataSourceTransactionManager.rollback(transactionStatus); //事务回滚 + return ApiResult.fail("数据处理失败,进行回滚。"); } + if (ObjectUtil.isNotNull(startQueueId)) { + int queueCount = insertQueueList.size(); + int queueIdLoop = 0; + for (Long queueId = startQueueId; queueId < (queueCount + startQueueId); queueId++) { + OpOrderRsyncPageQueue queueData = insertQueueList.get(queueIdLoop); + String queueRedisKey = RedisKeyConst.getQueueRedisKey(TblConst.op_order_rsync_page_queue, false); + redisTemplate.opsForList().leftPush(queueRedisKey, queueId.toString()); + queueIdLoop++; + } + } + return ApiResult.ok(); } private void doCheckRsyncOpEnd(Long shopId, Long queueId) { diff --git a/ms-biz/src/main/java/com/ms/api/spi/timer/MoveOpPageBufferTimerService.java b/ms-biz/src/main/java/com/ms/api/spi/timer/MoveOpPageBufferTimerService.java new file mode 100644 index 00000000..5fe71dd5 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/spi/timer/MoveOpPageBufferTimerService.java @@ -0,0 +1,28 @@ +package com.ms.api.spi.timer; + +import com.jinritemai.cloud.base.api.BaseRequest; +import com.jinritemai.cloud.base.api.BaseResponse; +import com.jinritemai.cloud.base.api.ExtensionService; +import com.jinritemai.cloud.base.api.ExtensionServiceHandler; +import com.ms.api.common.R; +import com.ms.api.common.Ret; +import com.ms.api.common.TimerBaseService; +import com.ms.api.dto.ItemDTO; +import com.ms.api.task.MoveOpPageBufferTaskService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +@ExtensionService("moveOpPageBufferTimer") +@Slf4j +public class MoveOpPageBufferTimerService extends TimerBaseService implements ExtensionServiceHandler { + + @Autowired + MoveOpPageBufferTaskService moveOpPageBufferTaskService; + + @Override + public BaseResponse handle(BaseRequest req) { + moveOpPageBufferTaskService.runTask(); + return R.ok(Ret.success()); + } + +} diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageBufferMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageBufferMapper.java index 8ba180b4..fec09b85 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageBufferMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageBufferMapper.java @@ -1,5 +1,7 @@ package com.ms.dal.mapper; +import java.util.List; + import com.ms.dal.entity.OpOrderRsyncPageBuffer; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -23,4 +25,8 @@ public interface OpOrderRsyncPageBufferMapper { int updateByPrimaryKey(OpOrderRsyncPageBuffer record); int selectCountByShopIdAndQueueId(@Param("shopId")Long shopId, @Param("queueId")Long queueId); + + List selectByBufferIdAndLimit(@Param("startBufferId")Long startBufferId, @Param("limit")int limit); + + void deleteByIdList(@Param("deleteBufferIds")List deleteBufferIds); } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageQueueMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageQueueMapper.java index 6e59f4e5..b2d18cba 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageQueueMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncPageQueueMapper.java @@ -24,7 +24,7 @@ public interface OpOrderRsyncPageQueueMapper { int updateByPrimaryKey(OpOrderRsyncPageQueue record); - void insertBatch(@Param("list") List list); + Long insertBatch(@Param("list") List list); OpOrderRsyncPageQueue queryFirstRowByQueueId(@Param("queueId") String queueId); diff --git a/ms-dal/src/main/resources/mapper/OpOrderRsyncPageBufferMapper.xml b/ms-dal/src/main/resources/mapper/OpOrderRsyncPageBufferMapper.xml index 12273ff3..52679060 100644 --- a/ms-dal/src/main/resources/mapper/OpOrderRsyncPageBufferMapper.xml +++ b/ms-dal/src/main/resources/mapper/OpOrderRsyncPageBufferMapper.xml @@ -29,15 +29,28 @@ select from op_order_rsync_page_buffer - where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + delete from op_order_rsync_page_buffer - where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + + + delete from op_order_rsync_page_buffer + where op_order_rsync_page_buffer_id IN + + #{item} + insert into op_order_rsync_page_buffer @@ -113,11 +126,11 @@ gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, - where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} update op_order_rsync_page_buffer - set + set op_order_rsync_queue_id = #{opOrderRsyncQueueId,jdbcType=BIGINT}, shop_id = #{shopId,jdbcType=BIGINT}, gmt_start_modified = #{gmtStartModified,jdbcType=TIMESTAMP}, @@ -128,6 +141,6 @@ preview_total = #{previewTotal,jdbcType=SMALLINT}, gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} - where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} + where op_order_rsync_page_buffer_id = #{opOrderRsyncPageBufferId,jdbcType=BIGINT} diff --git a/ms-dal/src/main/resources/mapper/OpOrderRsyncPageQueueMapper.xml b/ms-dal/src/main/resources/mapper/OpOrderRsyncPageQueueMapper.xml index 490c7faf..c583ed7a 100644 --- a/ms-dal/src/main/resources/mapper/OpOrderRsyncPageQueueMapper.xml +++ b/ms-dal/src/main/resources/mapper/OpOrderRsyncPageQueueMapper.xml @@ -99,7 +99,7 @@ #{gmtModified,jdbcType=TIMESTAMP}, - + insert into op_order_rsync_page_queue ( op_order_rsync_page_queue_id,op_order_rsync_queue_id,shop_id ,gmt_start_modified,gmt_end_modified,page_size diff --git a/ms-web/src/main/java/com/ms/web/OrderTestController.java b/ms-web/src/main/java/com/ms/web/OrderTestController.java index c392663c..6459c9c8 100644 --- a/ms-web/src/main/java/com/ms/web/OrderTestController.java +++ b/ms-web/src/main/java/com/ms/web/OrderTestController.java @@ -25,6 +25,7 @@ import com.ms.api.dto.order.SearchDsOrderListRequestDTO; import com.ms.api.service.DistributionOrderService; import com.ms.api.service.OpOrderService; import com.ms.api.service.PurchaseOrderService; +import com.ms.api.tool.CommonTool; import com.ms.api.util.OrderUtil; import com.ms.api.util.PurchaseOrderUtil; import com.ms.dal.mapper.OpOrderExtMapper; @@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -138,9 +140,9 @@ public class OrderTestController { return R.ok(Ret.success(result)); } - @PostMapping("/manualRsyncDdOrders") - public BaseResponse manualRsyncDdOrders(@RequestBody ManualRsyncDdOrdersDTO dto) { - ApiResult apiResult = orderUtil.rsyncOrder(AppConst.TEST_SHOP_ID, dto.getOrderIds()); + @GetMapping("/manualRsyncDdOrders") + public BaseResponse manualRsyncDdOrders(@RequestParam String orderIds) { + ApiResult apiResult = orderUtil.rsyncOrder(AppConst.TEST_SHOP_ID, CommonTool.splitWithComma(orderIds)); if (!apiResult.isSuccess()) { return R.fail(apiResult.getMsg()); } From 720787ee28315b7db8aa5f814a333e279c0c635b Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Thu, 7 Sep 2023 11:27:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OpOrderPhaseServiceImpl.java | 2 +- .../impl/OpOrderRedpackInfoServiceImpl.java | 2 +- .../ms/api/service/impl/OpOrderServiceImpl.java | 4 ++-- .../api/service/impl/OrderPrintServiceImpl.java | 16 ++++++++-------- .../service/impl/ProductToDsItemServiceImpl.java | 2 +- .../service/impl/PurchaseOrderServiceImpl.java | 14 +++++++------- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderPhaseServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderPhaseServiceImpl.java index 1fcbd079..70e013ed 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderPhaseServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderPhaseServiceImpl.java @@ -72,7 +72,7 @@ public class OpOrderPhaseServiceImpl implements OpOrderPhaseService{ if (ObjectUtil.isEmpty(rows)) { return new HashMap<>(); } - return rows.stream().collect(Collectors.toMap(OpOrderPhase::getOrderId, x->x)); + return rows.stream().collect(Collectors.toMap(OpOrderPhase::getOrderId, x->x,(v1,v2)->v1)); } } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderRedpackInfoServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderRedpackInfoServiceImpl.java index 0e5cbe2b..6b05a355 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderRedpackInfoServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderRedpackInfoServiceImpl.java @@ -73,7 +73,7 @@ public class OpOrderRedpackInfoServiceImpl implements OpOrderRedpackInfoService{ if (ObjectUtil.isEmpty(rows)) { return new HashMap<>(); } - return rows.stream().collect(Collectors.toMap(OpOrderRedpackInfo::getOrderId,x->x)); + return rows.stream().collect(Collectors.toMap(OpOrderRedpackInfo::getOrderId,x->x,(v1,v2)->v1)); } @Override diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java index 63121f17..6612751d 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java @@ -961,7 +961,7 @@ public class OpOrderServiceImpl implements OpOrderService { afterSaleData.setGmtCreate(new Date()); afterSaleDatas.add(afterSaleData); - Map childs = childInfoDatas.stream().collect(Collectors.toMap(OpOrderChild::getChildOrderId, x -> x)); + Map childs = childInfoDatas.stream().collect(Collectors.toMap(OpOrderChild::getChildOrderId, x -> x,(v1,v2)->v1)); if (ObjectUtil.isNotEmpty(skuOrder.getMasterSkuOrderIdList())) { for (String masterSkuOrderId : skuOrder.getMasterSkuOrderIdList()) { OpOrderGivenProduct item = new OpOrderGivenProduct(); @@ -1998,7 +1998,7 @@ public class OpOrderServiceImpl implements OpOrderService { startBufferId = chunkBufferList.stream().map(OpOrderRsyncPageBuffer::getOpOrderRsyncPageBufferId).max(Long::compare).orElse(0L); startMoveOpPageBufferToQueue(chunkBufferList, shopIdAndMoveCntMap); shopIdAndMoveCntMap = shopIdAndMoveCntMap.entrySet().stream().filter(r -> r.getValue() > 0) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,(v1,v2)->v1)); } log.info("end moveOpPageBufferToQueue"); } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OrderPrintServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OrderPrintServiceImpl.java index 6d93d2c9..9edc4672 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OrderPrintServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OrderPrintServiceImpl.java @@ -152,7 +152,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { if (ObjectUtil.isEmpty(rows)) { return new HashMap<>(); } - return rows.stream().collect(Collectors.toMap(OpOrderExt::getOrderId, x -> x)); + return rows.stream().collect(Collectors.toMap(OpOrderExt::getOrderId, x -> x,(v1,v2)->v1)); } @Override @@ -173,7 +173,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { if (ObjectUtil.isEmpty(rows)) { return new HashMap<>(); } - return rows.stream().collect(Collectors.toMap(OpOrderSensitive::getOrderId, x -> x)); + return rows.stream().collect(Collectors.toMap(OpOrderSensitive::getOrderId, x -> x,(v1,v2)->v1)); } @Override @@ -309,12 +309,12 @@ public class OrderPrintServiceImpl implements OrderPrintService { @Override public Map getDdLogisticsNameAndLogisticsIdMap() { List list = opLogisticsPlatformMapper.getDdLogisticsListByCompanyIds(null, AppConst.appPlatformDd); - return list.stream().collect(Collectors.toMap(OpLogisticsPlatformBO::getLogisticsName, OpLogisticsPlatformBO::getCompanyId)); + return list.stream().collect(Collectors.toMap(OpLogisticsPlatformBO::getLogisticsName, OpLogisticsPlatformBO::getCompanyId,(v1,v2)->v1)); } public Map getDdLogisticsCompanyCodeAndCompanyIdMapFromDb() { List list = opLogisticsPlatformMapper.getDdLogisticsListByCompanyIds(null, AppConst.appPlatformDd); - return list.stream().collect(Collectors.toMap(OpLogisticsPlatformBO::getCompanyCode, OpLogisticsPlatformBO::getCompanyId)); + return list.stream().collect(Collectors.toMap(OpLogisticsPlatformBO::getCompanyCode, OpLogisticsPlatformBO::getCompanyId,(v1,v2)->v1)); } @Override @@ -352,7 +352,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { return new HashMap<>(); } List orderChildList = opOrderChildAfterSaleMapper.seteltByChildOrderIds(childOrderIds); - return orderChildList.stream().collect(Collectors.toMap(OpOrderChildAfterSale::getChildOrderId, x -> x)); + return orderChildList.stream().collect(Collectors.toMap(OpOrderChildAfterSale::getChildOrderId, x -> x,(v1,v2)->v1)); } public Map getProductIdAndItemNumMap(List productIds) { @@ -360,7 +360,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { return new HashMap<>(); } List productList = productMapper.selectByProductIds(productIds); - return productList.stream().collect(Collectors.toMap(x -> x.getProductId().toString(), Product::getItemNum)); + return productList.stream().collect(Collectors.toMap(x -> x.getProductId().toString(), Product::getItemNum,(v1,v2)->v1)); } @Override @@ -396,7 +396,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { return new HashMap<>(); } - return opLogisticsBOList.stream().collect(Collectors.toMap(OpLogisticsBO::getLogisticsId, x -> x)); + return opLogisticsBOList.stream().collect(Collectors.toMap(OpLogisticsBO::getLogisticsId, x -> x,(v1,v2)->v1)); } @Transactional(rollbackFor = Exception.class) @@ -410,7 +410,7 @@ public class OrderPrintServiceImpl implements OrderPrintService { if (CollectionUtil.isEmpty(orderList)) { return false; } - Map orderMap = orderList.stream().collect(Collectors.toMap(OpOrder::getOrderId, x -> x)); + Map orderMap = orderList.stream().collect(Collectors.toMap(OpOrder::getOrderId, x -> x,(v1,v2)->v1)); List validOrderIds = orderList.stream().map(e->e.getOrderId()).collect(Collectors.toList()); List existsExtOrderIds = opOrderExtMapper.selectOrderIdById(orderIds, shopIds); List notExistsExtOrderIds = CollectionUtil.isEmpty(existsExtOrderIds) ? validOrderIds : new ArrayList<>(); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/ProductToDsItemServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/ProductToDsItemServiceImpl.java index d8a68de7..668dd34c 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/ProductToDsItemServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/ProductToDsItemServiceImpl.java @@ -99,7 +99,7 @@ public class ProductToDsItemServiceImpl implements ProductToDsItemService { } List rows = productToDsItemMapper.getProductIdAndProductToDsItemMapByProductIds(productIds, sourcePlatform); - return rows.stream().collect(Collectors.toMap(ProductToDsItem::getProductId, x -> x)); + return rows.stream().collect(Collectors.toMap(ProductToDsItem::getProductId, x -> x,(v1,v2)->v1)); } } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java index 8348d2c7..fa4ba3fb 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java @@ -299,7 +299,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { List orderIds = orderList.stream().map(OpOrder::getOrderId).collect(Collectors.toList()); Map> orderIdAndPurchaseOrdersMap = getOrderIdAndPurchaseOrdersMap(shopIds, orderIds, filter, true, false); - Map shopIdAndShopInfoMap = shopService.getShopByIds(shopIds).stream().collect(Collectors.toMap(Shop::getShopId, x -> x)); + Map shopIdAndShopInfoMap = shopService.getShopByIds(shopIds).stream().collect(Collectors.toMap(Shop::getShopId, x -> x,(v1,v2)->v1)); Map orderIdAndSameOrderIdsMap = new HashMap<>(); // TODO: 2023/8/28 配置表已经没有相关字段 跳过 // if (ObjectUtil.isNotNull(filter.getIsShowSameReceiverOrder()) && filter.getIsShowSameReceiverOrder()) { @@ -331,7 +331,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { } List opOrderOutstorageHistoryRows = opOrderOutstorageHistoryService.getByIdList(opOrderOutstorageHistoryIds); - Map orderIdAndOpOrderOutstrorageHistoryMap = opOrderOutstorageHistoryRows.stream().collect(Collectors.toMap(OpOrderOutstorageHistory::getOrderId, x -> x)); + Map orderIdAndOpOrderOutstrorageHistoryMap = opOrderOutstorageHistoryRows.stream().collect(Collectors.toMap(OpOrderOutstorageHistory::getOrderId, x -> x,(v1,v2)->v1)); for (JSONObject order : orders) { if (isDs && !OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS.equals(order.get("orderStatus"))) { @@ -694,7 +694,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { if (needItems) { List purchaseOrderIds = purchaseOrders.stream().map(x -> x.getPurchaseOrderId().toString()).collect(Collectors.toList()); - Map purchaseOrderItemsMap = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, StatusConst.normal).stream().collect(Collectors.toMap(PurchaseOrderItem::getPurchaseOrderId, x -> x)); + Map purchaseOrderItemsMap = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, StatusConst.normal).stream().collect(Collectors.toMap(PurchaseOrderItem::getPurchaseOrderId, x -> x,(v1,v2)->v1)); for (PurchaseOrderBO purchaseOrder : purchaseOrders) { if (purchaseOrderItemsMap.containsKey(purchaseOrder.getPurchaseOrderId().intValue())) { purchaseOrder.setItem(purchaseOrderItemsMap.get(purchaseOrder.getPurchaseOrderId().intValue())); @@ -739,7 +739,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { // } // } - return rows.stream().collect(Collectors.toMap(PurchaseOrderSetting::getPurchaseOrderId, x -> x)); + return rows.stream().collect(Collectors.toMap(PurchaseOrderSetting::getPurchaseOrderId, x -> x,(v1,v2)->v1)); } @Override @@ -1339,7 +1339,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { List items = orderIdAndOpOrderChildMap.get(orderId); Map skuIdAndOrderChildMap = this.mergeOpOrderChildSameSku(items); List currentOrderAfterSales = ObjectUtil.isNotEmpty(orderIdAndAftersalesMap.get(orderId)) ? orderIdAndAftersalesMap.get(orderId) : new ArrayList<>(); - Map childOrderIdAndAfterSaleMap = currentOrderAfterSales.stream().collect(Collectors.toMap(AfterSale::getOrderId, x -> x)); + Map childOrderIdAndAfterSaleMap = currentOrderAfterSales.stream().collect(Collectors.toMap(AfterSale::getOrderId, x -> x,(v1,v2)->v1)); attachSourceItemInfoToOpOrderChilds(skuIdAndOrderChildMap, productIdAndProductToDsItemMap, childOrderIdAndAfterSaleMap); List sourceItemIds = skuIdAndOrderChildMap.values().stream().map(OpOrderChildBO::getSourceItemId).collect(Collectors.toList()); @@ -1372,7 +1372,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { // orderAddressChangeApply = orderIdAndOrderAddressChangeApplyMap[orderId]; - Map purchasePlatforms = returnPurchaseOrders.values().stream().collect(Collectors.toMap(x -> x.get("purchasePlatform"), x -> x)); + Map purchasePlatforms = ObjectUtil.isEmpty(returnPurchaseOrders) ? new HashMap<>() : returnPurchaseOrders.values().stream().collect(Collectors.toMap(x -> x.getString("purchasePlatform"), x -> x,(v1,v2)->v1)); if (ObjectUtil.isEmpty(sourceItemIds) && purchasePlatforms.containsKey(PurchaseOrderConst.PURCHASE_PLATFORM1688_D_S)) { needDeleteOpOrderDsOrderIds.add(orderId); } @@ -1566,7 +1566,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { private void rebuildNoPurchaseOrderItems(Map skuIdAndOrderChildMap, List hasPurchaseSkuIds, List childOrderLogistics, List priceProtectionList, Map> childOrderIdAndGivenProductsMap, List returnOrderItems, List noPurchaseOrderItems, BigDecimal orderTotalAmount) { Map> childOrderIdAndLogisticsMap = childOrderLogistics.stream().collect(Collectors.groupingBy(OpOrderChildLogistics::getChildOrderId)); - Map childOrderIdAndPriceProtectionMap = priceProtectionList.stream().collect(Collectors.toMap(OpOrderPriceProtection::getChildOrderId, x -> x)); + Map childOrderIdAndPriceProtectionMap = priceProtectionList.stream().collect(Collectors.toMap(OpOrderPriceProtection::getChildOrderId, x -> x,(v1,v2)->v1)); for (Map.Entry entry : skuIdAndOrderChildMap.entrySet()) { OpOrderChildBO item = entry.getValue(); String skuSubNames = item.getSkuSubName(); From 12c2187909ee2ce062d4673c5c4e05b8a1c1af9b Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Thu, 7 Sep 2023 11:33:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=87=87=E8=B4=AD=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ms/api/spi/order/SavePurchaseSettingService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/spi/order/SavePurchaseSettingService.java b/ms-biz/src/main/java/com/ms/api/spi/order/SavePurchaseSettingService.java index e1928b02..84705d05 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/order/SavePurchaseSettingService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/order/SavePurchaseSettingService.java @@ -218,9 +218,9 @@ public class SavePurchaseSettingService extends SPIBaseService implements Extens log.error("自动扣款协议请求失败,原因:" + jsonObject.getString("reason")); throw new RuntimeException(jsonObject.getString("reason")); } else { - JSONObject paymentAgreements = jsonObject.getJSONObject("data").getJSONObject("paymentAgreements"); - for (Object paymentAgreement : paymentAgreements.values()) { - JSONObject obj = (JSONObject)paymentAgreement; + JSONArray paymentAgreements = jsonObject.getJSONObject("data").getJSONArray("paymentAgreements"); + for (int i = 0; i < paymentAgreements.size(); i++) { + JSONObject obj = paymentAgreements.getJSONObject(i); String signedStatus = obj.getString("signedStatus"); if (signedStatus.equals("true")) { isSigned = true;