From 0225703e7a84d2e9793c4e52e40de4e8dc9050dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Tue, 18 Feb 2025 17:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/utils/MathUtils.java | 10 ++++++++++ .../common/utils/collection/CollectionUtils.java | 9 +++++++++ .../java/com/ruoyi/yh/price/domain/PriceQuery.java | 10 ++++++++++ .../java/com/ruoyi/yh/price/mapper/PriceMapper.xml | 3 +++ .../yh/report/service/impl/ReportValidatorImpl.java | 12 ++++++++++-- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/MathUtils.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/MathUtils.java index 82c3039..b1f2612 100644 --- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/MathUtils.java +++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/MathUtils.java @@ -56,4 +56,14 @@ public class MathUtils { public static Long IntegerToLong(Integer num) { return num == null ? null : Long.valueOf(num); } + + // 大于 + public static boolean biggerThan(BigDecimal userNum, BigDecimal num) { + return userNum != null && num != null && userNum.compareTo(num) > 0; + } + + // 小于 + public static boolean smallerThan(BigDecimal userNum, BigDecimal num) { + return userNum != null && num != null && userNum.compareTo(num) < 0; + } } diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java index 296aacd..6467ee2 100644 --- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java +++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java @@ -2,6 +2,7 @@ package com.ruoyi.common.utils.collection; import com.ruoyi.common.utils.DateUtils; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.*; import java.util.function.Function; @@ -209,4 +210,12 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils { return result; } + + + /** + * 计算集合中BigDecimal的和 + */ + public static BigDecimal sumDecimal(Collection collection, Function decimalMapper) { + return collection.stream().map(decimalMapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java index 04582c1..cd0bcda 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java @@ -28,4 +28,14 @@ public class PriceQuery extends PriceVO { @ApiModelProperty("关键词列表") private List keywords; + + @ApiModelProperty("精准分类") + private String eqCategory; + + @ApiModelProperty("精准大小") + private String eqSize; + + @ApiModelProperty("精准图案") + private String eqPattern; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml index 6a47e1c..f9f6dfd 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml @@ -67,6 +67,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bp.deleted = false and bp.code like concat('%', #{query.code}, '%') and bp.surface like concat('%', #{query.surface}, '%') + and bp.category = #{query.eqCategory} + and bp.size = #{query.eqSize} + and bp.pattern = #{query.eqPattern} and ( bp.name like concat('%', #{query.keyword}, '%') diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java index d5b1ace..8c09f04 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.yh.report.service.impl; import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.utils.MathUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.system.service.ISysUserService; @@ -17,6 +18,7 @@ import com.ruoyi.yh.report.domain.bo.ReportBO; import com.ruoyi.yh.report.domain.enums.ReportStatus; import com.ruoyi.yh.report.service.ReportValidator; import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO; +import com.ruoyi.yh.reportOrderProd.domain.bo.ReportOrderProdBO; import com.ruoyi.yh.reportProd.domain.ReportProdVO; import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO; import com.ruoyi.yh.reportUserProd.domain.ReportUserProdVO; @@ -24,6 +26,7 @@ import com.ruoyi.yh.reportUserProd.domain.bo.ReportUserProdBO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Objects; @@ -132,10 +135,15 @@ public class ReportValidatorImpl implements ReportValidator { ServiceUtil.assertion(!PriceStatus.canCheckToReport().contains(price.getStatus()), "工序%s当前状态不允许被使用", price.getName()); ServiceUtil.assertion(price.getDisabled() == null || price.getDisabled(), "工序%s已被禁用,无法使用", price.getName()); + + // 校验是否超出工序的产量(员工、订单) + BigDecimal userNum = CollectionUtils.sumDecimal(prod.getUserProdList(), ReportUserProdBO::getNum); + ServiceUtil.assertion(MathUtils.biggerThan(userNum, prod.getNum()), "工序【%s】的用户产量超出工序的产量", prod.getPriceName()); + BigDecimal orderNum = CollectionUtils.sumDecimal(prod.getOrderProdList(), ReportOrderProdBO::getNum); + ServiceUtil.assertion(MathUtils.biggerThan(orderNum, prod.getNum()), "工序【%s】的订单产量超出工序的产量", prod.getPriceName()); } - - // TODO 员工是否当前报表可选(在当前报表的部门 or 排班在当前报表部门) + // 员工是否当前报表可选(在当前报表的部门 or 排班在当前报表部门) List userProdList = productList.stream().map(ReportProdBO::getUserProdList).flatMap(List::stream).collect(Collectors.toList()); SysUserQuery userQuery = new SysUserQuery(); userQuery.setUserIds(CollectionUtils.map(userProdList, ReportUserProdBO::getUserId));