Browse Source

feat:品号执行人基础资料接口代码提交

master
xieps 1 year ago
parent
commit
0bddd4191d
12 changed files with 635 additions and 0 deletions
  1. +56
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/ItemExecutorEntity.java
  2. +21
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/ItemExecutorMapper.xml
  3. +24
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/ItemExecutorRepository.java
  4. +17
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/Impl/ItemExecutorServiceImpl.java
  5. +13
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/ItemExecutorService.java
  6. +71
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/ItemExecutorEAIService.java
  7. +44
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/ItemExecutorEAIServiceImpl.java
  8. +25
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ExecutorUtil.java
  9. +128
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorCreateEAIService.java
  10. +57
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorDeleteEAIService.java
  11. +68
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorGetEAIService.java
  12. +111
    -0
      demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorUpdateEAIService.java

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

@ -0,0 +1,56 @@
package com.digiwin.athena.app.infra.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: xieps
* @Date: 2023/8/30 14:03
* @Version 1.0
* @Description
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = "cim_item_execute", autoResultMap = true)
public class ItemExecutorEntity extends BaseMgrEntity<ItemExecutorEntity> {
/**
* 品号
*/
@SerializedName(value = "item_no")
@JsonProperty(value = "item_no")
private String itemNo;
/**
* 品名
*/
@SerializedName(value = "item_name")
@JsonProperty(value = "item_name")
private String itemName;
/**
* 执行人编号
*/
@SerializedName(value = "procurement_executor_code")
@JsonProperty(value = "procurement_executor_code")
private String procurementExecutorCode;
/**
* 执行人名称
*/
@SerializedName(value = "procurement_executor_name")
@JsonProperty(value = "procurement_executor_name")
private String procurementExecutorName;
}

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

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.digiwin.athena.app.infra.repository.ItemExecutorRepository">
<update id="updateBatch">
<foreach collection="list" item="item" index="index" separator=";" open="" close="">
UPDATE cim_item_execute
<set>
`item_name` = #{item.itemName},
`procurement_executor_name` = #{item.procurementExecutorName}
</set>
WHERE `tenantsid`=#{tenantSid} AND
`item_no`= #{item.itemNo} AND `procurement_executor_code` = #{item.procurementExecutorCode}
</foreach>
</update>
</mapper>

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

@ -0,0 +1,24 @@
package com.digiwin.athena.app.infra.repository;
import com.digiwin.athena.app.infra.entity.ItemExecutorEntity;
import com.digiwin.athena.opt.persistence.repository.BaseRepository;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author: xieps
* @Date: 2023/8/30 14:21
* @Version 1.0
* @Description
*/
public interface ItemExecutorRepository extends BaseRepository<ItemExecutorEntity> {
/**
* 批量更新
*
* @param itemExecutorInfo
* @param tenantSid
*/
void updateBatch(@Param("list") List<ItemExecutorEntity> itemExecutorInfo, @Param("tenantSid") long tenantSid);
}

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

@ -0,0 +1,17 @@
package com.digiwin.athena.app.infra.service.Impl;
import com.digiwin.athena.app.infra.entity.ItemExecutorEntity;
import com.digiwin.athena.app.infra.repository.ItemExecutorRepository;
import com.digiwin.athena.app.infra.service.ItemExecutorService;
import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService;
import org.springframework.stereotype.Service;
/**
* @Author: xieps
* @Date: 2023/8/30 14:20
* @Version 1.0
* @Description
*/
@Service
public class ItemExecutorServiceImpl extends AbsBaseService<ItemExecutorRepository, ItemExecutorEntity> implements ItemExecutorService {
}

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

@ -0,0 +1,13 @@
package com.digiwin.athena.app.infra.service;
import com.digiwin.athena.app.infra.entity.ItemExecutorEntity;
import com.digiwin.athena.opt.persistence.service.IBaseService;
/**
* @Author: xieps
* @Date: 2023/8/30 14:19
* @Version 1.0
* @Description
*/
public interface ItemExecutorService extends IBaseService<ItemExecutorEntity> {
}

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

