| | |
| | | package com.ruoyi.device.mapper; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.dto.RepairAmountGroupDTO; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface DeviceMaintenanceMapper extends BaseMapper<DeviceMaintenance> { |
| | |
| | | IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto); |
| | | |
| | | DeviceMaintenanceDto detailById(Long id); |
| | | |
| | | @InterceptorIgnore(tenantLine = "true") |
| | | List<DeviceMaintenance> list1(Long id); |
| | | |
| | | /** |
| | | * 按“指定年份的年月+设备台账id”分组,求和报修金额 |
| | | * @param year 前端传入的年份(如"2025") |
| | | */ |
| | | @Select("SELECT " + |
| | | " DATE_FORMAT(maintenance_actually_time, '%m') AS repairYearMonth, " + |
| | | " device_ledger_id AS deviceLedgerId, " + |
| | | " SUM(maintenance_price) AS totalRepairPrice " + |
| | | "FROM device_maintenance " + |
| | | "WHERE DATE_FORMAT(maintenance_actually_time, '%Y') = #{year} " + // 只查询指定年份的数据 |
| | | "GROUP BY device_ledger_id,DATE_FORMAT(maintenance_actually_time, '%Y-%m') " + |
| | | "ORDER BY repairYearMonth ASC") // 按月份排序,方便前端展示 |
| | | List<RepairAmountGroupDTO> groupByMonthAndDeviceLedger(@Param("year") String year); |
| | | |
| | | /** |
| | | * 按“设备台账id”分组,求和报修金额 |
| | | * @param year 前端传入的年份(如"2025") |
| | | */ |
| | | @Select("SELECT " + |
| | | " device_ledger_id AS deviceLedgerId, " + |
| | | " SUM(maintenance_price) AS totalRepairPrice " + |
| | | "FROM device_maintenance " + |
| | | "WHERE DATE_FORMAT(maintenance_actually_time, '%Y') = #{year} " + // 只查询指定年份的数据 |
| | | "GROUP BY device_ledger_id ") // 按月份排序,方便前端展示 |
| | | List<RepairAmountGroupDTO> groupByDeviceLedger(@Param("year") String year); |
| | | |
| | | } |