Browse Source

供应商基础资料增删改查

master
baokuo 1 year ago
parent
commit
a1dce882f2
11 changed files with 516 additions and 0 deletions
  1. +46
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/FontSupplierEntity.java
  2. +11
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/FontSupplierRepository.java
  3. +11
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/FontSupplierService.java
  4. +16
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/FontSupplierServiceImpl.java
  5. +56
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/FontSupplierEAIService.java
  6. +40
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/FontSupplierEAIServiceImpl.java
  7. +109
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierCreateEAIService.java
  8. +46
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierDeleteEAIService.java
  9. +61
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierGetEAIService.java
  10. +91
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/supplier/FontSupplierUpdateEAIService.java
  11. +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;
}

+ 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> {
}

+ 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;
}

+ 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);
}
}

+ 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