Browse Source

Merge branch 'wanjing' into develop

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
dfb6c67c93
9 changed files with 84 additions and 89 deletions
  1. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionFileHandleMapper.java
  2. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionFileMapper.java
  3. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionHistoryMapper.java
  4. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java
  5. +59
    -66
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java
  6. +6
    -6
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionFileHandleMapper.xml
  7. +6
    -6
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionFileMapper.xml
  8. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionHistoryMapper.xml
  9. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionFileHandleMapper.java View File

@@ -30,9 +30,9 @@ public interface InspectionFileHandleMapper extends BaseMapper<InspectionFileHan
*
* 物理删除巡检任务问题处理结果
*
* @param map
* @param inspectionFileIdList
* @return
*/
int deletePhysicalByMap(Map<String, Object> map);
int deleteByInspectionFileIdList(List<String> inspectionFileIdList);

}

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionFileMapper.java View File

@@ -27,9 +27,9 @@ public interface InspectionFileMapper extends BaseMapper<InspectionFile> {
*
* 物理删除巡检任务问题
*
* @param map
* @param inspectionId
* @return
*/
int deletePhysicalByMap(Map<String, Object> map);
int deleteByInspectionId(String inspectionId);

}

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/InspectionHistoryMapper.java View File

@@ -28,9 +28,9 @@ public interface InspectionHistoryMapper extends BaseMapper<InspectionHistory> {
*
* 物理删除巡检任务问题历史
*
* @param map
* @param inspectionId
* @return
*/
int deletePhysicalByMap(Map<String, Object> map);
int deleteByInspectionId(String inspectionId);

}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/add/AddInspectionService.java View File

@@ -4,6 +4,7 @@ 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.InspectionWayEnum;
import com.tuoheng.admin.enums.code.inspection.AddInspectionCodeEnum;
import com.tuoheng.admin.mapper.*;
@@ -193,6 +194,7 @@ public class AddInspectionService {
inspection.setCreateUser(userId);
inspection.setCreateTime(DateUtils.now());
inspection.setMobile(user.getMobile());
inspection.setStatus(InspectionStatusEnum.WAIT_FLIGHT.getCode());
return JsonResult.success(inspection);
}


+ 59
- 66
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java View File

