lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/PlanChangeApplyController.java
@@ -10,7 +10,12 @@
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.DateUtils;
import org.jeecg.modules.eam.entity.DailyMaintenanceOrder;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -19,8 +24,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
 /**
/**
 * @Description: mom_eam_plan_change_apply
 * @Author: jeecg-boot
 * @Date:   2023-09-04
@@ -33,6 +39,12 @@
public class PlanChangeApplyController extends JeecgController<PlanChangeApply, IPlanChangeApplyService> {
   @Autowired
   private IPlanChangeApplyService planChangeApplyService;
   @Autowired
   private IDailyMaintenanceOrderService dailyMaintenanceOrderService;
   @Autowired
   private IMaintenanceCycleService maintenanceCycleService;
   
   /**
    * 分页列表查询
@@ -67,7 +79,31 @@
   //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_plan_change_apply:add")
   @PostMapping(value = "/add")
   public Result<String> add(@RequestBody PlanChangeApply planChangeApply) {
      planChangeApply.setMaintenanceOrderId(planChangeApply.getId());
      planChangeApply.setId("");
      planChangeApplyService.save(planChangeApply);
      /**
       * 根据申请延保时间  重新计算工单的结束时间
       */
      DailyMaintenanceOrder dailyMaintenanceOrder = dailyMaintenanceOrderService.getById(planChangeApply.getMaintenanceOrderId());
      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("添加成功!");
   }