更新:单价审核后,写回报表

This commit is contained in:
磷叶 2025-02-18 11:32:39 +08:00
parent a0d6e6897b
commit 1d0614f930
25 changed files with 409 additions and 47 deletions

View File

@ -72,9 +72,8 @@ public class Price extends BaseEntity implements LogBizParam
@Size(max = 200, message = "规格不允许超过200个字符")
private String spec;
@Excel(name = "单价(元)", cellType = Excel.ColumnType.NUMERIC, prompt = "必填", headerColor = IndexedColors.RED)
@Excel(name = "单价(元)")
@ApiModelProperty("单价")
@NotNull(message = "单价不允许为空", groups = ValidGroup.Create.class)
@Min(value = 0, message = "单价不允许小于0元")
private BigDecimal price;

View File

@ -2,9 +2,11 @@ package com.ruoyi.yh.price.domain.dto;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.interfaces.LogBizParam;
import com.ruoyi.common.utils.collection.CollectionUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@ -17,10 +19,11 @@ import java.util.List;
@Data
public class PriceVerifyDTO implements LogBizParam {
@ApiModelProperty("单价ID")
@NotNull(message = "单价ID不允许为空")
@Size(min = 1, message = "单价ID不允许为空")
private List<Long> priceIds;
@ApiModelProperty("单价列表")
@NotNull(message = "单价列表不允许为空")
@Size(min = 1, message = "单价列表不允许为空")
@Valid
private List<PriceVerifyPriceDTO> priceList;
@ApiModelProperty("是否通过")
@NotNull(message = "是否通过不允许为空")
@ -34,6 +37,6 @@ public class PriceVerifyDTO implements LogBizParam {
*/
@Override
public Object logBizId() {
return this.getPriceIds();
return CollectionUtils.map(priceList, PriceVerifyPriceDTO::getPriceId);
}
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.yh.price.domain.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class PriceVerifyPriceDTO {
@ApiModelProperty("单价ID")
@NotNull(message = "单价ID不允许为空")
private Long priceId;
@ApiModelProperty("单价")
@Min(value = 0, message = "单价不允许小于0")
private BigDecimal price;
}

View File

@ -73,7 +73,7 @@ public enum PriceStatus {
* 允许被报表使用的状态
*/
public static List<String> canCheckToReport() {
return asList(PASS);
return asList(PASS, WAIT_VERIFY);
}
/**
@ -82,4 +82,5 @@ public enum PriceStatus {
public static List<String> canDel() {
return asList(WAIT_SUBMIT, REJECT);
}
}

View File

@ -73,4 +73,9 @@ public interface PriceMapper
* 查询列统计
*/
List<PriceColumnCountVO> selectColumnCount(@Param("query") PriceQuery query, @Param("column") String column);
/**
* 批量审核
*/
int batchVerify(@Param("list") List<Price> list, @Param("query") PriceQuery query);
}

View File

@ -259,4 +259,68 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{priceId}
</foreach>
</delete>
<!-- batchVerify -->
<update id="batchVerify">
update bst_price bp
<trim prefix="SET" suffixOverrides=",">
<foreach open="price = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.price != null">
WHEN #{item.priceId} THEN #{item.price}
</when>
<otherwise>
WHEN #{item.priceId} THEN `price`
</otherwise>
</choose>
</foreach>
<foreach open="status = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.status != null">
WHEN #{item.priceId} THEN #{item.status}
</when>
<otherwise>
WHEN #{item.priceId} THEN `status`
</otherwise>
</choose>
</foreach>
<foreach open="verify_time = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.verifyTime != null">
WHEN #{item.priceId} THEN #{item.verifyTime}
</when>
<otherwise>
WHEN #{item.priceId} THEN `verify_time`
</otherwise>
</choose>
</foreach>
<foreach open="verify_by = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.verifyBy != null">
WHEN #{item.priceId} THEN #{item.verifyBy}
</when>
<otherwise>
WHEN #{item.priceId} THEN `verify_by`
</otherwise>
</choose>
</foreach>
<foreach open="verify_id = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.verifyId != null">
WHEN #{item.priceId} THEN #{item.verifyId}
</when>
<otherwise>
WHEN #{item.priceId} THEN `verify_id`
</otherwise>
</choose>
</foreach>
</trim>
where bp.price_id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.priceId}
</foreach>
<include refid="searchCondition"/>
</update>
</mapper>

View File

@ -1,7 +1,9 @@
package com.ruoyi.yh.price.service;
import com.ruoyi.yh.price.domain.Price;
import org.springframework.stereotype.Service;
import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO;
import java.util.List;
/**
* @author wjh
@ -18,4 +20,9 @@ public interface PriceConverter {
* 修改时转为PO
*/
Price toPoByUpdate(Price data);
/**
* 审核时转为PO
*/
List<Price> toPoByVerify(PriceVerifyDTO dto);
}

