From eea27b448ec2d289f5c9665bf4b3678d580457ee Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期二, 22 七月 2025 15:45:23 +0800 Subject: [PATCH] 三保变更基础代码,点检导出修改 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceChangeController.java | 140 +++++++++++++++++++++++++++++++++------------- 1 files changed, 100 insertions(+), 40 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceChangeController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceChangeController.java index 4e96dd1..6688ef7 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceChangeController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceChangeController.java @@ -1,23 +1,30 @@ package org.jeecg.modules.eam.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; 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.common.system.query.QueryGenerator; +import org.jeecg.common.util.TranslateDictTextUtils; +import org.jeecg.modules.eam.constant.ThirdMaintenanceChangeStatusEnum; +import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrderChange; import org.jeecg.modules.eam.entity.EamThirdMaintenanceChange; +import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderChangeRequest; +import org.jeecg.modules.eam.request.EamThirdMaintenanceChangeQuery; +import org.jeecg.modules.eam.request.EamThirdMaintenanceChangeRequest; import org.jeecg.modules.eam.service.IEamThirdMaintenanceChangeService; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.util.Arrays; /** @@ -34,11 +41,15 @@ @Resource private IEamThirdMaintenanceChangeService eamThirdMaintenanceChangeService; + @Resource + private ObjectMapper objectMapper; + @Resource + private TranslateDictTextUtils translateDictTextUtils; /** * 鍒嗛〉鍒楄〃鏌ヨ * - * @param eamThirdMaintenanceChange + * @param query * @param pageNo * @param pageSize * @param req @@ -47,41 +58,52 @@ @AutoLog(value = "涓変繚鍙樻洿-鍒嗛〉鍒楄〃鏌ヨ") @ApiOperation(value = "涓変繚鍙樻洿-鍒嗛〉鍒楄〃鏌ヨ", notes = "涓変繚鍙樻洿-鍒嗛〉鍒楄〃鏌ヨ") @GetMapping(value = "/list") - public Result<?> queryPageList(EamThirdMaintenanceChange eamThirdMaintenanceChange, + public Result<?> queryPageList(EamThirdMaintenanceChangeQuery query, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { - QueryWrapper<EamThirdMaintenanceChange> queryWrapper = QueryGenerator.initQueryWrapper(eamThirdMaintenanceChange, req.getParameterMap()); Page<EamThirdMaintenanceChange> page = new Page<EamThirdMaintenanceChange>(pageNo, pageSize); - IPage<EamThirdMaintenanceChange> pageList = eamThirdMaintenanceChangeService.page(page, queryWrapper); + IPage<EamThirdMaintenanceChange> pageList = eamThirdMaintenanceChangeService.queryPageList(page, query); return Result.OK(pageList); } /** * 娣诲姞 * - * @param eamThirdMaintenanceChange + * @param request * @return */ @AutoLog(value = "涓変繚鍙樻洿-娣诲姞") @ApiOperation(value = "涓変繚鍙樻洿-娣诲姞", notes = "涓変繚鍙樻洿-娣诲姞") @PostMapping(value = "/add") - public Result<?> add(@RequestBody EamThirdMaintenanceChange eamThirdMaintenanceChange) { - eamThirdMaintenanceChangeService.save(eamThirdMaintenanceChange); - return Result.OK("娣诲姞鎴愬姛锛�"); + public Result<?> add(@RequestBody EamThirdMaintenanceChange request) { + if (request == null) { + return Result.error("娣诲姞鐨勫璞′笉鑳戒负绌猴紒"); + } + boolean b = eamThirdMaintenanceChangeService.saveThirdMaintenanceChange(request); + if (!b) { + return Result.error("鍙樻洿澶辫触锛�"); + } + return Result.OK("鍙樻洿鎴愬姛锛�"); } /** * 缂栬緫 * - * @param eamThirdMaintenanceChange + * @param request * @return */ @AutoLog(value = "涓変繚鍙樻洿-缂栬緫") @ApiOperation(value = "涓変繚鍙樻洿-缂栬緫", notes = "涓変繚鍙樻洿-缂栬緫") @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) - public Result<?> edit(@RequestBody EamThirdMaintenanceChange eamThirdMaintenanceChange) { - eamThirdMaintenanceChangeService.updateById(eamThirdMaintenanceChange); + public Result<?> edit(@RequestBody EamThirdMaintenanceChange request) { + if (request == null) { + return Result.error("缂栬緫鐨勫璞′笉鑳戒负绌猴紒"); + } + boolean b = eamThirdMaintenanceChangeService.editThirdMaintenanceChange(request); + if (!b) { + return Result.error("缂栬緫澶辫触锛�"); + } return Result.OK("缂栬緫鎴愬姛!"); } @@ -113,6 +135,51 @@ return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�"); } + @AutoLog(value = "涓変繚鍙樻洿-鎻愪氦") + @ApiOperation(value = "涓変繚鍙樻洿-鎻愪氦", notes = "涓変繚鍙樻洿-鎻愪氦") + @GetMapping("/submit") + public Result<?> submit(@RequestParam(name = "id") String id) { + boolean b = eamThirdMaintenanceChangeService.submit(id); + if (!b) { + return Result.error("鎻愪氦澶辫触锛�"); + } + return Result.OK("鎻愪氦鎴愬姛!"); + } + + @AutoLog(value = "涓変繚鍙樻洿-浣滃簾") + @ApiOperation(value = "涓変繚鍙樻洿-浣滃簾", notes = "涓変繚鍙樻洿-浣滃簾") + @GetMapping("/abolish") + public Result<?> abolish(@RequestParam(name = "id") String id) { + EamThirdMaintenanceChange entity = eamThirdMaintenanceChangeService.getById(id); + if (entity == null) { + return Result.error("瑕佷綔搴熺殑鏁版嵁涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); + } + if (!ThirdMaintenanceChangeStatusEnum.WAIT_SUBMIT.name().equals(entity.getChangeStatus())) { + return Result.error("璇ョ姸鎬佺殑鏁版嵁涓嶅厑璁歌繘琛屼綔搴燂紒"); + } + entity.setChangeStatus(ThirdMaintenanceChangeStatusEnum.ABOLISH.name()); + eamThirdMaintenanceChangeService.updateById(entity); + return Result.OK("浣滃簾鎴愬姛!"); + } + + @AutoLog(value = "涓変繚鍙樻洿-瀹℃壒") + @ApiOperation(value = "涓変繚鍙樻洿-瀹℃壒", notes = "涓変繚鍙樻洿-瀹℃壒") + @PostMapping("/approval") + public Result<?> approval(@RequestBody EamThirdMaintenanceChangeRequest request) { + if (request == null) { + return Result.error("瀹℃壒鐨勫璞′笉鑳戒负绌猴紒"); + } + // 妫�鏌ヨ姹傚弬鏁� + if (StrUtil.isBlank(request.getTaskId()) || StrUtil.isBlank(request.getDataId()) || StrUtil.isBlank(request.getInstanceId())) { + return Result.error("瀹℃壒浠诲姟閿欒鎴栦笉瀛樺湪锛�"); + } + EamThirdMaintenanceChange b = eamThirdMaintenanceChangeService.approval(request); + if (b == null) { + return Result.error("鎿嶄綔澶辫触锛�"); + } + return Result.ok("鎿嶄綔鎴愬姛锛�"); + } + /** * 閫氳繃id鏌ヨ * @@ -123,31 +190,24 @@ @ApiOperation(value = "涓変繚鍙樻洿-閫氳繃id鏌ヨ", notes = "涓変繚鍙樻洿-閫氳繃id鏌ヨ") @GetMapping(value = "/queryById") public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { - EamThirdMaintenanceChange eamThirdMaintenanceChange = eamThirdMaintenanceChangeService.getById(id); - return Result.OK(eamThirdMaintenanceChange); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param eamThirdMaintenanceChange - */ - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, EamThirdMaintenanceChange eamThirdMaintenanceChange) { - return super.exportXls(request, eamThirdMaintenanceChange, EamThirdMaintenanceChange.class, "涓変繚鍙樻洿"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, EamThirdMaintenanceChange.class); + EamThirdMaintenanceChange entity = eamThirdMaintenanceChangeService.getById(id); + if (entity == null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + try { + String json = objectMapper.writeValueAsString(entity); + JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); + translateDictTextUtils.translateField("orderId", entity.getOrderId(), item, "eam_third_maintenance_order,order_num,id"); + translateDictTextUtils.translateField("applicant", entity.getApplicant(), item, "sys_user,realname,username"); + translateDictTextUtils.translateField("changeStatus", entity.getChangeStatus(), item, "third_maintenance_change_status"); + translateDictTextUtils.translateField("applyReasonType", entity.getApplyReasonType(), item, "third_maintenance_change_reason"); + translateDictTextUtils.translateField("equipmentManagerSignature", entity.getEquipmentManagerSignature(), item, "sys_user,realname,username"); + translateDictTextUtils.translateField("departManagerSignature", entity.getDepartManagerSignature(), item, "sys_user,realname,username"); + translateDictTextUtils.translateField("productionSupportSignature", entity.getProductionSupportSignature(), item, "sys_user,realname,username"); + return Result.OK(item); + } catch (JsonProcessingException e) { + return Result.error("鏁版嵁杞瘧澶辫触锛�"); + } } } -- Gitblit v1.9.3