| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.ReportRepairEnum; |
| | | import org.jeecg.modules.eam.entity.EamReportRepair; |
| | | import org.jeecg.modules.eam.request.EamReportRepairQuery; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | @Resource |
| | | private IEamReportRepairService eamReportRepairService; |
| | | |
| | | @Resource |
| | | private ObjectMapper objectMapper; |
| | | |
| | | @Resource |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | @ApiOperation(value = "故障报修-添加", notes = "故障报修-添加") |
| | | @PostMapping(value = "/add") |
| | | public Result<?> add(@RequestBody EamReportRepair eamReportRepair) { |
| | | // eamReportRepair.setReportStatus(); |
| | | eamReportRepairService.save(eamReportRepair); |
| | | EamReportRepair b = eamReportRepairService.add(eamReportRepair); |
| | | if(b == null) { |
| | | return Result.error("添加失败!"); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "故障报修-编辑", notes = "故障报修-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamReportRepair eamReportRepair) { |
| | | eamReportRepairService.updateById(eamReportRepair); |
| | | boolean b = eamReportRepairService.edit(eamReportRepair); |
| | | if(!b) { |
| | | return Result.error("编辑失败!"); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * 通过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) { |
| | | eamReportRepairService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | @AutoLog(value = "故障报修-作废") |
| | | @ApiOperation(value = "故障报修-作废", notes = "故障报修-作废") |
| | | @DeleteMapping(value = "/abolish") |
| | | public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { |
| | | eamReportRepairService.update(new LambdaUpdateWrapper<EamReportRepair>().set(EamReportRepair::getReportStatus, ReportRepairEnum.ABOLISH.name()).eq(EamReportRepair::getId, id).eq(EamReportRepair::getReportStatus, ReportRepairEnum.WAIT_REPAIR.name())); |
| | | 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.eamReportRepairService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | @AutoLog(value = "故障报修-批量作废") |
| | | @ApiOperation(value = "故障报修-批量作废", notes = "故障报修-批量作废") |
| | | @DeleteMapping(value = "/abolishBatch") |
| | | public Result<?> abolishBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<EamReportRepair> eamReportRepairs = eamReportRepairService.listByIds(Arrays.asList(ids.split(","))); |
| | | eamReportRepairs.forEach(eamReportRepair -> { |
| | | if(ReportRepairEnum.ABOLISH.name().equals(eamReportRepair.getReportStatus())) { |
| | | eamReportRepair.setReportStatus(ReportRepairEnum.ABOLISH.name()); |
| | | } |
| | | }); |
| | | this.eamReportRepairService.updateBatchById(eamReportRepairs); |
| | | return Result.OK("批量作废成功!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamReportRepair eamReportRepair = eamReportRepairService.getById(id); |
| | | return Result.OK(eamReportRepair); |
| | | if (eamReportRepair == null) { |
| | | return Result.error("未找到对应数据!"); |
| | | } |
| | | try { |
| | | String json = objectMapper.writeValueAsString(eamReportRepair); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("createBy", eamReportRepair.getCreateBy(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("breakdownFlag", eamReportRepair.getBreakdownFlag(), item, "breakdown_flag"); |
| | | translateDictTextUtils.translateField("faultType", eamReportRepair.getFaultType(), item, "fault_reason_category"); |
| | | translateDictTextUtils.translateField("reportStatus", eamReportRepair.getReportStatus(), item, "report_repair_status"); |
| | | translateDictTextUtils.translateField("equipmentId", eamReportRepair.getEquipmentId(), item, "eam_equipment,id,equipment_code"); |
| | | return Result.OK(item); |
| | | } catch (Exception e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, EamReportRepair eamReportRepair) { |
| | | return super.exportXls(request, eamReportRepair, EamReportRepair.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, EamReportRepair.class); |
| | | } |
| | | |
| | | } |