Browse Source

1、修改任务分页列表中删除权限代码;2、提交立即执行代码;

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
2c016cd7bf
2 changed files with 31 additions and 10 deletions
  1. +20
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/execute/ExecuteInspectionService.java
  2. +11
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/DeleteHandle.java

+ 20
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/execute/ExecuteInspectionService.java View File

@@ -3,15 +3,15 @@ package com.tuoheng.admin.service.inspection.execute;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionHistory;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.HttpUtils;
import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import com.tuoheng.common.core.utils.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,6 +33,8 @@ public class ExecuteInspectionService {
@Autowired
private TenantMapper tenantMapper;

@Autowired
private InspectionHistoryMapper inspectionHistoryMapper;

/**
* 重新提交任务
@@ -42,6 +44,8 @@ public class ExecuteInspectionService {
public JsonResult execute(String id) {
log.info("进入立即执行任务业务");
String userId = ShiroUtils.getUserId();
String tenantId = ShiroUtils.getTenantId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("立即执行任务业务:校验参数失败:{}", result.getMsg());
@@ -76,10 +80,11 @@ public class ExecuteInspectionService {
*
* 调用机场平台
*
* @param tenantId
* @param inspection
* @return
*/
public JsonResult executeTask(Inspection inspection) {
public JsonResult executeTask(String tenantId, Inspection inspection) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(inspection.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
@@ -116,10 +121,18 @@ public class ExecuteInspectionService {
*
* 更新任务中
*
* @param tenantId
* @param inspection
*/
private void updateInspection(Inspection inspection) {

private void insertInspectionHistory(String userId, String tenantId,Inspection inspection, String msg) {
InspectionHistory inspectionHistory = new InspectionHistory();
inspectionHistory.setTenantId(tenantId);
inspectionHistory.setInspectionId(inspection.getId());
inspectionHistory.setHistoryName(msg);
inspectionHistory.setCreateUser(userId);
inspectionHistory.setCreateTime(DateUtils.now());

inspectionHistoryMapper.insert(inspectionHistory);
}

}

+ 11
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/DeleteHandle.java View File

@@ -22,9 +22,11 @@ public class DeleteHandle implements GenerateInspectionFieldHander {
*
* 判断是否有删除权限
* 1)、 用户权限在前端判断
* 2)、管理员只能删除本部门的任务,因此将用户所在部门id与任务部门id对比,
* 2.1)、一致,则有删除权限
* 2.2)、不一致,则没有删除权限
* 2)、任务处于飞行中时无法删除
* 3)、管理员只能删除本部门的任务,因此将用户所在部门id与任务部门id对比,
* 3.1)、一致,则有删除权限
* 3.2)、不一致,则没有删除权限
*
*
* @param user
* @param dept
@@ -33,6 +35,12 @@ public class DeleteHandle implements GenerateInspectionFieldHander {
@Override
public void handler(User user, Dept dept, InspectionVo inspectionVo) {
log.info("处理删除字段");
if (InspectionStatusEnum.IN_FLIGHT.getCode() != inspectionVo.getStatus()) {
if (null != handler) {
handler.handler(user, dept, inspectionVo);
}
return;
}
if (user.getDeptId().equals(inspectionVo.getDeptId())) {
inspectionVo.setDelete(true);
}

Loading…
Cancel
Save