Zimo 6 цаг өмнө
parent
commit
258460c435
13 өөрчлөгдсөн 255 нэмэгдсэн , 43 устгасан
  1. 32 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/IotAccidentReportController.java
  2. 8 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportPageReqVO.java
  3. 7 5
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportRespVO.java
  4. 4 7
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportSaveReqVO.java
  5. 11 7
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/accident/IotAccidentReportDO.java
  6. 48 5
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/accident/IotAccidentReportMapper.java
  7. 2 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/accident/IotAccidentReportProcessMapper.java
  8. 4 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/accident/IotAccidentReportService.java
  9. 118 10
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/accident/IotAccidentReportServiceImpl.java
  10. 1 0
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
  11. 6 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
  12. 1 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
  13. 13 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

+ 32 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/IotAccidentReportController.java

@@ -6,14 +6,18 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportProcessDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident.IotAccidentReportProcessMapper;
 import cn.iocoder.yudao.module.pms.service.qhse.accident.IotAccidentReportService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -23,6 +27,9 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
 import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -36,6 +43,8 @@ public class IotAccidentReportController {
 
     @Resource
     private IotAccidentReportService iotAccidentReportService;
+    @Autowired
+    private IotAccidentReportProcessMapper iotAccidentReportProcessMapper;
 
     @PostMapping("/create")
     @Operation(summary = "创建QHSE事故上报")
@@ -91,4 +100,27 @@ public class IotAccidentReportController {
                         BeanUtils.toBean(list, IotAccidentReportRespVO.class));
     }
 
+
+    @GetMapping("/approval/page")
+    @Operation(summary = "获得QHSE事故审批分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-accident-report:query')")
+    public CommonResult<PageResult<IotAccidentReportRespVO>> getIotAccidentReportApprovalPage(@Valid IotAccidentReportPageReqVO pageReqVO) {
+        //查询当前处理人为登录人的上报信息
+        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        List<IotAccidentReportProcessDO> processes = iotAccidentReportProcessMapper.selectList("creator", loginUserId);
+        Set<Long> accidentIds = processes.stream().map(IotAccidentReportProcessDO::getAccidentId).collect(Collectors.toSet());
+        pageReqVO.setIds(accidentIds);
+        pageReqVO.setCurrentPerson(loginUserId);
+        PageResult<IotAccidentReportDO> pageResult = iotAccidentReportService.getIotAccidentReportApprovalPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotAccidentReportRespVO.class));
+    }
+
+    @GetMapping("/approval")
+    @Operation(summary = "上报操作")
+    @PreAuthorize("@ss.hasPermission('rq:iot-accident-report:approval')")
+    public CommonResult<String> approvalReport(Long id, String suggestion) {
+        assert Objects.nonNull(id);
+        iotAccidentReportService.approvalAccident(id, suggestion);
+        return success("成功");
+    }
 }

+ 8 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportPageReqVO.java

@@ -1,11 +1,14 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo;
 
-import lombok.*;
-import java.util.*;
-import io.swagger.v3.oas.annotations.media.Schema;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
+
 import java.time.LocalDateTime;
