| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.device.dto.DeviceRepairDto; |
| | | import com.ruoyi.device.dto.RepairAmountGroupDTO; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | 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 DeviceRepairMapper extends BaseMapper<DeviceRepair> { |
| | | IPage<DeviceRepairDto> queryPage(Page page, @Param("deviceRepairDto") DeviceRepairDto deviceRepairDto); |
| | | |
| | | DeviceRepairDto detailById(Long id); |
| | | |
| | | |
| | | /** |
| | | * 按“指定年份的年月+设备台账id”分组,求和报修金额 |
| | | * @param year 前端传入的年份(如"2025") |
| | | */ |
| | | @Select("SELECT " + |
| | | " DATE_FORMAT(repair_time, '%m') AS repairYearMonth, " + |
| | | " device_ledger_id AS deviceLedgerId, " + |
| | | " SUM(repair_price) AS totalRepairPrice " + |
| | | "FROM device_repair " + |
| | | "WHERE DATE_FORMAT(repair_time, '%Y') = #{year} " + // 只查询指定年份的数据 |
| | | "GROUP BY device_ledger_id,DATE_FORMAT(repair_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(repair_price) AS totalRepairPrice " + |
| | | "FROM device_repair " + |
| | | "WHERE DATE_FORMAT(repair_time, '%Y') = #{year} " + // 只查询指定年份的数据 |
| | | "GROUP BY device_ledger_id ") // 按月份排序,方便前端展示 |
| | | List<RepairAmountGroupDTO> groupByDeviceLedger(@Param("year") String year); |
| | | } |