diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java index 58a7a6e..94b1789 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java @@ -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; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyDTO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyDTO.java index 1b789c5..dddc85d 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyDTO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyDTO.java @@ -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 priceIds; + @ApiModelProperty("单价列表") + @NotNull(message = "单价列表不允许为空") + @Size(min = 1, message = "单价列表不允许为空") + @Valid + private List 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); } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyPriceDTO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyPriceDTO.java new file mode 100644 index 0000000..d0e8595 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceVerifyPriceDTO.java @@ -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; + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java index 66486bf..35d7ddd 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java @@ -73,7 +73,7 @@ public enum PriceStatus { * 允许被报表使用的状态 */ public static List canCheckToReport() { - return asList(PASS); + return asList(PASS, WAIT_VERIFY); } /** @@ -82,4 +82,5 @@ public enum PriceStatus { public static List canDel() { return asList(WAIT_SUBMIT, REJECT); } + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.java index 7bcaf14..d9a23d1 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.java @@ -73,4 +73,9 @@ public interface PriceMapper * 查询列统计 */ List selectColumnCount(@Param("query") PriceQuery query, @Param("column") String column); + + /** + * 批量审核 + */ + int batchVerify(@Param("list") List list, @Param("query") PriceQuery query); } 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 5ee26ef..6a47e1c 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 @@ -259,4 +259,68 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{priceId} + + + + + update bst_price bp + + + + + WHEN #{item.priceId} THEN #{item.price} + + + WHEN #{item.priceId} THEN `price` + + + + + + + WHEN #{item.priceId} THEN #{item.status} + + + WHEN #{item.priceId} THEN `status` + + + + + + + WHEN #{item.priceId} THEN #{item.verifyTime} + + + WHEN #{item.priceId} THEN `verify_time` + + + + + + + WHEN #{item.priceId} THEN #{item.verifyBy} + + + WHEN #{item.priceId} THEN `verify_by` + + + + + + + WHEN #{item.priceId} THEN #{item.verifyId} + + + WHEN #{item.priceId} THEN `verify_id` + + + + + where bp.price_id in + + #{item.priceId} + + + + diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceConverter.java index 4c9406f..f64dd37 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceConverter.java @@ -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 toPoByVerify(PriceVerifyDTO dto); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceConverterImpl.java index 1ce0945..c7c695e 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceConverterImpl.java @@ -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 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 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; + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java index 7d6df74..5d9c1a3 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java @@ -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 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 priceIds = CollectionUtils.map(dto.getPriceList(), PriceVerifyPriceDTO::getPriceId); + List 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 priceList = priceConverter.toPoByVerify(dto); + PriceQuery query = new PriceQuery(); + query.setStatusList(PriceStatus.canVerify()); + int update = priceMapper.batchVerify(priceList, query); + + if (pass && update > 0) { + // 若审核通过,则将通过的单价对应的报表中的单价更新 + List passList = selectPassListByIds(priceIds); + List newPriceList = reportProdConverter.toNewPriceDTO(passList); + reportProdService.batchUpdatePrice(newPriceList); + } + + return update; + }); + + + return result == null ? 0 : result; + } + + private List selectPassListByIds(List 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 diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportQuery.java index a483966..acf79c6 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportQuery.java @@ -26,4 +26,7 @@ public class ReportQuery extends ReportVO { @ApiModelProperty("报表ID列表") private List reportIds; + @ApiModelProperty("单价ID列表") + private List priceIds; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java index 8f50724..b102bc7 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java @@ -77,4 +77,11 @@ public interface ReportMapper * 逻辑删除 */ int logicDelByQuery(@Param("query") ReportQuery query); + + /** + * 根据单价ID列表,计算报表总价 + * @param query 报表查询条件 + * @return 报表总价 + */ + int calcTotalAmount(@Param("query") ReportQuery query); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml index f7c7b38..82338ee 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml @@ -62,6 +62,16 @@ and date(br.report_date) >= date(#{query.reportDateRange[0]}) and date(br.report_date) <= date(#{query.reportDateRange[1]}) + + and br.report_id in ( + select distinct brp.report_id + from bst_report_prod brp + where brp.price_id in + + #{item} + + ) + ${query.params.dataScope} @@ -182,4 +192,19 @@ #{reportId} + + + + + 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 + ) + + + + + diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportService.java index c4450f0..a6c28de 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportService.java @@ -102,4 +102,10 @@ public interface ReportService * 查询报表信息 */ List selectByReportIds(List reportIds); + + /** + * 根据单价ID,重新计算报表总价 + * @param priceIds 单价ID列表 + */ + int recalculateReportTotalAmountByPriceId(List priceIds); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java index 7661b18..c2d6b98 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java @@ -535,4 +535,14 @@ public class ReportServiceImpl implements ReportService return result; } + + @Override + public int recalculateReportTotalAmountByPriceId(List priceIds) { + if (CollectionUtils.isEmptyElement(priceIds)) { + return 0; + } + ReportQuery query = new ReportQuery(); + query.setPriceIds(priceIds); + return reportMapper.calcTotalAmount(query); + } } 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 f6ee888..d5b1ace 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 @@ -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()); - // 校验产量和工序的数值是否一致 - } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProd.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProd.java index c59a40e..5f6e56a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProd.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProd.java @@ -113,4 +113,7 @@ public class ReportProd extends BaseEntity @ApiModelProperty("排序") private Integer sort; + + @ApiModelProperty("已读单价变化") + private Boolean readPrice; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java index 3f76fb3..463c996 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java @@ -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; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/dto/ReportProdNewPriceDTO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/dto/ReportProdNewPriceDTO.java new file mode 100644 index 0000000..dc09ac5 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/dto/ReportProdNewPriceDTO.java @@ -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; + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.java index 953d9ab..2b8dde7 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.java @@ -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 list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml index a7148ad..63aa2e3 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml @@ -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" and brp.surface = like concat('%', #{query.surface}, '%') and brp.color = like concat('%', #{query.color}, '%') and brp.is_end = #{query.isEnd} + and brp.read_price = #{query.readPrice} + and bp.status = #{query.priceStatus} and brp.report_id in @@ -115,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" color, is_end, sort, + read_price, #{reportId}, @@ -140,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{color}, #{isEnd}, #{sort}, + #{readPrice}, @@ -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" default, #{i.sort}, default, + #{i.readPrice}, + default, @@ -257,6 +266,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" color = #{data.color}, is_end = #{data.isEnd}, sort = #{data.sort}, + read_price = #{data.readPrice}, @@ -493,10 +503,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + WHEN #{item.id} THEN #{item.readPrice} + + + WHEN #{item.id} THEN `read_price` + + + where id in - #{item.id} @@ -527,4 +546,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + + + update bst_report_prod + + + + + WHEN #{item.priceId} THEN #{item.price} + + + WHEN #{item.priceId} THEN `price_price` + + + + + + + WHEN #{item.priceId} THEN #{item.price} * if(num is null, 0, num) + + + WHEN #{item.priceId} THEN `total_amount` + + + + read_price = false + + where price_id in + + #{item.priceId} + + and deleted = false + + diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdConverter.java index f58126a..ba9d422 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdConverter.java @@ -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 toNewPriceDTO(List passList); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdService.java index 2d50bd4..496e198 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/ReportProdService.java @@ -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 list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java index 7a582b8..94fe037 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java @@ -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 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 toNewPriceDTO(List passList) { + if (CollectionUtils.isEmptyElement(passList)) { + return Collections.emptyList(); + } + + List result = new ArrayList<>(); + for (PriceVO price : passList) { + ReportProdNewPriceDTO dto = new ReportProdNewPriceDTO(); + dto.setPriceId(price.getPriceId()); + dto.setPrice(price.getPrice()); + result.add(dto); + } + + return result; + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdServiceImpl.java index a2440af..36b1611 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdServiceImpl.java @@ -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 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; + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java index 14797db..c0ec791 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java @@ -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')")