zhanghl
2025-04-16 be09966397e0f4678bf8029ba6a3bcebaef4907b
焊缝统计表-逻辑更新
已修改5个文件
98 ■■■■ 文件已修改
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsWeldSeamStatistics.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsWeldSeamStatisticsMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsWeldSeamServiceImpl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamMapper.xml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsWeldSeamStatisticsMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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代表存在 2代表删除) */
    private String delFlag;
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();
}
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;
    }
}
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>
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>