View File

@ -1,13 +1,22 @@
package com.ruoyi.yh.price.service.impl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.yh.material.utils.MaterialUtil;
import com.ruoyi.yh.price.domain.Price;
import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO;
import com.ruoyi.yh.price.domain.dto.PriceVerifyPriceDTO;
import com.ruoyi.yh.price.domain.enums.PriceStatus;
import com.ruoyi.yh.price.service.PriceConverter;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author wjh
* 2024/10/17
@ -76,4 +85,30 @@ public class PriceConverterImpl implements PriceConverter {
po.setCode(MaterialUtil.parseToCode(po.getCategory(), po.getSize(), po.getSurface(), po.getPattern()));
return po;
}
@Override
public List<Price> toPoByVerify(PriceVerifyDTO dto) {
if (dto == null || CollectionUtils.isEmptyElement(dto.getPriceList())) {
return Collections.emptyList();
}
SysUser verifyUser = dto.getVerifyUser();
LocalDateTime verifyTime = LocalDateTime.now();
String status = dto.getPass() ? PriceStatus.PASS.getStatus() : PriceStatus.REJECT.getStatus();
List<Price> result = new ArrayList<>();
for (PriceVerifyPriceDTO price : dto.getPriceList()) {
Price data = new Price();
data.setStatus(status);
data.setVerifyTime(verifyTime);
data.setPrice(price.getPrice());
data.setPriceId(price.getPriceId());
if (verifyUser != null) {
data.setVerifyBy(verifyUser.getNickName());
data.setVerifyId(verifyUser.getUserId());
}
result.add(data);
}
return result;
}
}

View File

