更新细节
This commit is contained in:
parent
1d0614f930
commit
0225703e7a
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <T> BigDecimal sumDecimal(Collection<T> collection, Function<T, BigDecimal> decimalMapper) {
|
||||
return collection.stream().map(decimalMapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,14 @@ public class PriceQuery extends PriceVO {
|
|||
|
||||
@ApiModelProperty("关键词列表")
|
||||
private List<String> keywords;
|
||||
|
||||
@ApiModelProperty("精准分类")
|
||||
private String eqCategory;
|
||||
|
||||
@ApiModelProperty("精准大小")
|
||||
private String eqSize;
|
||||
|
||||
@ApiModelProperty("精准图案")
|
||||
private String eqPattern;
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.deleted == null "> and bp.deleted = false</if>
|
||||
<if test="query.code != null and query.code!= ''"> and bp.code like concat('%', #{query.code}, '%')</if>
|
||||
<if test="query.surface != null and query.surface!= ''"> and bp.surface like concat('%', #{query.surface}, '%')</if>
|
||||
<if test="query.eqCategory != null and query.eqCategory != ''"> and bp.category = #{query.eqCategory}</if>
|
||||
<if test="query.eqSize != null and query.eqSize != ''"> and bp.size = #{query.eqSize}</if>
|
||||
<if test="query.eqPattern != null and query.eqPattern != ''"> and bp.pattern = #{query.eqPattern}</if>
|
||||
<if test="query.keyword != null and query.keyword != ''">
|
||||
and (
|
||||
bp.name like concat('%', #{query.keyword}, '%')
|
||||
|
|
|
@ -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<ReportUserProdBO> userProdList = productList.stream().map(ReportProdBO::getUserProdList).flatMap(List::stream).collect(Collectors.toList());
|
||||
SysUserQuery userQuery = new SysUserQuery();
|
||||
userQuery.setUserIds(CollectionUtils.map(userProdList, ReportUserProdBO::getUserId));
|
||||
|
|
Loading…
Reference in New Issue
Block a user