package com.ruoyi.device.controller;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.device.dto.DeviceMonthlyRepairTableDTO;
|
import com.ruoyi.device.dto.DeviceRepairDto;
|
import com.ruoyi.device.dto.RepairAmountGroupDTO;
|
import com.ruoyi.device.pojo.DeviceLedger;
|
import com.ruoyi.device.pojo.DeviceRepair;
|
import com.ruoyi.device.service.IDeviceLedgerService;
|
import com.ruoyi.device.service.IDeviceRepairService;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiModelProperty;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Api(tags = "设备报修管理")
|
@RequestMapping("/device/repair")
|
@RestController
|
public class DeviceRepairController {
|
|
@Autowired
|
private IDeviceRepairService deviceRepairService;
|
|
@Autowired
|
private IDeviceLedgerService deviceLedgerService;
|
|
@ApiModelProperty("设备报修列表")
|
@GetMapping("/page")
|
public AjaxResult page(Page page , DeviceRepairDto deviceRepairDto) {
|
return AjaxResult.success(deviceRepairService.queryPage(page,deviceRepairDto));
|
}
|
|
@PostMapping()
|
@ApiModelProperty("添加设备报修")
|
public AjaxResult add( @RequestBody DeviceRepair deviceRepair) {
|
return deviceRepairService.saveDeviceRepair(deviceRepair);
|
}
|
|
@ApiModelProperty("根据id查询设备报修")
|
@GetMapping("/{id}")
|
public AjaxResult detail(@PathVariable Long id) {
|
DeviceRepairDto byId = deviceRepairService.detailById(id);
|
return AjaxResult.success(byId);
|
}
|
|
@PutMapping ()
|
@ApiModelProperty("修改设备报修")
|
public AjaxResult update( @RequestBody DeviceRepair deviceRepair) {
|
return deviceRepairService.updateDeviceRepair(deviceRepair);
|
}
|
|
@PostMapping ("repair")
|
@ApiModelProperty("设备维修")
|
public AjaxResult repair( @RequestBody DeviceRepair deviceRepair) {
|
deviceRepair.setStatus(1);
|
return deviceRepairService.updateDeviceRepair(deviceRepair);
|
}
|
|
@DeleteMapping("/{ids}")
|
@ApiModelProperty("删除设备报修")
|
public AjaxResult delete(@PathVariable("ids") Long[] ids) {
|
boolean b = deviceRepairService.removeBatchByIds(Arrays.asList(ids));
|
if (!b) {
|
return AjaxResult.error("删除失败");
|
}
|
return AjaxResult.success();
|
}
|
|
@PostMapping("export")
|
@ApiModelProperty("导出设备报修")
|
public void export(HttpServletResponse response, Long[] ids) {
|
deviceRepairService.export(response, ids);
|
}
|
|
/**
|
* 按年份查询每月报修金额(按设备台账分组)
|
* @param year 前端传入的年份(如2025)
|
*/
|
@GetMapping("/monthlyAmount")
|
@ApiModelProperty("按年份查询每月报修金额(按设备台账分组)")
|
public AjaxResult getMonthlyAmount(@RequestParam(defaultValue = "2025", required = true,name = "year") String year) {
|
List<DeviceMonthlyRepairTableDTO> result = deviceRepairService.getMonthlyRepairAmountByYear(year);
|
return AjaxResult.success(result);
|
}
|
|
/**
|
* 按年份查询报修金额(按设备台账分组)
|
* @param year 前端传入的年份(如2025)
|
*/
|
@GetMapping("/yearlyAmount")
|
@ApiModelProperty("按年份查询报修金额(按设备台账分组)")
|
public AjaxResult yearlyAmount(@RequestParam(defaultValue = "2025", required = true,name = "year") String year) {
|
List<RepairAmountGroupDTO> result = deviceRepairService.getRepairAmountByYear(year);
|
return AjaxResult.success(result);
|
}
|
|
}
|