From ce0538a6ab0b0c9d3d6dcd98fc5f82f20480e7dc Mon Sep 17 00:00:00 2001 From: zhenggl Date: Thu, 14 Sep 2023 20:55:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E5=8E=BB=E9=87=8D?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReceivablesCreateEAIService.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesCreateEAIService.java index 2d5d218..8c14253 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesCreateEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesCreateEAIService.java @@ -1,19 +1,21 @@ package com.digiwin.athena.app.ptc.service.receivables; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.digiwin.app.service.DWEAIResult; import com.digiwin.athena.app.ptc.infra.entity.CollectionDetailEntity; import com.digiwin.athena.app.ptc.infra.repository.CollectionDetailRepository; import com.digiwin.athena.app.ptc.infra.service.CollectionDetailService; import com.digiwin.athena.opt.common.eai.EAIRequest; import com.digiwin.athena.opt.common.eai.service.AbsEAIService; -import com.digiwin.athena.opt.common.security.SecurityUtil; import lombok.extern.log4j.Log4j2; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; /** * @auther: zhenggl @@ -42,8 +44,26 @@ public class ReceivablesCreateEAIService extends AbsEAIService { /*//根据bk删除数据 //先删除 collectionDetailRepository.deleteBatch(receivablesDetailEntities, SecurityUtil.getUserProfile().getTenantSid());*/ + //根据bk查询数据,删除已存在 + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.and(queryWrapperInner -> { + for (CollectionDetailEntity collectionDetailEntity : receivablesDetailEntities) { + queryWrapperInner.or( + wrapper -> wrapper + .eq(CollectionDetailEntity::getSalesOrder, collectionDetailEntity.getSalesOrder()) + .eq(CollectionDetailEntity::getSalesOrderNumber, collectionDetailEntity.getSalesOrderNumber()) + ); + } - collectionDetailService.saveBatch(receivablesDetailEntities); - return buildOK("query_result",receivablesDetailEntities); + }); + List list = collectionDetailService.list(lmq); + Map collect = list.stream().collect(Collectors.toMap(item -> item.getSalesOrder() + "-" + item.getSalesOrderNumber(), Function.identity())); + + + List receivablesList = receivablesDetailEntities.stream().filter(item -> !collect.containsKey(item.getSalesOrder() + "-" + item.getSalesOrderNumber())).collect(Collectors.toList()); + + + collectionDetailService.saveBatch(receivablesList); + return buildOK("query_result",receivablesList); } }