From cd74983dc1937546c1efe80beae3e138a3603925 Mon Sep 17 00:00:00 2001 From: zhenggl Date: Wed, 13 Sep 2023 15:31:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BE=A6=E6=B5=8B=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/mapper/ReceivablesDetailMapper.xml | 17 +++++++++++ .../ReceivablesDetailRepository.java | 5 ++++ .../ReceivablesInitialCreateEAIService.java | 30 ++++++++++++++----- 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/mapper/ReceivablesDetailMapper.xml diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/mapper/ReceivablesDetailMapper.xml b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/mapper/ReceivablesDetailMapper.xml new file mode 100644 index 0000000..7d4f9e1 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/mapper/ReceivablesDetailMapper.xml @@ -0,0 +1,17 @@ + + + + + + + delete from cim_receivables_detail where tenantsid=#{tenantSid} + + ( + sales_order = #{item.salesOrder} + and sales_order_number = #{item.salesOrderNumber} + ) + + + diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/repository/ReceivablesDetailRepository.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/repository/ReceivablesDetailRepository.java index a63d366..387e1c4 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/repository/ReceivablesDetailRepository.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/repository/ReceivablesDetailRepository.java @@ -1,11 +1,16 @@ package com.digiwin.athena.app.ptc.infra.repository; +import com.digiwin.athena.app.ptc.infra.entity.CollectionDetailEntity; import com.digiwin.athena.app.ptc.infra.entity.ReceivablesDetailEntity; import com.digiwin.athena.opt.persistence.repository.BaseRepository; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @auther: zhenggl * @date: 2023/9/12 */ public interface ReceivablesDetailRepository extends BaseRepository { + void deleteBatch(@Param("list") List list, @Param("tenantSid")Long tenantSid); } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesInitialCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesInitialCreateEAIService.java index 6e30605..544c896 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesInitialCreateEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesInitialCreateEAIService.java @@ -1,11 +1,14 @@ package com.digiwin.athena.app.ptc.service.receivables; import com.alibaba.fastjson.TypeReference; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; 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.repository.ReceivablesDetailRepository; 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 com.digiwin.athena.opt.common.util.DateUtils; @@ -27,6 +30,9 @@ public class ReceivablesInitialCreateEAIService extends AbsEAIService { @Resource private CollectionDetailRepository collectionDetailRepository; + @Resource + private ReceivablesDetailRepository receivablesDetailRepository; + @Resource private CollectionDetailService collectionDetailService; @@ -53,14 +59,24 @@ public class ReceivablesInitialCreateEAIService extends AbsEAIService { @Override public DWEAIResult execute(Map headers, String messageBody) throws Exception { - EAIRequest eaiRequest = EAIRequest.build(messageBody); - List collectionDetailEntities = eaiRequest.getObject("receivables_info", new TypeReference>() {}); - //先删除 - collectionDetailRepository.deleteBatch(collectionDetailEntities, SecurityUtil.getUserProfile().getTenantSid()); + Long tenantSid = SecurityUtil.getUserProfile().getTenantSid(); + + //取出已完成的数据 + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(CollectionDetailEntity::getTenantSid,tenantSid); + lmq.eq(CollectionDetailEntity::getStatus, TabStatusEnums.COMPLETED.getValue()); + List list = collectionDetailService.list(lmq); + + //删除应收数据 + if (CollectionUtils.isNotEmpty(list)){ + receivablesDetailRepository.deleteBatch(list,tenantSid); + } + + Random random = new Random(); //随机新增 - for (CollectionDetailEntity collectionDetailEntity : list) { + for (CollectionDetailEntity collectionDetailEntity : this.list) { int randomNumber = random.nextInt(100); int nextInt = random.nextInt(30); int dayInt = random.nextInt(10); @@ -81,7 +97,7 @@ public class ReceivablesInitialCreateEAIService extends AbsEAIService { collectionDetailEntity.setOverdueDays(String.valueOf(DateUtils.getDayInterval(new Date(),collectionDetailEntity.getReceivableDate()))); } - collectionDetailService.saveBatch(list); + collectionDetailService.saveBatch(this.list);