Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
1eada0fb3d
2 changed files with 107 additions and 102 deletions
  1. +24
    -19
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java
  2. +83
    -83
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/ReportMapper.xml

+ 24
- 19
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java View File

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

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -39,37 +40,36 @@ public class QueryNewInspectionListService {
private UserMapper userMapper;



public JsonResult getList() {
//获取登录用户信息
String username = SecurityUserUtils.username();
if(StringUtils.isEmpty(username)){
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg());
if (StringUtils.isEmpty(username)) {
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(), ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg());
}
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getUsername, username)
.eq(User::getStatus,1)
.eq(User::getStatus, 1)
.eq(User::getMark, 1));
if(ObjectUtil.isNull(user)){
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
if (ObjectUtil.isNull(user)) {
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(), ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
}
String tenantId = user.getTenantId();
if(StringUtils.isEmpty(tenantId)){
JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg());
if (StringUtils.isEmpty(tenantId)) {
JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg());
}

//判断用户角色 1超级管理员 2部门管理员 3普通用户
if(null == user.getRoleId()){
if (null == user.getRoleId()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//若角色为超级管理员,查询任务表最新五条数据
if(RoleEnum.SUPER_ADMIN.getCode()==user.getRoleId()) {
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getMark, 1)
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if (inspectionList == null) {
if (CollectionUtil.isEmpty(inspectionList)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
@@ -82,10 +82,10 @@ public class QueryNewInspectionListService {


//若角色为部门管理员或普通用户,查询最新五条数据
if(RoleEnum.ADMIN.getCode()==user.getRoleId() || RoleEnum.ORDINARY_USER.getCode()==user.getRoleId()){
if (RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
String deptId = user.getDeptId();
if(StringUtils.isEmpty(deptId)){
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(),QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg());
if (StringUtils.isEmpty(deptId)) {
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(), QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg());
}
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId)
@@ -93,7 +93,7 @@ public class QueryNewInspectionListService {
.eq(Inspection::getMark, 1)
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if(inspectionList==null){
if (CollectionUtil.isEmpty(inspectionList)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
Stream<InspectionListVo> inspectionListVoStream = this.getInspectionListVoStream(inspectionList);
@@ -107,10 +107,15 @@ public class QueryNewInspectionListService {

private Stream<InspectionListVo> getInspectionListVoStream(List<Inspection> inspectionList) {
return inspectionList.stream().map(x -> {
InspectionListVo vo = new InspectionListVo();
BeanUtils.copyProperties(x, vo);
return vo;
});
InspectionListVo vo = new InspectionListVo();
BeanUtils.copyProperties(x, vo);
//修改执行人属性为realname
User user = userMapper.selectById(x.getCreateUser());
if(ObjectUtil.isNotNull(user)){
vo.setCreateUser(user.getRealname());
}
return vo;
});

}
}

+ 83
- 83
tuoheng-service/tuoheng-admin/src/main/resources/mapper/ReportMapper.xml View File

@@ -1,84 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.ReportMapper">
<resultMap type="com.tuoheng.admin.entity.Report" id="ReportResult">
<result property="id" column="id" />
<result property="tenantId" column="tenant_id" />
<result property="deptId" column="dept_id" />
<result property="reportCode" column="report_code" />
<result property="inspectionId" column="inspection_id" />
<result property="inspectionCode" column="inspection_code" />
<result property="inspectionName" column="inspection_name" />
<result property="type" column="type" />
<result property="roadId" column="road_id" />
<result property="roadName" column="road_name" />
<result property="sectionId" column="section_id" />
<result property="sectionName" column="section_name" />
<result property="inspectionType" column="inspection_type" />
<result property="airportId" column="airport_id" />
<result property="airportName" column="airport_name" />
<result property="inspectionLine" column="inspection_line" />
<result property="inspectionLineName" column="inspection_line_name" />
<result property="equipmentId" column="equipment_id" />
<result property="equipmentName" column="equipment_name" />
<result property="equipmentMountId" column="equipment_mount_id" />
<result property="equipmentMountName" column="equipment_mount_name" />
<result property="cloudBoxId" column="cloud_box_id" />
<result property="cloudBoxName" column="cloud_box_name" />
<result property="boxSn" column="box_sn" />
<result property="flightHand" column="flight_hand" />
<result property="flightHandName" column="flight_hand_name" />
<result property="inspectionTime" column="inspection_time" />
<result property="executionStartTime" column="execution_start_time" />
<result property="executionEndTime" column="execution_end_time" />
<result property="isLive" column="is_live" />
<result property="isTaken" column="is_taken" />
<result property="isTilt" column="is_tilt" />
<result property="videoUrl" column="video_url" />
<result property="aiVideoUrl" column="ai_video_url" />
<result property="reportUrl" column="report_url" />
<result property="srtUrl" column="srt_url" />
<result property="status" column="status" />
<result property="analyseStatus" column="analyse_status" />
<result property="progressbar" column="progressbar" />
<result property="note" column="note" />
<result property="weather" column="weather" />
<result property="flyHeight" column="fly_height" />
<result property="srtName" column="srt_name" />
<result property="heartbeatTime" column="heartbeat_time" />
<result property="executionStatus" column="execution_status" />
<result property="startLongitude" column="start_longitude" />
<result property="startLatitude" column="start_latitude" />
<result property="endLongitude" column="end_longitude" />
<result property="endLatitude" column="end_latitude" />
<result property="mobile" column="mobile" />
<result property="patrolLocation" column="patrol_location" />
<result property="problemTotalCount" column="problem_total_count" />
<result property="problemHandleCount" column="problem_handle_count" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>
<sql id="selectReportVo">
select id, tenant_id, dept_id, report_code, inspection_id, inspection_code, inspection_name, type, road_id, road_name, section_id, section_name, inspection_type, airport_id, airport_name, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id, equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, flight_hand, flight_hand_name, inspection_time, execution_start_time, execution_end_time, is_live, is_taken, is_tilt, video_url, ai_video_url, report_url, srt_url, status, analyse_status, progressbar, note, weather, fly_height, srt_name, heartbeat_time, execution_status, start_longitude, start_latitude, end_longitude, end_latitude, mobile, patrol_location, problem_total_count, problem_handle_count, create_user, create_time, update_user, update_time, mark from th_report
</sql>
<select id="selectPageList" parameterType="com.tuoheng.admin.request.report.QueryReportPageListRequest" resultMap="ReportResult">
<include refid="selectReportVo"/>
<where>
<if test="1 == 1"> and mark = 1 </if>
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if>
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if>
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if>
<if test="request.createUser != null and request.createUser != ''"> and create_user = #{request.createUser} </if>
</where>
order by create_time desc
</select>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.ReportMapper">
<resultMap type="com.tuoheng.admin.entity.Report" id="ReportResult">
<result property="id" column="id" />
<result property="tenantId" column="tenant_id" />
<result property="deptId" column="dept_id" />
<result property="reportCode" column="report_code" />
<result property="inspectionId" column="inspection_id" />
<result property="inspectionCode" column="inspection_code" />
<result property="inspectionName" column="inspection_name" />
<result property="type" column="type" />
<result property="roadId" column="road_id" />
<result property="roadName" column="road_name" />
<result property="sectionId" column="section_id" />
<result property="sectionName" column="section_name" />
<result property="inspectionType" column="inspection_type" />
<result property="airportId" column="airport_id" />
<result property="airportName" column="airport_name" />
<result property="inspectionLine" column="inspection_line" />
<result property="inspectionLineName" column="inspection_line_name" />
<result property="equipmentId" column="equipment_id" />
<result property="equipmentName" column="equipment_name" />
<result property="equipmentMountId" column="equipment_mount_id" />
<result property="equipmentMountName" column="equipment_mount_name" />
<result property="cloudBoxId" column="cloud_box_id" />
<result property="cloudBoxName" column="cloud_box_name" />
<result property="boxSn" column="box_sn" />
<result property="flightHand" column="flight_hand" />
<result property="flightHandName" column="flight_hand_name" />
<result property="inspectionTime" column="inspection_time" />
<result property="executionStartTime" column="execution_start_time" />
<result property="executionEndTime" column="execution_end_time" />
<result property="isLive" column="is_live" />
<result property="isTaken" column="is_taken" />
<result property="isTilt" column="is_tilt" />
<result property="videoUrl" column="video_url" />
<result property="aiVideoUrl" column="ai_video_url" />
<result property="reportUrl" column="report_url" />
<result property="srtUrl" column="srt_url" />
<result property="status" column="status" />
<result property="analyseStatus" column="analyse_status" />
<result property="progressbar" column="progressbar" />
<result property="note" column="note" />
<result property="weather" column="weather" />
<result property="flyHeight" column="fly_height" />
<result property="srtName" column="srt_name" />
<result property="heartbeatTime" column="heartbeat_time" />
<result property="executionStatus" column="execution_status" />
<result property="startLongitude" column="start_longitude" />
<result property="startLatitude" column="start_latitude" />
<result property="endLongitude" column="end_longitude" />
<result property="endLatitude" column="end_latitude" />
<result property="mobile" column="mobile" />
<result property="patrolLocation" column="patrol_location" />
<result property="problemTotalCount" column="problem_total_count" />
<result property="problemHandleCount" column="problem_handle_count" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>
<sql id="selectReportVo">
select id, tenant_id, dept_id, report_code, inspection_id, inspection_code, inspection_name, type, road_id, road_name, section_id, section_name, inspection_type, airport_id, airport_name, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id, equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, flight_hand, flight_hand_name, inspection_time, execution_start_time, execution_end_time, is_live, is_taken, is_tilt, video_url, ai_video_url, report_url, srt_url, status, analyse_status, progressbar, note, weather, fly_height, srt_name, heartbeat_time, execution_status, start_longitude, start_latitude, end_longitude, end_latitude, mobile, patrol_location, problem_total_count, problem_handle_count, create_user, create_time, update_user, update_time, mark from th_report
</sql>
<select id="selectPageList" parameterType="com.tuoheng.admin.request.report.QueryReportPageListRequest" resultMap="ReportResult">
<include refid="selectReportVo"/>
<where>
<if test="1 == 1"> and mark = 1 </if>
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if>
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if>
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if>
<if test="request.createUser != null and request.createUser != ''"> and create_user = #{request.createUser} </if>
</where>
order by create_time desc
</select>
</mapper>

Loading…
Cancel
Save