@ -24,11 +24,16 @@ import com.ruoyi.yh.price.domain.PriceQuery;
import com.ruoyi.yh.price.domain.PriceVO;
import com.ruoyi.yh.price.domain.dto.PriceImportParams;
import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO;
import com.ruoyi.yh.price.domain.dto.PriceVerifyPriceDTO;
import com.ruoyi.yh.price.domain.enums.PriceColumn;
import com.ruoyi.yh.price.domain.enums.PriceStatus;
import com.ruoyi.yh.price.domain.vo.PriceSearchConditionVO;
import com.ruoyi.yh.price.mapper.PriceMapper;
import com.ruoyi.yh.price.service.PriceConverter;
import com.ruoyi.yh.price.service.PriceService;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import com.ruoyi.yh.reportProd.service.ReportProdConverter;
import com.ruoyi.yh.reportProd.service.ReportProdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -77,6 +82,15 @@ public class PriceServiceImpl implements PriceService
@Autowired
protected Validator validator;
@Autowired
private ReportProdService reportProdService;
@Autowired
private ReportProdConverter reportProdConverter;
@Autowired
private PriceConverter priceConverter;
/**
* 查询单价
*
@ -218,42 +232,57 @@ public class PriceServiceImpl implements PriceService
@Override
public int verify(PriceVerifyDTO dto) {
if (dto == null || CollectionUtils.isEmptyElement(dto.getPriceIds()) || dto.getPass() == null) {
if (dto == null || CollectionUtils.isEmptyElement(dto.getPriceList()) || dto.getPass() == null) {
return 0;
}
List<PriceVO> oldList = selectPriceListByIds(dto.getPriceIds());
int verified = 0;
for (Long priceId : dto.getPriceIds()) {
PriceVO old = oldList.stream().filter(item -> item.getPriceId().equals(priceId)).findFirst().orElse(null);
ServiceUtil.assertion(old == null, "待审核ID为%s的单价不存在请刷新后重试", priceId);
ServiceUtil.assertion(!PriceStatus.canVerify().contains(old.getStatus()), "待审核ID为%s的单价当前状态无法审核请刷新后重试", priceId);
Integer result = transactionTemplate.execute(status -> {
// 修改状态
Price data = new Price();
data.setStatus(dto.getPass() ? PriceStatus.PASS.getStatus() : PriceStatus.REJECT.getStatus());
data.setVerifyTime(LocalDateTime.now());
SysUser verifyUser = dto.getVerifyUser();
if (verifyUser != null) {
data.setVerifyBy(verifyUser.getNickName());
data.setVerifyId(verifyUser.getUserId());
}
PriceQuery query = new PriceQuery();
query.setPriceId(priceId);
query.setStatusList(PriceStatus.canVerify());
int update = this.updateByQuery(data, query);
ServiceUtil.assertion(update != 1, "审核失败待审核ID为%s的单价状态已发生变化请刷新后重试", priceId);
return update;
});
verified += (result == null ? 0 : result);
boolean pass = dto.getPass() != null && dto.getPass();
if (pass) {
dto.getPriceList().stream().filter(item -> item.getPrice() == null).findFirst()
.ifPresent(price -> {
throw new ServiceException(String.format("ID为%s的工序单价不允许为空", price.getPriceId()));
});
}
return verified;
// 获取旧单价数据
List<Long> priceIds = CollectionUtils.map(dto.getPriceList(), PriceVerifyPriceDTO::getPriceId);
List<PriceVO> oldList = selectPriceListByIds(priceIds);
// 校验
for (PriceVerifyPriceDTO price : dto.getPriceList()) {
PriceVO old = oldList.stream().filter(item -> item.getPriceId().equals(price.getPriceId())).findFirst().orElse(null);
ServiceUtil.assertion(old == null, "待审核ID为%s的单价不存在请刷新后重试", price.getPriceId());
ServiceUtil.assertion(!PriceStatus.canVerify().contains(old.getStatus()), "待审核ID为%s的单价当前状态无法审核请刷新后重试", price.getPriceId());
}
Integer result = transactionTemplate.execute(status -> {
// 修改状态
List<Price> priceList = priceConverter.toPoByVerify(dto);
PriceQuery query = new PriceQuery();
query.setStatusList(PriceStatus.canVerify());
int update = priceMapper.batchVerify(priceList, query);
if (pass && update > 0) {
// 若审核通过则将通过的单价对应的报表中的单价更新
List<PriceVO> passList = selectPassListByIds(priceIds);
List<ReportProdNewPriceDTO> newPriceList = reportProdConverter.toNewPriceDTO(passList);
reportProdService.batchUpdatePrice(newPriceList);
}
return update;
});
return result == null ? 0 : result;
}
private List<PriceVO> selectPassListByIds(List<Long> priceIds) {
if (CollectionUtils.isEmptyElement(priceIds)) {
return Collections.emptyList();
}
PriceQuery query = new PriceQuery();
query.setPriceIds(priceIds);
query.setStatus(PriceStatus.PASS.getStatus());
return priceMapper.selectPriceList(query);
}
@Override

View File

@ -26,4 +26,7 @@ public class ReportQuery extends ReportVO {
@ApiModelProperty("报表ID列表")
private List<Long> reportIds;
@ApiModelProperty("单价ID列表")
private List<Long> priceIds;
}

View File

@ -77,4 +77,11 @@ public interface ReportMapper
* 逻辑删除
*/
int logicDelByQuery(@Param("query") ReportQuery query);
/**
* 根据单价ID列表计算报表总价
* @param query 报表查询条件
* @return 报表总价
*/
int calcTotalAmount(@Param("query") ReportQuery query);
}

View File

@ -62,6 +62,16 @@
<if test="query.reportDateRange != null and query.reportDateRange.size() > 1">
and date(br.report_date) >= date(#{query.reportDateRange[0]}) and date(br.report_date) &lt;= date(#{query.reportDateRange[1]})
</if>
<if test="query.priceIds != null and query.priceIds.size() > 0">
and br.report_id in (
select distinct brp.report_id
from bst_report_prod brp
where brp.price_id in
<foreach collection="query.priceIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
</if>
${query.params.dataScope}
</sql>
@ -182,4 +192,19 @@
#{reportId}
</foreach>
</delete>
<!-- calcTotalAmount -->
<update id="calcTotalAmount">
update bst_report br
set br.total_amount = (
select sum(brp.total_amount)
from bst_report_prod brp
where brp.report_id = br.report_id
)
<where>
<include refid="searchCondition"/>
</where>
</update>
</mapper>

View File

@ -102,4 +102,10 @@ public interface ReportService
* 查询报表信息
*/
List<ReportVO> selectByReportIds(List<Long> reportIds);
/**
* 根据单价ID重新计算报表总价
* @param priceIds 单价ID列表
*/
int recalculateReportTotalAmountByPriceId(List<Long> priceIds);
}

View File

@ -535,4 +535,14 @@ public class ReportServiceImpl implements ReportService
return result;
}
@Override
public int recalculateReportTotalAmountByPriceId(List<Long> priceIds) {
if (CollectionUtils.isEmptyElement(priceIds)) {
return 0;
}
ReportQuery query = new ReportQuery();
query.setPriceIds(priceIds);
return reportMapper.calcTotalAmount(query);
}
}

