“linengliang”
2023-08-29 14b1e801322db00b6b0d8dd059b9720adeb21bd8
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/RepairOrderController.java
@@ -1,42 +1,41 @@
package org.jeecg.modules.eam.controller;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
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.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.eam.entity.*;
import org.jeecg.modules.eam.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import java.math.BigDecimal;
import java.util.*;
import org.jeecg.common.util.oConvertUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
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.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.entity.*;
import org.jeecg.modules.eam.service.*;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
 /**
@@ -280,7 +279,21 @@
    //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_repair_order:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        repairOrderService.update(new UpdateWrapper<RepairOrder>().set("del_flag", CommonConstant.DEL_FLAG_1).eq("id",id));
      /**
       * 根据业务类型获取维修工单的来源 删除工单时恢复来源状态
       * 2023-8-17
       */
      RepairOrder repairOrder = repairOrderService.getById(id);
      String businessType = repairOrder.getBusinessType();
      if("2".equals(businessType)){//1:报修故障单 2:项目性维修
         String projectMaintenanceOrderDetailId = repairOrder.getProjectMaintenanceOrderId();
         projectMaintenanceOrderDetailService.update(new UpdateWrapper<ProjectMaintenanceOrderDetail>().set("is_create_order",0).eq("id",projectMaintenanceOrderDetailId));
      }else if("1".equals(businessType)){
         String reportRepairId = repairOrder.getReportRepairId();
         equipmentReportRepairService.update(new UpdateWrapper<EquipmentReportRepair>().set("is_create_order",0).eq("id",reportRepairId));
      }
      repairOrderService.update(new UpdateWrapper<RepairOrder>().set("del_flag", CommonConstant.DEL_FLAG_1).eq("id",id));
        return Result.OK("删除成功!");
    }
@@ -1475,9 +1488,18 @@
         //判断项目性维修子表状态
          ProjectMaintenanceOrderDetail projectMaintenanceOrderDetail = projectMaintenanceOrderDetailService.getById(repairOrder.getProjectMaintenanceOrderId());
         projectMaintenanceOrderDetail.setTypeStatus("underExecution");
         projectMaintenanceOrderDetail.setActualStartTime(new Date());
         projectMaintenanceOrderDetailService.updateById(projectMaintenanceOrderDetail);
         //判断项目性维修主表状态
         ProjectMaintenanceOrder projectMaintenanceOrder = projectMaintenanceOrderService.getById(projectMaintenanceOrderDetail.getProjectMaintenanceOrderId());
         /**
          * 项目项维修主表维护首次开始时间,
          * 逻辑:如果是null,明细生成的维修工单开工时,维护实际开始时间,
          */
         Date actualStartTime = projectMaintenanceOrder.getActualStartTime();
         if(actualStartTime == null){
            projectMaintenanceOrder.setActualStartTime(new Date());
         }
         projectMaintenanceOrder.setTypeStatus("underExecution");
         projectMaintenanceOrderService.updateById(projectMaintenanceOrder);
      }
@@ -1494,10 +1516,13 @@
          //判断项目性维修子表状态
          ProjectMaintenanceOrderDetail projectMaintenanceOrderDetail = projectMaintenanceOrderDetailService.getById(repairOrder.getProjectMaintenanceOrderId());
          projectMaintenanceOrderDetail.setTypeStatus("completed");
          projectMaintenanceOrderDetail.setActualEndTime(new Date());
          projectMaintenanceOrderDetailService.updateById(projectMaintenanceOrderDetail);
          //判断项目性维修主表状态
          List<ProjectMaintenanceOrderDetail> projectMaintenanceOrderDetailList = projectMaintenanceOrderDetailService.lambdaQuery().eq(ProjectMaintenanceOrderDetail::getProjectMaintenanceOrderId,projectMaintenanceOrderDetail.getProjectMaintenanceOrderId())
                .eq(ProjectMaintenanceOrderDetail::getDelFlag,CommonConstant.DEL_FLAG_0).list();
          List<ProjectMaintenanceOrderDetail> projectMaintenanceOrderDetailList = projectMaintenanceOrderDetailService.lambdaQuery()
                .eq(ProjectMaintenanceOrderDetail::getProjectMaintenanceOrderId,projectMaintenanceOrderDetail.getProjectMaintenanceOrderId())
                .eq(ProjectMaintenanceOrderDetail::getDelFlag,CommonConstant.DEL_FLAG_0)
                .list();
          ProjectMaintenanceOrder projectMaintenanceOrder = projectMaintenanceOrderService.getById(projectMaintenanceOrderDetail.getProjectMaintenanceOrderId());
          boolean flag = true;
          for(ProjectMaintenanceOrderDetail projectMaintenanceOrderDetail1 : projectMaintenanceOrderDetailList){
@@ -1508,6 +1533,7 @@
            }
          }
          if(flag){
             projectMaintenanceOrder.setActualEndTime(new Date());
             projectMaintenanceOrder.setTypeStatus("completed");
          }else {
             projectMaintenanceOrder.setTypeStatus("underExecution");