5 天以前 0d7d874912d0147376826b55667a1deb6547ed91
src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -12,7 +12,8 @@
import com.ruoyi.device.pojo.DeviceMaintenance;
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
@@ -28,7 +29,7 @@
@RequestMapping("/device/ledger")
@RestController
@AllArgsConstructor
public class DeviceLedgerController {
public class DeviceLedgerController extends BaseController {
    private IDeviceLedgerService deviceLedgerService;
    private DeviceLedgerMapper deviceLedgerMapper;
@@ -38,37 +39,37 @@
    @Operation(summary = "设备台账列表")
    @GetMapping("/page")
    public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) {
        return AjaxResult.success(deviceLedgerService.queryPage(page,deviceLedger));
    public R<?> page(Page page , DeviceLedgerDto deviceLedger) {
        return R.ok(deviceLedgerService.queryPage(page,deviceLedger));
    }
    @PostMapping()
    @Operation(summary = "添加设备台账")
    public AjaxResult add(@RequestBody DeviceLedger deviceLedger) {
    public R<?> add(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.saveDeviceLedger(deviceLedger);
    }
    @Operation(summary = "根据id查询设备台账")
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(deviceLedgerService.getById(id));
    public R<?> detail(@PathVariable Long id) {
        return R.ok(deviceLedgerService.getById(id));
    }
    @PutMapping ()
    @Operation(summary = "修改设备台账")
    public AjaxResult update(@RequestBody DeviceLedger deviceLedger) {
    public R<?> update(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.updateDeviceLedger(deviceLedger);
    }
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除设备台账")
    public AjaxResult delete(@PathVariable("ids") ArrayList<Long> ids) {
    public R<?> delete(@PathVariable("ids") ArrayList<Long> ids) {
        boolean b = deviceLedgerService.removeBatchByIds(ids);
        if (!b) {
            return AjaxResult.error("删除失败");
            return R.fail("删除失败");
        }
        return AjaxResult.success();
        return R.ok();
    }
    @PostMapping("export")
@@ -86,32 +87,32 @@
    @PostMapping("/import")
    @Operation(summary = "导入设备台账")
    public AjaxResult importData(MultipartFile file) throws IOException {
    public R<?> importData(MultipartFile file) throws IOException {
        Boolean b = deviceLedgerService.importData(file);
        if (b) {
            return AjaxResult.success("导入成功");
            return R.ok(null, "导入成功");
        }
        return AjaxResult.error("导入失败");
        return R.fail("导入失败");
    }
    @GetMapping("getDeviceLedger")
    @Operation(summary = "获取设备台账")
    public AjaxResult getDeviceLedger( ) {
        return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
    public R<?> getDeviceLedger( ) {
        return R.ok(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
                .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel)));
    }
    @GetMapping("scanDevice")
    @Operation(summary = "获取设备台账")
    @Anonymous
    public AjaxResult scanDevice(Long id) {
    public R<?> scanDevice(Long id) {
        List<DeviceMaintenance> list = deviceMaintenanceMapper.list1(id);
        DeviceLedger deviceLedger = deviceLedgerMapper.selectById1(id);
        if (list.size()>0){
            deviceLedger.setUpdateTime(list.get(0).getMaintenanceActuallyTime());//最后维护时间
        }
        deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//下次维护时间
        return AjaxResult.success(deviceLedger);
        return R.ok(deviceLedger);
    }
}