diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/ItemSupplierEntity.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/ItemSupplierEntity.java new file mode 100644 index 0000000..ef65a4c --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/ItemSupplierEntity.java @@ -0,0 +1,45 @@ +package com.digiwin.athena.app.infra.entity; + +import java.math.BigDecimal; + +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 zhenggl + * @date 2023-08-31 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName(value = "cim_item_supplier", autoResultMap = true) +public class ItemSupplierEntity extends BaseMgrEntity { + + + /** 品号 */ + @SerializedName(value = "item_no") + private String itemNo; + + /** 品名 */ + @SerializedName(value = "item_name") + private String itemName; + + /** 供应商编号 */ + @SerializedName(value = "supplier_no") + private String supplierNo; + + /** 供应商名称 */ + @SerializedName(value = "supplier_name") + private String supplierName; + + /** 单价 */ + @SerializedName(value = "price") + private BigDecimal price; +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/SupplierRepository.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/SupplierRepository.java new file mode 100644 index 0000000..8cffe34 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/SupplierRepository.java @@ -0,0 +1,11 @@ +package com.digiwin.athena.app.infra.repository; + +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.opt.persistence.repository.BaseRepository; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +public interface SupplierRepository extends BaseRepository { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/SupplierServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/SupplierServiceImpl.java new file mode 100644 index 0000000..dc3fa8d --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/SupplierServiceImpl.java @@ -0,0 +1,16 @@ +package com.digiwin.athena.app.infra.service.Impl; + + +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.app.infra.repository.SupplierRepository; +import com.digiwin.athena.app.infra.service.SupplierService; +import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService; +import org.springframework.stereotype.Service; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +@Service +public class SupplierServiceImpl extends AbsBaseService implements SupplierService { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/SupplierService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/SupplierService.java new file mode 100644 index 0000000..1a9ea45 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/SupplierService.java @@ -0,0 +1,11 @@ +package com.digiwin.athena.app.infra.service; + +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.opt.persistence.service.IBaseService; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +public interface SupplierService extends IBaseService { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/SupplierEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/SupplierEAIService.java new file mode 100644 index 0000000..931b22c --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/SupplierEAIService.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.SupplierUtil; + +import java.util.Map; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +public interface SupplierEAIService extends DWService { + + + /** + * 品号供应商修改 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_UPDATE) + DWEAIResult update(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商获取 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_GET) + DWEAIResult get(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商新增 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_CREATE) + DWEAIResult create(Map headers, String messageBody) throws Exception; + + /** + * 品号供应商删除 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = SupplierUtil.DEMO_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/impl/SupplierEAIServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/SupplierEAIServiceImpl.java new file mode 100644 index 0000000..9c3906a --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/SupplierEAIServiceImpl.java @@ -0,0 +1,40 @@ +package com.digiwin.athena.app.provider.impl; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.provider.SupplierEAIService; +import com.digiwin.athena.app.service.supplier.SupplierUtil; +import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +public class SupplierEAIServiceImpl implements SupplierEAIService { + + @Resource + private EAIServiceContext eaiServiceContext; + + @Override + public DWEAIResult update(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_UPDATE,headers,messageBody); + } + + @Override + public DWEAIResult get(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_GET,headers,messageBody); + } + + + @Override + public DWEAIResult create(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_CREATE,headers,messageBody); + } + + @Override + public DWEAIResult delete(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_DELETE,headers,messageBody); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierCreateEAIService.java new file mode 100644 index 0000000..5f2e761 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierCreateEAIService.java @@ -0,0 +1,40 @@ +package com.digiwin.athena.app.service.supplier; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.app.infra.service.SupplierService; +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; + +/** + * @auther: zhenggl + * @date: 2023/9/1 + */ +@Log4j2 +@Service +public class SupplierCreateEAIService extends AbsEAIService { + + @Resource + private SupplierService supplierService; + + @Override + public String getServiceName() { + return SupplierUtil.DEMO_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", SupplierUtil.LIST_ENTITY_SUPPLIER); + supplierService.saveBatch(supplierInfo); + return EAIUtil.buildEAIResult(new HashMap<>()); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierDeleteEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierDeleteEAIService.java new file mode 100644 index 0000000..43c2e90 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierDeleteEAIService.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.ItemSupplierEntity; +import com.digiwin.athena.app.infra.service.SupplierService; +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: zhenggl + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class SupplierDeleteEAIService extends AbsEAIService { + + + @Resource + private SupplierService supplierService; + + @Override + public String getServiceName() { + return SupplierUtil.DEMO_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", SupplierUtil.LIST_ENTITY_SUPPLIER); + List collect = supplierInfo.stream().map(ItemSupplierEntity::getId).collect(Collectors.toList()); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.in(ItemSupplierEntity::getId,collect); + supplierService.remove(lmq); + return EAIUtil.buildEAIResult(new HashMap<>()); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierGetEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierGetEAIService.java new file mode 100644 index 0000000..e8fbe5b --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierGetEAIService.java @@ -0,0 +1,58 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.app.infra.service.SupplierService; +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: zhenggl + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class SupplierGetEAIService extends AbsEAIService { + + + @Resource + private SupplierService supplierService; + + @Override + public String getServiceName() { + return SupplierUtil.DEMO_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", SupplierUtil.LIST_ENTITY_SUPPLIER); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(ItemSupplierEntity::getTenantId, SecurityUtil.getUserProfile().getTenantId()); + lmq.and( + queryWrapperInner -> { + for (ItemSupplierEntity itemSupplierEntity : supplierInfo) { + queryWrapperInner.or( + wrapper -> wrapper + .eq(ItemSupplierEntity::getItemNo, itemSupplierEntity.getItemNo()) + .eq(ItemSupplierEntity::getItemName, itemSupplierEntity.getItemName()) + .eq(ItemSupplierEntity::getSupplierNo, itemSupplierEntity.getSupplierNo()) + .eq(ItemSupplierEntity::getSupplierName, itemSupplierEntity.getSupplierName()) + ); + } + }); + + List list = supplierService.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/SupplierUpdateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierUpdateEAIService.java new file mode 100644 index 0000000..1aea2a3 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierUpdateEAIService.java @@ -0,0 +1,40 @@ +package com.digiwin.athena.app.service.supplier; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; +import com.digiwin.athena.app.infra.service.SupplierService; +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; + +/** + * @auther: zhenggl + * @date: 2023/8/31 + */ +@Service +@Log4j2 +public class SupplierUpdateEAIService extends AbsEAIService { + + @Resource + private SupplierService supplierService; + + @Override + public String getServiceName() { + return SupplierUtil.DEMO_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", SupplierUtil.LIST_ENTITY_SUPPLIER); + supplierService.updateBatchById(supplierInfo); + return EAIUtil.buildEAIResult(new HashMap<>()); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierUtil.java new file mode 100644 index 0000000..94e55d5 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/SupplierUtil.java @@ -0,0 +1,27 @@ +package com.digiwin.athena.app.service.supplier; + +import com.alibaba.fastjson.TypeReference; +import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; + +import java.util.List; + +/** + * @auther: zhenggl + * @date: 2023/8/31 + */ +public class SupplierUtil { + + /** + * 品号供应商get,update,delete + */ + public static final String DEMO_ITEM_SUPPLIER_INFO_UPDATE = "demo.item.supplier.info.update"; + + public static final String DEMO_ITEM_SUPPLIER_INFO_GET = "demo.item.supplier.info.get"; + + public static final String DEMO_ITEM_SUPPLIER_INFO_DELETE = "demo.item.supplier.info.delete"; + + public static final String DEMO_ITEM_SUPPLIER_INFO_CREATE = "demo.item.supplier.info.create"; + + public static final TypeReference> LIST_ENTITY_SUPPLIER = new TypeReference>() { + }; +}