View File

@ -132,8 +132,6 @@ 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());
// 校验产量和工序的数值是否一致
}

View File

@ -113,4 +113,7 @@ public class ReportProd extends BaseEntity
@ApiModelProperty("排序")
private Integer sort;
@ApiModelProperty("已读单价变化")
private Boolean readPrice;
}

View File

@ -33,6 +33,9 @@ public class ReportProdVO extends ReportProd {
@ApiModelProperty("工序部门名称")
private String priceDeptName;
@ApiModelProperty("工序状态")
private String priceStatus;
@ApiModelProperty("报表状态")
@Excel(name = "报表状态", dictType = DictType.REPORT_STATUS)
private String reportStatus;

View File

@ -0,0 +1,17 @@
package com.ruoyi.yh.reportProd.domain.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ReportProdNewPriceDTO {
@ApiModelProperty("单价ID")
private Long priceId;
@ApiModelProperty("价格")
private BigDecimal price;
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.yh.reportProd.mapper;
import com.ruoyi.yh.reportProd.domain.ReportProd;
import com.ruoyi.yh.reportProd.domain.ReportProdQuery;
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -82,4 +83,9 @@ public interface ReportProdMapper
* 批量根据报表id逻辑删除
*/
int logicDelByReportId(Long reportId);
/**
* 批量更新单价
*/
int batchUpdatePrice(@Param("list") List<ReportProdNewPriceDTO> list);
}

View File

@ -35,7 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
brp.color,
brp.is_end,
brp.sort,
brp.read_price,
bp.dept_id as price_dept_id,
bp.status as price_status,
br.status as report_status,
sd.dept_name as price_dept_name
from bst_report_prod brp
@ -64,6 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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.readPrice != null"> and brp.read_price = #{query.readPrice}</if>
<if test="query.priceStatus != null and query.priceStatus != ''"> and bp.status = #{query.priceStatus}</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=",">
@ -115,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="color != null">color,</if>
<if test="isEnd != null">is_end,</if>
<if test="sort != null">sort,</if>
<if test="readPrice != null">read_price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">#{reportId},</if>
@ -140,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="color != null">#{color},</if>
<if test="isEnd != null">#{isEnd},</if>
<if test="sort != null">#{sort},</if>
<if test="readPrice != null">#{readPrice},</if>
</trim>
</insert>
@ -168,7 +174,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
surface,
color,
is_end,
sort
sort,
read_price
)
values
@ -220,6 +227,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="i.isEnd == null">default,</if>
<if test="i.sort != null">#{i.sort},</if>
<if test="i.sort == null">default,</if>
<if test="i.readPrice != null">#{i.readPrice},</if>
<if test="i.readPrice == null">default,</if>
</trim>
</foreach>
@ -257,6 +266,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<if test="data.readPrice != null">read_price = #{data.readPrice},</if>
</sql>
@ -493,10 +503,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise>
</choose>
</foreach>
<foreach open="read_price = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.readPrice != null">
WHEN #{item.id} THEN #{item.readPrice}
</when>
<otherwise>
WHEN #{item.id} THEN `read_price`
</otherwise>
</choose>
</foreach>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
@ -527,4 +546,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<!-- batchUpdatePrice -->
<update id="batchUpdatePrice">
update bst_report_prod
<trim prefix="SET" suffixOverrides=",">
<foreach open="price_price = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.price != null">
WHEN #{item.priceId} THEN #{item.price}
</when>
<otherwise>
WHEN #{item.priceId} THEN `price_price`
</otherwise>
</choose>
</foreach>
<foreach open="total_amount = CASE price_id" collection="list" item="item" close="END,">
<choose>
<when test="item.price != null">
WHEN #{item.priceId} THEN #{item.price} * if(num is null, 0, num)
</when>
<otherwise>
WHEN #{item.priceId} THEN `total_amount`
</otherwise>
</choose>
</foreach>
read_price = false
</trim>
where price_id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.priceId}
</foreach>
and deleted = false
</update>
</mapper>

View File

