批量新建库位
parent
8cae2ac0f6
commit
995bf973d8
|
|
@ -42,7 +42,7 @@ public class AreaEntity {
|
|||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean disabledFlag;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class AreaVO {
|
|||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否禁用")
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.lab1024.sa.admin.module.business.base.area.domain.form.AreaUpdateForm
|
|||
import net.lab1024.sa.admin.module.business.base.area.manager.AreaManager;
|
||||
import net.lab1024.sa.admin.module.business.base.location.service.LocationQueryService;
|
||||
import net.lab1024.sa.admin.util.JoinerResult;
|
||||
import net.lab1024.sa.admin.util.ResponseDTOUtils;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
|
|
@ -89,7 +90,6 @@ public class AreaService {
|
|||
}
|
||||
|
||||
JoinerResult joiner = JoinerResult.createJoiner();
|
||||
int sussCount = joiner.getSussCount();
|
||||
List<Long> idsToDelete = new ArrayList<>();
|
||||
for (Long id : idList) {
|
||||
AreaEntity area = areaManager.queryArea(id);
|
||||
|
|
@ -98,7 +98,6 @@ public class AreaService {
|
|||
} else {
|
||||
idsToDelete.add(id);
|
||||
joiner.getSussMsg().add(area.getAreaName() + "删除成功");
|
||||
joiner.setSussCount(sussCount++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,10 +108,7 @@ public class AreaService {
|
|||
areaManager.removeCache();
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("success", joiner.getSussCount() == idList.size() ? "删除成功" : joiner.getSussMsg().toString());
|
||||
jsonObject.put("error", joiner.getErrorMsg().toString());
|
||||
return ResponseDTO.ok(jsonObject.toString());
|
||||
return ResponseDTOUtils.buildResponseDTO(joiner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class ItemEntity {
|
|||
private BigDecimal packFactor;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean disabledFlag;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class ItemAddForm {
|
|||
private String itemType;
|
||||
|
||||
@Schema(description = "包装系数")
|
||||
@NotNull(message = "商品价格不能为空")
|
||||
@NotNull(message = "包装系数不能为空")
|
||||
@DecimalMin(value = "1", message = "包装系数最低1")
|
||||
private BigDecimal packFactor;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ItemVO {
|
|||
@Schema(description = "包装系数")
|
||||
private BigDecimal packFactor;
|
||||
|
||||
@Schema(description = "是否禁用")
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "物料类型")
|
||||
|
|
|
|||
|
|
@ -84,7 +84,14 @@ public class LocationController {
|
|||
@Operation(summary = "批量调整 霍锦")
|
||||
@PostMapping("/location/multipleAdjust")
|
||||
@SaCheckPermission("location:multipleAdjust")
|
||||
public ResponseDTO<String> multipleAdjust(@RequestBody MultipleAdjust multipleAdjust) {
|
||||
public ResponseDTO<String> multipleAdjust(@RequestBody @Valid MultipleAdjust multipleAdjust) {
|
||||
return locationService.multipleAdjust(multipleAdjust);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量调整 霍锦")
|
||||
@PostMapping("/location/multipleInsert")
|
||||
@SaCheckPermission("location:multipleInsert")
|
||||
public ResponseDTO<String> multipleInsert(@RequestBody @Valid MultipleInsert multipleInsert) {
|
||||
return locationService.multipleInsert(multipleInsert);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -17,6 +19,7 @@ import lombok.Data;
|
|||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("t_location")
|
||||
public class LocationEntity {
|
||||
|
||||
|
|
@ -47,24 +50,24 @@ public class LocationEntity {
|
|||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean disabledFlag;
|
||||
|
||||
/**
|
||||
* 排
|
||||
*/
|
||||
private Long locationRow;
|
||||
private String locationRow;
|
||||
|
||||
/**
|
||||
* 列
|
||||
*/
|
||||
private Long locationLine;
|
||||
private String locationLine;
|
||||
|
||||
/**
|
||||
* 层
|
||||
*/
|
||||
private Long locationCow;
|
||||
private String locationCow;
|
||||
|
||||
/**
|
||||
* 库位类型
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
package net.lab1024.sa.admin.module.business.base.location.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MultipleAdjust {
|
||||
@Schema(description = "库位集合")
|
||||
@Schema(description = "库位", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "库位 不能为空")
|
||||
List<Long> locationIds;
|
||||
|
||||
@Schema(description = "状态;true:空闲;false:占用")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,26 @@
|
|||
package net.lab1024.sa.admin.module.business.base.location.domain.form;public class MultipleInsert {
|
||||
}
|
||||
package net.lab1024.sa.admin.module.business.base.location.domain.form;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MultipleInsert {
|
||||
@Schema(description = "库位编码集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "库位 不能为空")
|
||||
List<String> locationCodes;
|
||||
|
||||
@Schema(description = "库区", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "库区 不能为空")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "库位类型")
|
||||
@NotBlank(message = "库位类型 不能为空 ")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String locationType;
|
||||
}
|
||||
|
|
@ -41,17 +41,17 @@ public class LocationVO {
|
|||
@Schema(description = "库区名称")
|
||||
private String areaName;
|
||||
|
||||
@Schema(description = "是否禁用")
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "排")
|
||||
private Long locationRow;
|
||||
private String locationRow;
|
||||
|
||||
@Schema(description = "列")
|
||||
private Long locationLine;
|
||||
private String locationLine;
|
||||
|
||||
@Schema(description = "层")
|
||||
private Long locationCow;
|
||||
private String locationCow;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String locationType;
|
||||
|
|
|
|||
|
|
@ -170,5 +170,17 @@ public class LocationQueryService {
|
|||
return locationDao.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据库位编码集合查询库位信息
|
||||
*
|
||||
* @param locationCodes 库位编码集合
|
||||
* @return List<LocationEntity>
|
||||
*/
|
||||
public List<LocationEntity> queryByLocationCodes(List<String> locationCodes) {
|
||||
LambdaQueryWrapper<LocationEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(LocationEntity::getLocationCode, locationCodes);
|
||||
return locationDao.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,29 @@
|
|||
package net.lab1024.sa.admin.module.business.base.location.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import net.lab1024.sa.admin.constant.UsageStatusEnum;
|
||||
import net.lab1024.sa.admin.module.business.base.location.dao.LocationDao;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationAddForm;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationUpdateForm;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.MultipleAdjust;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.MultipleInsert;
|
||||
import net.lab1024.sa.admin.module.business.base.location.manager.LocationManager;
|
||||
import net.lab1024.sa.admin.util.AdminRequestUtil;
|
||||
import net.lab1024.sa.admin.util.JoinerResult;
|
||||
import net.lab1024.sa.admin.util.ResponseDTOUtils;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -38,6 +48,9 @@ public class LocationService {
|
|||
@Resource
|
||||
private LocationQueryService locationQueryService;
|
||||
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
|
|
@ -116,6 +129,7 @@ public class LocationService {
|
|||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> multipleAdjust(MultipleAdjust multipleAdjust) {
|
||||
|
||||
if (CollectionUtils.isEmpty(multipleAdjust.getLocationIds())) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, UserErrorCode.PARAM_ERROR.getMsg());
|
||||
}
|
||||
|
|
@ -149,4 +163,89 @@ public class LocationService {
|
|||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建库位
|
||||
*
|
||||
* @param locationCode 库位编码
|
||||
* @param areaId 区域ID
|
||||
* @param locationRow 行
|
||||
* @param locationLine 列
|
||||
* @param locationCow 层
|
||||
* @param locationType 类型
|
||||
* @return LocationEntity
|
||||
*/
|
||||
public LocationEntity createLocation(String locationCode, Long areaId, String locationRow, String locationLine, String locationCow, String locationType) {
|
||||
return LocationEntity.builder()
|
||||
.locationCode(locationCode)
|
||||
.locationName(locationCode)
|
||||
.status(UsageStatusEnum.FREE.getValue())
|
||||
.areaId(areaId)
|
||||
.disabledFlag(true)
|
||||
.locationRow(locationRow)
|
||||
.locationLine(locationLine)
|
||||
.locationCow(locationCow)
|
||||
.locationType(locationType)
|
||||
.createUserId(SmartRequestUtil.getRequestUser().getUserId())
|
||||
.createUserName(SmartRequestUtil.getRequestUser().getUserName())
|
||||
.build();
|
||||
}
|
||||
|
||||
public void multipleInsert(List<String> locationCodes, Long areaId, String locationType) {
|
||||
List<LocationEntity> insertToLocation = new ArrayList<>();
|
||||
for (String locationCode : locationCodes) {
|
||||
int firstDashIndex = locationCode.indexOf('-');
|
||||
String[] parts = locationCode.substring(firstDashIndex + 1).split("-");
|
||||
String row = parts[0];
|
||||
String col = parts[1];
|
||||
String layer = parts[2];
|
||||
LocationEntity location = createLocation(locationCode, areaId, row, col, layer, locationType);
|
||||
insertToLocation.add(location);
|
||||
}
|
||||
//批量新增
|
||||
if (CollectionUtils.isNotEmpty(insertToLocation)) {
|
||||
locationDao.insert(insertToLocation);
|
||||
}
|
||||
|
||||
// 更新缓存
|
||||
locationManager.removeCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
*
|
||||
* @param multipleInsert 参数
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> multipleInsert(MultipleInsert multipleInsert) {
|
||||
//入参的所以库位集合
|
||||
List<String> locationCodes = multipleInsert.getLocationCodes();
|
||||
|
||||
//查询数据库已存在的库位集合
|
||||
List<LocationEntity> list = locationQueryService.queryByLocationCodes(locationCodes);
|
||||
JoinerResult joiner = JoinerResult.createJoiner();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
List<String> existingLocationCodes = list.stream()
|
||||
.map(LocationEntity::getLocationCode)
|
||||
.toList();
|
||||
// 获取两个集合的交集说明库位已存在;提示错误
|
||||
List<String> getIntersection = SmartStringUtil.getIntersection(locationCodes, existingLocationCodes);
|
||||
joiner.getErrorMsg().add(getIntersection + "库位已存在,新增失败");
|
||||
// 获取两个集合的非交集说明库位不存在;批量新增
|
||||
List<String> difference = SmartStringUtil.getDifference(locationCodes, existingLocationCodes);
|
||||
//批量新增
|
||||
multipleInsert(difference, multipleInsert.getAreaId(), multipleInsert.getLocationType());
|
||||
joiner.getSussMsg().add(difference + "库位新增成功");
|
||||
|
||||
return ResponseDTOUtils.buildResponseDTO(joiner);
|
||||
}
|
||||
|
||||
// 没有查询到库位,直接新增
|
||||
multipleInsert(locationCodes, multipleInsert.getAreaId(), multipleInsert.getLocationType());
|
||||
joiner.getSussMsg().add(locationCodes + "库位新增成功");
|
||||
|
||||
return ResponseDTOUtils.buildResponseDTO(joiner);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class CategoryEntity {
|
|||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 是否禁用
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean disabledFlag;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class EmployeeQueryForm extends PageParam {
|
|||
@Schema(description = "部门id")
|
||||
private Long departmentId;
|
||||
|
||||
@Schema(description = "是否禁用")
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "员工id集合")
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class RequestEmployee implements RequestUser {
|
|||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "是否禁用")
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "是否为超管")
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public interface MenuDao extends BaseMapper<MenuEntity> {
|
|||
* 查询菜单列表
|
||||
*
|
||||
* @param deletedFlag 是否删除
|
||||
* @param disabledFlag 是否禁用
|
||||
* @param disabledFlag 是否启用
|
||||
* @param menuTypeList 菜单类型集合
|
||||
*/
|
||||
List<MenuVO> queryMenuList(@Param("deletedFlag") Boolean deletedFlag, @Param("disabledFlag") Boolean disabledFlag, @Param("menuTypeList") List<Integer> menuTypeList);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ import java.util.StringJoiner;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class JoinerResult {
|
||||
StringJoiner sussMsg;
|
||||
StringJoiner errorMsg;
|
||||
int sussCount=0;
|
||||
|
||||
StringJoiner sussMsg = null;
|
||||
StringJoiner errorMsg = null;
|
||||
public static JoinerResult createJoiner() {
|
||||
return new JoinerResult(new StringJoiner(","), new StringJoiner(","), 0);
|
||||
return new JoinerResult(new StringJoiner(","), new StringJoiner(","));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,26 @@
|
|||
package net.lab1024.sa.admin.util;public class ResponseDTOUtils {
|
||||
package net.lab1024.sa.admin.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseDTOUtils {
|
||||
private ResponseDTOUtils() {
|
||||
// 私有构造函数,防止实例化
|
||||
}
|
||||
|
||||
public static ResponseDTO<String> buildResponseDTO(JoinerResult joiner) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (joiner.getSussMsg() != null) {
|
||||
jsonObject.put("success", joiner.getSussMsg().toString());
|
||||
}
|
||||
|
||||
if (joiner.getErrorMsg() != null) {
|
||||
jsonObject.put("error", joiner.getErrorMsg().toString());
|
||||
}
|
||||
return ResponseDTO.ok(jsonObject.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package net.lab1024.sa.admin;
|
||||
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
|
|
@ -13,12 +16,23 @@ import java.util.StringJoiner;
|
|||
public class AdminApplicationTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
StringJoiner sj = new StringJoiner(",");
|
||||
// 向 StringJoiner 中添加元素
|
||||
sj.add("apple");
|
||||
sj.add("banana");
|
||||
sj.add("cherry");
|
||||
System.out.println(sj.length());
|
||||
List<String> locationCodes = new ArrayList<>();
|
||||
locationCodes.add("A");
|
||||
locationCodes.add("B");
|
||||
locationCodes.add("C");
|
||||
|
||||
List<String> existingLocationCodes = new ArrayList<>();
|
||||
existingLocationCodes.add("B");
|
||||
|
||||
// 获取交集
|
||||
List<String> intersection = SmartStringUtil.getIntersection(locationCodes, existingLocationCodes);
|
||||
// 获取非交集
|
||||
List<String> difference = SmartStringUtil.getDifference(locationCodes, existingLocationCodes);
|
||||
|
||||
// 输出交集
|
||||
System.out.println("交集: " + intersection);
|
||||
// 输出非交集
|
||||
System.out.println("非交集: " + difference);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
|
|||
|
|
@ -116,6 +116,4 @@ public class ResponseDTO<T> {
|
|||
public static <T> ResponseDTO<T> errorData(ErrorCode errorCode, T data) {
|
||||
return new ResponseDTO<>(errorCode, false, null, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,5 +323,56 @@ public class SmartStringUtil extends StrUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取两个列表的交集
|
||||
* @param list1 第一个列表
|
||||
* @param list2 第二个列表
|
||||
* @return 交集列表
|
||||
*/
|
||||
public static List<String> getIntersection(List<String> list1, List<String> list2) {
|
||||
// 将 list2 转换为 HashSet,以便快速查找
|
||||
Set<String> set2 = new HashSet<>(list2);
|
||||
// 存储交集的列表
|
||||
List<String> intersection = new ArrayList<>();
|
||||
|
||||
// 遍历 list1
|
||||
for (String element : list1) {
|
||||
if (set2.contains(element)) {
|
||||
// 如果元素存在于 set2 中,则为交集元素
|
||||
intersection.add(element);
|
||||
}
|
||||
}
|
||||
return intersection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取两个列表的非交集
|
||||
* @param list1 第一个列表
|
||||
* @param list2 第二个列表
|
||||
* @return 非交集列表
|
||||
*/
|
||||
public static List<String> getDifference(List<String> list1, List<String> list2) {
|
||||
// 将 list2 转换为 HashSet,以便快速查找
|
||||
Set<String> set2 = new HashSet<>(list2);
|
||||
// 存储非交集的列表
|
||||
List<String> difference = new ArrayList<>();
|
||||
|
||||
// 遍历 list1,将不在 list2 中的元素添加到非交集中
|
||||
for (String element : list1) {
|
||||
if (!set2.contains(element)) {
|
||||
difference.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
// 将 list2 中不在 list1 中的元素添加到非交集中
|
||||
Set<String> set1 = new HashSet<>(list1);
|
||||
for (String element : list2) {
|
||||
if (!set1.contains(element)) {
|
||||
difference.add(element);
|
||||
}
|
||||
}
|
||||
return difference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue