diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesTaskDeleteEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesTaskDeleteEAIService.java new file mode 100644 index 0000000..33aca83 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/ptc/service/receivables/ReceivablesTaskDeleteEAIService.java @@ -0,0 +1,48 @@ +package com.digiwin.athena.app.ptc.service.receivables; + +import com.alibaba.fastjson.TypeReference; +import com.alibaba.nacos.common.utils.StringUtils; +import com.digiwin.app.container.exceptions.DWBusinessException; +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.opt.common.eai.EAIRequest; +import com.digiwin.athena.opt.common.eai.service.AbsEAIService; +import com.digiwin.athena.opt.common.security.SecurityUtil; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * @auther: zhenggl + * @date: 2023/9/13 + */ +public class ReceivablesTaskDeleteEAIService extends AbsEAIService { + + @Resource + private CollectionDetailRepository collectionDetailRepository; + + + @Override + public String getServiceName() { + return ReceivablesUtil.RECEIVABLES_TASK_DELETE; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + EAIRequest eaiRequest = EAIRequest.build(messageBody); + List collectionDetailEntities = eaiRequest.getObject("receivables_info", new TypeReference>() {}); + + + for (CollectionDetailEntity collectionDetailEntity : collectionDetailEntities) { + if (StringUtils.isEmpty(collectionDetailEntity.getSalesOrder()) + ||StringUtils.isEmpty(collectionDetailEntity.getSalesOrderNumber())){ + throw new DWBusinessException("缺少必要参数"); + } + } + + collectionDetailRepository.deleteBatch(collectionDetailEntities, SecurityUtil.getUserProfile().getTenantSid()); + return buildOK(); + } +}