@@ -2,10 +2,11 @@ package com.tuoheng.admin.service.inspection.delete;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.UserTypeEnum;
import com.tuoheng.admin.enums.code.dept.DeleteDeptCodeEnum;
import com.tuoheng.admin.enums.code.inspection.DeleteInspectionCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.ShiroUtils;
@@ -15,6 +16,7 @@ import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
@@ -51,18 +53,18 @@ public class DeleteInspectionService {
private InspectionHistoryMapper inspectionHistoryMapper;

/**
*
* 删除任务业务
* 1)、对入参判断
* 2)、对任务状态判断,处于飞行中的任务无法删除
* 3)、对用户权限判断,超级管理员可删除任何任务;管理员能删除本部门任务,不能删除子部门任务;普通用户不能删除任务
* 4)、删除任务、任务问题、任务处理数据
* 4.1)、已完成的任务,进行逻辑删除
* 4.2)、待飞行任务、失败状态的任务,进行物理删除
* 1)、对入参判断
* 2)、对任务状态判断,处于飞行中的任务无法删除
* 3)、对用户权限判断,超级管理员可删除任何任务;管理员能删除本部门任务,不能删除子部门任务;普通用户不能删除任务
* 4)、删除任务、任务问题、任务处理数据
* 4.1)、已完成的任务,进行逻辑删除
* 4.2)、待飞行任务、失败状态的任务,进行物理删除
*
* @param id
* @return
*/
@Transactional
public JsonResult deleteById(String id) {
log.info("进入删除任务业务接口");
String userId = ShiroUtils.getUserId();
@@ -107,6 +109,7 @@ public class DeleteInspectionService {

/**
* 检查参数
*
* @param tenantId
* @param id
* @return
@@ -119,9 +122,9 @@ public class DeleteInspectionService {

// 判断任务是否存在
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(DeleteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), DeleteInspectionCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
@@ -142,12 +145,10 @@ public class DeleteInspectionService {
}

/**
*
* 判断是否有删除权限
* 1)、超级管理员可以删除所有任务
* 2)、管理员可删除本部门任务,无法删除子部门任务
* 3)、普通用户无权限删除任务
*
* 1)、超级管理员可以删除所有任务
* 2)、管理员可删除本部门任务,无法删除子部门任务
* 3)、普通用户无权限删除任务
*
* @param tenantId
* @param userId
@@ -173,21 +174,19 @@ public class DeleteInspectionService {
}

/**
* 删除任务
* 1)、已完成的任务被删除后任务历史信息保留在服务器中,不再展示
* 2)、待飞行任务、失败状态的任务被删除后,任务不再执行,不保存任务信息到服务器中
* 3)、此处删除根据 1,2中需求,涉及逻辑删除和物理删除,不同删除操作,对任务、任务问题、任务问题处理结果的关联删除也不一样
* 4)、此方法,提前将任务问题、任务问题处理结果给取出,后面进行不同的处理业务
* 删除任务
* 1)、已完成的任务被删除后任务历史信息保留在服务器中,不再展示
* 2)、待飞行任务、失败状态的任务被删除后,任务不再执行,不保存任务信息到服务器中
* 3)、此处删除根据 1,2中需求,涉及逻辑删除和物理删除,不同删除操作,对任务、任务问题、任务问题处理结果的关联删除也不一样
* 4)、此方法,提前将任务问题、任务问题处理结果给取出,后面进行不同的处理业务
*
* @return
*/
private JsonResult deleted(Inspection inspection) {
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getInspectionId, inspection.getId())
.eq(InspectionFile::getMark, 1));

.eq(InspectionFile::getInspectionId, inspection.getId())
.eq(InspectionFile::getMark, 1));
List<String> inspectionFileIdList = inspectionFileList.stream().map(o -> o.getId()).collect(Collectors.toList());

if (InspectionStatusEnum.FLIGHT_COMPLETED.getCode() == inspection.getStatus()) {
this.deleteByLogic(inspection, inspectionFileIdList);
} else if (InspectionStatusEnum.WAIT_FLIGHT.getCode() == inspection.getStatus()) {
@@ -199,7 +198,7 @@ public class DeleteInspectionService {
}

/**
* 逻辑删除已完成的任务,任务被删除后任务历史信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
* 逻辑删除已完成的任务,任务被删除后任务历史信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
*
* @return
*/
@@ -208,7 +207,7 @@ public class DeleteInspectionService {
inspection.setMark(0);
Integer rowId = inspectionMapper.deleteByLogic(inspection);
log.info("删除任务业务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务:逻辑删除任务失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -226,9 +225,9 @@ public class DeleteInspectionService {
}

/**
* 逻辑删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、任务问题信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
* 逻辑删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、任务问题信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
*
* @return
*/
@@ -236,7 +235,7 @@ public class DeleteInspectionService {
Map<String, Object> map = this.getInspectionMap(inspection);
Integer rowId = inspectionFileMapper.deleteLogicByMap(map);
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务问题失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -244,9 +243,9 @@ public class DeleteInspectionService {
}

/**
* 逻辑删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、任务问题信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
* 逻辑删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、任务问题信息保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
*
* @return
*/
@@ -257,7 +256,7 @@ public class DeleteInspectionService {
Map<String, Object> map = this.getInspectionFileMap(inspection, inspectionFileIdList);
Integer rowId = inspectionFileHandleMapper.deleteLogicByMap(map);
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务问题处理结果失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -265,17 +264,17 @@ public class DeleteInspectionService {
}

/**
* 逻辑删除任务历史记录
* 1)、已完成任务被删除后,任务历史记录也需要删除
* 2)、任务历史记录保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
* 逻辑删除任务历史记录
* 1)、已完成任务被删除后,任务历史记录也需要删除
* 2)、任务历史记录保留在服务器中,不再展示,做逻辑删除,mark置为0,不去真正删除
*
* @return
*/
private JsonResult deleteInspectionHistoryByLogic(Inspection inspection) {
Map<String, Object> map = this.getInspectionMap(inspection);
Integer rowId = inspectionFileMapper.deleteLogicByMap(map);
Integer rowId = inspectionHistoryMapper.deleteLogicByMap(map);
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务历史记录失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -283,14 +282,14 @@ public class DeleteInspectionService {
}

/**
* 物理删除待飞行任务、失败状态的任务,删除后,任务不再执行,不保存任务信息到服务器中,做物理删除,真正删除
* 物理删除待飞行任务、失败状态的任务,删除后,任务不再执行,不保存任务信息到服务器中,做物理删除,真正删除
*
* @return
*/
private JsonResult deleteByPhysical(Inspection inspection, List<String> inspectionFileIdList) {
Integer rowId = inspectionMapper.deleteById(inspection.getId());
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:物理删除任务失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -308,17 +307,16 @@ public class DeleteInspectionService {
}

/**
* 物理删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
* 物理删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
*
* @return
*/
private JsonResult deleteInspectionFileByPhysical(Inspection inspection) {
Map<String, Object> map = this.getInspectionMap(inspection);
Integer rowId = inspectionFileMapper.deleteLogicByMap(map);
Integer rowId = inspectionFileMapper.deleteByInspectionId(inspection.getId());
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务问题失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -326,20 +324,16 @@ public class DeleteInspectionService {
}

/**
* 物理删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
* 物理删除已完成的任务问题,
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
*
* @return
*/
private JsonResult deleteInspectionFileHandleByPhysical(Inspection inspection, List<String> inspectionFileIdList) {
if (CollectionUtil.isEmpty(inspectionFileIdList)) {
return JsonResult.success();
}
Map<String, Object> map = this.getInspectionFileMap(inspection, inspectionFileIdList);
Integer rowId = inspectionFileHandleMapper.deleteLogicByMap(map);
Integer rowId = inspectionFileHandleMapper.deleteByInspectionFileIdList(inspectionFileIdList);
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务问题处理结果失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -347,17 +341,16 @@ public class DeleteInspectionService {
}

/**
* 物理删除任务历史记录
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
* 物理删除任务历史记录
* 1)、已完成任务被删除后,同步任务问题也需要删除
* 2)、物理删除
*
* @return
*/
private JsonResult deleteInspectionHistoryByPhysical(Inspection inspection) {
Map<String, Object> map = this.getInspectionMap(inspection);
Integer rowId = inspectionHistoryMapper.deleteLogicByMap(map);
Integer rowId = inspectionHistoryMapper.deleteByInspectionId(inspection.getId());
log.info("删除任务, 返回结果: rowId={}", rowId);
if (rowId <= 0) {
if (rowId < 0) {
log.info("删除任务业务接口:逻辑删除任务历史记录失败");
return JsonResult.error(DeleteInspectionCodeEnum.DELETE_IS_FAILED.getCode(), DeleteInspectionCodeEnum.DELETE_IS_FAILED.getMsg());
}
@@ -366,18 +359,18 @@ public class DeleteInspectionService {

private Map<String, Object> getInspectionMap(Inspection inspection) {
Map<String, Object> map = new HashMap<>();
map.put("mark", 0);
map.put("updateUser", inspection.getUpdateUser());
map.put("updateTime", DateUtils.now());
map.put("mark", 0);
map.put("inspectionId", inspection.getId());
return map;
}

private Map<String, Object> getInspectionFileMap(Inspection inspection, List<String> inspectionFileIdList) {
Map<String, Object> map = new HashMap<>();
map.put("mark", 0);
map.put("updateUser", inspection.getUpdateUser());
map.put("updateTime", DateUtils.now());
map.put("mark", 0);
map.put("inspectionFileIdList", inspectionFileIdList);
return map;
}

+ 6
- 6
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionFileHandleMapper.xml View File

@@ -23,12 +23,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, tenant_id, inspection_file_id, handler_user, handler_image, handler_result, handler_time, create_user, create_time, update_user, update_time, mark from th_inspection_file_handle
</sql>
<update id="deleteByLogic" parameterType="hashmap">
<update id="deleteLogicByMap" parameterType="hashmap">
update th_inspection_file_handle
<trim prefix="SET" suffixOverrides=",">
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
<if test="updateTime != null and updateTime != ''"> update_time = #{updateTime}, </if>
<if test="mark != null and mark != ''"> mark = #{mark},</if>
<if test="updateTime != null"> update_time = #{updateTime}, </if>
<if test="mark != null"> mark = #{mark},</if>
</trim>
<where>
<if test="inspectionFileId != null and inspectionId != ''">
@@ -40,12 +40,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</update>
<delete id="deleteByPhysical" parameterType="String">
<delete id="deleteByInspectionFileIdList" parameterType="list">
delete from th_inspection_file_handle
<where>
<if test="inspectionFileId != null and inspectionId != ''">
<if test="list != null and list.size() > 0">
and inspection_file_id in
<foreach collection="inspectionFileIdList" item="inspectionFileId" separator="," open="(" close=")">
<foreach collection="list" item="inspectionFileId" separator="," open="(" close=")">
#{inspectionFileId}
</foreach>
</if>

+ 6
- 6
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionFileMapper.xml View File

@@ -41,19 +41,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<update id="deleteLogicByMap" parameterType="hashmap">
update th_inspection
update th_inspection_file
<trim prefix="SET" suffixOverrides=",">
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
<if test="updateTime != null and updateTime != ''"> update_time = #{updateTime}, </if>
<if test="mark != null and mark != ''"> mark = #{mark},</if>
<if test="updateTime != null"> update_time = #{updateTime}, </if>
<if test="mark != null"> mark = #{mark},</if>
</trim>
<where>
<if test="inspectionId != null and inspectionId != ''"> inspection_id = #{inspectionId}, </if>
<if test="inspectionId != null and inspectionId != ''"> inspection_id = #{inspectionId} </if>
</where>
</update>
<delete id="deletePhysicalByMap" parameterType="String">
delete from th_inspection where inspection_id = #{id}
<delete id="deleteByInspectionId" parameterType="String">
delete from th_inspection_file where inspection_id = #{id}
</delete>
</mapper>

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionHistoryMapper.xml View File

@@ -24,15 +24,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update th_inspection_history
<trim prefix="SET" suffixOverrides=",">
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
<if test="updateTime != null and updateTime != ''"> update_time = #{updateTime}, </if>
<if test="mark != null and mark != ''"> mark = #{mark},</if>
<if test="updateTime != null"> update_time = #{updateTime}, </if>
<if test="mark != null"> mark = #{mark},</if>
</trim>
<where>
<if test="inspectionId != null and inspectionId != ''"> inspection_id = #{inspectionId}, </if>
<if test="inspectionId != null and inspectionId != ''"> inspection_id = #{inspectionId} </if>
</where>
</update>
<delete id="deletePhysicalByMap" parameterType="String">
<delete id="deleteByInspectionId" parameterType="String">
delete from th_inspection_history where inspection_id = #{id}
</delete>

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

@@ -218,7 +218,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteByLogic" parameterType="com.tuoheng.admin.entity.Inspection">
update th_inspection
<trim prefix="SET" suffixOverrides=",">
<if test="updateUser != null"> update_user = #{updateUser}, </if>
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
<if test="updateTime != null"> update_time = #{updateTime}, </if>
<if test="mark != null"> mark = #{mark}, </if>
</trim>

Loading…
Cancel
Save