| | |
| | | */ |
| | | package org.sxkj.gd.workorder.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.sxkj.gd.workorder.entity.GdManageDeviceEntity; |
| | | import org.sxkj.gd.workorder.vo.GdManageDeviceVO; |
| | | import org.sxkj.gd.workorder.excel.GdManageDeviceExcel; |
| | | import org.sxkj.gd.workorder.wrapper.GdManageDeviceWrapper; |
| | | import org.sxkj.gd.workorder.service.IGdManageDeviceService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.sxkj.gd.common.GenericConverter; |
| | | import org.sxkj.gd.common.IdParam; |
| | | import org.sxkj.gd.workorder.dto.GdManageDeviceDTO; |
| | | import org.sxkj.gd.workorder.entity.GdManageDeviceEntity; |
| | | import org.sxkj.gd.workorder.excel.GdManageDeviceExcel; |
| | | import org.sxkj.gd.workorder.param.GdManageDevicePageParam; |
| | | import org.sxkj.gd.workorder.service.IGdManageDeviceService; |
| | | import org.sxkj.gd.workorder.vo.GdManageDeviceVO; |
| | | import org.sxkj.gd.workorder.wrapper.GdManageDeviceWrapper; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 设备信息 控制器 |
| | |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入gdManageDevice") |
| | | public R<GdManageDeviceVO> detail(GdManageDeviceEntity gdManageDevice) { |
| | | GdManageDeviceEntity detail = gdManageDeviceService.getOne(Condition.getQueryWrapper(gdManageDevice)); |
| | | public R<GdManageDeviceVO> detail(@Valid IdParam manageDevice) { |
| | | GdManageDeviceEntity detail = gdManageDeviceService.getOne(Condition.getQueryWrapper(GenericConverter.convert(manageDevice, GdManageDeviceEntity.class))); |
| | | if (detail == null) { |
| | | return R.fail("该设备不存在"); |
| | | } |
| | | return R.data(GdManageDeviceWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 设备信息 自定义分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "不分页", notes = "传入gdManageDevice") |
| | | public R<List<GdManageDeviceVO>> page(GdManageDevicePageParam gdManageDevice) { |
| | | List<GdManageDeviceVO> pages = gdManageDeviceService.selectGdManageDevice(gdManageDevice); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入gdManageDevice") |
| | | public R<IPage<GdManageDeviceVO>> page(GdManageDeviceVO gdManageDevice, Query query) { |
| | | public R<IPage<GdManageDeviceVO>> page(GdManageDevicePageParam gdManageDevice, Query query) { |
| | | IPage<GdManageDeviceVO> pages = gdManageDeviceService.selectGdManageDevicePage(Condition.getPage(query), gdManageDevice); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 设备信息 新增或修改 |
| | | * 设备信息 新增或修改(对外) |
| | | */ |
| | | @PostMapping("/submit") |
| | | @PostMapping("/submitExternal") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入gdManageDevice") |
| | | public R submit(@Valid @RequestBody GdManageDeviceEntity gdManageDevice) { |
| | | return R.status(gdManageDeviceService.saveOrUpdate(gdManageDevice)); |
| | | @ApiOperation(value = "新增或修改", notes = "传入gdManageDevice,设备编码相同则修改") |
| | | public R submitExternal(@Valid @RequestBody GdManageDeviceDTO gdManageDevice) throws Exception { |
| | | |
| | | if (StringUtil.isBlank(gdManageDevice.getDeviceSn())) { |
| | | return R.fail("设备编码不能为空"); |
| | | } |
| | | |
| | | QueryWrapper<GdManageDeviceEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(GdManageDeviceEntity::getDeviceSn, gdManageDevice.getDeviceSn()); |
| | | |
| | | GdManageDeviceEntity detail = gdManageDeviceService.getOne(queryWrapper); |
| | | if (detail != null) { |
| | | gdManageDevice.setId(detail.getId()); |
| | | } |
| | | |
| | | |
| | | return R.status(gdManageDeviceService.saveOrUpdateDevice(GdManageDeviceWrapper.build().entityDTO(gdManageDevice))); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.status(gdManageDeviceService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 同步星图设备(测试接口) |
| | | */ |
| | | @PostMapping("/sync-xingtu") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "同步星图设备(测试)", notes = "同步无人机和机巢到设备表") |
| | | public R syncXingtuDevice() throws Exception { |
| | | int count = gdManageDeviceService.syncXingtuDevice(); |
| | | return R.data(count); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出数据 |