|
|
|
@ -208,19 +208,21 @@ public class StudentClientLinkService extends CoreBaseService<StudentClientLink>
|
|
|
|
|
.limit(1, 1)
|
|
|
|
|
.select(StudentClientLink::getStudentClientLinkOrder);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(result)) {
|
|
|
|
|
StudentClientLink minOrderClientLink = result.get(0);
|
|
|
|
|
// 最小的排序值
|
|
|
|
|
BigDecimal minLinkOrder = minOrderClientLink.getStudentClientLinkOrder();
|
|
|
|
|
// 置顶就现有的最小值减1。但是需要确保结果小于0
|
|
|
|
|
BigDecimal calcedOrder = BigDecimal.valueOf(NumberUtil.sub(min(minLinkOrder.floatValue(), 0), 1));
|
|
|
|
|
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(calcedOrder);
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
if (CollectionUtil.isEmpty(result)) {
|
|
|
|
|
throw new PlatformException("已处于置顶状态!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudentClientLink minOrderClientLink = result.get(0);
|
|
|
|
|
// 最小的排序值
|
|
|
|
|
BigDecimal minLinkOrder = minOrderClientLink.getStudentClientLinkOrder();
|
|
|
|
|
// 置顶就现有的最小值减1。但是需要确保结果小于0
|
|
|
|
|
BigDecimal calcedOrder = BigDecimal.valueOf(NumberUtil.sub(min(minLinkOrder.floatValue(), 0), 1));
|
|
|
|
|
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(calcedOrder);
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -234,27 +236,28 @@ public class StudentClientLinkService extends CoreBaseService<StudentClientLink>
|
|
|
|
|
.limit(1, 2)
|
|
|
|
|
.select(StudentClientLink::getStudentClientLinkOrder);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(result)) {
|
|
|
|
|
// 找到应该安插的位置
|
|
|
|
|
BigDecimal LinkOrder0 = result.get(0).getStudentClientLinkOrder();
|
|
|
|
|
BigDecimal LinkOrder1 = LinkOrder0.subtract(BigDecimal.ONE);
|
|
|
|
|
if (result.size() == 2) {
|
|
|
|
|
LinkOrder1 = result.get(1).getStudentClientLinkOrder();
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isEmpty(result)) {
|
|
|
|
|
throw new PlatformException("已处于置顶状态!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BigDecimal min = NumberUtil.min(LinkOrder0, LinkOrder1);
|
|
|
|
|
BigDecimal max = NumberUtil.max(LinkOrder0, LinkOrder1);
|
|
|
|
|
// 找到应该安插的位置
|
|
|
|
|
BigDecimal LinkOrder0 = result.get(0).getStudentClientLinkOrder();
|
|
|
|
|
BigDecimal LinkOrder1 = LinkOrder0.subtract(BigDecimal.ONE);
|
|
|
|
|
if (result.size() == 2) {
|
|
|
|
|
LinkOrder1 = result.get(1).getStudentClientLinkOrder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 左移位后的值
|
|
|
|
|
double calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
|
|
|
|
|
BigDecimal min = NumberUtil.min(LinkOrder0, LinkOrder1);
|
|
|
|
|
BigDecimal max = NumberUtil.max(LinkOrder0, LinkOrder1);
|
|
|
|
|
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(BigDecimal.valueOf(calcedOrder));
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
// 左移位后的值
|
|
|
|
|
double calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(BigDecimal.valueOf(calcedOrder));
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -268,26 +271,28 @@ public class StudentClientLinkService extends CoreBaseService<StudentClientLink>
|
|
|
|
|
.limit(1, 2)
|
|
|
|
|
.select(StudentClientLink::getStudentClientLinkOrder);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(result)) {
|
|
|
|
|
// 找到应该安插的位置
|
|
|
|
|
BigDecimal LinkOrder0 = result.get(0).getStudentClientLinkOrder();
|
|
|
|
|
BigDecimal LinkOrder1 = LinkOrder0.add(BigDecimal.ONE);
|
|
|
|
|
if (result.size() == 2) {
|
|
|
|
|
LinkOrder1 = result.get(1).getStudentClientLinkOrder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BigDecimal min = NumberUtil.min(LinkOrder0, LinkOrder1);
|
|
|
|
|
BigDecimal max = NumberUtil.max(LinkOrder0, LinkOrder1);
|
|
|
|
|
|
|
|
|
|
// 右移位后的值
|
|
|
|
|
double calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(BigDecimal.valueOf(calcedOrder));
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
if (CollectionUtil.isEmpty(result)) {
|
|
|
|
|
throw new PlatformException("已处于置顶状态!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 找到应该安插的位置
|
|
|
|
|
BigDecimal LinkOrder0 = result.get(0).getStudentClientLinkOrder();
|
|
|
|
|
BigDecimal LinkOrder1 = LinkOrder0.add(BigDecimal.ONE);
|
|
|
|
|
if (result.size() == 2) {
|
|
|
|
|
LinkOrder1 = result.get(1).getStudentClientLinkOrder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BigDecimal min = NumberUtil.min(LinkOrder0, LinkOrder1);
|
|
|
|
|
BigDecimal max = NumberUtil.max(LinkOrder0, LinkOrder1);
|
|
|
|
|
|
|
|
|
|
// 右移位后的值
|
|
|
|
|
double calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
// 改变排序记录值
|
|
|
|
|
StudentClientLink updatePO = new StudentClientLink();
|
|
|
|
|
updatePO.setStudentClientLinkId(studentClientLink.getStudentClientLinkId());
|
|
|
|
|
updatePO.setStudentClientLinkOrder(BigDecimal.valueOf(calcedOrder));
|
|
|
|
|
updateTemplate(updatePO);
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|