diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/entity/ReceivablesDetailEntity.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/entity/ReceivablesDetailEntity.java index b394bef..901f815 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/entity/ReceivablesDetailEntity.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/infra/entity/ReceivablesDetailEntity.java @@ -3,6 +3,7 @@ package com.digiwin.athena.app.ptc.infra.entity; import java.math.BigDecimal; import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; import com.google.gson.annotations.SerializedName; @@ -115,6 +116,9 @@ public class ReceivablesDetailEntity extends BaseMgrEntity + + + + + + 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/paymentdetails/ReceivablesGetEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/paymentdetails/ReceivablesGetEAIService.java index 9ce5557..5693de0 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/paymentdetails/ReceivablesGetEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/paymentdetails/ReceivablesGetEAIService.java @@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.digiwin.app.service.DWEAIResult; import com.digiwin.athena.app.ptc.infra.entity.LimitCreditEntity; import com.digiwin.athena.app.ptc.infra.entity.PaymentDetailsEntity; +import com.digiwin.athena.app.ptc.infra.entity.ReceivablesDetailEntity; import com.digiwin.athena.app.ptc.infra.service.LimitCreditService; import com.digiwin.athena.app.ptc.infra.service.PaymentDetailsService; +import com.digiwin.athena.app.ptc.infra.service.ReceivablesDetailService; import com.digiwin.athena.opt.common.eai.service.AbsEAIService; import com.digiwin.athena.opt.common.security.SecurityUtil; import lombok.extern.log4j.Log4j2; @@ -27,7 +29,7 @@ import java.util.stream.Collectors; public class ReceivablesGetEAIService extends AbsEAIService { @Resource - private PaymentDetailsService paymentDetailsService; + private ReceivablesDetailService receivablesDetailService; @Resource private LimitCreditService limitCreditService; @@ -40,25 +42,25 @@ public class ReceivablesGetEAIService extends AbsEAIService { @Override public DWEAIResult execute(Map headers, String messageBody) throws Exception { - LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); - lmq.eq(PaymentDetailsEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); - List list = paymentDetailsService.list(lmq); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(ReceivablesDetailEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); + List list = receivablesDetailService.list(lmq); if (CollectionUtils.isEmpty(list)){ return buildOK("query_result",list); } //查询限制额度 - List customerNoList = list.stream().map(PaymentDetailsEntity::getCustomerNo).collect(Collectors.toList()); + List customerNoList = list.stream().map(ReceivablesDetailEntity::getCustomerNo).collect(Collectors.toList()); LambdaQueryWrapper creditLmq = new LambdaQueryWrapper<>(); creditLmq.in(LimitCreditEntity::getCustomerNo,customerNoList); List limitCreditEntityList = limitCreditService.list(creditLmq); if (CollectionUtils.isNotEmpty(limitCreditEntityList)){ - for (PaymentDetailsEntity paymentDetailsEntity : list) { + for (ReceivablesDetailEntity receivablesDetailEntity : list) { for (LimitCreditEntity limitCreditEntity : limitCreditEntityList) { - if (Objects.nonNull(limitCreditEntity.getLimitAmount())&&paymentDetailsEntity.getCustomerNo().equals(limitCreditEntity.getCustomerNo())){ - paymentDetailsEntity.setLimitAmount(limitCreditEntity.getLimitAmount()); + if (Objects.nonNull(limitCreditEntity.getLimitAmount())&&receivablesDetailEntity.getCustomerNo().equals(limitCreditEntity.getCustomerNo())){ + receivablesDetailEntity.setLimitAmount(limitCreditEntity.getLimitAmount()); } } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/production/ProductionCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/production/ProductionCreateEAIService.java index 8dbd85c..583f103 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/production/ProductionCreateEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/production/ProductionCreateEAIService.java @@ -43,7 +43,7 @@ public class ProductionCreateEAIService extends AbsEAIService { } //随机赋值list - List list = Arrays.asList( + private List list = Arrays.asList( new ProductionDetailsEntity("001", "一号工厂", "一号工厂刘晓鹏"), new ProductionDetailsEntity("002", "二号工厂", "二号工厂饶文豪"), new ProductionDetailsEntity("003", "三号工厂", "三号工厂卢人辅")); @@ -65,10 +65,9 @@ public class ProductionCreateEAIService extends AbsEAIService { - + Random random = new Random(); //默认赋值 for (ProductionDetailsEntity productionDetailsEntity : productionDetailsEntities) { - Random random = new Random(); int randomNumber = random.nextInt(3); productionDetailsEntity.setFactoryNo(this.list.get(randomNumber).getFactoryNo()); productionDetailsEntity.setFactoryName(this.list.get(randomNumber).getFactoryName()); @@ -77,7 +76,7 @@ public class ProductionCreateEAIService extends AbsEAIService { productionDetailsEntity.setProduceBoss("23467345221"); productionDetailsEntity.setProductionStatus(TabStatusEnums.PENDING.getValue().toString()); productionDetailsEntity.setNature(String.valueOf(randomNumber)); - String batchNo = cteateBatchNo(); + String batchNo = createBatchNo(); productionDetailsEntity.setBatchNo("MMDD-"+batchNo); //预计产量赋值 if (CollectionUtils.isNotEmpty(list)) { @@ -98,7 +97,7 @@ public class ProductionCreateEAIService extends AbsEAIService { return buildOK(); } - private String cteateBatchNo(){ + private String createBatchNo(){ StringBuffer sb = new StringBuffer(); Long batchNo; if (redisUtil.getRedisTemplate().hasKey(ProductionUtil.KEY)) { 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 217823e..2d5d218 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 @@ -39,9 +39,9 @@ public class ReceivablesCreateEAIService extends AbsEAIService { EAIRequest eaiRequest = EAIRequest.build(messageBody); List receivablesDetailEntities = eaiRequest.getObject("get_data", new TypeReference>() {}); - //根据bk删除数据 + /*//根据bk删除数据 //先删除 - collectionDetailRepository.deleteBatch(receivablesDetailEntities, SecurityUtil.getUserProfile().getTenantSid()); + collectionDetailRepository.deleteBatch(receivablesDetailEntities, SecurityUtil.getUserProfile().getTenantSid());*/ collectionDetailService.saveBatch(receivablesDetailEntities); return buildOK("query_result",receivablesDetailEntities); 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 ab88599..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; @@ -38,7 +44,7 @@ public class ReceivablesInitialCreateEAIService extends AbsEAIService { //随机赋值list - List list = Arrays.asList( + private List list = Arrays.asList( new CollectionDetailEntity("鼎捷A半导体有限公司","dj001","张三","186****9498"), new CollectionDetailEntity("鼎捷B半导体有限公司","dj002","李四","158****4794"), new CollectionDetailEntity("鼎捷C半导体有限公司","dj003","王五","150****9529"), @@ -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);