| | |
| | | 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.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.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.ReportRepairEnum; |
| | | import org.jeecg.modules.eam.entity.EamReportRepair; |
| | | import org.jeecg.modules.eam.request.EamReportRepairQuery; |
| | |
| | | |
| | | @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(ReportRepairEnum.WAIT_REPAIR.name()); |
| | | eamReportRepair.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | 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("编辑成功!"); |
| | | } |
| | | |
| | |
| | | @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)); |
| | | 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("作废成功!"); |
| | | } |
| | | |
| | |
| | | @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 -> eamReportRepair.setReportStatus(ReportRepairEnum.ABOLISH.name())); |
| | | 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("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |