parent
171ef18412
commit
31e433fc64
28 changed files with 613 additions and 41 deletions
@ -0,0 +1,150 @@ |
||||
package org.springblade.modules.business.contraller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import jakarta.validation.Valid; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.business.pojo.dto.DeviceDTO; |
||||
import org.springblade.modules.business.pojo.entity.Device; |
||||
import org.springblade.modules.business.pojo.entity.DeviceAttach; |
||||
import org.springblade.modules.business.pojo.vo.DeviceVO; |
||||
import org.springblade.modules.business.service.IDeviceAttachService; |
||||
import org.springblade.modules.business.service.IDeviceService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* 设备表 控制器 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Slf4j |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/device") |
||||
public class DeviceController extends BladeController { |
||||
|
||||
private final IDeviceService deviceService; |
||||
private final IDeviceAttachService deviceAttachService; |
||||
|
||||
/** |
||||
* 设备表 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<DeviceVO> detail(Device device) { |
||||
Device detail = deviceService.getOne(Condition.getQueryWrapper(device)); |
||||
DeviceVO deviceVO = Objects.requireNonNull(BeanUtil.copy(detail, DeviceVO.class)); |
||||
List<DeviceAttach> attaches = deviceAttachService.list(Wrappers.lambdaQuery(DeviceAttach.class).eq(DeviceAttach::getDeviceId, device.getId())); |
||||
deviceVO.setAttaches(attaches); |
||||
return R.data(deviceVO); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
public R<IPage<Device>> list(DeviceDTO device, Query query) { |
||||
if (device == null || query == null) { |
||||
throw new IllegalArgumentException("Device or Query cannot be null"); |
||||
} |
||||
|
||||
// 验证用户身份
|
||||
Long userId = AuthUtil.getUserId(); |
||||
if (userId == null) { |
||||
throw new IllegalArgumentException("User not authenticated"); |
||||
} |
||||
LambdaQueryWrapper<Device> wrapper = Wrappers.lambdaQuery(Device.class); |
||||
wrapper.like(StringUtils.isNotBlank(sanitizeInput(device.getName())), Device::getName, device.getName()); |
||||
wrapper.eq(StringUtils.isNotBlank(sanitizeInput(device.getPosition())), Device::getPosition, device.getPosition()); |
||||
wrapper.eq(StringUtils.isNotBlank(sanitizeInput(device.getType())), Device::getType, device.getType()); |
||||
// wrapper.eq(Device::getCreateUser, AuthUtil.getUserId());
|
||||
wrapper.orderByDesc(Device::getCreateTime); |
||||
try { |
||||
IPage<Device> pages = deviceService.page(Condition.getPage(query), wrapper); |
||||
return R.data(pages); |
||||
} catch (Exception e) { |
||||
// 记录异常日志
|
||||
log.error("Error occurred while fetching device list", e); |
||||
throw new RuntimeException("Failed to fetch device list", e); |
||||
} |
||||
} |
||||
|
||||
private String sanitizeInput(String input) { |
||||
// 对输入进行清理,防止 SQL 注入等安全问题
|
||||
if (input == null) { |
||||
return null; |
||||
} |
||||
return input.replaceAll("[^a-zA-Z0-9_\\-\\. ]", ""); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
public R<IPage<DeviceVO>> page(DeviceVO device, Query query) { |
||||
IPage<DeviceVO> pages = deviceService.selectDevicePage(Condition.getPage(query), device); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
public R save(@Valid @RequestBody DeviceDTO device) { |
||||
return R.status(deviceService.add(device)); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
public R update(@Valid @RequestBody DeviceDTO device) { |
||||
return R.status(deviceService.edit(device)); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 生成二维码 |
||||
*/ |
||||
@PostMapping("/qrcode") |
||||
@ApiOperationSupport(order = 5) |
||||
public R qrcode(@Valid @RequestBody Device device) { |
||||
return R.status(deviceService.qrcode(device)); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
public R submit(@Valid @RequestBody Device device) { |
||||
return R.status(deviceService.saveOrUpdate(device)); |
||||
} |
||||
|
||||
/** |
||||
* 设备表 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
public R remove(@RequestParam String ids) { |
||||
return R.status(deviceService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.DeviceMaintenance; |
||||
|
||||
/** |
||||
* 设备巡检表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface DeviceMaintenanceMapper extends BaseMapper<DeviceMaintenance> { |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlanDetail; |
||||
|
||||
/** |
||||
* 维保计划详情 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface MaintenancePlanDetailMapper extends BaseMapper<MaintenancePlanDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlan; |
||||
|
||||
/** |
||||
* 维保计划 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> { |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTaskDetail; |
||||
|
||||
/** |
||||
* 维保任务详情 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface MaintenanceTaskDetailMapper extends BaseMapper<MaintenanceTaskDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTask; |
||||
|
||||
/** |
||||
* 维保任务 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface MaintenanceTaskMapper extends BaseMapper<MaintenanceTask> { |
||||
|
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
package org.springblade.modules.business.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 设备巡检表 |
||||
* |
||||
* @author liuqingkun |
||||
*/ |
||||
@Data |
||||
@TableName("lab_device_maintenance") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@Schema(description = "设备巡检表") |
||||
public class DeviceMaintenance extends BaseEntity { |
||||
|
||||
private Long deviceId; |
||||
|
||||
/** |
||||
* 楼层 |
||||
*/ |
||||
private String floorName; |
||||
|
||||
/** |
||||
* 巡检内容 |
||||
*/ |
||||
private String checkContent; |
||||
|
||||
/** |
||||
* 工艺要求 |
||||
*/ |
||||
private String craft; |
||||
|
||||
/** |
||||
* 巡检周期 1:月, 2:季, 3:半年 |
||||
*/ |
||||
private Integer period; |
||||
|
||||
/** |
||||
* 计划开始时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd" |
||||
) |
||||
private Date startTime; |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.DeviceMaintenance; |
||||
|
||||
/** |
||||
* 设备巡检表 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IDeviceMaintenanceService extends BaseService<DeviceMaintenance> { |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlanDetail; |
||||
|
||||
/** |
||||
* 维保计划详情 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IMaintenancePlanDetailService extends BaseService<MaintenancePlanDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlan; |
||||
|
||||
/** |
||||
* 维保计划 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IMaintenancePlanService extends BaseService<MaintenancePlan> { |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTaskDetail; |
||||
|
||||
/** |
||||
* 维保任务详情 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IMaintenanceTaskDetailService extends BaseService<MaintenanceTaskDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTask; |
||||
|
||||
/** |
||||
* 维保任务 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IMaintenanceTaskService extends BaseService<MaintenanceTask> { |
||||
|
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.mapper.DeviceMaintenanceMapper; |
||||
import org.springblade.modules.business.pojo.entity.DeviceMaintenance; |
||||
import org.springblade.modules.business.service.IDeviceMaintenanceService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 设备巡检表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
public class DeviceMaintenanceServiceImpl extends BaseServiceImpl<DeviceMaintenanceMapper, DeviceMaintenance> implements IDeviceMaintenanceService { |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.service.IMaintenancePlanDetailService; |
||||
import org.springblade.modules.business.mapper.MaintenancePlanDetailMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlanDetail; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 巡检计划详情 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
public class MaintenancePlanDetailServiceImpl extends BaseServiceImpl<MaintenancePlanDetailMapper, MaintenancePlanDetail> implements IMaintenancePlanDetailService { |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.service.IMaintenancePlanService; |
||||
import org.springblade.modules.business.mapper.MaintenancePlanMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlan; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 巡检计划 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanMapper, MaintenancePlan> implements IMaintenancePlanService { |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.mapper.MaintenanceTaskDetailMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTaskDetail; |
||||
import org.springblade.modules.business.service.IMaintenanceTaskDetailService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 巡检任务详情 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<MaintenanceTaskDetailMapper, MaintenanceTaskDetail> implements IMaintenanceTaskDetailService { |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.service.IMaintenanceTaskService; |
||||
import org.springblade.modules.business.mapper.MaintenanceTaskMapper; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTask; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 巡检任务 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
public class MaintenanceTaskServiceImpl extends BaseServiceImpl<MaintenanceTaskMapper, MaintenanceTask> implements IMaintenanceTaskService { |
||||
|
||||
|
||||
} |
||||
Loading…
Reference in new issue