@ -0,0 +1,71 @@
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.executor.ExecutorUtil;
import java.util.Map;
/**
* @Author: xieps
* @Date: 2023/9/4 10:28
* @Version 1.0
* @Description
*/
public interface ItemExecutorEAIService extends DWService {
/**
* 品号执行人信息新增
*
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_CREATE)
DWEAIResult itemExecutorInfoCreate(Map<String, String> headers, String messageBody) throws Exception;
/**
* 品号执行人信息查询
*
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_GET)
DWEAIResult itemExecutorInfoGet(Map<String, String> headers, String messageBody) throws Exception;
/**
* 品号执行人信息删除
*
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_DELETE)
DWEAIResult itemExecutorInfoDelete(Map<String, String> headers, String messageBody) throws Exception;
/**
* 品号执行人信息更新
*
* @param headers
* @param messageBody
* @return
* @throws Exception
*/
@EAIService(id = ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_UPDATE)
DWEAIResult itemExecutorInfoUpdate(Map<String, String> headers, String messageBody) throws Exception;
}

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

@ -0,0 +1,44 @@
package com.digiwin.athena.app.provider.impl;
import com.digiwin.app.service.DWEAIResult;
import com.digiwin.athena.app.provider.ItemExecutorEAIService;
import com.digiwin.athena.app.service.executor.ExecutorUtil;
import com.digiwin.athena.opt.common.eai.service.EAIServiceContext;
import javax.annotation.Resource;
import java.util.Map;
/**
* @Author: xieps
* @Date: 2023/9/4 10:31
* @Version 1.0
* @Description
*/
public class ItemExecutorEAIServiceImpl implements ItemExecutorEAIService {
@Resource
private EAIServiceContext eaiServiceContext;
@Override
public DWEAIResult itemExecutorInfoCreate(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_CREATE, headers, messageBody);
}
@Override
public DWEAIResult itemExecutorInfoGet(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_GET, headers, messageBody);
}
@Override
public DWEAIResult itemExecutorInfoDelete(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_DELETE, headers, messageBody);
}
@Override
public DWEAIResult itemExecutorInfoUpdate(Map<String, String> headers, String messageBody) throws Exception {
return eaiServiceContext.execute(ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_UPDATE, headers, messageBody);
}
}

+ 25
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ExecutorUtil.java View File

@ -0,0 +1,25 @@
package com.digiwin.athena.app.service.executor;
import com.alibaba.fastjson.TypeReference;
import com.digiwin.athena.app.infra.entity.ItemExecutorEntity;
import java.util.List;
/**
* @Author: xieps
* @Date: 2023/8/30 13:32
* @Version 1.0
* @Description
*/
public class ExecutorUtil {
public static final String DEMO_ITEM_EXECUTOR_INFO_CREATE = "demo.item.executor.info.create";
public static final String DEMO_ITEM_EXECUTOR_INFO_UPDATE = "demo.item.executor.info.update";
public static final String DEMO_ITEM_EXECUTOR_INFO_GET = "demo.item.executor.info.get";
public static final String DEMO_ITEM_EXECUTOR_INFO_DELETE = "demo.item.executor.info.delete";
public static final TypeReference<List<ItemExecutorEntity>> ITEM_EXECUTOR_LIST = new TypeReference<List<ItemExecutorEntity>>() {
};
}

+ 128
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorCreateEAIService.java View File

