gongchunyi
6 天以前 ad65726388fc99ff95db91b4a8a716362cccedd7
src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -12,6 +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.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
@@ -35,32 +37,34 @@
    private DeviceMaintenanceMapper deviceMaintenanceMapper;
    @Operation(summary = "设备台账列表")
    @GetMapping("/page")
    public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) {
        return AjaxResult.success(deviceLedgerService.queryPage(page,deviceLedger));
    public AjaxResult page(Page page, DeviceLedgerDto deviceLedger) {
        return AjaxResult.success(deviceLedgerService.queryPage(page, deviceLedger));
    }
    @Log(title = "新增设备台账", businessType = BusinessType.INSERT)
    @PostMapping()
    @Operation(summary = "添加设备台账")
    public AjaxResult add(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.saveDeviceLedger(deviceLedger);
    public AjaxResult add(@RequestBody DeviceLedgerDto deviceLedgerDto) {
        return deviceLedgerService.saveDeviceLedger(deviceLedgerDto);
    }
    @Operation(summary = "根据id查询设备台账")
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(deviceLedgerService.getById(id));
        DeviceLedgerDto deviceLedgerDto = deviceLedgerService.getDeviceLedgerDetail(id);
        return AjaxResult.success(deviceLedgerDto);
    }
    @PutMapping ()
    @Log(title = "修改设备台账", businessType = BusinessType.UPDATE)
    @PutMapping()
    @Operation(summary = "修改设备台账")
    public AjaxResult update(@RequestBody DeviceLedger deviceLedger) {
        return deviceLedgerService.updateDeviceLedger(deviceLedger);
    public AjaxResult update(@RequestBody DeviceLedgerDto deviceLedgerDto) {
        return deviceLedgerService.updateDeviceLedger(deviceLedgerDto);
    }
    @Log(title = "删除设备台账", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除设备台账")
    public AjaxResult delete(@PathVariable("ids") ArrayList<Long> ids) {
@@ -71,12 +75,14 @@
        return AjaxResult.success();
    }
    @Log(title = "导出设备台账", businessType = BusinessType.EXPORT)
    @PostMapping("export")
    @Operation(summary = "导出设备台账")
    public void export(HttpServletResponse response, Long[] ids) {
         deviceLedgerService.export(response, ids);
        deviceLedgerService.export(response, ids);
    }
    @Log(title = "下载设备台账模板", businessType = BusinessType.EXPORT)
    @Operation(summary = "下载模板")
    @PostMapping("/downloadTemplate")
    public void downloadTemplate(HttpServletResponse response) {
@@ -84,6 +90,7 @@
        util.importTemplateExcel(response, "设备导入模板");
    }
    @Log(title = "导入设备台账", businessType = BusinessType.IMPORT)
    @PostMapping("/import")
    @Operation(summary = "导入设备台账")
    public AjaxResult importData(MultipartFile file) throws IOException {
@@ -97,9 +104,9 @@
    @GetMapping("getDeviceLedger")
    @Operation(summary = "获取设备台账")
    public AjaxResult getDeviceLedger( ) {
    public AjaxResult getDeviceLedger() {
        return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
                .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel)));
                .select(DeviceLedger::getId, DeviceLedger::getDeviceName, DeviceLedger::getDeviceModel)));
    }
    @GetMapping("scanDevice")
@@ -108,8 +115,8 @@
    public AjaxResult scanDevice(Long id) {
        List<DeviceMaintenance> list = deviceMaintenanceMapper.list1(id);
        DeviceLedger deviceLedger = deviceLedgerMapper.selectById1(id);
        if (list.size()>0){
            deviceLedger.setUpdateTime(list.get(0).getMaintenanceActuallyTime());//最后维护时间
        if (!list.isEmpty()) {
            deviceLedger.setUpdateTime(list.getFirst().getMaintenanceActuallyTime());//最后维护时间
        }
        deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//下次维护时间
        return AjaxResult.success(deviceLedger);