@ -1,7 +1,11 @@
package com.ruoyi.yh.reportProd.service;
import com.ruoyi.yh.price.domain.PriceVO;
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import java.util.List;
/**
* @author wjh
@ -22,4 +26,11 @@ public interface ReportProdConverter {
* @return
*/
ReportProdBO toBoByUpdate(ReportProdVO vo);
/**
* 将通过的单价转为报表单价
* @param passList
* @return
*/
List<ReportProdNewPriceDTO> toNewPriceDTO(List<PriceVO> passList);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.yh.reportProd.service;
import com.ruoyi.yh.reportProd.domain.ReportProd;
import com.ruoyi.yh.reportProd.domain.ReportProdQuery;
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import java.util.List;
@ -91,4 +92,10 @@ public interface ReportProdService
* 批量删除
*/
int logicDelByReportId(Long reportId);
/**
* 批量更新单价
* @param list
*/
int batchUpdatePrice(List<ReportProdNewPriceDTO> list);
}

View File

@ -1,21 +1,24 @@
package com.ruoyi.yh.reportProd.service.impl;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.yh.price.domain.PriceVO;
import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO;
import com.ruoyi.yh.reportOrderProd.domain.bo.ReportOrderProdBO;
import com.ruoyi.yh.reportOrderProd.service.ReportOrderProdConverter;
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import com.ruoyi.yh.reportProd.service.ReportProdConverter;
import com.ruoyi.yh.reportUserProd.domain.ReportUserProdVO;
import com.ruoyi.yh.reportUserProd.domain.bo.ReportUserProdBO;
import com.ruoyi.yh.reportUserProd.service.ReportUserProdConverter;
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.Collections;
import java.util.List;
/**
@ -64,6 +67,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
// 用户产量明细
List<ReportUserProdBO> userProdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(vo.getUserProdList())) {
for (ReportUserProdVO item : vo.getUserProdList()) {
ReportUserProdBO userProd = reportUserProdConverter.toBoByCreate(item);
userProdList.add(userProd);
@ -144,4 +148,21 @@ public class ReportProdConverterImpl implements ReportProdConverter {
BigDecimal count = MathUtils.addDecimal(bo.getNum(), bo.getDefectNum());
return MathUtils.multiply(bo.getPricePrice(), count);
}
@Override
public List<ReportProdNewPriceDTO> toNewPriceDTO(List<PriceVO> passList) {
if (CollectionUtils.isEmptyElement(passList)) {
return Collections.emptyList();
}
List<ReportProdNewPriceDTO> result = new ArrayList<>();
for (PriceVO price : passList) {
ReportProdNewPriceDTO dto = new ReportProdNewPriceDTO();
dto.setPriceId(price.getPriceId());
dto.setPrice(price.getPrice());
result.add(dto);
}
return result;
}
}

View File

@ -1,9 +1,12 @@
package com.ruoyi.yh.reportProd.service.impl;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.yh.report.service.ReportService;
import com.ruoyi.yh.reportProd.domain.ReportProd;
import com.ruoyi.yh.reportProd.domain.ReportProdQuery;
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
import com.ruoyi.yh.reportProd.mapper.ReportProdMapper;
import com.ruoyi.yh.reportProd.service.ReportProdService;
import com.ruoyi.yh.reportUserProd.service.ReportUserProdService;
@ -34,6 +37,9 @@ public class ReportProdServiceImpl implements ReportProdService
@Autowired
private ReportUserProdService reportUserProdService;
@Autowired
private ReportService reportService;
/**
* 查询报表产量
*
@ -148,4 +154,25 @@ public class ReportProdServiceImpl implements ReportProdService
}
return reportProdMapper.logicDelByReportId(reportId);
}
@Override
public int batchUpdatePrice(List<ReportProdNewPriceDTO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;
}
Integer result = transactionTemplate.execute(status -> {
int update = reportProdMapper.batchUpdatePrice(list);
if (update > 0) {
// 若更新成功则将对应的报表总价更新
int calc = reportService.recalculateReportTotalAmountByPriceId(CollectionUtils.map(list, ReportProdNewPriceDTO::getPriceId));
ServiceUtil.assertion(calc == 0, "更新报表总价失败");
}
return update;
});
return result == null ? 0 : result;
}
}

View File

@ -148,7 +148,7 @@ public class PriceController extends BaseController
@PutMapping("/verify")
public AjaxResult verify(@RequestBody @Validated PriceVerifyDTO dto) {
dto.setVerifyUser(SecurityUtils.getLoginUser().getUser());
return toAjax(priceService.verify(dto));
return success(priceService.verify(dto));
}
@PreAuthorize("@ss.hasPermi('yh:price:disable')")