+import java.util.Set;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
@@ -31,6 +34,8 @@ public class IotAccidentReportPageReqVO extends PageParam {
     @Schema(description = "部门id", example = "13049")
     private Long deptId;
 
+    private Set<Long> ids;
+
     @Schema(description = "队伍名称", example = "李四")
     private String deptName;
 

+ 7 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportRespVO.java

@@ -1,11 +1,12 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.*;
-import java.util.*;
-import org.springframework.format.annotation.DateTimeFormat;
+import lombok.Data;
+
 import java.time.LocalDateTime;
-import com.alibaba.excel.annotation.*;
+import java.util.Set;
 
 @Schema(description = "管理后台 - QHSE事故上报 Response VO")
 @Data
@@ -67,7 +68,8 @@ public class IotAccidentReportRespVO {
     /**
      * 当前处理人
      */
-    private Long currentPerson;
+    @Schema(description = "当前操作人数组", example = "1")
+    private Set<Long> currentPerson;
     /**
      * 流程状态位
      */

+ 4 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/accident/vo/IotAccidentReportSaveReqVO.java

@@ -1,13 +1,12 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo;
 
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.*;
-import java.util.*;
-import org.springframework.format.annotation.DateTimeFormat;
+import lombok.Data;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
+import java.util.Set;
 
 @Schema(description = "管理后台 - QHSE事故上报新增/修改 Request VO")
 @Data
@@ -54,10 +53,8 @@ public class IotAccidentReportSaveReqVO {
     @Schema(description = "附件/现场图片")
     private String pic;
 
-    /**
-     * 当前处理人
-     */
-    private Long currentPerson;
+    @Schema(description = "当前操作人数组", example = "1")
+    private Set<Long> currentPerson;
     /**
      * 流程状态位
      */

+ 11 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/accident/IotAccidentReportDO.java

@@ -1,19 +1,22 @@
 package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident;
 
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
+
 import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import java.util.Set;
 
 /**
  * QHSE事故上报 DO
  *
  * @author 超级管理员
  */
-@TableName("rq_iot_accident_report")
+@TableName(value = "rq_iot_accident_report", autoResultMap = true)
 @KeySequence("rq_iot_accident_report_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -75,7 +78,8 @@ public class IotAccidentReportDO extends BaseDO {
     /**
      * 当前处理人
      */
-    private Long currentPerson;
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private Set<Long> currentPerson;
     /**
      * 流程状态位
      */

+ 48 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/accident/IotAccidentReportMapper.java

@@ -1,12 +1,11 @@
 package cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident;
 
-import java.util.*;
-
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportPageReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -18,7 +17,7 @@ import org.apache.ibatis.annotations.Mapper;
 public interface IotAccidentReportMapper extends BaseMapperX<IotAccidentReportDO> {
 
     default PageResult<IotAccidentReportDO> selectPage(IotAccidentReportPageReqVO reqVO) {
-        return selectPage(reqVO, new LambdaQueryWrapperX<IotAccidentReportDO>()
+        LambdaQueryWrapperX<IotAccidentReportDO> queryWrapperX = new LambdaQueryWrapperX<IotAccidentReportDO>()
                 .betweenIfPresent(IotAccidentReportDO::getActualTime, reqVO.getActualTime())
                 .eqIfPresent(IotAccidentReportDO::getAccidentGrade, reqVO.getAccidentGrade())
                 .eqIfPresent(IotAccidentReportDO::getAccidentType, reqVO.getAccidentType())
@@ -30,9 +29,53 @@ public interface IotAccidentReportMapper extends BaseMapperX<IotAccidentReportDO
                 .eqIfPresent(IotAccidentReportDO::getEmergencyMeasure, reqVO.getEmergencyMeasure())
                 .eqIfPresent(IotAccidentReportDO::getDescription, reqVO.getDescription())
                 .eqIfPresent(IotAccidentReportDO::getPic, reqVO.getPic())
+//                .inIfPresent(IotAccidentReportDO::getCurrentPerson, reqVO.getCurrentPerson())
                 .betweenIfPresent(IotAccidentReportDO::getCreateTime, reqVO.getCreateTime())
                 .eqIfPresent(IotAccidentReportDO::getRemark, reqVO.getRemark())
-                .orderByDesc(IotAccidentReportDO::getId));
+                .orderByDesc(IotAccidentReportDO::getId);
+        if (reqVO.getCurrentPerson() != null) {
+            queryWrapperX.apply("JSON_CONTAINS(CAST(current_person AS JSON), CAST({0} AS JSON))", reqVO.getCurrentPerson());
+
+        }
+        return selectPage(reqVO, queryWrapperX);
     }
 
+
+    default PageResult<IotAccidentReportDO> selectApprovalPage(IotAccidentReportPageReqVO reqVO) {
+        LambdaQueryWrapperX<IotAccidentReportDO> queryWrapperX = (LambdaQueryWrapperX<IotAccidentReportDO>) new LambdaQueryWrapperX<IotAccidentReportDO>()
+                // 原有基础条件(保持不变,使用 LambdaQueryWrapperX 的扩展方法)
+                .betweenIfPresent(IotAccidentReportDO::getActualTime, reqVO.getActualTime())
+                .eqIfPresent(IotAccidentReportDO::getAccidentGrade, reqVO.getAccidentGrade())
+                .eqIfPresent(IotAccidentReportDO::getAccidentType, reqVO.getAccidentType())
+                .eqIfPresent(IotAccidentReportDO::getAccidentAddress, reqVO.getAccidentAddress())
+                .eqIfPresent(IotAccidentReportDO::getDeptId, reqVO.getDeptId())
+                .likeIfPresent(IotAccidentReportDO::getDeptName, reqVO.getDeptName())
+                .eqIfPresent(IotAccidentReportDO::getDutyPerson, reqVO.getDutyPerson())
+                .eqIfPresent(IotAccidentReportDO::getLossSituation, reqVO.getLossSituation())
+                .eqIfPresent(IotAccidentReportDO::getEmergencyMeasure, reqVO.getEmergencyMeasure())
+                .eqIfPresent(IotAccidentReportDO::getDescription, reqVO.getDescription())
+                .eqIfPresent(IotAccidentReportDO::getPic, reqVO.getPic())
+                .betweenIfPresent(IotAccidentReportDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(IotAccidentReportDO::getRemark, reqVO.getRemark())
+                // 修复:嵌套逻辑使用原生 LambdaQueryWrapper 类型,手动实现非空判断
+                .nested((LambdaQueryWrapper<IotAccidentReportDO> wrapper) -> {
+                    boolean hasIdCondition = false;
+                    // 手动实现 inIfPresent 的逻辑:ids 非空时才添加 in 条件
+                    if (reqVO.getIds() != null && !reqVO.getIds().isEmpty()) {
+                        wrapper.in(IotAccidentReportDO::getId, reqVO.getIds());
+                        hasIdCondition = true;
+                    }
+                    // 处理 currentPerson 的 OR 条件
+                    if (reqVO.getCurrentPerson() != null) {
+                        // 只有当已有 id 条件时才加 OR,避免空条件下的语法错误
+                        if (hasIdCondition) {
+                            wrapper.or();
+                        }
+                        wrapper.apply("JSON_CONTAINS(CAST(current_person AS JSON), CAST({0} AS JSON))", reqVO.getCurrentPerson());
+                    }
+                })
+                .orderByDesc(IotAccidentReportDO::getId);
+
+        return selectPage(reqVO, queryWrapperX);
+    }
 }

+ 2 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/accident/IotAccidentReportProcessMapper.java

@@ -1,10 +1,8 @@
 package cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident;
 
-import java.util.*;
-
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportProcessPageReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportProcessDO;
 import org.apache.ibatis.annotations.Mapper;
@@ -25,6 +23,7 @@ public interface IotAccidentReportProcessMapper extends BaseMapperX<IotAccidentR
                 .likeIfPresent(IotAccidentReportProcessDO::getNodeName, reqVO.getNodeName())
                 .betweenIfPresent(IotAccidentReportProcessDO::getCreateTime, reqVO.getCreateTime())
                 .eqIfPresent(IotAccidentReportProcessDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotAccidentReportProcessDO::getAccidentId, reqVO.getAccidentId())
                 .orderByDesc(IotAccidentReportProcessDO::getId));
     }
 

+ 4 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/accident/IotAccidentReportService.java

@@ -1,13 +1,12 @@
 package cn.iocoder.yudao.module.pms.service.qhse.accident;
 
-import java.util.*;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
 
 import javax.validation.Valid;
+import java.util.Set;
 
 /**
  * QHSE事故上报 Service 接口
@@ -15,7 +14,8 @@ import javax.validation.Valid;
  * @author 超级管理员
  */
 public interface IotAccidentReportService {
-
+    Set<Long> getDeptIdCompany(Long deviceDept);
+    void approvalAccident(Long id, String suggestion);
     /**
      * 创建QHSE事故上报
      *
@@ -53,5 +53,6 @@ public interface IotAccidentReportService {
      * @return QHSE事故上报分页
      */
     PageResult<IotAccidentReportDO> getIotAccidentReportPage(IotAccidentReportPageReqVO pageReqVO);
+    PageResult<IotAccidentReportDO> getIotAccidentReportApprovalPage(IotAccidentReportPageReqVO pageReqVO);
 
 }

+ 118 - 10
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/accident/IotAccidentReportServiceImpl.java

@@ -3,33 +3,37 @@ package cn.iocoder.yudao.module.pms.service.qhse.accident;
 import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.framework.common.exception.ErrorCode;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportProcessDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident.IotAccidentReportMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident.IotAccidentReportProcessMapper;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.PostApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO;
 import cn.iocoder.yudao.module.system.api.permission.RoleApi;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
+import com.google.common.collect.ImmutableSet;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
 
+import javax.annotation.Resource;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-
-
-import javax.annotation.Resource;
-
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 
 /**
@@ -49,6 +53,104 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
     private AdminUserApi adminUserApi;
     @Autowired
     private RoleApi roleApi;
+    @Autowired
+    private DeptService deptService;
+    @Autowired
+    private PostApi postApi;
+    @Autowired
+    private IotAccidentReportProcessMapper iotAccidentReportProcessMapper;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approvalAccident(Long id, String suggestion) {
+        IotAccidentReportDO iotAccidentReportDO = iotAccidentReportMapper.selectById(id);
+        assert Objects.nonNull(iotAccidentReportDO);
+        IotAccidentReportProcessDO processDO = new IotAccidentReportProcessDO();
+        processDO.setAccidentId(id);
+        processDO.setOperator(SecurityFrameworkUtils.getLoginUserNickname());
+        processDO.setDescription(suggestion);
+        processDO.setStatus("上报");
+        processDO.setDeleted(false);
+        Set<Long> deptIds = getDeptIdCompany(iotAccidentReportDO.getDeptId());
+        List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIdsNew(deptIds);
+        if ("2".equals(iotAccidentReportDO.getFlowStatus())) {//项目经理操作的
+            processDO.setNodeName("项目经理");
+            iotAccidentReportDO.setFlowStatus("3");
+            PostRespDTO bz = postApi.getPostByName("QHSE部长");
+            Long postId = bz.getId();
+            users.stream().filter(e -> e.getPostIds().contains(postId)).findFirst().ifPresent(f ->{
+                //设置当前操作人为QHSE部长
+                iotAccidentReportDO.setCurrentPerson(Collections.singleton(f.getId()));
+            });
+        } else if ("3".equals(iotAccidentReportDO.getFlowStatus())){//QHSE部长操作的
+            processDO.setNodeName("公司QHSE部长");
+            iotAccidentReportDO.setFlowStatus("4");
+            PostRespDTO bz = postApi.getPostByName("总经理");
+            Long postId = bz.getId();
+            boolean b = users.stream().anyMatch(e -> e.getPostIds().contains(postId));
+            if (!b) {
+                throw new ServiceException(new ErrorCode(1,"未找到总经理岗位"));
+            }
+            users.stream().filter(e -> e.getPostIds().contains(postId)).findFirst().ifPresent(f->{
+                iotAccidentReportDO.setCurrentPerson(ImmutableSet.of(f.getId(), 873L));
+            });
+        } else if ("4".equals(iotAccidentReportDO.getFlowStatus())) {//总经理或者集团QHSE副总监操作的
+            Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+            if (Objects.nonNull(loginUserId) && loginUserId==873L) {//如果集团QHSE副总监
+                processDO.setNodeName("集团QHSE副总监");
+            } else {
+                processDO.setNodeName("总经理");
+            }
+            iotAccidentReportDO.setFlowStatus("5");
+            iotAccidentReportDO.setStatus("finished");
+            PostRespDTO zz = postApi.getPostByName("总裁");
+            Long postId = zz.getId();
+            List<AdminUserRespDTO> allUser = adminUserApi.getUserListByPostIdsNoPermission(Collections.singleton(postId));
+            if (CollUtil.isEmpty(allUser)){
+                throw new ServiceException(new ErrorCode(2,"未找到审批岗位"));
+            }
+            allUser.stream().filter(e -> e.getPostIds().contains(postId)).findFirst().ifPresent(f ->{
+                iotAccidentReportDO.setCurrentPerson(ImmutableSet.of(f.getId()));
+            });
+        }
+        iotAccidentReportProcessMapper.insert(processDO);
+        iotAccidentReportMapper.updateById(iotAccidentReportDO);
+
+    }
+
+    public Set<Long> getDeptIdCompany(Long deviceDept) {
+        List<DeptRespDTO> rhdept = deptApi.getDeptByNamePermission("瑞恒兴域");
+        Set<Long> rhDeptIds = Collections.emptySet();
+        if (CollUtil.isNotEmpty(rhdept)) {
+            Long deptId = rhdept.get(0).getId();
+            rhDeptIds = deptService.getChildDeptIdListFromCache(deptId);
+            rhDeptIds.add(deptId);
+        }
+
+        List<DeptRespDTO> rddept = deptApi.getDeptByNamePermission("四川瑞都");
+        Set<Long> rdDeptIds = Collections.emptySet();
+        if (CollUtil.isNotEmpty(rddept)) {
+            Long deptId = rddept.get(0).getId();
+            rdDeptIds = deptService.getChildDeptIdListFromCache(deptId);
+            rdDeptIds.add(deptId);
+        }
+
+        List<DeptRespDTO> rydept = deptApi.getDeptByNamePermission("瑞鹰国际");
+        Set<Long> ryDeptIds = Collections.emptySet();
+        if (CollUtil.isNotEmpty(rydept)) {
+            Long deptId = rydept.get(0).getId();
+            ryDeptIds = deptService.getChildDeptIdListFromCache(deptId);
+            ryDeptIds.add(deptId);
+        }
+
+        if (rhDeptIds.contains(deviceDept)) {
+            return rhDeptIds;
+        } else if (rdDeptIds.contains(deviceDept)) {
+            return rdDeptIds;
+        } else {
+            return ryDeptIds;
+        }
+    }
 
     @Override
     public Long createIotAccidentReport(IotAccidentReportSaveReqVO createReqVO) {
@@ -75,7 +177,7 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
         if (CollUtil.isEmpty(currentUserIds)){
             throw new ServiceException(new ErrorCode(22,"未找到项目经理,无法完成事故上报"));
         }
-        iotAccidentReport.setCurrentPerson(currentUserIds.stream().findFirst().get());
+        iotAccidentReport.setCurrentPerson(Collections.singleton(currentUserIds.stream().findFirst().get()));
         iotAccidentReportMapper.insert(iotAccidentReport);
         //插入流程明细表
         IotAccidentReportProcessDO processDO = new IotAccidentReportProcessDO();
@@ -84,8 +186,10 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
         processDO.setOperator(loginUserNickname);
         processDO.setDescription("发起事故事件上报");
         processDO.setNodeName("发起人");
+        processDO.setDeleted(false);
         processDO.setCreateTime(LocalDateTime.now());
         processDO.setStatus("提交上报");
+        iotAccidentReportProcessMapper.insert(processDO);
         // 返回
         return iotAccidentReport.getId();
     }
@@ -123,4 +227,8 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
         return iotAccidentReportMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    public PageResult<IotAccidentReportDO> getIotAccidentReportApprovalPage(IotAccidentReportPageReqVO pageReqVO) {
+        return iotAccidentReportMapper.selectApprovalPage(pageReqVO);
+    }
 }

+ 1 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java

@@ -58,6 +58,7 @@ public interface AdminUserApi {
      * @return 用户数组
      */
     List<AdminUserRespDTO> getUserListByPostIds(Collection<Long> postIds);
+    List<AdminUserRespDTO> getUserListByPostIdsNoPermission(Collection<Long> postIds);
     List<AdminUserRespDTO> getAllUser();
 
     /**

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java

@@ -117,6 +117,12 @@ public class AdminUserApiImpl implements AdminUserApi {
         return BeanUtils.toBean(users, AdminUserRespDTO.class);
     }
 
+    @Override
+    public List<AdminUserRespDTO> getUserListByPostIdsNoPermission(Collection<Long> postIds) {
+        List<AdminUserDO> users = userService.getUserListByPostIdsNoPermission(postIds);
+        return BeanUtils.toBean(users, AdminUserRespDTO.class);
+    }
+
     @Override
     public List<AdminUserRespDTO> getAllUser() {
         List<AdminUserDO> allUsers = userService.getAllUsers();

+ 1 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@@ -152,6 +152,7 @@ public interface AdminUserService {
      * @return 用户数组
      */
     List<AdminUserDO> getUserListByPostIds(Collection<Long> postIds);
+    List<AdminUserDO> getUserListByPostIdsNoPermission(Collection<Long> postIds);
     List<AdminUserDO> getAllUsers();
 
     /**

+ 13 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -393,6 +393,19 @@ public class AdminUserServiceImpl implements AdminUserService {
         return userMapper.selectBatchIds(userIds);
     }
 
+    @Override
+    @DataPermission(enable = false)
+    public List<AdminUserDO> getUserListByPostIdsNoPermission(Collection<Long> postIds) {
+        if (CollUtil.isEmpty(postIds)) {
+            return Collections.emptyList();
+        }
+        Set<Long> userIds = convertSet(userPostMapper.selectListByPostIds(postIds), UserPostDO::getUserId);
+        if (CollUtil.isEmpty(userIds)) {
+            return Collections.emptyList();
+        }
+        return userMapper.selectBatchIds(userIds);
+    }
+
     @Override
     public List<AdminUserDO> getUserList(Collection<Long> ids) {
         if (CollUtil.isEmpty(ids)) {