You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
4.3 KiB
Java
131 lines
4.3 KiB
Java
1 year ago
|
package com.glxp.api.controller.dev;
|
||
|
|
||
|
import com.github.pagehelper.PageInfo;
|
||
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||
|
import com.glxp.api.common.res.BaseResponse;
|
||
|
import com.glxp.api.common.util.ResultVOUtils;
|
||
|
import com.glxp.api.controller.BaseController;
|
||
|
import com.glxp.api.entity.auth.AuthAdmin;
|
||
|
import com.glxp.api.entity.dev.DevicePlanDetailEntity;
|
||
|
import com.glxp.api.entity.dev.DevicePlanEntity;
|
||
|
import com.glxp.api.req.dev.DevicePlanDetailGroupQuery;
|
||
|
import com.glxp.api.req.dev.DevicePlanDetailParam;
|
||
|
import com.glxp.api.req.dev.DevicePlanDetailQuery;
|
||
|
import com.glxp.api.res.PageSimpleResponse;
|
||
|
import com.glxp.api.service.dev.DeviceInfoService;
|
||
|
import com.glxp.api.service.dev.DevicePlanDetailService;
|
||
|
import com.glxp.api.service.dev.DevicePlanService;
|
||
|
import com.glxp.api.vo.dev.DevicePlanDetailVo;
|
||
|
import lombok.RequiredArgsConstructor;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
||
|
import javax.validation.Valid;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* 设备计划明细
|
||
|
* data: 2023/11/12
|
||
|
*/
|
||
|
@RestController
|
||
|
@RequestMapping
|
||
|
@RequiredArgsConstructor
|
||
|
@Slf4j
|
||
|
public class DevicePlanDetailController extends BaseController {
|
||
|
|
||
|
private final DeviceInfoService deviceInfoService;
|
||
|
private final DevicePlanService devicePlanService;
|
||
|
private final DevicePlanDetailService devicePlanDetailService;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设备巡检计划分页
|
||
|
*
|
||
|
* @param query
|
||
|
* @return
|
||
|
*/
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/udi/device/plan/detailGroup/page")
|
||
|
public BaseResponse pageGroup(@RequestBody @Valid DevicePlanDetailGroupQuery query) {
|
||
|
List<DevicePlanDetailVo> list = devicePlanDetailService.pageGroupVo(query);
|
||
|
PageInfo pageInfo = new PageInfo<>(list);
|
||
|
PageSimpleResponse page = new PageSimpleResponse();
|
||
|
page.setTotal(pageInfo.getTotal());
|
||
|
page.setList(pageInfo.getList());
|
||
|
return ResultVOUtils.success(page);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设备巡检计划明细分页
|
||
|
*
|
||
|
* @param query
|
||
|
* @return
|
||
|
*/
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/udi/device/plan/detail/page")
|
||
|
public BaseResponse pageGroup(@RequestBody @Valid DevicePlanDetailQuery query) {
|
||
|
List<DevicePlanDetailVo> list = devicePlanDetailService.pageVo(query);
|
||
|
PageInfo pageInfo = new PageInfo<>(list);
|
||
|
PageSimpleResponse page = new PageSimpleResponse();
|
||
|
page.setTotal(pageInfo.getTotal());
|
||
|
page.setList(pageInfo.getList());
|
||
|
return ResultVOUtils.success(page);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设备巡检计划明细新增
|
||
|
*
|
||
|
* @param param 参数
|
||
|
* @return 计划id
|
||
|
*/
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/udi/device/plan/detail/add")
|
||
|
public BaseResponse add(@RequestBody @Valid DevicePlanDetailParam param) {
|
||
|
DevicePlanEntity entity = null;
|
||
|
if (!param.valid(devicePlanService)) {
|
||
|
AuthAdmin user = super.getUser();
|
||
|
entity = param.getDevicePlanParam().getEntity(user);
|
||
|
devicePlanService.save(entity);
|
||
|
param.getDevicePlanParam().setPlanId(entity.getPlanId());
|
||
|
param.setPlanId(entity.getPlanId());
|
||
|
} else {
|
||
|
entity = devicePlanService.getById(param.getPlanId());
|
||
|
}
|
||
|
param.valid(devicePlanService);
|
||
|
List<DevicePlanDetailEntity> list = param.getEntity(deviceInfoService);
|
||
|
devicePlanDetailService.replaceBatch(list);
|
||
|
return ResultVOUtils.success(entity);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设备巡检计划明细删除
|
||
|
*
|
||
|
* @param planId 计划id
|
||
|
* @param productId 产品id
|
||
|
*/
|
||
|
@AuthRuleAnnotation("")
|
||
|
@DeleteMapping("/udi/device/plan/detail/delByProductId/{planId}/{productId}")
|
||
|
public BaseResponse delByProductId(@PathVariable Long planId, @PathVariable Long productId) {
|
||
|
devicePlanDetailService.delByProductId(planId, productId);
|
||
|
return ResultVOUtils.successMsg("删除成功");
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设备巡检计划明细删除
|
||
|
*
|
||
|
* @param planId 计划id
|
||
|
* @param deviceCode 设备编码
|
||
|
*/
|
||
|
@AuthRuleAnnotation("")
|
||
|
@DeleteMapping("/udi/device/plan/detail/delByDeviceCode/{planId}/{deviceCode}")
|
||
|
public BaseResponse delByDeviceCode(@PathVariable Long planId, @PathVariable String deviceCode) {
|
||
|
devicePlanDetailService.delByDeviceCode(planId, deviceCode);
|
||
|
return ResultVOUtils.successMsg("删除成功");
|
||
|
}
|
||
|
|
||
|
}
|