From bafc61051b2b3a3c77d07d5305190b0c76b77d7b 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: Fri, 21 Feb 2025 10:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/yh/price/domain/PriceQuery.java | 10 +- .../com/ruoyi/yh/price/mapper/PriceMapper.xml | 15 + .../ruoyi/yh/price/service/PriceService.java | 9 +- .../price/service/impl/PriceServiceImpl.java | 34 +- .../yh/reportProd/domain/ReportProd.java | 13 +- .../yh/reportProd/domain/ReportProdQuery.java | 15 +- .../yh/reportProd/domain/ReportProdVO.java | 22 +- .../reportProd/mapper/ReportProdMapper.java | 12 +- .../yh/reportProd/mapper/ReportProdMapper.xml | 518 ++++++++++-------- .../service/ReportProdConverter.java | 6 +- .../reportProd/service/ReportProdService.java | 11 +- .../service/impl/ReportProdServiceImpl.java | 100 +++- .../ruoyi/web/yh/ReportProdController.java | 31 +- 13 files changed, 499 insertions(+), 297 deletions(-) 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 cd0bcda..aedb9f5 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 @@ -1,11 +1,11 @@ package com.ruoyi.yh.price.domain; +import java.util.List; + import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.List; - /** * @author wjh * 2024/10/17 @@ -38,4 +38,10 @@ public class PriceQuery extends PriceVO { @ApiModelProperty("精准图案") private String eqPattern; + @ApiModelProperty("精准名称") + private String eqName; + + @ApiModelProperty("是否需要所有匹配") + private Boolean needAllMatch; + } 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 f9f6dfd..f08f5c8 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 @@ -70,6 +70,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bp.category = #{query.eqCategory} and bp.size = #{query.eqSize} and bp.pattern = #{query.eqPattern} + and bp.name = #{query.eqName} + + + and (bp.name is null or bp.name = '') + + + and (bp.category is null or bp.category = '') + + + and (bp.size is null or bp.size = '') + + + and (bp.pattern is null or bp.pattern = '') + + and ( bp.name like concat('%', #{query.keyword}, '%') diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java index e2444b0..c319a22 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java @@ -1,5 +1,7 @@ package com.ruoyi.yh.price.service; +import java.util.List; + import com.ruoyi.yh.price.domain.Price; import com.ruoyi.yh.price.domain.PriceQuery; import com.ruoyi.yh.price.domain.PriceVO; @@ -7,8 +9,6 @@ import com.ruoyi.yh.price.domain.dto.PriceImportParams; import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO; import com.ruoyi.yh.price.domain.vo.PriceSearchConditionVO; -import java.util.List; - /** * 单价Service接口 * @@ -127,4 +127,9 @@ public interface PriceService * 查询条件 */ PriceSearchConditionVO selectSearchCondition(PriceQuery query); + + /** + * 查询一个 + */ + PriceVO selectOne(PriceQuery query); } 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 5d9c1a3..a08dbfe 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 @@ -1,5 +1,19 @@ package com.ruoyi.yh.price.service.impl; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import javax.validation.Validator; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + import com.github.pagehelper.PageHelper; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; @@ -34,19 +48,8 @@ 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; -import org.springframework.transaction.support.TransactionTemplate; -import javax.validation.Validator; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; /** * 单价Service业务层处理 @@ -477,4 +480,11 @@ public class PriceServiceImpl implements PriceService return vo; } + + @Override + public PriceVO selectOne(PriceQuery query) { + PageHelper.startPage(1, 1); + List list = priceMapper.selectPriceList(query); + return CollectionUtils.firstElement(list); + } } 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 5f6e56a..0f85269 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 @@ -1,14 +1,16 @@ package com.ruoyi.yh.reportProd.domain; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; +import java.math.BigDecimal; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.math.BigDecimal; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; /** * 报表产量对象 bst_report_prod @@ -29,7 +31,6 @@ public class ReportProd extends BaseEntity private Long reportId; @ApiModelProperty("工序ID") - @NotNull(message = "工序不允许为空") private Long priceId; @Excel(name = "良品数") diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java index 88cf044..6d59a8d 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java @@ -1,12 +1,13 @@ package com.ruoyi.yh.reportProd.domain; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - import java.time.LocalDate; import java.util.List; +import org.springframework.format.annotation.DateTimeFormat; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + /** * @author wjh * 2024/10/31 @@ -20,4 +21,10 @@ public class ReportProdQuery extends ReportProdVO { @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("报表日期范围") private List reportDateRange; + + @ApiModelProperty("单价匹配") + private Boolean priceMatch; + + @ApiModelProperty("ID列表") + private List ids; } 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 463c996..72c3114 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 @@ -1,16 +1,19 @@ package com.ruoyi.yh.reportProd.domain; +import java.time.LocalDate; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.Size; + import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.constant.DictType; import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO; import com.ruoyi.yh.reportUserProd.domain.ReportUserProdVO; + import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import javax.validation.Valid; -import javax.validation.constraints.Size; -import java.util.List; - /** * @author wjh * 2024/10/31 @@ -30,14 +33,19 @@ public class ReportProdVO extends ReportProd { @ApiModelProperty("工序部门ID") private Long priceDeptId; - @ApiModelProperty("工序部门名称") - private String priceDeptName; - @ApiModelProperty("工序状态") private String priceStatus; @ApiModelProperty("报表状态") @Excel(name = "报表状态", dictType = DictType.REPORT_STATUS) private String reportStatus; + + @ApiModelProperty("报表部门名称") + private String deptName; + @ApiModelProperty("报表日期") + private LocalDate reportDate; + + @ApiModelProperty("报表部门ID") + private Long deptId; } 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 2b8dde7..7448278 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 @@ -1,12 +1,13 @@ package com.ruoyi.yh.reportProd.mapper; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + 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; /** * 报表产量Mapper接口 @@ -88,4 +89,9 @@ public interface ReportProdMapper * 批量更新单价 */ int batchUpdatePrice(@Param("list") List list); + + /** + * 刷新匹配的工序 + */ + int refreshPriceMatch(@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 63aa2e3..2bceef4 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 @@ -39,11 +39,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.dept_id as price_dept_id, bp.status as price_status, br.status as report_status, - sd.dept_name as price_dept_name + sd.dept_name as dept_name, + sd.dept_id as dept_id, + br.report_date as report_date 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 + left join sys_dept sd on sd.dept_id = br.dept_id @@ -68,6 +70,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and brp.is_end = #{query.isEnd} and brp.read_price = #{query.readPrice} and bp.status = #{query.priceStatus} + and sd.dept_id = #{query.deptId} + + and brp.price_id is not null + and brp.report_id in @@ -78,6 +84,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date(br.report_date) >= #{query.reportDateRange[0]} and date(br.report_date) <= #{query.reportDateRange[1]} + + and brp.id in + + #{item} + + ${query.params.dataScope} @@ -271,248 +283,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bst_report_prod + update bst_report_prod brp - - - - WHEN #{item.id} THEN #{item.reportId} - - - WHEN #{item.id} THEN `report_id` - - - - - - - WHEN #{item.id} THEN #{item.priceId} - - - WHEN #{item.id} THEN `price_id` - - - - - - - WHEN #{item.id} THEN #{item.num} - - - WHEN #{item.id} THEN `num` - - - - - - - WHEN #{item.id} THEN #{item.priceCategory} - - - WHEN #{item.id} THEN `price_category` - - - - - - - WHEN #{item.id} THEN #{item.priceSize} - - - WHEN #{item.id} THEN `price_size` - - - - - - - WHEN #{item.id} THEN #{item.priceName} - - - WHEN #{item.id} THEN `price_name` - - - - - - - WHEN #{item.id} THEN #{item.priceSubName} - - - WHEN #{item.id} THEN `price_sub_name` - - - - - - - WHEN #{item.id} THEN #{item.pricePattern} - - - WHEN #{item.id} THEN `price_pattern` - - - - - - - WHEN #{item.id} THEN #{item.priceSpec} - - - WHEN #{item.id} THEN `price_spec` - - - - - - - WHEN #{item.id} THEN #{item.pricePrice} - - - WHEN #{item.id} THEN `price_price` - - - - - - - WHEN #{item.id} THEN #{item.priceUnit} - - - WHEN #{item.id} THEN `price_unit` - - - - - - - WHEN #{item.id} THEN #{item.priceClassify} - - - WHEN #{item.id} THEN `price_classify` - - - - - - - WHEN #{item.id} THEN #{item.priceQuantityNumerator} - - - WHEN #{item.id} THEN `price_quantity_numerator` - - - - - - - WHEN #{item.id} THEN #{item.priceQuantityDenominator} - - - WHEN #{item.id} THEN `price_quantity_denominator` - - - - - - - WHEN #{item.id} THEN #{item.priceType} - - - WHEN #{item.id} THEN `price_type` - - - - - - - WHEN #{item.id} THEN #{item.remark} - - - WHEN #{item.id} THEN `remark` - - - - - - - WHEN #{item.id} THEN #{item.defectNum} - - - WHEN #{item.id} THEN `defect_num` - - - - - - - WHEN #{item.id} THEN #{item.totalAmount} - - - WHEN #{item.id} THEN `total_amount` - - - - - - - WHEN #{item.id} THEN #{item.priceCode} - - - WHEN #{item.id} THEN `price_code` - - - - - - - WHEN #{item.id} THEN #{item.surface} - - - WHEN #{item.id} THEN `surface` - - - - - - - WHEN #{item.id} THEN #{item.color} - - - WHEN #{item.id} THEN `color` - - - - - - - WHEN #{item.id} THEN #{item.isEnd} - - - WHEN #{item.id} THEN `is_end` - - - - - - - WHEN #{item.id} THEN #{item.sort} - - - WHEN #{item.id} THEN `sort` - - - - - - - WHEN #{item.id} THEN #{item.readPrice} - - - WHEN #{item.id} THEN `read_price` - - - + where id in @@ -520,6 +293,249 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + WHEN #{item.id} THEN #{item.reportId} + + + WHEN #{item.id} THEN brp.report_id + + + + + + + WHEN #{item.id} THEN #{item.priceId} + + + WHEN #{item.id} THEN brp.price_id + + + + + + + WHEN #{item.id} THEN #{item.num} + + + WHEN #{item.id} THEN brp.num + + + + + + + WHEN #{item.id} THEN #{item.priceCategory} + + + WHEN #{item.id} THEN brp.price_category + + + + + + + WHEN #{item.id} THEN #{item.priceSize} + + + WHEN #{item.id} THEN brp.price_size + + + + + + + WHEN #{item.id} THEN #{item.priceName} + + + WHEN #{item.id} THEN brp.price_name + + + + + + + WHEN #{item.id} THEN #{item.priceSubName} + + + WHEN #{item.id} THEN brp.price_sub_name + + + + + + + WHEN #{item.id} THEN #{item.pricePattern} + + + WHEN #{item.id} THEN brp.price_pattern + + + + + + + WHEN #{item.id} THEN #{item.priceSpec} + + + WHEN #{item.id} THEN brp.price_spec + + + + + + + WHEN #{item.id} THEN #{item.pricePrice} + + + WHEN #{item.id} THEN brp.price_price + + + + + + + WHEN #{item.id} THEN #{item.priceUnit} + + + WHEN #{item.id} THEN brp.price_unit + + + + + + + WHEN #{item.id} THEN #{item.priceClassify} + + + WHEN #{item.id} THEN brp.price_classify + + + + + + + WHEN #{item.id} THEN #{item.priceQuantityNumerator} + + + WHEN #{item.id} THEN brp.price_quantity_numerator + + + + + + + WHEN #{item.id} THEN #{item.priceQuantityDenominator} + + + WHEN #{item.id} THEN brp.price_quantity_denominator + + + + + + + WHEN #{item.id} THEN #{item.priceType} + + + WHEN #{item.id} THEN brp.price_type + + + + + + + WHEN #{item.id} THEN #{item.remark} + + + WHEN #{item.id} THEN brp.remark + + + + + + + WHEN #{item.id} THEN #{item.defectNum} + + + WHEN #{item.id} THEN brp.defect_num + + + + + + + WHEN #{item.id} THEN #{item.totalAmount} + + + WHEN #{item.id} THEN brp.total_amount + + + + + + + WHEN #{item.id} THEN #{item.priceCode} + + + WHEN #{item.id} THEN brp.price_code + + + + + + + WHEN #{item.id} THEN #{item.surface} + + + WHEN #{item.id} THEN brp.surface + + + + + + + WHEN #{item.id} THEN #{item.color} + + + WHEN #{item.id} THEN brp.color + + + + + + + WHEN #{item.id} THEN #{item.isEnd} + + + WHEN #{item.id} THEN brp.is_end + + + + + + + WHEN #{item.id} THEN #{item.sort} + + + WHEN #{item.id} THEN brp.sort + + + + + + + WHEN #{item.id} THEN #{item.readPrice} + + + WHEN #{item.id} THEN brp.read_price + + + + + update bst_report_prod set deleted = true @@ -581,4 +597,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and deleted = false + + + + update bst_report_prod brp + left join bst_report br on brp.report_id = br.report_id + + + + where brp.id in + + #{item.id} + + and brp.deleted = false + and brp.price_id is null + and br.status in ('1', '4') + 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 ba9d422..89874aa 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,12 +1,13 @@ package com.ruoyi.yh.reportProd.service; +import java.util.List; + import com.ruoyi.yh.price.domain.PriceVO; +import com.ruoyi.yh.reportProd.domain.ReportProd; 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 * 2024/11/2 @@ -33,4 +34,5 @@ public interface ReportProdConverter { * @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 496e198..363ba59 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 @@ -1,12 +1,12 @@ package com.ruoyi.yh.reportProd.service; +import java.util.List; + 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; - /** * 报表产量Service接口 * @@ -98,4 +98,11 @@ public interface ReportProdService * @param list */ int batchUpdatePrice(List list); + + /** + * 刷新单价匹配 + * @param ids + * @return + */ + int refreshPriceMatch(List ids); } 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 36b1611..58873dd 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,23 +1,29 @@ package com.ruoyi.yh.reportProd.service.impl; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.yh.price.domain.PriceQuery; +import com.ruoyi.yh.price.domain.PriceVO; +import com.ruoyi.yh.price.service.PriceService; 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.ReportProdConverter; import com.ruoyi.yh.reportProd.service.ReportProdService; import com.ruoyi.yh.reportUserProd.service.ReportUserProdService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.support.TransactionTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; /** * 报表产量Service业务层处理 @@ -40,6 +46,12 @@ public class ReportProdServiceImpl implements ReportProdService @Autowired private ReportService reportService; + @Autowired + private PriceService priceService; + + @Autowired + private ReportProdConverter reportProdConverter; + /** * 查询报表产量 * @@ -175,4 +187,76 @@ public class ReportProdServiceImpl implements ReportProdService return result == null ? 0 : result; } + + @Override + public int refreshPriceMatch(List ids) { + if (CollectionUtils.isEmptyElement(ids)) { + return 0; + } + + // 获取未匹配的工序 + List oldList = this.selectByIds(ids).stream() + .filter(item -> item.getPriceId() == null).collect(Collectors.toList()); + if (CollectionUtils.isEmptyElement(oldList)) { + return 0; + } + + // 已匹配的工序 + List list = new ArrayList<>(); + + // 依次匹配工序 + for (ReportProdVO old : oldList) { + PriceQuery query = new PriceQuery(); + query.setEqName(old.getPriceName()); + query.setEqCategory(old.getPriceCategory()); + query.setEqSize(old.getPriceSize()); + query.setEqPattern(old.getPricePattern()); + query.setDeptId(old.getDeptId()); + query.setNeedAllMatch(true); + PriceVO price = priceService.selectOne(query); + if (price == null) { + continue; + } + ReportProd prod = new ReportProd(); + prod.setId(old.getId()); + prod.setPriceId(price.getPriceId()); + prod.setPriceSubName(price.getSubName()); + prod.setPriceSpec(price.getSpec()); + prod.setPricePrice(price.getPrice()); + prod.setPriceUnit(price.getUnit()); + prod.setPriceClassify(price.getClassify()); + prod.setPriceQuantityNumerator(price.getQuantityNumerator()); + prod.setPriceQuantityDenominator(price.getQuantityDenominator()); + prod.setPriceCode(price.getCode()); + prod.setPriceCategory(price.getCategory()); + prod.setPriceSize(price.getSize()); + prod.setPriceName(price.getName()); + prod.setPricePattern(price.getPattern()); + list.add(prod); + } + + if (CollectionUtils.isEmptyElement(list)) { + return 0; + } + + Integer result = transactionTemplate.execute(status -> { + int update = reportProdMapper.refreshPriceMatch(list); + if (update > 0) { + // 若更新成功,则将对应的报表总价更新 + int calc = reportService.recalculateReportTotalAmountByPriceId(CollectionUtils.map(list, ReportProd::getPriceId)); + ServiceUtil.assertion(calc == 0, "更新报表总价失败"); + } + return update; + }); + return result == null ? 0 : result; + } + + private List selectByIds(List ids) { + if (CollectionUtils.isEmptyElement(ids)) { + return Collections.emptyList(); + } + ReportProdQuery query = new ReportProdQuery(); + query.setIds(ids); + return reportProdMapper.selectReportProdList(query); + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportProdController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportProdController.java index 14c7a6a..07697ba 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportProdController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportProdController.java @@ -1,5 +1,20 @@ package com.ruoyi.web.yh; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -11,12 +26,6 @@ import com.ruoyi.yh.reportProd.domain.ReportProdQuery; import com.ruoyi.yh.reportProd.domain.ReportProdVO; import com.ruoyi.yh.reportProd.service.ReportProdAssembler; import com.ruoyi.yh.reportProd.service.ReportProdService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; /** * 报表产量Controller @@ -105,4 +114,14 @@ public class ReportProdController extends BaseController { return toAjax(reportProdService.deleteReportProdByIds(ids)); } + + /** + * 刷新单价匹配 + */ + @PutMapping("/priceMatch") + @PreAuthorize("@ss.hasPermi('yh:reportProd:priceMatch')") + @Log(title = "刷新单价匹配", businessType = BusinessType.UPDATE) + public AjaxResult priceMatch(@RequestBody List ids){ + return success(reportProdService.refreshPriceMatch(ids)); + } }