Byd_Dg_Java/youchain-system/src/test/java/com/youchain/EladminSystemApplicationTes...

243 lines
8.0 KiB
Java
Raw Normal View History

2024-05-29 18:21:05 +08:00
package com.youchain;
2024-06-24 15:58:49 +08:00
import com.youchain.basicdata.domain.BigItem;
2025-02-25 09:11:10 +08:00
import com.youchain.basicdata.domain.Point;
2024-07-01 20:38:35 +08:00
import com.youchain.basicdata.vo.BarCodeVo;
2024-06-27 18:10:20 +08:00
import com.youchain.businessdata.domain.PickDetail;
2024-08-27 10:26:23 +08:00
import com.youchain.exception.BadRequestException;
2024-07-17 16:49:29 +08:00
import com.youchain.utils.BaseStatus;
2025-03-05 14:26:52 +08:00
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
2024-05-29 18:21:05 +08:00
import org.junit.jupiter.api.Test;
2025-03-05 14:26:52 +08:00
import org.springframework.beans.factory.annotation.Autowired;
2024-05-29 18:21:05 +08:00
import org.springframework.boot.test.context.SpringBootTest;
2024-06-27 18:10:20 +08:00
2024-07-01 20:38:35 +08:00
import java.util.*;
import java.util.concurrent.*;
2024-08-20 15:11:45 +08:00
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2024-06-24 15:58:49 +08:00
import java.util.stream.Collectors;
2024-05-29 18:21:05 +08:00
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class EladminSystemApplicationTests {
2025-03-05 14:26:52 +08:00
@Autowired
private static TestService testService;
2024-05-29 18:21:05 +08:00
@Test
public void contextLoads() {
}
public static void main(String[] args) {
2025-03-10 10:43:05 +08:00
String pointCode = "QXJL002";
String currentCallPoint="QXJL001,QXJL002,QXJL001";
Set<String> callPointSet = new HashSet<>(Arrays.asList(currentCallPoint.split(",")));
callPointSet.add(pointCode);
String newCallPoint = String.join(",", callPointSet);
System.out.println(newCallPoint);
}
public void cc1(){
2025-03-05 14:26:52 +08:00
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
// 设置服务接口
factory.setServiceClass(TestService.class);
// 设置服务地址
factory.setAddress("http://example.com/yourService");
2025-03-04 17:44:49 +08:00
2025-03-05 14:26:52 +08:00
String result = testService.pickAndPost("123");
2025-03-04 17:44:49 +08:00
}
public void cc(){
2025-02-25 17:25:35 +08:00
// 创建一个 HashSet 实例
Set<String> hashSet = new HashSet<>();
// 向集合中添加元素
2025-03-03 17:18:59 +08:00
hashSet.add("QXJL002");
2025-02-25 17:25:35 +08:00
hashSet.add("QXJL002");
2025-02-25 09:11:10 +08:00
2025-02-25 17:25:35 +08:00
// 打印原始集合
System.out.println("原始集合: " + hashSet);
2025-02-23 13:19:03 +08:00
2025-02-25 17:25:35 +08:00
// 尝试移除 "apple" 元素
boolean isRemoved = hashSet.remove("QXJL001");
2025-02-25 09:11:10 +08:00
2025-02-25 17:25:35 +08:00
if (isRemoved) {
System.out.println("集合中包含元素 apple已成功移除。");
} else {
System.out.println("集合中不包含元素 apple。");
}
2025-02-25 09:11:10 +08:00
2025-02-25 17:25:35 +08:00
// 打印移除元素后的集合
String result = hashSet.stream()
.collect(Collectors.joining(", "));
if(result.isEmpty()){
System.out.println("kong");
}else{
System.out.println(result);
2025-02-23 13:19:03 +08:00
}
2025-02-25 09:11:10 +08:00
}
public static List<String> getValuesFromMap(List<String> list, Map<String, String> map) {
List<String> values = new ArrayList<>();
int count = list.size();
int index = 0;
2025-02-23 13:19:03 +08:00
2025-02-25 09:11:10 +08:00
// 遍历 map 的键值对
for (Map.Entry<String, String> entry : map.entrySet()) {
if (index >= count) {
break;
}
values.add(entry.getValue());
index++;
}
return values;
2024-07-19 15:59:25 +08:00
}
static Set bb(Set set1, Set set2) {
Set<String> difference = new HashSet<>(set1);
difference.addAll(set2);
Set<String> tmp = new HashSet<>(set1);
tmp.retainAll(set2);
difference.removeAll(tmp);
return difference;
2024-07-17 16:49:29 +08:00
}
private static final int MAX_TASK_COUNT = 4;
private static final long TIMEOUT_MS = 600000; // 10分钟以毫秒为单位
private long lastTaskTime = System.currentTimeMillis();
private List<Integer> taskQueue = new ArrayList<>(MAX_TASK_COUNT);
void aa() {
2024-07-19 15:59:25 +08:00
Set<String> itemCodes = new HashSet<>();
itemCodes.add("A");
itemCodes.add("B");
itemCodes.add("C");
itemCodes.add("D");
Set<String> newItemCodes = new HashSet<>();
newItemCodes.add("A");
newItemCodes.add("B");
Set<String> difference = bb(itemCodes, newItemCodes);
StringBuffer sbf = new StringBuffer();
sbf.append("WMS不存在的物料集合,请维护:").append(difference);
System.out.println(sbf.toString());
2024-07-10 16:29:34 +08:00
List<String> list = new ArrayList<>();
list.add("物料库存不足,请先补充库存!");
list.add("数量已分配!");
list.add("托盘有任务,请先完成任务!");
boolean containsSuccess = list.stream().anyMatch(s -> s.contains("分配成功"));
if (containsSuccess) {
System.out.println("集合中存在分配成功的信息!");
} else {
System.out.println("集合中不存在分配成功的信息!");
}
2024-07-31 17:21:20 +08:00
2024-07-01 20:38:35 +08:00
Set<BarCodeVo> barCodeVos = new HashSet<>();
BarCodeVo barCodeVo = new BarCodeVo();
barCodeVo.setItemCode("123");
barCodeVo.setBoxNumber("1");
barCodeVos.add(barCodeVo);
BarCodeVo barCodeVo2 = new BarCodeVo();
barCodeVo2.setItemCode("123");
barCodeVo2.setBoxNumber("2");
barCodeVos.add(barCodeVo2);
BarCodeVo barCodeVo3 = new BarCodeVo();
barCodeVo3.setItemCode("456");
barCodeVo3.setBoxNumber("3");
barCodeVos.add(barCodeVo3);
for (BarCodeVo vo : barCodeVos) {
System.out.println(vo.getItemCode());
}
String firstItemCode = barCodeVos.iterator().next().getItemCode();
boolean allSame = barCodeVos.stream()
.allMatch(vo -> vo.getItemCode().equals(firstItemCode));
if (allSame) {
System.out.println("全部匹配");
} else {
System.out.println("不匹配");
}
2024-06-27 18:10:20 +08:00
PickDetail pickDetail1 = new PickDetail();
pickDetail1.setId(1L);
pickDetail1.setOrderQty(2d);
pickDetail1.setAllocatedQty(2d);
PickDetail pickDetail2 = new PickDetail();
pickDetail2.setId(2L);
pickDetail2.setOrderQty(2d);
pickDetail2.setAllocatedQty(2d);
PickDetail pickDetail3 = new PickDetail();
pickDetail3.setId(2L);
pickDetail3.setOrderQty(2d);
pickDetail3.setAllocatedQty(0d);
List<PickDetail> pickDetails = new ArrayList<>();
pickDetails.add(pickDetail1);
pickDetails.add(pickDetail2);
pickDetails.add(pickDetail3);
boolean allAllocated = pickDetails.stream()
.allMatch(detail -> detail.getOrderQty().equals(detail.getAllocatedQty()));
boolean anyAllocated = pickDetails.stream()
.anyMatch(detail -> detail.getOrderQty().equals(detail.getAllocatedQty()));
2024-07-01 20:38:35 +08:00
if (allAllocated) {
2024-06-27 18:10:20 +08:00
System.out.println("全部已分配");
2024-07-01 20:38:35 +08:00
} else if (anyAllocated) {
2024-06-27 18:10:20 +08:00
System.out.println("部分已分配");
}
2024-06-26 17:22:10 +08:00
List<Integer> list1 = Arrays.asList();
List<Integer> list2 = Arrays.asList();
List<Integer> list3 = new ArrayList<>(list1);
list3.addAll(list2);
System.out.println(list3); // 输出: [1, 2, 3, 4, 5]
2024-06-24 15:58:49 +08:00
/*double taoQty=2;//基础套数
double xTaoQty=3;//需求套数
double ckdQty=Math.ceil(xTaoQty/taoQty);//生成出库单数量
System.out.println(ckdQty);*/
}
2024-05-29 18:21:05 +08:00
@Test
2024-06-27 18:10:20 +08:00
public void test() {
List<Integer> taskLists = new ArrayList<>();
2024-05-29 18:21:05 +08:00
taskLists.add(1);
taskLists.add(2);
taskLists.add(3);
taskLists.add(4);
taskLists.add(5);
taskLists.add(6);
2024-06-27 18:10:20 +08:00
for (Integer id : taskLists) {
2024-05-29 18:21:05 +08:00
try {
taskQueue.add(id);
if (taskQueue.size() >= MAX_TASK_COUNT) {
System.out.println("任务已满足,当前任务数:" + taskQueue.size());
taskQueue.clear();
lastTaskTime = System.currentTimeMillis();
} else if (System.currentTimeMillis() - lastTaskTime >= TIMEOUT_MS) {
System.out.println("超过10分钟未满足4个任务当前任务数" + taskQueue.size());
taskQueue.clear();
lastTaskTime = System.currentTimeMillis();
}
} catch (Exception e) {
2024-08-27 10:26:23 +08:00
throw new BadRequestException(e.getMessage());
2024-05-29 18:21:05 +08:00
}
System.out.println(id);
}
}
}