¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.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 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags="设å¤ä¸çº§ä¿å
»") |
| | | @RestController |
| | | @RequestMapping("/eam/thirdMaintenanceOrder") |
| | | public class EamThirdMaintenanceOrderController extends JeecgController<EamThirdMaintenanceOrder, IEamThirdMaintenanceOrderService> { |
| | | @Autowired |
| | | private IEamThirdMaintenanceOrderService eamThirdMaintenanceOrderService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤ä¸çº§ä¿å
»-å页å表æ¥è¯¢") |
| | | @ApiOperation(value = "设å¤ä¸çº§ä¿å
»-å页å表æ¥è¯¢", notes = "设å¤ä¸çº§ä¿å
»-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamThirdMaintenanceQuery query, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Page<EamThirdMaintenanceOrder> page = new Page<EamThirdMaintenanceOrder>(pageNo, pageSize); |
| | | IPage<EamThirdMaintenanceOrder> pageList = eamThirdMaintenanceOrderService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤ä¸çº§ä¿å
»-æ·»å ") |
| | | @ApiOperation(value = "设å¤ä¸çº§ä¿å
»-æ·»å ", notes = "设å¤ä¸çº§ä¿å
»-æ·»å ") |
| | | @PostMapping(value = "/add") |
| | | 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 request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤ä¸çº§ä¿å
»-ç¼è¾") |
| | | @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æ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | 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() + " æ¡å·¥åï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æçå¾
åï¼å®¡æ¹å¨ä½ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "ä¸ä¿å·¥å-æ§è¡æä½", notes = "ä¸ä¿å·¥å-æ§è¡æä½") |
| | | @PutMapping(value = "/approval") |
| | | public Result<?> approval(@RequestBody EamThirdMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("审æ¹ç对象ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | // æ£æ¥è¯·æ±åæ° |
| | | if (StrUtil.isBlank(request.getTaskId()) || StrUtil.isBlank(request.getDataId()) || StrUtil.isBlank(request.getInstanceId())) { |
| | | return Result.error("审æ¹ä»»å¡é误æä¸åå¨ï¼"); |
| | | } |
| | | EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderService.approval(request); |
| | | if (entity == null) { |
| | | return Result.error("æä½å¤±è´¥ï¼"); |
| | | } |
| | | return Result.ok("æä½æåï¼"); |
| | | } |
| | | } |