| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private IEamThirdMaintenanceChangeService eamThirdMaintenanceChangeService; |
| | | @Resource |
| | | private ObjectMapper objectMapper; |
| | | @Resource |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param eamThirdMaintenanceChange |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | |
| | | @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("编辑成功!"); |
| | | } |
| | | |
| | |
| | | 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查询 |
| | | * |
| | |
| | | @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("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | } |