| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | 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.constant.CommonConstant; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.eam.entity.DailyMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EquipmentMaintenancePlanDetail; |
| | | import org.jeecg.modules.eam.entity.MaintenanceCycle; |
| | | import org.jeecg.modules.eam.entity.PlanChangeApply; |
| | | import org.jeecg.modules.eam.service.IDailyMaintenanceOrderService; |
| | | import org.jeecg.modules.eam.service.IMaintenanceCycleService; |
| | | import org.jeecg.modules.eam.service.IPlanChangeApplyService; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | |
| | | |
| | | @Autowired |
| | | private IMaintenanceCycleService maintenanceCycleService; |
| | | |
| | | |
| | | @Autowired |
| | | private IEquipmentMaintenancePlanDetailService maintenancePlanDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | IPage<PlanChangeApply> pageList = planChangeApplyService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | |
| | | |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | |
| | | planChangeApplyService.updateById(planChangeApply); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | |
| | | planChangeApplyService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | |
| | | this.planChangeApplyService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, PlanChangeApply.class); |
| | | } |
| | | @PostMapping(value = "/addForPlan") |
| | | public Result<String> addForPlan(@RequestBody PlanChangeApply planChangeApply) { |
| | | DailyMaintenanceOrder dailyMaintenanceOrder = dailyMaintenanceOrderService |
| | | .getOne(new QueryWrapper<DailyMaintenanceOrder>() |
| | | .eq("maintenance_order_uda1",planChangeApply.getPlanId()) |
| | | .eq("maintenance_order_uda2",planChangeApply.getId()),false); |
| | | if(ObjectUtils.isNull(dailyMaintenanceOrder)){ |
| | | return Result.error("尚未生成工单,无需申请"); |
| | | }else if(!dailyMaintenanceOrder.getStatus().equals(CommonConstant.STATUS_1)){ |
| | | return Result.error("工单已下达不允许进行变更"); |
| | | } |
| | | maintenancePlanDetailService.update(new UpdateWrapper<EquipmentMaintenancePlanDetail>().eq("id",planChangeApply.getId()).set("plan_start_time",planChangeApply.getPlanDelayTime())); |
| | | planChangeApply.setMaintenanceOrderId(dailyMaintenanceOrder.getId()); |
| | | planChangeApply.setId(""); |
| | | planChangeApplyService.save(planChangeApply); |
| | | /** |
| | | * 根据申请延保时间 重新计算工单的结束时间 |
| | | */ |
| | | String maintenanceCycleId = dailyMaintenanceOrder.getMaintenanceCycleId(); |
| | | Date planDelayTime = planChangeApply.getPlanDelayTime(); |
| | | MaintenanceCycle maintenanceCycle = maintenanceCycleService.getById(maintenanceCycleId); |
| | | String unit = maintenanceCycle.getUnit(); |
| | | int effectiveTime = maintenanceCycle.getEffectiveTime().intValue(); |
| | | Date date = null; |
| | | if ("min".equals(unit)) { |
| | | date = DateUtils.getMinAfter(planDelayTime, effectiveTime); |
| | | } else if ("hour".equals(unit)) { |
| | | date = DateUtils.getHourAfter(planDelayTime, effectiveTime); |
| | | } else if ("day".equals(unit)) { |
| | | date = DateUtils.getDayAfter(planDelayTime, effectiveTime); |
| | | } |
| | | dailyMaintenanceOrder.setPlanEndTime(date); |
| | | dailyMaintenanceOrder.setPlanStartTime(planDelayTime); |
| | | dailyMaintenanceOrderService.updateById(dailyMaintenanceOrder); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | |
| | | } |