From be09966397e0f4678bf8029ba6a3bcebaef4907b Mon Sep 17 00:00:00 2001 From: zhanghl <253316343@qq.com> Date: 星期三, 16 四月 2025 15:30:45 +0800 Subject: [PATCH] 焊缝统计表-逻辑更新 --- aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java | 2 + aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml | 19 ++------- aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java | 20 ++++++++++ aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml | 6 +++ aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java | 51 ++++++++++++++++++++++++- 5 files changed, 82 insertions(+), 16 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java index 26977f9..8e80a40 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java @@ -70,6 +70,26 @@ @Excel(name = "鏄惁婊¤冻") private String isSatisfy; + public String getWorkOrderType() { + return workOrderType; + } + + public void setWorkOrderType(String workOrderType) { + this.workOrderType = workOrderType; + } + + public String getClassification() { + return classification; + } + + public void setClassification(String classification) { + this.classification = classification; + } + + private String workOrderType; + private String classification; + + /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */ private String delFlag; diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java index 1577bb1..06b8fcb 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java @@ -60,4 +60,6 @@ * @return 缁撴灉 */ public int deleteApsWeldSeamStatisticsByIds(String[] ids); + + int removeLastBatch(); } diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java index b4c43fb..145f118 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java @@ -3,6 +3,7 @@ import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.StringUtils; import com.aps.common.core.utils.uuid.IdUtils; +import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsWeldSeam; import com.aps.core.domain.ApsWeldSeamStatistics; import com.aps.core.domain.ApsWeldSeamTemp; @@ -14,6 +15,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -100,6 +102,7 @@ return apsWeldSeamMapper.deleteApsWeldSeamById(id); } + @Transactional @Override public int confirmWeldSeam(ApsWeldSeamTemp apsWeldSeamTemp) { //鏌ヨ涓存椂琛ㄦ暟鎹� @@ -128,16 +131,60 @@ if (count == apsWeldSeamTemps.size()) { apsWeldSeamTempMapper.deleteApsWeldSeamTempByIds(ids); } + /*鍒犻櫎鏃ф暟鎹�*/ + apsWeldSeamStatisticsMapper.removeLastBatch(); //鎻掑叆鐒婄紳缁熻琛� List<ApsWeldSeamStatistics> apsWeldSeamStatistics = apsWeldSeamMapper.weldSeamStat(apsWeldSeamTemps); - for (int i = 0; i < apsWeldSeamStatistics.size(); i++) { + + List<Long> years = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getYear).distinct().toList(); + List<Long> months = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getMonth).distinct().toList(); + List<String> bases = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getProductionBase).distinct().toList(); + + for (Long year : years) { + for (Long month : months) { + for (String basis : bases) { + List<ApsWeldSeamStatistics> list = apsWeldSeamStatistics.stream() + .filter(x -> x.getYear().equals(year) && x.getMonth().equals(month) && x.getProductionBase().equals(basis)).toList(); + + long gasOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("0") && x.getClassification().equals("0")) + .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); + long gasPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("1") && x.getClassification().equals("0")) + .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); + long pipingOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("0") && x.getClassification().equals("1")) + .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); + long pipingPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("1") && x.getClassification().equals("1")) + .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); + + ApsWeldSeamStatistics seamStatistics = new ApsWeldSeamStatistics(); + seamStatistics.setId(IdUtils.fastSimpleUUID()); + seamStatistics.setYear(year); + seamStatistics.setMonth(month); + seamStatistics.setProductionBase(basis); + seamStatistics.setPipingOrderRequirement(pipingOrderRequirement); + seamStatistics.setPipingPredictionRequirement(pipingPredictionRequirement); + seamStatistics.setGasOrderRequirement(gasOrderRequirement); + seamStatistics.setGasPredictionRequirement(gasPredictionRequirement); + seamStatistics.setTotal(gasOrderRequirement + gasPredictionRequirement + pipingOrderRequirement + pipingPredictionRequirement); + seamStatistics.setCreateTime(DateUtils.getNowDate()); + seamStatistics.setCreateBy(SecurityUtils.getUsername()); + apsWeldSeamStatisticsMapper.insertApsWeldSeamStatistics(seamStatistics); + } + } + + } + + + /*for (int i = 0; i < apsWeldSeamStatistics.size(); i++) { List<ApsWeldSeamStatistics> apsWeldSeamStatistics1 = apsWeldSeamStatisticsMapper.selectApsWeldSeamStatisticsList(apsWeldSeamStatistics.get(i)); if (apsWeldSeamStatistics1.size() > 0) { + ApsWeldSeamStatistics apsWeldSeamStatistics2 = apsWeldSeamStatistics1.get(0); + apsWeldSeamStatistics2.setPipingOrderRequirement(apsWeldSeamStatistics.get(i).getPipingOrderRequirement()); apsWeldSeamStatistics2.setGasOrderRequirement(apsWeldSeamStatistics.get(i).getGasOrderRequirement()); apsWeldSeamStatistics2.setPipingPredictionRequirement(apsWeldSeamStatistics.get(i).getPipingPredictionRequirement()); apsWeldSeamStatistics2.setGasPredictionRequirement(apsWeldSeamStatistics.get(i).getGasPredictionRequirement()); + //棰勭暀绱ф�ヨ鍗曚骇鍑烘槸鍚︿负绌� if (apsWeldSeamStatistics2.getReserveEmergencyOrderOutput() != null) { apsWeldSeamStatistics2.setTotal(apsWeldSeamStatistics2.getPipingOrderRequirement() + apsWeldSeamStatistics2.getPipingPredictionRequirement() + apsWeldSeamStatistics2.getGasOrderRequirement() + apsWeldSeamStatistics2.getGasPredictionRequirement() + apsWeldSeamStatistics2.getReserveEmergencyOrderOutput()); @@ -165,7 +212,7 @@ apsWeldSeamStatisticsMapper.insertApsWeldSeamStatistics(apsWeldSeamStatistics.get(i)); } - } + }*/ return 1; } } diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml index 0a92ab9..453ae4d 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml @@ -157,19 +157,10 @@ SELECT produce_year as year, produce_month as month, production_base as productionBase, - SUM ( CASE WHEN work_order_type = '0' AND classification = '1' THEN total_weld_seam ELSE 0 END ) AS pipingOrderRequirement, - SUM ( CASE WHEN work_order_type = '0' AND classification = '0' THEN total_weld_seam ELSE 0 END ) AS gasOrderRequirement, - SUM ( CASE WHEN work_order_type = '1' AND classification = '1' THEN total_weld_seam ELSE 0 END ) AS pipingPredictionRequirement, - SUM ( CASE WHEN work_order_type = '1' AND classification = '0' THEN total_weld_seam ELSE 0 END ) AS gasPredictionRequirement - FROM - aps_weld_seam - where 1=1 - <foreach item="item" index="index" collection="list" separator=" "> - or ( produce_year=#{item.produceYear} and produce_month=#{item.produceMonth} and production_base=#{item.productionBase}) - </foreach> - GROUP BY - produce_year, - produce_month, - production_base + work_order_type as workOrderType, + classification, + sum(total_weld_seam) as total + FROM aps_weld_seam + GROUP BY produce_year, produce_month, production_base, work_order_type, classification </select> </mapper> \ No newline at end of file diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml index a8d82c3..0829f08 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml @@ -36,7 +36,9 @@ <if test="params.beginYear != null and params.beginYear != '' and params.endYear != null and params.endYear != ''"> and year between #{params.beginYear} and #{params.endYear}</if> <if test="params.beginMonth != null and params.beginMonth != '' and params.endMonth != null and params.endMonth != ''"> and month between #{params.beginMonth} and #{params.endMonth}</if> <if test="productionBase != null and productionBase != ''"> and production_base like '%'|| #{productionBase}|| '%'</if> + and del_flag='0' </where> + order by year, month ,production_base </select> <select id="selectApsWeldSeamStatisticsById" parameterType="String" resultMap="ApsWeldSeamStatisticsResult"> @@ -125,4 +127,8 @@ #{id} </foreach> </delete> + <update id="removeLastBatch" parameterType="String"> + update aps_weld_seam_statistics set del_flag='1' where del_flag='0' + </update> + </mapper> \ No newline at end of file -- Gitblit v1.9.3