Sfoglia il codice sorgente

重构添加任务代码

tags/v1.3.1
wanjing 1 anno fa
parent
commit
50f92c9240
1 ha cambiato i file con 8 aggiunte e 24 eliminazioni
  1. +8
    -24
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java

+ 8
- 24
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java Vedi File

@@ -1,6 +1,5 @@
package com.tuoheng.admin.service.inspection.add;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.InspectionConverMapper;
import com.tuoheng.admin.entity.*;
@@ -11,8 +10,8 @@ import com.tuoheng.admin.enums.code.inspection.AddInspectionCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspection.AddInspectionRequest;
import com.tuoheng.admin.service.third.pilot.PilotService;
import com.tuoheng.admin.utils.GaodeUtil;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.utils.GaodeUtil;
import com.tuoheng.common.core.constant.CommonConstants;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
@@ -52,10 +51,10 @@ public class AddInspectionService {

@Autowired
private PilotService pilotService;

@Autowired
private DspServiceInstMapper dspServiceInstMapper;


/**
* 添加任务
*
@@ -63,14 +62,14 @@ public class AddInspectionService {
*/
public JsonResult add(AddInspectionRequest addInspectionRequest) {
log.info("进入添加任务业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
JsonResult result = this.checkParam(userId, tenantId, addInspectionRequest);
if (0 != result.getCode()) {
log.info("添加任务业务:校验参数失败:{}", result.getMsg());
return result;
}
User user = (User) result.getData();

// 构造inspection对象
Inspection inspection = this.buildInspection(user, tenantId, addInspectionRequest);
@@ -119,11 +118,11 @@ public class AddInspectionService {
}
if (InspectionTypeEnum.AIRPORT.getCode() == addInspectionRequest.getInspectionType()) {
// 巡检方式:机场巡逻,可选择巡检机场和巡检路线
if (null == addInspectionRequest.getAirportId() || StringUtils.isEmpty(addInspectionRequest.getAirportName())) {
if (null == addInspectionRequest.getAirportId()) {
return JsonResult.error(AddInspectionCodeEnum.AIRPORT_IS_NULL.getCode(), AddInspectionCodeEnum.AIRPORT_IS_NULL.getMsg());
}

if (null == addInspectionRequest.getInspectionLine() || StringUtils.isEmpty(addInspectionRequest.getInspectionLineName())) {
if (null == addInspectionRequest.getInspectionLine()) {
return JsonResult.error(AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getCode(), AddInspectionCodeEnum.INSPECTION_LINE_IS_NULL.getMsg());
}
} else if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == addInspectionRequest.getInspectionType()) {
@@ -165,22 +164,7 @@ public class AddInspectionService {
return JsonResult.error(AddInspectionCodeEnum.SECTION_IS_NOT_EXIST.getCode(), AddInspectionCodeEnum.SECTION_IS_NOT_EXIST.getMsg());
}

User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, userId)
.eq(User::getMark, MarkEnum.VALID.getCode()));
if (null == user) {
return JsonResult.error(AddInspectionCodeEnum.USER_IS_NOT_EXIST.getCode(), AddInspectionCodeEnum.USER_IS_NOT_EXIST.getMsg());
}

Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, user.getDeptId())
.eq(Dept::getMark, MarkEnum.VALID.getCode()));
if (null == dept) {
return JsonResult.error(AddInspectionCodeEnum.DEPT_IS_NOT_EXIST.getCode(), AddInspectionCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(user);
return JsonResult.success();
}

/**

Loading…
Annulla
Salva