细节更新

This commit is contained in:
磷叶 2025-02-21 10:32:02 +08:00
parent 0225703e7a
commit bafc61051b
13 changed files with 499 additions and 297 deletions

View File

@ -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;
}

View File

@ -70,6 +70,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.eqCategory != null and query.eqCategory != ''"> and bp.category = #{query.eqCategory}</if>
<if test="query.eqSize != null and query.eqSize != ''"> and bp.size = #{query.eqSize}</if>
<if test="query.eqPattern != null and query.eqPattern != ''"> and bp.pattern = #{query.eqPattern}</if>
<if test="query.eqName != null and query.eqName != ''"> and bp.name = #{query.eqName}</if>
<if test="query.needAllMatch != null and query.needAllMatch == true">
<if test="query.eqName == null or query.eqName == ''">
and (bp.name is null or bp.name = '')
</if>
<if test="query.eqCategory == null or query.eqCategory == ''">
and (bp.category is null or bp.category = '')
</if>
<if test="query.eqSize == null or query.eqSize == ''">
and (bp.size is null or bp.size = '')
</if>
<if test="query.eqPattern == null or query.eqPattern == ''">
and (bp.pattern is null or bp.pattern = '')
</if>
</if>
<if test="query.keyword != null and query.keyword != ''">
and (
bp.name like concat('%', #{query.keyword}, '%')

View File

@ -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);
}

View File

@ -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<PriceVO> list = priceMapper.selectPriceList(query);
return CollectionUtils.firstElement(list);
}
}

View File

@ -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 = "良品数")

View File

@ -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<LocalDate> reportDateRange;
@ApiModelProperty("单价匹配")
private Boolean priceMatch;
@ApiModelProperty("ID列表")
private List<Long> ids;
}

View File

@ -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;
}

View File

@ -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<ReportProdNewPriceDTO> list);
/**
* 刷新匹配的工序
*/
int refreshPriceMatch(@Param("list") List<ReportProd> list);
}

View File