@ -0,0 +1,128 @@
package com.digiwin.athena.app.service.executor;
import com.alibaba.fastjson.JSON;
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.ItemExecutorEntity;
import com.digiwin.athena.app.infra.repository.ItemExecutorRepository;
import com.digiwin.athena.app.infra.service.ItemExecutorService;
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.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;
/**
* @Author: xieps
* @Date: 2023/8/30 14:33
* @Version 1.0
* @Description
*/
@Service
@Log4j2
public class ItemExecutorCreateEAIService extends AbsEAIService {
@Resource
private ItemExecutorRepository itemExecutorRepository;
@Resource
private ItemExecutorService itemExecutorService;
@Override
public String getServiceName() {
return ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_CREATE;
}
@Override
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception {
EAIRequest request = new EAIRequest(messageBody);
List<ItemExecutorEntity> itemExecutorInfo = request.getToList("item_executor_info", ItemExecutorEntity.class);
//对必传参数 品号和执行人编号不可以重复 进行校验
validateParameter(itemExecutorInfo);
//进行批量新增
itemExecutorService.saveBatch(itemExecutorInfo);
return EAIUtil.buildEAIResult(new HashMap<>());
}
/**
* 对入参进行参数校验
*
* @param itemExecutorInfo
* @throws DWBusinessException
*/
private void validateParameter(List<ItemExecutorEntity> itemExecutorInfo) throws DWBusinessException {
if (Objects.isNull(itemExecutorInfo) || itemExecutorInfo.isEmpty()) {
throw new DWBusinessException("入参数据为空~~");
}
for (ItemExecutorEntity item : itemExecutorInfo) {
if (StringUtils.isEmpty(item.getItemNo())) {
throw new DWBusinessException("品号字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getItemName())) {
throw new DWBusinessException("品名字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getProcurementExecutorCode())) {
throw new DWBusinessException("执行人编号字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getProcurementExecutorName())) {
throw new DWBusinessException("执行人名称字段值不为空或者NULL~");
}
}
List<ItemExecutorEntity> distinctList = itemExecutorInfo.stream().filter(distinctByKey(item -> Stream.of(item.getItemNo(), item.getProcurementExecutorCode()).toArray())).collect(Collectors.toList());
if (itemExecutorInfo.size() > distinctList.size()) {
throw new DWBusinessException("品号和执行人编号入参重复~");
}
LambdaQueryWrapper<ItemExecutorEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ItemExecutorEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid());
List<ItemExecutorEntity> entityList = itemExecutorRepository.selectList(queryWrapper);
if (!entityList.isEmpty()) {
for (ItemExecutorEntity executorEntity : entityList) {
String itemNo = executorEntity.getItemNo();
String executorNo = executorEntity.getProcurementExecutorCode();
boolean match = itemExecutorInfo.stream().anyMatch(item -> Objects.equals(item.getItemNo(), itemNo)
&& Objects.equals(item.getProcurementExecutorCode(), 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;
}
}

+ 57
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorDeleteEAIService.java View File

@ -0,0 +1,57 @@
package com.digiwin.athena.app.service.executor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.digiwin.app.service.DWEAIResult;
import com.digiwin.athena.app.infra.repository.ItemExecutorRepository;
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.*;
/**
* @Author: xieps
* @Date: 2023/8/30 14:25
* @Version 1.0
* @Description
*/
@Service
@Log4j2
public class ItemExecutorDeleteEAIService extends AbsEAIService {
@Resource
private ItemExecutorRepository itemExecutorRepository;
@Override
public String getServiceName() {
return ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_DELETE;
}
@Override
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception {
JSONObject parameter = new EAIRequest(messageBody).getParameter();
JSONArray itemExecutorInfo = parameter.getJSONArray("item_executor_info");
List<Long> idList = new ArrayList<>();
for (Iterator<Object> iterator = itemExecutorInfo.iterator(); iterator.hasNext(); ) {
JSONObject item = (JSONObject) iterator.next();
Long id = item.getLong("id");
if (!Objects.isNull(id)) {
idList.add(id);
}
}
if (!idList.isEmpty()) {
itemExecutorRepository.deleteBatchIds(idList);
}
return EAIUtil.buildEAIResult(new HashMap<>());
}
}

+ 68
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorGetEAIService.java View File

@ -0,0 +1,68 @@
package com.digiwin.athena.app.service.executor;
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.ItemExecutorEntity;
import com.digiwin.athena.app.infra.repository.ItemExecutorRepository;
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.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Author: xieps
* @Date: 2023/8/30 13:55
* @Version 1.0
* @Description 品号执行人Get
*/
@Service
@Log4j2
public class ItemExecutorGetEAIService extends AbsEAIService {
@Resource
private ItemExecutorRepository itemExecutorRepository;
@Override
public String getServiceName() {
return ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_GET;
}
@Override
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception {
EAIRequest request = new EAIRequest(messageBody);
List<ItemExecutorEntity> itemExecutorInfo = request.getToList("item_executor_info", ItemExecutorEntity.class);
//组装查询条件 进行查询
LambdaQueryWrapper<ItemExecutorEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ItemExecutorEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid());
if (!itemExecutorInfo.isEmpty()) {
queryWrapper.and(
queryWrapperInner -> {
for (ItemExecutorEntity item : itemExecutorInfo) {
queryWrapperInner.or(
wrapper -> wrapper
.eq(!StringUtils.isEmpty(item.getItemNo()), ItemExecutorEntity::getItemNo, item.getItemNo())
.eq(!StringUtils.isEmpty(item.getItemName()), ItemExecutorEntity::getItemName, item.getItemName())
.eq(!StringUtils.isEmpty(item.getProcurementExecutorCode()), ItemExecutorEntity::getProcurementExecutorCode, item.getProcurementExecutorCode())
.eq(!StringUtils.isEmpty(item.getProcurementExecutorName()), ItemExecutorEntity::getProcurementExecutorName, item.getProcurementExecutorName())
);
}
}
);
}
List<ItemExecutorEntity> itemExecutorEntities = itemExecutorRepository.selectList(queryWrapper);
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("item_executor_info", itemExecutorEntities));
}
}

+ 111
- 0
demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/executor/ItemExecutorUpdateEAIService.java View File

@ -0,0 +1,111 @@
package com.digiwin.athena.app.service.executor;
import com.alibaba.fastjson.JSON;
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.ItemExecutorEntity;
import com.digiwin.athena.app.infra.repository.ItemExecutorRepository;
import com.digiwin.athena.app.infra.service.ItemExecutorService;
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.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;
/**
* @Author: xieps
* @Date: 2023/8/30 14:59
* @Version 1.0
* @Description
*/
@Service
@Log4j2
public class ItemExecutorUpdateEAIService extends AbsEAIService {
@Resource
private ItemExecutorService itemExecutorService;
@Resource
private ItemExecutorRepository itemExecutorRepository;
@Override
public String getServiceName() {
return ExecutorUtil.DEMO_ITEM_EXECUTOR_INFO_UPDATE;
}
@Override
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception {
EAIRequest request = new EAIRequest(messageBody);
List<ItemExecutorEntity> itemExecutorInfo = request.getToList("item_executor_info", ItemExecutorEntity.class);
//对必传参数 品号和执行人编号不可以重复 进行校验
validateParameter(itemExecutorInfo);
//根据品号和执行人编号进行更新
itemExecutorRepository.updateBatch(itemExecutorInfo, SecurityUtil.getUserProfile().getTenantSid());
return EAIUtil.buildEAIResult(new HashMap<>());
}
/**
* 对入参进行参数校验
*
* @param itemExecutorInfo
* @throws DWBusinessException
*/
private void validateParameter(List<ItemExecutorEntity> itemExecutorInfo) throws DWBusinessException {
if (Objects.isNull(itemExecutorInfo) || itemExecutorInfo.isEmpty()) {
throw new DWBusinessException("入参数据为空~~");
}
for (ItemExecutorEntity item : itemExecutorInfo) {
if (StringUtils.isEmpty(item.getItemNo())) {
throw new DWBusinessException("品号字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getItemName())) {
throw new DWBusinessException("品名字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getProcurementExecutorCode())) {
throw new DWBusinessException("执行人编号字段值不为空或者NULL~");
}
if (StringUtils.isEmpty(item.getProcurementExecutorName())) {
throw new DWBusinessException("执行人名称字段值不为空或者NULL~");
}
}
List<ItemExecutorEntity> distinctList = itemExecutorInfo.stream().filter(distinctByKey(item -> Stream.of(item.getItemNo(), item.getProcurementExecutorCode()).toArray())).collect(Collectors.toList());
if (itemExecutorInfo.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;
}
}

Loading…
Cancel
Save