更新
This commit is contained in:
parent
2ea21e2c6f
commit
a0d6e6897b
|
@ -0,0 +1,59 @@
|
|||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2025/1/17
|
||||
*/
|
||||
public class MathUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 判断a和b的值是否一致
|
||||
*/
|
||||
public static boolean equals(BigDecimal a, BigDecimal b) {
|
||||
return a != null && b != null && a.compareTo(b) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加法
|
||||
*/
|
||||
public static BigDecimal addDecimal(BigDecimal... values) {
|
||||
BigDecimal result = BigDecimal.ZERO;
|
||||
for (BigDecimal value : values) {
|
||||
if (value != null) {
|
||||
result = result.add(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 减法
|
||||
*/
|
||||
public static BigDecimal subtractDecimal(BigDecimal a, BigDecimal ...values) {
|
||||
BigDecimal result = a;
|
||||
for (BigDecimal value : values) {
|
||||
if (value != null) {
|
||||
result = result.subtract(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 乘法
|
||||
*/
|
||||
public static BigDecimal multiply(BigDecimal a, BigDecimal b) {
|
||||
if (a == null || b == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return a.multiply(b);
|
||||
}
|
||||
|
||||
// 把Integer转为Long类型
|
||||
public static Long IntegerToLong(Integer num) {
|
||||
return num == null ? null : Long.valueOf(num);
|
||||
}
|
||||
}
|
|
@ -22,4 +22,10 @@ public class PriceQuery extends PriceVO {
|
|||
|
||||
@ApiModelProperty("排除的单价ID列表")
|
||||
private List<Long> excludePriceIds;
|
||||
|
||||
@ApiModelProperty("关键词")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty("关键词列表")
|
||||
private List<String> keywords;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,22 @@ 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.keyword != null and query.keyword != ''">
|
||||
and (
|
||||
bp.name like concat('%', #{query.keyword}, '%')
|
||||
or bp.code like concat('%', #{query.keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="query.keywords != null and query.keywords.size() > 0">
|
||||
and (
|
||||
<foreach item="item" collection="query.keywords" separator=" and ">
|
||||
(
|
||||
bp.name like concat('%', #{item}, '%')
|
||||
or bp.code like concat('%', #{item}, '%')
|
||||
)
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="query.statusList != null and query.statusList.size() > 0">
|
||||
and bp.status in
|
||||
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
|
||||
|
|
|
@ -33,4 +33,7 @@ public class ProdOrderQuery extends ProdOrderVO {
|
|||
@ApiModelProperty("用户部门ID")
|
||||
private Long userDeptId;
|
||||
|
||||
@ApiModelProperty("关键词")
|
||||
private String keyword;
|
||||
|
||||
}
|
||||
|
|
|
@ -86,6 +86,12 @@
|
|||
<if test="query.materialGraphics != null and query.materialGraphics != ''">
|
||||
and bpo.material_graphics like concat('%',#{query.materialGraphics},'%')
|
||||
</if>
|
||||
<if test="query.keyword != null and query.keyword != ''">
|
||||
and (
|
||||
bpo.erp_bill_no like concat('%',#{query.keyword},'%')
|
||||
or bpo.material_number like concat('%',#{query.keyword},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="query.erpStatusList != null and query.erpStatusList.size() > 0">
|
||||
and bpo.erp_status in
|
||||
<foreach collection="query.erpStatusList" item="item" open="(" close=")" separator=",">
|
||||
|
|
|
@ -9,7 +9,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
@ -67,8 +66,6 @@ public class Report extends BaseEntity implements LogBizParam
|
|||
|
||||
@Excel(name = "总价(元)")
|
||||
@ApiModelProperty("总金额")
|
||||
@NotNull(message = "总金额不能为空")
|
||||
@Min(value = 0, message = "总金额必须大于0")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Excel(name = "创建人")
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package com.ruoyi.yh.report.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.yh.price.service.PriceService;
|
||||
import com.ruoyi.yh.report.domain.ReportVO;
|
||||
import com.ruoyi.yh.report.domain.bo.ReportBO;
|
||||
import com.ruoyi.yh.report.domain.enums.ReportStatus;
|
||||
|
@ -17,6 +16,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,7 +54,6 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
}
|
||||
bo.setCreateId(user.getUserId());
|
||||
bo.setReportDate(vo.getReportDate());
|
||||
bo.setTotalAmount(vo.getTotalAmount());
|
||||
bo.setCreateBy(user.getNickName());
|
||||
|
||||
// 报表产量数据
|
||||
|
@ -69,6 +68,7 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
// 组装数据
|
||||
bo.setProductList(productList);
|
||||
bo.setDept(deptService.selectDeptById(bo.getDeptId(), true));
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
return bo;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,6 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
bo.setReportId(vo.getReportId());
|
||||
bo.setDeptId(vo.getDeptId());
|
||||
bo.setReportDate(vo.getReportDate());
|
||||
bo.setTotalAmount(vo.getTotalAmount());
|
||||
if (submit) {
|
||||
bo.setStatus(ReportStatus.WAIT_VERIFY.getStatus());
|
||||
}
|
||||
|
@ -105,6 +104,17 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
bo.setProductList(productList);
|
||||
bo.setDept(deptService.selectDeptById(bo.getDeptId(), true));
|
||||
bo.setOld(reportService.selectReportByReportId(vo.getReportId()));
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
return bo;
|
||||
}
|
||||
|
||||
private BigDecimal calculateTotalAmount(ReportBO bo) {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
if (CollectionUtils.isNotEmpty(bo.getProductList())) {
|
||||
for (ReportProdBO item : bo.getProductList()) {
|
||||
totalAmount = MathUtils.addDecimal(totalAmount, item.getTotalAmount());
|
||||
}
|
||||
}
|
||||
return totalAmount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ReportValidatorImpl implements ReportValidator {
|
|||
if (prod == null || prod.getPriceId() == null) {
|
||||
continue;
|
||||
}
|
||||
ServiceUtil.assertion(!Objects.equals(prod.getPriceDeptId(), deptId), "工序%s不是部门%s的工序", prod.getPriceName(), vo.getDeptName());
|
||||
ServiceUtil.assertion(!Objects.equals(prod.getPriceDeptId(), deptId), "工序【%s】不是部门【%s】的工序", prod.getPriceName(), vo.getDeptName());
|
||||
}
|
||||
|
||||
// 订单校验
|
||||
|
@ -88,8 +88,8 @@ public class ReportValidatorImpl implements ReportValidator {
|
|||
if (orderProd == null || orderProd.getOrderId() == null) {
|
||||
continue;
|
||||
}
|
||||
ServiceUtil.assertion(!Objects.equals(orderProd.getOrderDeptId(), deptId), "订单%s不是部门%s的订单", orderProd.getOrderErpBillNo(), vo.getDeptName());
|
||||
ServiceUtil.assertion(!ProdOrderErpStatus.canReport().contains(orderProd.getOrderErpStatus()), "订单%s当前状态不允许关联", orderProd.getOrderErpBillNo());
|
||||
ServiceUtil.assertion(!Objects.equals(orderProd.getOrderDeptId(), deptId), "订单【%s】不是部门【%s】的订单", orderProd.getOrderErpBillNo(), vo.getDeptName());
|
||||
ServiceUtil.assertion(!ProdOrderErpStatus.canReport().contains(orderProd.getOrderErpStatus()), "订单【%s】当前状态不允许关联", orderProd.getOrderErpBillNo());
|
||||
}
|
||||
|
||||
// 员工是否当天在该部门排班
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package com.ruoyi.yh.reportProd.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.constant.DictType;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.system.valid.DictValid;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -43,7 +40,6 @@ public class ReportProd extends BaseEntity
|
|||
|
||||
@Excel(name = "不良品数")
|
||||
@ApiModelProperty("不良品数")
|
||||
@NotNull(message = "不良品数不允许为空")
|
||||
@Min(value = 0, message = "不良品数不允许小于0")
|
||||
private BigDecimal defectNum;
|
||||
|
||||
|
@ -89,10 +85,7 @@ public class ReportProd extends BaseEntity
|
|||
@ApiModelProperty("工序生产数量倍数分母(个)")
|
||||
private BigDecimal priceQuantityDenominator;
|
||||
|
||||
@Excel(name = "工序类型", dictType = DictType.PRICE_TYPE)
|
||||
@ApiModelProperty("工序类型")
|
||||
@NotBlank(message = "工序类型不允许为空")
|
||||
@DictValid(type = DictType.PRICE_TYPE, message = "非法的工序类型")
|
||||
private String priceType;
|
||||
|
||||
@Size(max = 200, message = "备注长度不允许超过200个字符")
|
||||
|
@ -113,4 +106,11 @@ public class ReportProd extends BaseEntity
|
|||
@Excel(name = "颜色")
|
||||
@ApiModelProperty("颜色")
|
||||
private String color;
|
||||
|
||||
@Excel(name = "是否成品", readConverterExp = "true=是,false=否")
|
||||
@ApiModelProperty("是否成品")
|
||||
private Boolean isEnd;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
brp.total_amount,
|
||||
brp.surface,
|
||||
brp.color,
|
||||
brp.is_end,
|
||||
brp.sort,
|
||||
bp.dept_id as price_dept_id,
|
||||
br.status as report_status,
|
||||
sd.dept_name as price_dept_name
|
||||
from bst_report_prod brp
|
||||
left join bst_report br on br.report_id = brp.report_id
|
||||
|
||||
left join bst_price bp on bp.price_id = brp.price_id
|
||||
left join sys_dept sd on sd.dept_id = bp.dept_id
|
||||
</sql>
|
||||
|
@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.priceCode != null and query.priceCode != ''">and brp.price_code like concat('%', #{query.priceCode}, '%')</if>
|
||||
<if test="query.surface != null and query.surface != ''"> and brp.surface = like concat('%', #{query.surface}, '%')</if>
|
||||
<if test="query.color != null and query.color != ''"> and brp.color = like concat('%', #{query.color}, '%')</if>
|
||||
<if test="query.isEnd != null"> and brp.is_end = #{query.isEnd}</if>
|
||||
<if test="query.reportIds != null and query.reportIds.size() > 0">
|
||||
and brp.report_id in
|
||||
<foreach collection="query.reportIds" item="item" open="(" close=")" separator=",">
|
||||
|
@ -111,10 +113,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="priceCode != null">price_code,</if>
|
||||
<if test="surface != null">surface,</if>
|
||||
<if test="color != null">color,</if>
|
||||
<if test="isEnd != null">is_end,</if>
|
||||
<if test="sort != null">sort,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="reportId != null">#{reportId},</if>
|
||||
|
||||
<if test="priceId != null">#{priceId},</if>
|
||||
<if test="num != null">#{num},</if>
|
||||
<if test="defectNum != null">#{defectNum},</if>
|
||||
|
@ -135,6 +138,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="priceCode != null">#{priceCode},</if>
|
||||
<if test="surface != null">#{surface},</if>
|
||||
<if test="color != null">#{color},</if>
|
||||
<if test="isEnd != null">#{isEnd},</if>
|
||||
<if test="sort != null">#{sort},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -161,7 +166,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
total_amount,
|
||||
price_code,
|
||||
surface,
|
||||
color
|
||||
color,
|
||||
is_end,
|
||||
sort
|
||||
)
|
||||
values
|
||||
|
||||
|
@ -209,6 +216,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="i.surface == null ">default,</if>
|
||||
<if test="i.color != null">#{i.color},</if>
|
||||
<if test="i.color == null">default,</if>
|
||||
<if test="i.isEnd != null">#{i.isEnd},</if>
|
||||
<if test="i.isEnd == null">default,</if>
|
||||
<if test="i.sort != null">#{i.sort},</if>
|
||||
<if test="i.sort == null">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
|
||||
|
@ -244,6 +255,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.priceCode != null">price_code = #{data.priceCode},</if>
|
||||
<if test="data.surface != null">surface = #{data.surface},</if>
|
||||
<if test="data.color != null">color = #{data.color},</if>
|
||||
<if test="data.isEnd != null">is_end = #{data.isEnd},</if>
|
||||
<if test="data.sort != null">sort = #{data.sort},</if>
|
||||
</sql>
|
||||
|
||||
|
||||
|
@ -460,6 +473,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="is_end = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.isEnd != null">
|
||||
WHEN #{item.id} THEN #{item.isEnd}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `is_end`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="sort = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.sort != null">
|
||||
WHEN #{item.id} THEN #{item.sort}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `sort`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
where id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.yh.reportProd.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO;
|
||||
import com.ruoyi.yh.reportOrderProd.domain.bo.ReportOrderProdBO;
|
||||
import com.ruoyi.yh.reportOrderProd.service.ReportOrderProdConverter;
|
||||
|
@ -13,6 +14,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -55,7 +57,9 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
bo.setPriceCode(vo.getPriceCode());
|
||||
bo.setSurface(vo.getSurface());
|
||||
bo.setColor(vo.getColor());
|
||||
bo.setTotalAmount(vo.getPricePrice().multiply(vo.getNum().add(vo.getDefectNum())));
|
||||
bo.setIsEnd(vo.getIsEnd());
|
||||
bo.setSort(vo.getSort());
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
|
||||
// 用户产量明细
|
||||
List<ReportUserProdBO> userProdList = new ArrayList<>();
|
||||
|
@ -108,7 +112,9 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
bo.setPriceCode(vo.getPriceCode());
|
||||
bo.setSurface(vo.getSurface());
|
||||
bo.setColor(vo.getColor());
|
||||
bo.setTotalAmount(vo.getPricePrice().multiply(vo.getNum().add(vo.getDefectNum())));
|
||||
bo.setIsEnd(vo.getIsEnd());
|
||||
bo.setSort(vo.getSort());
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
|
||||
// 用户产量明细
|
||||
List<ReportUserProdBO> userProdList = new ArrayList<>();
|
||||
|
@ -133,4 +139,9 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
|
||||
return bo;
|
||||
}
|
||||
|
||||
private BigDecimal calculateTotalAmount(ReportProdBO bo) {
|
||||
BigDecimal count = MathUtils.addDecimal(bo.getNum(), bo.getDefectNum());
|
||||
return MathUtils.multiply(bo.getPricePrice(), count);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user