Browse Source

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_freeway into develop

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
fe96b5ad1f
7 changed files with 197 additions and 24 deletions
  1. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +52
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/ExecuteInspectionCodeEnum.java
  3. +63
    -22
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/execute/ExecuteInspectionService.java
  4. +30
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java
  5. +45
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/DeleteHandle.java
  6. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/InspectionVo.java
  7. +1
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java View File

@@ -124,7 +124,7 @@ public class InspectionController {
/**
* 重新提交巡检任务
*/
@PostMapping("/resubmit")
@PutMapping("/resubmit")
public JsonResult resubmit(@RequestBody EditInspectionRequest editInspectionRequest) {
log.info("进入重新提交任务接口, id={}", editInspectionRequest.getId());
return iInspectionService.resubmit(editInspectionRequest);

+ 52
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/ExecuteInspectionCodeEnum.java View File

@@ -0,0 +1,52 @@
package com.tuoheng.admin.enums.code.inspection;

/**
* 重新提交任务信息返回码
* 模块代码:23(任务管理)
* 接口代码:08 (立即执行)
*
* @author wanjing
* @team tuoheng
* @date 2022-12-02
*/
public enum ExecuteInspectionCodeEnum {

Execute_IS_FAILED(1230800, "重新提交失败"),
ID_IS_NULL(1230801, "任务ID为空"),
INSPECTION_IS_NOT_EXIST(1230802, "任务不存在"),
TENANT_IS_NOT_EXIST(1230803, "租户不存在"),
AIRPORT_URL_IS_NULL(1230804, "机场平台URL为空"),
AIRPORT_RETURN_DATA_IS_NULL(1230804, "机场接口返回数据为空");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

ExecuteInspectionCodeEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

}

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

@@ -1,16 +1,15 @@
package com.tuoheng.admin.service.inspection.execute;

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.*;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.enums.code.inspection.ResubmitInspectionCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspection.EditInspectionRequest;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.DateUtils;
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 lombok.extern.slf4j.Slf4j;
@@ -29,19 +28,11 @@ import org.springframework.stereotype.Service;
public class ExecuteInspectionService {

@Autowired
private UserMapper userMapper;

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;
private InspectionMapper inspectionMapper;

@Autowired
private SectionMapper sectionMapper;
private TenantMapper tenantMapper;

@Autowired
private InspectionMapper inspectionMapper;

/**
* 重新提交任务
@@ -66,19 +57,69 @@ public class ExecuteInspectionService {

/**
* 检查参数
*
* @param id
* @return
*/
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(ResubmitInspectionCodeEnum.ID_IS_NULL.getCode(), ResubmitInspectionCodeEnum.ID_IS_NULL.getMsg());
return JsonResult.error(ExecuteInspectionCodeEnum.ID_IS_NULL.getCode(), ExecuteInspectionCodeEnum.ID_IS_NULL.getMsg());
}
Inspection inspection = inspectionMapper.selectById(id);
if (null == inspection) {
return JsonResult.error(ResubmitInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), ResubmitInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
return JsonResult.error(ExecuteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), ExecuteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
}

/**
*
* 调用机场平台
*
* @param inspection
* @return
*/
public JsonResult executeTask(Inspection inspection) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(inspection.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
return JsonResult.error(ExecuteInspectionCodeEnum.TENANT_IS_NOT_EXIST.getCode(), ExecuteInspectionCodeEnum.TENANT_IS_NOT_EXIST.getMsg());
}

if (StringUtils.isEmpty(tenant.getAirportUrl())) {
return JsonResult.error(ExecuteInspectionCodeEnum.AIRPORT_URL_IS_NULL.getCode(), ExecuteInspectionCodeEnum.AIRPORT_URL_IS_NULL.getMsg());
}

String url = tenant.getAirportUrl() + "/api/airportInterface/executeTask";
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", inspection.getInspectionLine());
jsonObject.put("requestId", String.valueOf(inspection.getId()));

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStr)) {
log.info("立即执行任务业务:机场接口返回数据为空,任务id:{},任务名称:{},机场id:{},机场名称:{}, 路线id:{},路线名称:{}",
inspection.getId(), inspection.getName(), inspection.getAirportId(), inspection.getAirportName(), inspection.getInspectionLine(), inspection.getInspectionLineName());
return JsonResult.error(ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getCode(), ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getMsg());
}

JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (jsonResult.getCode() != 0) {
log.info("立即执行任务业务:机场接口返回结果:失败:{}", jsonResult.getMsg());

return JsonResult.error(jsonResult.getMsg());
} else {
return JsonResult.success();
}
}

/**
*
* 更新任务中
*
* @param inspection
*/
private void updateInspection(Inspection inspection) {

}

}

+ 30
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java View File

@@ -25,7 +25,10 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 查询巡检任务分页列表业务层处理
@@ -77,6 +80,10 @@ public class QueryInspectionPageListService {
@Qualifier("resubmitHandle")
private GenerateInspectionFieldHander resubmitHandle;

@Autowired
@Qualifier("deleteHandle")
private GenerateInspectionFieldHander deleteHandle;

@PostConstruct
public void start() {
executeHandle.setNextHandler(liveHandle);
@@ -84,7 +91,8 @@ public class QueryInspectionPageListService {
playBackHandle.setNextHandler(problemVerifyHandleHandle);
problemVerifyHandleHandle.setNextHandler(problemDetailsHandleHandle);
problemDetailsHandleHandle.setNextHandler(problemCountHandle);
problemCountHandle.setNextHandler(resubmitHandle);
problemCountHandle.setNextHandler(deleteHandle);
deleteHandle.setNextHandler(resubmitHandle);
}

public JsonResult getPageList(QueryInspectionPageListRequest request) {
@@ -207,11 +215,32 @@ public class QueryInspectionPageListService {
* @return
*/
private List<InspectionVo> buildIspectionVoList(User user, Dept dept, List<Inspection> inspectionList) {
Map<String, String> deptMap = this.getDeptMap(inspectionList);
List<InspectionVo> inspectionVoList = InspectionConverMapper.INSTANCE.fromInspectionListToInspectionVoList(inspectionList);
String deptName;
for (InspectionVo inspectionVo : inspectionVoList) {
deptName = deptMap.get(inspectionVo.getDeptId());
inspectionVo.setDeptName(deptName);
executeHandle.handler(user, dept, inspectionVo);
}
return inspectionVoList;
}

/**
* 设置任务列表中每一个任务的部门名称
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
*
* @param inspectionList
* @return
*/
private Map<String, String> getDeptMap(List<Inspection> inspectionList) {
Map<String, String> map = new HashMap<>();
List<String> deptIdList = inspectionList.stream().map(o -> o.getDeptId()).collect(Collectors.toList());
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList);
for (Dept dept : deptList) {
map.put(dept.getId(), dept.getName());
}
return map;
}

}

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

@@ -0,0 +1,45 @@
package com.tuoheng.admin.service.inspection.query.handle;

import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.vo.InspectionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service("deleteHandle")
public class DeleteHandle implements GenerateInspectionFieldHander {

private GenerateInspectionFieldHander handler;

@Override
public void setNextHandler(GenerateInspectionFieldHander handler) {
this.handler = handler;
}

/**
*
* 判断是否有删除权限
* 1)、 用户权限在前端判断
* 2)、管理员只能删除本部门的任务,因此将用户所在部门id与任务部门id对比,
* 2.1)、一致,则有删除权限
* 2.2)、不一致,则没有删除权限
*
* @param user
* @param dept
* @param inspectionVo
*/
@Override
public void handler(User user, Dept dept, InspectionVo inspectionVo) {
log.info("处理删除字段");
if (user.getDeptId().equals(inspectionVo.getDeptId())) {
inspectionVo.setDelete(true);
}
if (null != handler) {
handler.handler(user, dept, inspectionVo);
return;
}
}

}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/InspectionVo.java View File

@@ -312,4 +312,9 @@ public class InspectionVo extends BaseEntity {
*/
private boolean resubmit;
/**
* 删除
*/
private boolean delete;
}

+ 1
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml View File

@@ -97,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
</where>
order by create_time desc
</select>

<!-- 根据云盒ID查询执行中的巡检任务-->

Loading…
Cancel
Save