diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java new file mode 100644 index 0000000..82babdb --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java @@ -0,0 +1,46 @@ +package com.digiwin.athena.app.infra.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 人资报道对象 cim_item_supplier + * + * @author bk + * @date 2023-04-28 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName(value = "cim_item_supplier", autoResultMap = true) +public class FontSupplierEntity extends BaseMgrEntity { + private static final long serialVersionUID = 1L; + + + /** 品号 */ + @SerializedName("item_no") + private String itemNo; + + /** 品名 */ + @SerializedName("item_name") + private String itemName; + + /** 供应商编号 */ + @SerializedName("supplier_no") + private String supplierNo; + + /** 供应商名称 */ + @SerializedName("supplier_name") + private String supplierName; + + /** 单价 */ + @SerializedName("price") + private String price; + +} 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/FontSupplierRepository.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/FontSupplierRepository.java new file mode 100644 index 0000000..2570407 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/FontSupplierRepository.java @@ -0,0 +1,11 @@ +package com.digiwin.athena.app.infra.repository; + +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.opt.persistence.repository.BaseRepository; + +/** + * @auther: bk + * @date: 2023/9/1 + */ +public interface FontSupplierRepository extends BaseRepository { +} 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/infra/service/FontSupplierService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/FontSupplierService.java new file mode 100644 index 0000000..8d11c9d --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/FontSupplierService.java @@ -0,0 +1,11 @@ +package com.digiwin.athena.app.infra.service; + +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.opt.persistence.service.IBaseService; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +public interface FontSupplierService extends IBaseService { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java new file mode 100644 index 0000000..ad1fafa --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java @@ -0,0 +1,16 @@ +package com.digiwin.athena.app.infra.service.Impl; + + +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.repository.FontSupplierRepository; +import com.digiwin.athena.app.infra.service.FontSupplierService; +import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService; +import org.springframework.stereotype.Service; + +/** + * @auther: bk + * @date: 2023/9/1 + */ +@Service +public class FontSupplierServiceImpl extends AbsBaseService implements FontSupplierService { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java new file mode 100644 index 0000000..2d5fae5 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java @@ -0,0 +1,56 @@ +package com.digiwin.athena.app.provider; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.app.service.DWService; +import com.digiwin.app.service.eai.EAIService; +import com.digiwin.athena.app.service.supplier.FontSupplierUtil; + +import java.util.Map; + +/** + * @auther: bk + * @date: 2023/9/1 + */ +public interface FontSupplierEAIService extends DWService { + + + /** + * 品号供应商修改 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_UPDATE) + DWEAIResult update(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商获取 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_GET) + DWEAIResult get(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商新增 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE) + DWEAIResult create(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商删除 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE) + DWEAIResult delete(Map headers, String messageBody) throws Exception; +} 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..839d9d9 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 @@ -16,14 +16,17 @@ import java.util.Map; */ public interface PurchaseDemoEAIService extends DWService { - @AllowAnonymous @EAIService(id = PurchaseUtil.DEMO_PURCHASE_DEMO_CREATE) DWEAIResult create(Map headers, String messageBody) throws Exception; - @AllowAnonymous @EAIService(id = PurchaseUtil.DEMO_PURCHASE_DEMO_GET) DWEAIResult get(Map headers, String messageBody) throws Exception; @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/FontSupplierEAIServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/FontSupplierEAIServiceImpl.java new file mode 100644 index 0000000..07c4855 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/FontSupplierEAIServiceImpl.java @@ -0,0 +1,40 @@ +package com.digiwin.athena.app.provider.impl; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.provider.FontSupplierEAIService; +import com.digiwin.athena.app.service.supplier.FontSupplierUtil; +import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @auther: bk + * @date: 2023/9/1 + */ +public class FontSupplierEAIServiceImpl implements FontSupplierEAIService { + + @Resource + private EAIServiceContext eaiServiceContext; + + @Override + public DWEAIResult update(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_UPDATE,headers,messageBody); + } + + @Override + public DWEAIResult get(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_GET,headers,messageBody); + } + + + @Override + public DWEAIResult create(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE,headers,messageBody); + } + + @Override + public DWEAIResult delete(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE,headers,messageBody); + } +} 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 diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java new file mode 100644 index 0000000..72c5f67 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java @@ -0,0 +1,109 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.digiwin.app.container.exceptions.DWBusinessException; +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.entity.ItemExecutorEntity; +import com.digiwin.athena.app.infra.repository.FontSupplierRepository; +import com.digiwin.athena.app.infra.service.FontSupplierService; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentSkipListMap; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * @auther: bk + * @date: 2023/9/1 + */ +@Log4j2 +@Service +public class FontSupplierCreateEAIService extends AbsEAIService { + + @Resource + private FontSupplierService fontSupplierService; + + @Override + public String getServiceName() { + return FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + EAIRequest eaiRequest = EAIRequest.build(messageBody); + List supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER); + //对必传参数 且 品号和供应商编号不可以重复 进行校验 + validateParameter(supplierInfo); + + fontSupplierService.saveBatch(supplierInfo); + return EAIUtil.buildEAIResult(new JSONObject().fluentPut("item_supplier_info", supplierInfo)); + } + + private void validateParameter(List supplierInfo) throws DWBusinessException { + if (Objects.isNull(supplierInfo) || supplierInfo.isEmpty()) { + throw new DWBusinessException("入参数据为空"); + } + for (FontSupplierEntity item : supplierInfo) { + if (StringUtils.isEmpty(item.getItemNo())) { + throw new DWBusinessException("品号字段值不为空或者NULL"); + } + if (StringUtils.isEmpty(item.getItemName())) { + throw new DWBusinessException("品名字段值不为空或者NULL"); + } + if (StringUtils.isEmpty(item.getSupplierNo())) { + throw new DWBusinessException("供应商编号字段值不为空或者NULL"); + } + if (StringUtils.isEmpty(item.getSupplierName())) { + throw new DWBusinessException("供应商名称字段值不为空或者NULL"); + } + } + List distinctList = supplierInfo.stream().filter(distinctByKey(item -> Stream.of(item.getItemNo(), item.getSupplierNo()).toArray())).collect(Collectors.toList()); + if (supplierInfo.size() > distinctList.size()) { + throw new DWBusinessException("品号和供应商编号入参重复"); + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FontSupplierEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); + List entityList =fontSupplierService.list(queryWrapper); + + if (!entityList.isEmpty()) { + for (FontSupplierEntity executorEntity : entityList) { + String itemNo = executorEntity.getItemNo(); + String executorNo = executorEntity.getSupplierNo(); + boolean match = supplierInfo.stream().anyMatch(item -> Objects.equals(item.getItemNo(), itemNo) + && Objects.equals(item.getSupplierNo(), executorNo)); + if (match) { + throw new DWBusinessException("品号和供应商编号入参重复"); + } + } + } + } + + /** + * 用于对象去重 + * + * @param keyExtractor 需要去重的属性 + * @param + * @return + */ + private static Predicate distinctByKey(Function keyExtractor) { + //记录已有对象或者属性 + ConcurrentSkipListMap skipListMap = new ConcurrentSkipListMap<>(); + return t -> skipListMap.putIfAbsent(JSON.toJSONString(keyExtractor.apply(t)), Boolean.TRUE) == null; + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java new file mode 100644 index 0000000..8a8283e --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java @@ -0,0 +1,46 @@ +package com.digiwin.athena.app.service.supplier; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.service.FontSupplierService; +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 lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @auther: bk + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class FontSupplierDeleteEAIService extends AbsEAIService { + + + @Resource + private FontSupplierService fontSupplierService; + + @Override + public String getServiceName() { + return FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + EAIRequest eaiRequest = EAIRequest.build(messageBody); + List supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER); + List collect = supplierInfo.stream().map(FontSupplierEntity::getId).collect(Collectors.toList()); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.in(FontSupplierEntity::getId,collect); + fontSupplierService.remove(lmq); + return EAIUtil.buildEAIResult(new HashMap<>()); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java new file mode 100644 index 0000000..009fcdd --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java @@ -0,0 +1,61 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.JSONObject; +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.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.service.FontSupplierService; +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 javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * @auther: bk + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class FontSupplierGetEAIService extends AbsEAIService { + + + @Resource + private FontSupplierService fontSupplierService; + + @Override + public String getServiceName() { + return FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_GET; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + EAIRequest eaiRequest = EAIRequest.build(messageBody); + List supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(FontSupplierEntity::getTenantId, SecurityUtil.getUserProfile().getTenantId()); + if (CollectionUtils.isNotEmpty(supplierInfo)) { + lmq.and( + queryWrapperInner -> { + for (FontSupplierEntity fontSupplierEntity : supplierInfo) { + queryWrapperInner.or( + wrapper -> wrapper + .eq(FontSupplierEntity::getItemNo, fontSupplierEntity.getItemNo()) + .eq(FontSupplierEntity::getItemName, fontSupplierEntity.getItemName()) + .eq(FontSupplierEntity::getSupplierNo, fontSupplierEntity.getSupplierNo()) + .eq(FontSupplierEntity::getSupplierName, fontSupplierEntity.getSupplierName()) + ); + } + }); + } + + List list = fontSupplierService.list(lmq); + return EAIUtil.buildEAIResult(new JSONObject().fluentPut("item_supplier_info", list)); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java new file mode 100644 index 0000000..be3ae56 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java @@ -0,0 +1,91 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.JSON; +import com.digiwin.app.container.exceptions.DWBusinessException; +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.entity.ItemExecutorEntity; +import com.digiwin.athena.app.infra.service.FontSupplierService; +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 lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentSkipListMap; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * @auther: bk + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class FontSupplierUpdateEAIService extends AbsEAIService { + + @Resource + private FontSupplierService supplierService; + + @Override + public String getServiceName() { + return FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_UPDATE; + } + + @Override + public DWEAIResult execute(Map headers, String messageBody) throws Exception { + EAIRequest eaiRequest = EAIRequest.build(messageBody); + List supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER); + + //对必传参数 且 品号和执行人编号不可以重复 进行校验 + validateParameter(supplierInfo); + + supplierService.updateBatchById(supplierInfo); + return EAIUtil.buildEAIResult(new HashMap<>()); + } + + private void validateParameter(List supplierInfo) throws DWBusinessException { + if (Objects.isNull(supplierInfo) || supplierInfo.isEmpty()) { + throw new DWBusinessException("入参数据为空"); + } + for (FontSupplierEntity item : supplierInfo) { + if (StringUtils.isEmpty(item.getItemNo())) { + throw new DWBusinessException("品号字段值为空或者NULL"); + } + if (StringUtils.isEmpty(item.getItemName())) { + throw new DWBusinessException("品名字段值为空或者NULL"); + } + if (StringUtils.isEmpty(item.getSupplierNo())) { + throw new DWBusinessException("供应商no为空或者NULL"); + } + if (StringUtils.isEmpty(item.getSupplierName())) { + throw new DWBusinessException("供应商name为空或者NULL"); + } + } + List distinctList = supplierInfo.stream().filter(distinctByKey(item -> Stream.of(item.getItemNo(), item.getSupplierNo()).toArray())).collect(Collectors.toList()); + if (supplierInfo.size() > distinctList.size()) { + throw new DWBusinessException("品号和供应商编号入参重复"); + } + } + + /** + * 用于对象去重 + * + * @param keyExtractor 需要去重的属性 + * @param + * @return + */ + private static Predicate distinctByKey(Function keyExtractor) { + //记录已有对象或者属性 + ConcurrentSkipListMap skipListMap = new ConcurrentSkipListMap<>(); + return t -> skipListMap.putIfAbsent(JSON.toJSONString(keyExtractor.apply(t)), Boolean.TRUE) == null; + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUtil.java new file mode 100644 index 0000000..82e6f5a --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUtil.java @@ -0,0 +1,29 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.TypeReference; +import com.digiwin.athena.app.infra.entity.FontSupplierEntity; +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; + +import java.awt.*; +import java.util.List; + +/** + * @auther: bk + * @date: 2023/8/31 + */ +public class FontSupplierUtil { + + /** + * 品号供应商get,update,delete + */ + public static final String DEMO_FONT_ITEM_SUPPLIER_INFO_UPDATE = "demo.font.item.supplier.info.update"; + + public static final String DEMO_FONT_ITEM_SUPPLIER_INFO_GET = "demo.font.item.supplier.info.get"; + + public static final String DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE = "demo.font.item.supplier.info.delete"; + + public static final String DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE = "demo.font.item.supplier.info.create"; + + public static final TypeReference> LIST_ENTITY_SUPPLIER = new TypeReference>() { + }; +}