|
@ -1,19 +1,21 @@ |
|
|
package com.digiwin.athena.app.ptc.service.receivables; |
|
|
package com.digiwin.athena.app.ptc.service.receivables; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.digiwin.app.service.DWEAIResult; |
|
|
import com.digiwin.app.service.DWEAIResult; |
|
|
import com.digiwin.athena.app.ptc.infra.entity.CollectionDetailEntity; |
|
|
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.CollectionDetailRepository; |
|
|
import com.digiwin.athena.app.ptc.infra.service.CollectionDetailService; |
|
|
import com.digiwin.athena.app.ptc.infra.service.CollectionDetailService; |
|
|
import com.digiwin.athena.opt.common.eai.EAIRequest; |
|
|
import com.digiwin.athena.opt.common.eai.EAIRequest; |
|
|
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; |
|
|
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; |
|
|
import com.digiwin.athena.opt.common.security.SecurityUtil; |
|
|
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
import lombok.extern.log4j.Log4j2; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @auther: zhenggl |
|
|
* @auther: zhenggl |
|
@ -42,8 +44,26 @@ public class ReceivablesCreateEAIService extends AbsEAIService { |
|
|
/*//根据bk删除数据 |
|
|
/*//根据bk删除数据 |
|
|
//先删除 |
|
|
//先删除 |
|
|
collectionDetailRepository.deleteBatch(receivablesDetailEntities, SecurityUtil.getUserProfile().getTenantSid());*/ |
|
|
collectionDetailRepository.deleteBatch(receivablesDetailEntities, SecurityUtil.getUserProfile().getTenantSid());*/ |
|
|
|
|
|
//根据bk查询数据,删除已存在 |
|
|
|
|
|
LambdaQueryWrapper<CollectionDetailEntity> 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<CollectionDetailEntity> list = collectionDetailService.list(lmq); |
|
|
|
|
|
Map<String, CollectionDetailEntity> collect = list.stream().collect(Collectors.toMap(item -> item.getSalesOrder() + "-" + item.getSalesOrderNumber(), Function.identity())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CollectionDetailEntity> receivablesList = receivablesDetailEntities.stream().filter(item -> !collect.containsKey(item.getSalesOrder() + "-" + item.getSalesOrderNumber())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectionDetailService.saveBatch(receivablesList); |
|
|
|
|
|
return buildOK("query_result",receivablesList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |