Browse Source

Merge branch 'feature/S3' into release/S3

master
clong 1 year ago
parent
commit
b5107999a4
18 changed files with 693 additions and 2 deletions
  1. +46
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java
  2. +15
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java
  3. +60
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/PurchaseOrderDetailMapper.xml
  4. +11
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/FontSupplierRepository.java
  5. +8
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java
  6. +11
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/FontSupplierService.java
  7. +16
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java
  8. +56
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java
  9. +5
    -2
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java
  10. +40
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/FontSupplierEAIServiceImpl.java
  11. +5
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java
  12. +79
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseOrderUpdateEAIService.java
  13. +5
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java
  14. +109
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java
  15. +46
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java
  16. +61
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java
  17. +91
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java
  18. +29
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUtil.java

+ 46
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java View File

@ -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<FontSupplierEntity> {
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;
}

+ 15
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/PurchaseOrderDetailEntity.java View File

@ -31,72 +31,84 @@ public class PurchaseOrderDetailEntity extends BaseMgrEntity<PurchaseOrderDetail
* 请购单号
*/
@SerializedName(value = "purchase_order_no")
@JsonProperty(value = "purchase_order_no")
private String purchaseOrderNo;
/**
* 请购单序号
*/
@SerializedName(value = "purchase_order_seq")
@JsonProperty(value = "purchase_order_seq")
private String purchaseOrderSeq;
/**
* 品号
*/
@SerializedName(value = "item_no")
@JsonProperty(value = "item_no")
private String itemNo;
/**
* 品名
*/
@SerializedName(value = "item_name")
@JsonProperty(value = "item_name")
private String itemName;
/**
* 供应商名称
*/
@SerializedName(value = "supplier_name")
@JsonProperty(value = "supplier_name")
private String supplierName;
/**
* 供应商编号
*/
@SerializedName(value = "supplier_no")
@JsonProperty(value = "supplier_no")
private String supplierNo;
/**
* 请购数量
*/
@SerializedName(value = "requisition_num")
@JsonProperty(value = "requisition_num")
private Integer requisitionNum;
/**
* 采购数量
*/
@SerializedName(value = "purchase_num")
@JsonProperty(value = "purchase_num")
private Integer purchaseNum;
/**
* 采购单价
*/
@SerializedName(value = "purchase_price")
@JsonProperty(value = "purchase_price")
private BigDecimal purchasePrice;
/**
* 金额
*/
@SerializedName(value = "amount")
@JsonProperty(value = "amount")
private BigDecimal amount;
/**
* 采购剩余数量
*/
@SerializedName(value = "purchase_residue_num")
@JsonProperty(value = "purchase_residue_num")
private Integer purchaseResidueNum;
/**
* 采购执行人
*/
@SerializedName(value = "procurement_executor_code")
@JsonProperty(value = "procurement_executor_code")
private String procurementExecutorCode;
/**
@ -117,18 +129,21 @@ public class PurchaseOrderDetailEntity extends BaseMgrEntity<PurchaseOrderDetail
* 异常处理方式
*/
@SerializedName(value = "abnormal_handle_plan")
@JsonProperty(value = "abnormal_handle_plan")
private String abnormalHandlePlan;
/**
* 任务卡状态
*/
@SerializedName(value = "tab_status")
@JsonProperty(value = "tab_status")
private String tabStatus;
/**
* 任务卡类型:1是采购任务,2是交期回复任务,3是异常排除任务
*/
@SerializedName(value = "task_type")
@JsonProperty(value = "task_type")
private String taskType;
}

+ 60
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/PurchaseOrderDetailMapper.xml View File

@ -22,4 +22,64 @@
</update>
<update id="updateBatch">
<foreach collection="list" item="item" index="index" separator=";" open="" close="">
UPDATE cim_purchase_order_detail
<set>
<if test="item.itemNo != null and '' != item.itemNo">
item_no = #{item.itemNo},
</if>
<if test="item.itemName != null and '' != item.itemName">
item_name = #{item.itemName},
</if>
<if test="item.supplierName != null and '' != item.supplierName">
supplier_name = #{item.supplierName},
</if>
<if test="item.supplierNo != null and '' != item.supplierNo">
supplier_no = #{item.supplierNo},
</if>
<if test="item.requisitionNum != null ">
requisition_num = #{item.requisitionNum},
</if>
<if test="item.purchaseNum != null ">
purchase_num = #{item.purchaseNum},
</if>
<if test="item.purchasePrice != null ">
purchase_price = #{item.purchasePrice},
</if>
<if test="item.amount != null ">
amount = #{item.amount},
</if>
<if test="item.purchaseResidueNum != null ">
purchase_residue_num = #{item.purchaseResidueNum},
</if>
<if test="item.procurementExecutorCode != null ">
procurement_executor_code = #{item.procurementExecutorCode},
</if>
<if test="item.purchaseDate != null ">
purchase_date = #{item.purchaseDate},
</if>
<if test="item.expectedDate != null ">
expected_date = #{item.expectedDate},
</if>
<if test="item.abnormalHandlePlan != null and '' != item.abnormalHandlePlan">
abnormal_handle_plan = #{item.abnormalHandlePlan},
</if>
<if test="item.tabStatus != null and '' != item.tabStatus">
tab_status = #{item.tabStatus},
</if>
<if test="item.taskType != null and '' != item.taskType">
task_type = #{item.taskType},
</if>
modified_by = #{item.modifiedBy},
modified_date = #{item.modifiedDate}
</set>
WHERE tenantsid = #{item.tenantSid} AND purchase_order_no = #{item.purchaseOrderNo}
AND purchase_order_seq = #{item.purchaseOrderSeq}
</foreach>
</update>
</mapper>

+ 11
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/FontSupplierRepository.java View File

@ -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<FontSupplierEntity> {
}

+ 8
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/PurchaseOrderDetailRepository.java View File

@ -15,4 +15,12 @@ import java.util.List;
public interface PurchaseOrderDetailRepository extends BaseRepository<PurchaseOrderDetailEntity> {
public void updateAbnormalHandlePlan(@Param("list") List<PurchaseOrderDetailEntity> list);
/**
* 请购采购更新
*
* @param entityList
*/
void updateBatch(@Param("list") List<PurchaseOrderDetailEntity> entityList);
}

+ 11
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/FontSupplierService.java View File

@ -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<FontSupplierEntity> {
}

+ 16
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java View File

@ -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<FontSupplierRepository, FontSupplierEntity> implements FontSupplierService {
}

+ 56
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception;
/**
* 品号供应商获取
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_GET)
DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception;
/**
* 品号供应商新增
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE)
DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception;
/**
* 品号供应商删除
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE)
DWEAIResult delete(Map<String, String> headers, String messageBody) throws Exception;
}

+ 5
- 2
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/PurchaseDemoEAIService.java View File

@ -16,14 +16,17 @@ import java.util.Map;
*/
public interface PurchaseDemoEAIService extends DWService {
@AllowAnonymous
@EAIService(id = PurchaseUtil.DEMO_PURCHASE_DEMO_CREATE)
DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception;
@AllowAnonymous
@EAIService(id = PurchaseUtil.DEMO_PURCHASE_DEMO_GET)
DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception;
@EAIService(id = PurchaseUtil.DEMO_PURCHASE_ORDER_ABNORMAL_UPDATE)
DWEAIResult abnormalUpdate(Map<String, String> headers, String messageBody) throws Exception;
@EAIService(id = PurchaseUtil.DEMO_PURCHASE_ORDER_UPDATE)
DWEAIResult purchaseOrderUpdate(Map<String, String> headers, String messageBody) throws Exception;
}

+ 40
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/FontSupplierEAIServiceImpl.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_UPDATE,headers,messageBody);
}
@Override
public DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_GET,headers,messageBody);
}
@Override
public DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_CREATE,headers,messageBody);
}
@Override
public DWEAIResult delete(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(FontSupplierUtil.DEMO_FONT_ITEM_SUPPLIER_INFO_DELETE,headers,messageBody);
}
}

+ 5
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/PurchaseDemoEAIServiceImpl.java View File

@ -34,4 +34,9 @@ public class PurchaseDemoEAIServiceImpl implements PurchaseDemoEAIService {
public DWEAIResult abnormalUpdate(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(PurchaseUtil.DEMO_PURCHASE_ORDER_ABNORMAL_UPDATE, headers, messageBody);
}
@Override
public DWEAIResult purchaseOrderUpdate(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(PurchaseUtil.DEMO_PURCHASE_ORDER_UPDATE, headers, messageBody);
}
}

+ 79
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseOrderUpdateEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
EAIRequest request = new EAIRequest(messageBody);
List<PurchaseOrderDetailEntity> 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<PurchaseOrderDetailEntity> 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~");
}
}
}
}

+ 5
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/purchase/PurchaseUtil.java View File

@ -26,4 +26,9 @@ public class PurchaseUtil {
public static final TypeReference<List<PurchaseOrderDetailEntity>> LIST_ENTITY_PURCHASE = new TypeReference<List<PurchaseOrderDetailEntity>>() {
};
/**
* 请购单更新
*/
public static final String DEMO_PURCHASE_ORDER_UPDATE = "demo.purchase.order.update";
}

+ 109
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
EAIRequest eaiRequest = EAIRequest.build(messageBody);
List<FontSupplierEntity> 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<FontSupplierEntity> 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<FontSupplierEntity> 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<FontSupplierEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FontSupplierEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid());
List<FontSupplierEntity> 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 <T>
* @return
*/
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
//记录已有对象或者属性
ConcurrentSkipListMap<Object, Boolean> skipListMap = new ConcurrentSkipListMap<>();
return t -> skipListMap.putIfAbsent(JSON.toJSONString(keyExtractor.apply(t)), Boolean.TRUE) == null;
}
}

+ 46
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
EAIRequest eaiRequest = EAIRequest.build(messageBody);
List<FontSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER);
List<Long> collect = supplierInfo.stream().map(FontSupplierEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<FontSupplierEntity> lmq = new LambdaQueryWrapper<>();
lmq.in(FontSupplierEntity::getId,collect);
fontSupplierService.remove(lmq);
return EAIUtil.buildEAIResult(new HashMap<>());
}
}

+ 61
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
EAIRequest eaiRequest = EAIRequest.build(messageBody);
List<FontSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER);
LambdaQueryWrapper<FontSupplierEntity> 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<FontSupplierEntity> list = fontSupplierService.list(lmq);
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("item_supplier_info", list));
}
}

+ 91
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java View File

@ -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<String, String> headers, String messageBody) throws Exception {
EAIRequest eaiRequest = EAIRequest.build(messageBody);
List<FontSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", FontSupplierUtil.LIST_ENTITY_SUPPLIER);
//对必传参数 品号和执行人编号不可以重复 进行校验
validateParameter(supplierInfo);
supplierService.updateBatchById(supplierInfo);
return EAIUtil.buildEAIResult(new HashMap<>());
}
private void validateParameter(List<FontSupplierEntity> 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<FontSupplierEntity> 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 <T>
* @return
*/
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
//记录已有对象或者属性
ConcurrentSkipListMap<Object, Boolean> skipListMap = new ConcurrentSkipListMap<>();
return t -> skipListMap.putIfAbsent(JSON.toJSONString(keyExtractor.apply(t)), Boolean.TRUE) == null;
}
}

+ 29
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUtil.java View File

@ -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<FontSupplierEntity>> LIST_ENTITY_SUPPLIER = new TypeReference<List<FontSupplierEntity>>() {
};
}

Loading…
Cancel
Save