@ -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
</sql>
<sql id="searchCondition">
@ -68,6 +70,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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.deptId != null"> and sd.dept_id = #{query.deptId}</if>
<if test="query.priceMatch != null">
and brp.price_id is <if test="query.priceMatch">not</if> null
</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=",">
@ -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) &lt;= #{query.reportDateRange[1]}
</if>
<if test="query.ids != null and query.ids.size() > 0">
and brp.id in
<foreach collection="query.ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
${query.params.dataScope}
</sql>
@ -271,248 +283,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="batchUpdate">
update bst_report_prod
update bst_report_prod brp
<trim prefix="SET" suffixOverrides=",">
<foreach open="report_id = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.reportId != null">
WHEN #{item.id} THEN #{item.reportId}
</when>
<otherwise>
WHEN #{item.id} THEN `report_id`
</otherwise>
</choose>
</foreach>
<foreach open="price_id = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceId != null">
WHEN #{item.id} THEN #{item.priceId}
</when>
<otherwise>
WHEN #{item.id} THEN `price_id`
</otherwise>
</choose>
</foreach>
<foreach open="num = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.num != null">
WHEN #{item.id} THEN #{item.num}
</when>
<otherwise>
WHEN #{item.id} THEN `num`
</otherwise>
</choose>
</foreach>
<foreach open="price_category = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceCategory != null">
WHEN #{item.id} THEN #{item.priceCategory}
</when>
<otherwise>
WHEN #{item.id} THEN `price_category`
</otherwise>
</choose>
</foreach>
<foreach open="price_size = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSize != null">
WHEN #{item.id} THEN #{item.priceSize}
</when>
<otherwise>
WHEN #{item.id} THEN `price_size`
</otherwise>
</choose>
</foreach>
<foreach open="price_name = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceName != null">
WHEN #{item.id} THEN #{item.priceName}
</when>
<otherwise>
WHEN #{item.id} THEN `price_name`
</otherwise>
</choose>
</foreach>
<foreach open="price_sub_name = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSubName != null">
WHEN #{item.id} THEN #{item.priceSubName}
</when>
<otherwise>
WHEN #{item.id} THEN `price_sub_name`
</otherwise>
</choose>
</foreach>
<foreach open="price_pattern = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.pricePattern != null">
WHEN #{item.id} THEN #{item.pricePattern}
</when>
<otherwise>
WHEN #{item.id} THEN `price_pattern`
</otherwise>
</choose>
</foreach>
<foreach open="price_spec = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSpec != null">
WHEN #{item.id} THEN #{item.priceSpec}
</when>
<otherwise>
WHEN #{item.id} THEN `price_spec`
</otherwise>
</choose>
</foreach>
<foreach open="price_price = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.pricePrice != null">
WHEN #{item.id} THEN #{item.pricePrice}
</when>
<otherwise>
WHEN #{item.id} THEN `price_price`
</otherwise>
</choose>
</foreach>
<foreach open="price_unit = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceUnit != null">
WHEN #{item.id} THEN #{item.priceUnit}
</when>
<otherwise>
WHEN #{item.id} THEN `price_unit`
</otherwise>
</choose>
</foreach>
<foreach open="price_classify = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceClassify != null">
WHEN #{item.id} THEN #{item.priceClassify}
</when>
<otherwise>
WHEN #{item.id} THEN `price_classify`
</otherwise>
</choose>
</foreach>
<foreach open="price_quantity_numerator = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceQuantityNumerator != null">
WHEN #{item.id} THEN #{item.priceQuantityNumerator}
</when>
<otherwise>
WHEN #{item.id} THEN `price_quantity_numerator`
</otherwise>
</choose>
</foreach>
<foreach open="price_quantity_denominator = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceQuantityDenominator != null">
WHEN #{item.id} THEN #{item.priceQuantityDenominator}
</when>
<otherwise>
WHEN #{item.id} THEN `price_quantity_denominator`
</otherwise>
</choose>
</foreach>
<foreach open="price_type = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceType != null">
WHEN #{item.id} THEN #{item.priceType}
</when>
<otherwise>
WHEN #{item.id} THEN `price_type`
</otherwise>
</choose>
</foreach>
<foreach open="remark = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.remark != null">
WHEN #{item.id} THEN #{item.remark}
</when>
<otherwise>
WHEN #{item.id} THEN `remark`
</otherwise>
</choose>
</foreach>
<foreach open="defect_num = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.defectNum != null">
WHEN #{item.id} THEN #{item.defectNum}
</when>
<otherwise>
WHEN #{item.id} THEN `defect_num`
</otherwise>
</choose>
</foreach>
<foreach open="total_amount = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.totalAmount != null">
WHEN #{item.id} THEN #{item.totalAmount}
</when>
<otherwise>
WHEN #{item.id} THEN `total_amount`
</otherwise>
</choose>
</foreach>
<foreach open="price_code = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceCode != null">
WHEN #{item.id} THEN #{item.priceCode}
</when>
<otherwise>
WHEN #{item.id} THEN `price_code`
</otherwise>
</choose>
</foreach>
<foreach open="surface = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.surface != null ">
WHEN #{item.id} THEN #{item.surface}
</when>
<otherwise>
WHEN #{item.id} THEN `surface`
</otherwise>
</choose>
</foreach>
<foreach open="color = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.color != null">
WHEN #{item.id} THEN #{item.color}
</when>
<otherwise>
WHEN #{item.id} THEN `color`
</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>
<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>
<include refid="batchUpdateColumns"/>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
@ -520,6 +293,249 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<sql id="batchUpdateColumns">
<foreach open="brp.report_id = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.reportId != null">
WHEN #{item.id} THEN #{item.reportId}
</when>
<otherwise>
WHEN #{item.id} THEN brp.report_id
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_id = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceId != null">
WHEN #{item.id} THEN #{item.priceId}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_id
</otherwise>
</choose>
</foreach>
<foreach open="brp.num = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.num != null">
WHEN #{item.id} THEN #{item.num}
</when>
<otherwise>
WHEN #{item.id} THEN brp.num
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_category = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceCategory != null">
WHEN #{item.id} THEN #{item.priceCategory}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_category
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_size = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSize != null">
WHEN #{item.id} THEN #{item.priceSize}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_size
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_name = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceName != null">
WHEN #{item.id} THEN #{item.priceName}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_name
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_sub_name = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSubName != null">
WHEN #{item.id} THEN #{item.priceSubName}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_sub_name
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_pattern = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.pricePattern != null">
WHEN #{item.id} THEN #{item.pricePattern}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_pattern
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_spec = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceSpec != null">
WHEN #{item.id} THEN #{item.priceSpec}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_spec
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_price = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.pricePrice != null">
WHEN #{item.id} THEN #{item.pricePrice}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_price
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_unit = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceUnit != null">
WHEN #{item.id} THEN #{item.priceUnit}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_unit
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_classify = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceClassify != null">
WHEN #{item.id} THEN #{item.priceClassify}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_classify
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_quantity_numerator = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceQuantityNumerator != null">
WHEN #{item.id} THEN #{item.priceQuantityNumerator}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_quantity_numerator
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_quantity_denominator = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceQuantityDenominator != null">
WHEN #{item.id} THEN #{item.priceQuantityDenominator}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_quantity_denominator
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_type = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceType != null">
WHEN #{item.id} THEN #{item.priceType}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_type
</otherwise>
</choose>
</foreach>
<foreach open="brp.remark = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.remark != null">
WHEN #{item.id} THEN #{item.remark}
</when>
<otherwise>
WHEN #{item.id} THEN brp.remark
</otherwise>
</choose>
</foreach>
<foreach open="brp.defect_num = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.defectNum != null">
WHEN #{item.id} THEN #{item.defectNum}
</when>
<otherwise>
WHEN #{item.id} THEN brp.defect_num
</otherwise>
</choose>
</foreach>
<foreach open="brp.total_amount = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.totalAmount != null">
WHEN #{item.id} THEN #{item.totalAmount}
</when>
<otherwise>
WHEN #{item.id} THEN brp.total_amount
</otherwise>
</choose>
</foreach>
<foreach open="brp.price_code = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.priceCode != null">
WHEN #{item.id} THEN #{item.priceCode}
</when>
<otherwise>
WHEN #{item.id} THEN brp.price_code
</otherwise>
</choose>
</foreach>
<foreach open="brp.surface = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.surface != null ">
WHEN #{item.id} THEN #{item.surface}
</when>
<otherwise>
WHEN #{item.id} THEN brp.surface
</otherwise>
</choose>
</foreach>
<foreach open="brp.color = CASE brp.id" collection="list" item="item" close="END,">
<choose>
<when test="item.color != null">
WHEN #{item.id} THEN #{item.color}
</when>
<otherwise>
WHEN #{item.id} THEN brp.color
</otherwise>
</choose>
</foreach>
<foreach open="brp.is_end = CASE brp.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 brp.is_end
</otherwise>
</choose>
</foreach>
<foreach open="brp.sort = CASE brp.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 brp.sort
</otherwise>
</choose>
</foreach>
<foreach open="brp.read_price = CASE brp.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 brp.read_price
</otherwise>
</choose>
</foreach>
</sql>
<update id="batchLogicDel">
update bst_report_prod
set deleted = true
@ -581,4 +597,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and deleted = false
</update>
<!-- refreshPriceMatch -->
<update id="refreshPriceMatch">
update bst_report_prod brp
left join bst_report br on brp.report_id = br.report_id
<trim prefix="SET" suffixOverrides=",">
<include refid="batchUpdateColumns"/>
</trim>
where brp.id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
and brp.deleted = false
and brp.price_id is null
and br.status in ('1', '4')
</update>
</mapper>

View File

@ -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<ReportProdNewPriceDTO> toNewPriceDTO(List<PriceVO> passList);
}

View File

@ -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<ReportProdNewPriceDTO> list);
/**
* 刷新单价匹配
* @param ids
* @return
*/
int refreshPriceMatch(List<Long> ids);
}

View File

@ -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<Long> ids) {
if (CollectionUtils.isEmptyElement(ids)) {
return 0;
}
// 获取未匹配的工序
List<ReportProdVO> oldList = this.selectByIds(ids).stream()
.filter(item -> item.getPriceId() == null).collect(Collectors.toList());
if (CollectionUtils.isEmptyElement(oldList)) {
return 0;
}
// 已匹配的工序
List<ReportProd> 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<ReportProdVO> selectByIds(List<Long> ids) {
if (CollectionUtils.isEmptyElement(ids)) {
return Collections.emptyList();
}
ReportProdQuery query = new ReportProdQuery();
query.setIds(ids);
return reportProdMapper.selectReportProdList(query);
}
}

View File

@ -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<Long> ids){
return success(reportProdService.refreshPriceMatch(ids));
}
}