| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; |
| | | import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.IEamThirdMaintenanceOrderService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | /** |
| | | * @Description: 设备三级保养 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-04-29 |
| | |
| | | @Slf4j |
| | | @Api(tags="设备三级保养") |
| | | @RestController |
| | | @RequestMapping("/eam/eamThirdMaintenanceOrder") |
| | | @RequestMapping("/eam/thirdMaintenanceOrder") |
| | | public class EamThirdMaintenanceOrderController extends JeecgController<EamThirdMaintenanceOrder, IEamThirdMaintenanceOrderService> { |
| | | @Autowired |
| | | private IEamThirdMaintenanceOrderService eamThirdMaintenanceOrderService; |
| | | |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param eamThirdMaintenanceOrder |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-分页列表查询") |
| | | @ApiOperation(value="设备三级保养-分页列表查询", notes="设备三级保养-分页列表查询") |
| | | @ApiOperation(value = "设备三级保养-分页列表查询", notes = "设备三级保养-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamThirdMaintenanceOrder eamThirdMaintenanceOrder, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | public Result<?> queryPageList(EamThirdMaintenanceQuery query, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<EamThirdMaintenanceOrder> queryWrapper = QueryGenerator.initQueryWrapper(eamThirdMaintenanceOrder, req.getParameterMap()); |
| | | Page<EamThirdMaintenanceOrder> page = new Page<EamThirdMaintenanceOrder>(pageNo, pageSize); |
| | | IPage<EamThirdMaintenanceOrder> pageList = eamThirdMaintenanceOrderService.page(page, queryWrapper); |
| | | IPage<EamThirdMaintenanceOrder> pageList = eamThirdMaintenanceOrderService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param eamThirdMaintenanceOrder |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-添加") |
| | | @ApiOperation(value="设备三级保养-添加", notes="设备三级保养-添加") |
| | | @ApiOperation(value = "设备三级保养-添加", notes = "设备三级保养-添加") |
| | | @PostMapping(value = "/add") |
| | | public Result<?> add(@RequestBody EamThirdMaintenanceOrder eamThirdMaintenanceOrder) { |
| | | eamThirdMaintenanceOrderService.save(eamThirdMaintenanceOrder); |
| | | public Result<?> add(@RequestBody EamThirdMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.THIRD_MAINTENANCE_CODE_RULE); |
| | | request.setOrderNum(codeSeq); |
| | | request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); |
| | | boolean b = eamThirdMaintenanceOrderService.addMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("添加失败!"); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param eamThirdMaintenanceOrder |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-编辑") |
| | | @ApiOperation(value="设备三级保养-编辑", notes="设备三级保养-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamThirdMaintenanceOrder eamThirdMaintenanceOrder) { |
| | | eamThirdMaintenanceOrderService.updateById(eamThirdMaintenanceOrder); |
| | | @ApiOperation(value = "设备三级保养-编辑", notes = "设备三级保养-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamThirdMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | boolean b = eamThirdMaintenanceOrderService.editMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("编辑失败!"); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-通过id删除") |
| | | @ApiOperation(value="设备三级保养-通过id删除", notes="设备三级保养-通过id删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<?> delete(@RequestParam(name="id",required=true) String id) { |
| | | eamThirdMaintenanceOrderService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-批量删除") |
| | | @ApiOperation(value="设备三级保养-批量删除", notes="设备三级保养-批量删除") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.eamThirdMaintenanceOrderService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-通过id查询") |
| | | @ApiOperation(value="设备三级保养-通过id查询", notes="设备三级保养-通过id查询") |
| | | @ApiOperation(value = "设备三级保养-通过id查询", notes = "设备三级保养-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name="id",required=true) String id) { |
| | | EamThirdMaintenanceOrder eamThirdMaintenanceOrder = eamThirdMaintenanceOrderService.getById(id); |
| | | return Result.OK(eamThirdMaintenanceOrder); |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamThirdMaintenanceOrder order = eamThirdMaintenanceOrderService.getById(id); |
| | | return Result.OK(order); |
| | | } |
| | | |
| | | /** |
| | | * 通过id作废 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备三级保养-作废") |
| | | @ApiOperation(value = "设备三级保养-作废", notes = "设备三级保养-作废") |
| | | @DeleteMapping(value = "/abolish") |
| | | public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { |
| | | EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderService.getById(id); |
| | | if (entity == null) { |
| | | return Result.error("要作废的数据不存在,请刷新重试!"); |
| | | } |
| | | if (!ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | return Result.error("该状态的数据不允许进行作废!"); |
| | | } |
| | | entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamThirdMaintenanceOrderService.updateById(entity); |
| | | 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 = eamThirdMaintenanceOrderService.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 -> { |
| | | EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderService.getById(id); |
| | | if (entity != null && ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamThirdMaintenanceOrderService.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 -> { |
| | | EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderService.getById(id); |
| | | if (entity != null && ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | boolean b = eamThirdMaintenanceOrderService.collect(id); |
| | | if (b) { |
| | | i.getAndIncrement(); |
| | | } |
| | | } |
| | | }); |
| | | return Result.OK("批量领取成功 " + i.get() + " 条工单!"); |
| | | } |
| | | } |