update 地锁逻辑修改

This commit is contained in:
2023-09-09 15:05:37 +08:00
parent 147a5df11b
commit c3c072d2a7
4 changed files with 129 additions and 23 deletions

View File

@@ -0,0 +1,85 @@
import com.google.common.collect.Lists;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @program: com.cjml.service.partitem
* @description:
* @author: dc
* @create: 2023-09-09 13:46
**/
public class Test {
public static void main(String[] args) {
List<Category> testList = Lists.newArrayList();
testList.add(new Category("100-50-10", 100, 50, 10));
testList.add(new Category("110-30-8", 110, 30, 8));
testList.add(new Category("0-10-12", 0, 10, 12));
testList = testList.stream().sorted(
Comparator.comparing(Category::getCategoryGroupSort, Comparator.reverseOrder())
.thenComparing(Category::getCategorySort, Comparator.reverseOrder())
.thenComparing(Category::getPartSort)
)
.collect(Collectors.toList());
System.out.println(testList.get(0).getCategoryName());
System.out.println(testList.get(1).getCategoryName());
System.out.println(testList.get(2).getCategoryName());
}
static class Category {
private String categoryName;
private int categoryGroupSort;
private int categorySort;
private int partSort;
public Category() {
}
public Category(String categoryName, int categoryGroupSort, int categorySort, int partSort) {
this.categoryName = categoryName;
this.categoryGroupSort = categoryGroupSort;
this.categorySort = categorySort;
this.partSort = partSort;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public int getCategoryGroupSort() {
return categoryGroupSort;
}
public void setCategoryGroupSort(int categoryGroupSort) {
this.categoryGroupSort = categoryGroupSort;
}
public int getCategorySort() {
return categorySort;
}
public void setCategorySort(int categorySort) {
this.categorySort = categorySort;
}
public int getPartSort() {
return partSort;
}
public void setPartSort(int partSort) {
this.partSort = partSort;
}
}
}