zss
4 小时以前 7d45b1aa345be565648f9ae01cd200631eb008a2
生产计划的下发状态逻辑调整+能耗统计查询sql优化
已修改4个文件
17 ■■■■ 文件已修改
src/main/java/com/ruoyi/energy/service/impl/EnergyConsumptionDetailServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/energy/service/impl/EnergyConsumptionDetailServiceImpl.java
@@ -102,6 +102,7 @@
        EnergyStatisticsDto energyStatisticsDto = new EnergyStatisticsDto();
        //计算总耗用量+总能耗费用
        Map<String, BigDecimal> map=energyConsumptionDetailMapper.calculateEnergy(energyStatisticsVo);
        energyStatisticsDto.setTotalEnergyConsumption(map.get("totalEnergyConsumption"));
        energyStatisticsDto.setTotalEnergyCost(map.get("totalEnergyCost"));
        //平均用量
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -164,10 +164,10 @@
                // 最后一个计划,分配剩余方数
                BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
                plan.setStatus(1);
                if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
                plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
                if (plan.getAssignedQuantity().compareTo(plan.getVolume()) >= 0) {
                    plan.setStatus(2);
                }
                plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
                productOrderPlan.setAssignedQuantity(lastRemainingVolume);
                productionPlanMapper.updateById(plan);
                productOrderPlanMapper.insert(productOrderPlan);
src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml
@@ -41,14 +41,17 @@
         </where>
    </select>
    <select id="calculateEnergy" resultType="java.util.Map">
        select SUM(COALESCE(ecd.dosage,0)) totalEnergyConsumption,
               SUM(COALESCE(ecd.dosage,0) * COALESCE(e.unit_price,0)) totalEnergyCost
        select  COALESCE(t.totalEnergyConsumption, 0) AS totalEnergyConsumption,
                COALESCE(t.totalEnergyCost, 0) AS totalEnergyCost
        from (select SUM(ecd.dosage) totalEnergyConsumption,
               SUM(ecd.dosage * e.unit_price) totalEnergyCost
            from energy_consumption_detail ecd
            left join  energy e on ecd.energy_id = e.id
            where ecd.meter_reading_date between #{c.startDate} and #{c.endDate}
            <if test="c.type != null and c.type != ''">
                and ecd.type =#{c.type}
            </if>
        )t
    </select>
    <select id="energyConsumptionTypeProportion"
            resultType="com.ruoyi.energy.dto.EnergyConsumptionTypeDto">
src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml
@@ -58,6 +58,9 @@
        <if test="c.model != null and c.model != '' ">
            AND pms.model LIKE CONCAT('%',#{c.model},'%')
        </if>
         <if test="c.status != null">
            AND pp.status =#{c.status}
        </if>
        <if test="c.applyNo != null and c.applyNo != '' ">
            AND pp.apply_no LIKE CONCAT('%',#{c.applyNo},'%')
        </if>
@@ -125,4 +128,4 @@
        </foreach>
        ORDER BY pp.id ASC
    </select>
</mapper>
</mapper>