| | |
| | | import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder; |
| | | import org.jeecg.modules.eam.request.EamSecondMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * @Description: 设备二级保养 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-04-29 |
| | | * @Date: 2025-04-29 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags="设备二级保养") |
| | | @Api(tags = "设备二级保养") |
| | | @RestController |
| | | @RequestMapping("/eam/secondMaintenanceOrder") |
| | | public class EamSecondMaintenanceOrderController extends JeecgController<EamSecondMaintenanceOrder, IEamSecondMaintenanceOrderService> { |
| | | @Autowired |
| | | private IEamSecondMaintenanceOrderService eamSecondMaintenanceOrderService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private IEamSecondMaintenanceOrderDetailService secondMaintenanceOrderDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-分页列表查询") |
| | | @ApiOperation(value="设备二级保养-分页列表查询", notes="设备二级保养-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamSecondMaintenanceQuery query, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | @Autowired |
| | | private IEamSecondMaintenanceOrderService eamSecondMaintenanceOrderService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-分页列表查询") |
| | | @ApiOperation(value = "设备二级保养-分页列表查询", notes = "设备二级保养-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamSecondMaintenanceQuery query, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | // QueryWrapper<EamSecondMaintenanceOrder> queryWrapper = QueryGenerator.initQueryWrapper(eamSecondMaintenanceOrder, req.getParameterMap()); |
| | | Page<EamSecondMaintenanceOrder> page = new Page<EamSecondMaintenanceOrder>(pageNo, pageSize); |
| | | IPage<EamSecondMaintenanceOrder> pageList = eamSecondMaintenanceOrderService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-添加") |
| | | @ApiOperation(value="设备二级保养-添加", notes="设备二级保养-添加") |
| | | @PostMapping(value = "/add") |
| | | public Result<?> add(@RequestBody EamSecondMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.SECOND_MAINTENANCE_CODE_RULE); |
| | | request.setOrderNum(codeSeq); |
| | | request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); |
| | | boolean b = eamSecondMaintenanceOrderService.addWeekMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("添加失败!"); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-编辑") |
| | | @ApiOperation(value="设备二级保养-编辑", notes="设备二级保养-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamSecondMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | boolean b = eamSecondMaintenanceOrderService.editWeekMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("编辑失败!"); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | Page<EamSecondMaintenanceOrder> page = new Page<EamSecondMaintenanceOrder>(pageNo, pageSize); |
| | | IPage<EamSecondMaintenanceOrder> pageList = eamSecondMaintenanceOrderService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-通过id查询") |
| | | @ApiOperation(value="设备二级保养-通过id查询", notes="设备二级保养-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name="id",required=true) String id) { |
| | | EamSecondMaintenanceOrder eamSecondMaintenanceOrder = eamSecondMaintenanceOrderService.getById(id); |
| | | return Result.OK(eamSecondMaintenanceOrder); |
| | | } |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-添加") |
| | | @ApiOperation(value = "设备二级保养-添加", notes = "设备二级保养-添加") |
| | | @PostMapping(value = "/add") |
| | | public Result<?> add(@RequestBody EamSecondMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.SECOND_MAINTENANCE_CODE_RULE); |
| | | request.setOrderNum(codeSeq); |
| | | request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); |
| | | boolean b = eamSecondMaintenanceOrderService.addMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("添加失败!"); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id作废 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-作废") |
| | | @ApiOperation(value = "设备二级保养-作废", notes = "设备二级保养-作废") |
| | | @DeleteMapping(value = "/abolish") |
| | | public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity == null) { |
| | | return Result.error("要作废的数据不存在,请刷新重试!"); |
| | | } |
| | | if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | return Result.error("该状态的数据不允许进行作废!"); |
| | | } |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamSecondMaintenanceOrderService.updateById(entity); |
| | | return Result.OK("作废成功!"); |
| | | } |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-编辑") |
| | | @ApiOperation(value = "设备二级保养-编辑", notes = "设备二级保养-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamSecondMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | boolean b = eamSecondMaintenanceOrderService.editMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("编辑失败!"); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id领取 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-领取") |
| | | @ApiOperation(value = "设备二级保养-领取", notes = "设备二级保养-领取") |
| | | @GetMapping(value = "/collect") |
| | | public Result<?> collect(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = eamSecondMaintenanceOrderService.collect(id); |
| | | if (!b) { |
| | | Result.OK("领取失败!"); |
| | | } |
| | | return Result.OK("领取成功!"); |
| | | } |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-通过id查询") |
| | | @ApiOperation(value = "设备二级保养-通过id查询", notes = "设备二级保养-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamSecondMaintenanceOrder eamSecondMaintenanceOrder = eamSecondMaintenanceOrderService.getById(id); |
| | | return Result.OK(eamSecondMaintenanceOrder); |
| | | } |
| | | |
| | | /** |
| | | * 通过id批量作废 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "周保工单-批量作废") |
| | | @ApiOperation(value = "周保工单-批量作废", notes = "周保工单-批量作废") |
| | | @DeleteMapping(value = "/abolishBatch") |
| | | public Result<?> abolishBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity != null && SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamSecondMaintenanceOrderService.updateById(entity); |
| | | i.getAndIncrement(); |
| | | } |
| | | }); |
| | | return Result.OK("批量作废成功 " + i.get() + " 条工单!"); |
| | | } |
| | | /** |
| | | * 通过id作废 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-作废") |
| | | @ApiOperation(value = "设备二级保养-作废", notes = "设备二级保养-作废") |
| | | @DeleteMapping(value = "/abolish") |
| | | public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity == null) { |
| | | return Result.error("要作废的数据不存在,请刷新重试!"); |
| | | } |
| | | if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | return Result.error("该状态的数据不允许进行作废!"); |
| | | } |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamSecondMaintenanceOrderService.updateById(entity); |
| | | return Result.OK("作废成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id批量领取 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "周保工单-批量领取") |
| | | @ApiOperation(value = "周保工单-批量领取", notes = "周保工单-批量领取") |
| | | @DeleteMapping(value = "/collectBatch") |
| | | public Result<?> collectBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity != null && SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | boolean b = eamSecondMaintenanceOrderService.collect(id); |
| | | if (b) { |
| | | i.getAndIncrement(); |
| | | } |
| | | } |
| | | }); |
| | | return Result.OK("批量领取成功 " + i.get() + " 条工单!"); |
| | | } |
| | | /** |
| | | * 通过id领取 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备二级保养-领取") |
| | | @ApiOperation(value = "设备二级保养-领取", notes = "设备二级保养-领取") |
| | | @GetMapping(value = "/collect") |
| | | public Result<?> collect(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = eamSecondMaintenanceOrderService.collect(id); |
| | | if (!b) { |
| | | Result.OK("领取失败!"); |
| | | } |
| | | return Result.OK("领取成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id批量作废 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "周保工单-批量作废") |
| | | @ApiOperation(value = "周保工单-批量作废", notes = "周保工单-批量作废") |
| | | @DeleteMapping(value = "/abolishBatch") |
| | | public Result<?> abolishBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity != null && SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamSecondMaintenanceOrderService.updateById(entity); |
| | | i.getAndIncrement(); |
| | | } |
| | | }); |
| | | return Result.OK("批量作废成功 " + i.get() + " 条工单!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id批量领取 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "周保工单-批量领取") |
| | | @ApiOperation(value = "周保工单-批量领取", notes = "周保工单-批量领取") |
| | | @DeleteMapping(value = "/collectBatch") |
| | | public Result<?> collectBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); |
| | | if (entity != null && SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | boolean b = eamSecondMaintenanceOrderService.collect(id); |
| | | if (b) { |
| | | i.getAndIncrement(); |
| | | } |
| | | } |
| | | }); |
| | | return Result.OK("批量领取成功 " + i.get() + " 条工单!"); |
| | | } |
| | | } |