diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java index e02a71e..7ae4483 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java @@ -31,72 +31,84 @@ public class PurchaseOrderDetailEntity extends BaseMgrEntity + + + + UPDATE cim_purchase_order_detail + + + item_no = #{item.itemNo}, + + + item_name = #{item.itemName}, + + + supplier_name = #{item.supplierName}, + + + supplier_no = #{item.supplierNo}, + + + requisition_num = #{item.requisitionNum}, + + + purchase_num = #{item.purchaseNum}, + + + purchase_price = #{item.purchasePrice}, + + + amount = #{item.amount}, + + + purchase_residue_num = #{item.purchaseResidueNum}, + + + procurement_executor_code = #{item.procurementExecutorCode}, + + + purchase_date = #{item.purchaseDate}, + + + expected_date = #{item.expectedDate}, + + + abnormal_handle_plan = #{item.abnormalHandlePlan}, + + + tab_status = #{item.tabStatus}, + + + task_type = #{item.taskType}, + + modified_by = #{item.modifiedBy}, + modified_date = #{item.modifiedDate} + + WHERE tenantsid = #{item.tenantSid} AND purchase_order_no = #{item.purchaseOrderNo} + AND purchase_order_seq = #{item.purchaseOrderSeq} + + + + + diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java index d2c7425..a6bebcf 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java @@ -15,4 +15,12 @@ import java.util.List; public interface PurchaseOrderDetailRepository extends BaseRepository { public void updateAbnormalHandlePlan(@Param("list") List list); + + + /** + * 请购采购更新 + * + * @param entityList + */ + void updateBatch(@Param("list") List entityList); } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java index faa160c..32dda5f 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java @@ -26,4 +26,9 @@ public interface PurchaseDemoEAIService extends DWService { @EAIService(id = PurchaseUtil.DEMO_PURCHASE_ORDER_ABNORMAL_UPDATE) DWEAIResult abnormalUpdate(Map headers, String messageBody) throws Exception; + + + @EAIService(id = PurchaseUtil.DEMO_PURCHASE_ORDER_UPDATE) + DWEAIResult purchaseOrderUpdate(Map headers, String messageBody) throws Exception; + } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java index 24a12ec..3dbd9f0 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java @@ -34,4 +34,9 @@ public class PurchaseDemoEAIServiceImpl implements PurchaseDemoEAIService { public DWEAIResult abnormalUpdate(Map headers, String messageBody) throws Exception { return eaiServiceContext.execute(PurchaseUtil.DEMO_PURCHASE_ORDER_ABNORMAL_UPDATE, headers, messageBody); } + + @Override + public DWEAIResult purchaseOrderUpdate(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(PurchaseUtil.DEMO_PURCHASE_ORDER_UPDATE, headers, messageBody); + } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseOrderUpdateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseOrderUpdateEAIService.java new file mode 100644 index 0000000..6833f4e --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseOrderUpdateEAIService.java @@ -0,0 +1,79 @@ +package com.digiwin.athena.app.service.purchase; + +import com.digiwin.app.container.exceptions.DWBusinessException; +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.PurchaseOrderDetailEntity; +import com.digiwin.athena.app.infra.repository.PurchaseOrderDetailRepository; +import com.digiwin.athena.opt.common.eai.EAIRequest; +import com.digiwin.athena.opt.common.eai.EAIUtil; +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 org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.util.*; + +/** + * @Author: xieps + * @Date: 2023/9/5 15:29 + * @Version 1.0 + * @Description + */ +@Service +@Log4j2 +public class PurchaseOrderUpdateEAIService extends AbsEAIService { + + + @Resource + PurchaseOrderDetailRepository purchaseOrderDetailRepository; + + @Override + public String getServiceName() { + return PurchaseUtil.DEMO_PURCHASE_ORDER_UPDATE; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + + EAIRequest request = new EAIRequest(messageBody); + List entityList = request.getToList("purchase_info", PurchaseOrderDetailEntity.class); + //校验请购单号、序号 必传 + validateParameter(entityList); + //管理字段赋值 + entityList.stream().forEach(item -> { + item.setTenantSid(SecurityUtil.getUserProfile().getTenantSid()); + item.setModifiedBy(SecurityUtil.getUserProfile().getUserId()); + item.setModifiedDate(new Date()); + }); + //根据单号,序号进行批量更新 + purchaseOrderDetailRepository.updateBatch(entityList); + + return EAIUtil.buildEAIResult(new HashMap<>()); + } + + + /** + * 校验必传参数 + * + * @param entityList + */ + private void validateParameter(List entityList) throws DWBusinessException { + if (Objects.isNull(entityList) || entityList.isEmpty()) { + throw new DWBusinessException("入参数据为空~~"); + } + for (PurchaseOrderDetailEntity entity : entityList) { + + if (StringUtils.isEmpty(entity.getPurchaseOrderNo())) { + throw new DWBusinessException("请购单号不为空或者NULL~"); + } + + if (StringUtils.isEmpty(entity.getPurchaseOrderSeq())) { + throw new DWBusinessException("请购单序号不为空或者NULL~"); + } + } + } + + +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java index 0b4594a..63f91f0 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java @@ -26,4 +26,9 @@ public class PurchaseUtil { public static final TypeReference> LIST_ENTITY_PURCHASE = new TypeReference>() { }; + + /** + * 请购单更新 + */ + public static final String DEMO_PURCHASE_ORDER_UPDATE = "demo.purchase.order.update"; } \ No newline at end of file