gps功能优化,添加人员轨迹,补充绑定车辆时历史记录返回车辆名称
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.gps.controller;
|
package org.dromara.gps.controller;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserQue
|
|||||||
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
|
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
|
||||||
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
|
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
|
||||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||||
|
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
|
||||||
import org.dromara.gps.domain.vo.*;
|
import org.dromara.gps.domain.vo.*;
|
||||||
import org.dromara.project.service.IBusProjectService;
|
import org.dromara.project.service.IBusProjectService;
|
||||||
import org.dromara.system.domain.SysUser;
|
import org.dromara.system.domain.SysUser;
|
||||||
@ -222,4 +224,12 @@ public class GpsEquipmentController extends BaseController {
|
|||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(gpsEquipmentService.deleteWithValidByIds(List.of(ids), true));
|
return toAjax(gpsEquipmentService.deleteWithValidByIds(List.of(ids), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询GPS人员或设备定位日期信息列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDateList")
|
||||||
|
public R<List<LocalDate>> getRlList(GpsEquipmentSonBo bo) {
|
||||||
|
return R.ok(gpsEquipmentService.getRlList(bo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,13 +19,18 @@ public interface GpsEquipmentMapper extends BaseMapperPlus<GpsEquipment, GpsEqui
|
|||||||
|
|
||||||
@Select("SELECT\n" +
|
@Select("SELECT\n" +
|
||||||
" gm.user_id AS userId,\n" +
|
" gm.user_id AS userId,\n" +
|
||||||
" su.nick_name AS userName, \n" +
|
" CASE\n" + // 根据gm.type动态选择userName的取值来源
|
||||||
|
" WHEN gm.trip_id IS NULL THEN su.nick_name\n" + // type=1时取用户昵称(sys_user)
|
||||||
|
" WHEN gm.trip_id IS NOT NULL THEN vvi.plate_number\n" + // type=2时取车辆名称(veh_vehicle_info)
|
||||||
|
" ELSE ''\n" + // 其他type默认空值(或自定义默认内容)
|
||||||
|
" END AS userName,\n" +
|
||||||
" gm.project_id AS projectId,\n" +
|
" gm.project_id AS projectId,\n" +
|
||||||
" bp.project_name AS projectName \n" +
|
" bp.project_name AS projectName \n" +
|
||||||
"FROM\n" +
|
"FROM\n" +
|
||||||
" gps_equipment_son gm\n" +
|
" gps_equipment_son gm\n" +
|
||||||
" LEFT JOIN sys_user su ON gm.user_id = su.user_id \n" +
|
|
||||||
"LEFT JOIN bus_project bp ON gm.project_id = bp.id \n" +
|
"LEFT JOIN bus_project bp ON gm.project_id = bp.id \n" +
|
||||||
|
" LEFT JOIN sys_user su ON gm.user_id = su.user_id and gm.trip_id IS NULL\n" +
|
||||||
|
" LEFT JOIN veh_vehicle_info vvi ON gm.user_id = vvi.id and gm.trip_id IS NOT NULL\n" +
|
||||||
"WHERE\n" +
|
"WHERE\n" +
|
||||||
" gm.client_id = #{clientId}" +
|
" gm.client_id = #{clientId}" +
|
||||||
" GROUP BY gm.user_id,gm.project_id")
|
" GROUP BY gm.user_id,gm.project_id")
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
|
|||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
import org.dromara.gps.domain.vo.GpsStatusVo;
|
import org.dromara.gps.domain.vo.GpsStatusVo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -112,6 +113,28 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, G
|
|||||||
" rn = 1;")
|
" rn = 1;")
|
||||||
List<GpsEquipmentSonVo> getUeClientList(@Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now);
|
List<GpsEquipmentSonVo> getUeClientList(@Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now);
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"SELECT\n" +
|
||||||
|
" DATE(create_time)\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" gps_equipment_son\n" +
|
||||||
|
"WHERE \n" + // 避免条件拼接时的AND开头问题
|
||||||
|
" project_id = #{bo.projectId}\n" +
|
||||||
|
" <choose>\n" + // 互斥选择:userId和clientId二选一
|
||||||
|
" <when test='bo.clientId != null and bo.clientId != \"\"'>\n" + // 其次clientId
|
||||||
|
" AND client_id = #{bo.clientId}\n" +
|
||||||
|
" <if test='bo.userId != null and bo.userId != \"\"'>\n" + // 嵌套if:userId存在则追加
|
||||||
|
" AND user_id = #{bo.userId}\n" +
|
||||||
|
" </if>\n" +
|
||||||
|
" </when>\n" +
|
||||||
|
" <when test='bo.userId != null and bo.userId != \"\"'>\n" + // 优先userId(可调整顺序)
|
||||||
|
" AND user_id = #{bo.userId} AND client_id IS NULL\n" +
|
||||||
|
" </when>\n" +
|
||||||
|
" </choose>\n" +
|
||||||
|
" AND create_time BETWEEN #{bo.startTime} AND #{bo.endTime}\n" +
|
||||||
|
"GROUP BY DATE(create_time)\n" +
|
||||||
|
"</script>")
|
||||||
|
List<LocalDate> getUserOrClientDate(@Param("bo") GpsEquipmentSonBo bo);
|
||||||
@Select("WITH RankedData AS (\n" +
|
@Select("WITH RankedData AS (\n" +
|
||||||
" SELECT\n" +
|
" SELECT\n" +
|
||||||
" *,\n" +
|
" *,\n" +
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.gps.service;
|
package org.dromara.gps.service;
|
||||||
|
|
||||||
|
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
|
||||||
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
|
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
|
||||||
import org.dromara.gps.domain.vo.GpsEquipmentVo;
|
import org.dromara.gps.domain.vo.GpsEquipmentVo;
|
||||||
import org.dromara.gps.domain.bo.GpsEquipmentBo;
|
import org.dromara.gps.domain.bo.GpsEquipmentBo;
|
||||||
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.dromara.gps.domain.vo.GpsProjectVo;
|
import org.dromara.gps.domain.vo.GpsProjectVo;
|
||||||
import org.dromara.gps.domain.vo.GpsUserVo;
|
import org.dromara.gps.domain.vo.GpsUserVo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -108,4 +110,11 @@ public interface IGpsEquipmentService extends IService<GpsEquipment>{
|
|||||||
List<GpsEquipmentSonVo> getUeUserListByProjectId(LocalDateTime startOfDay, LocalDateTime now);
|
List<GpsEquipmentSonVo> getUeUserListByProjectId(LocalDateTime startOfDay, LocalDateTime now);
|
||||||
|
|
||||||
List<GpsEquipmentVo> getListToVehicle(GpsEquipmentBo bo);
|
List<GpsEquipmentVo> getListToVehicle(GpsEquipmentBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询GPS人员或设备定位日期信息列表
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<LocalDate> getRlList(GpsEquipmentSonBo bo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.dromara.gps.domain.vo.GpsStatusVo;
|
import org.dromara.gps.domain.vo.GpsStatusVo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -88,4 +89,11 @@ public interface IGpsEquipmentSonService extends IService<GpsEquipmentSon>{
|
|||||||
|
|
||||||
List<GpsEquipmentSonVo> getVehicleList(GpsEquipmentSonBo bo);
|
List<GpsEquipmentSonVo> getVehicleList(GpsEquipmentSonBo bo);
|
||||||
List<GpsEquipmentSonVo> getNewVehicleList(GpsEquipmentSonBo bo);
|
List<GpsEquipmentSonVo> getNewVehicleList(GpsEquipmentSonBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询GPS人员或设备定位日期信息列表
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<LocalDate> getUserOrClientDate(GpsEquipmentSonBo bo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -118,7 +119,13 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
|||||||
} else {
|
} else {
|
||||||
item.setType(2);
|
item.setType(2);
|
||||||
}
|
}
|
||||||
if (item.getClientType() != null) {
|
if (item.getGpsType() == 1){
|
||||||
|
SysUserVo sysUserVo = userService.queryById(item.getUserId());
|
||||||
|
if (sysUserVo != null) {
|
||||||
|
item.setUserName(sysUserVo.getNickName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.getGpsType() == 0 && item.getClientType() != null) {
|
||||||
if (item.getClientType() == 0) {
|
if (item.getClientType() == 0) {
|
||||||
SysUserVo sysUserVo = userService.queryById(item.getUserId());
|
SysUserVo sysUserVo = userService.queryById(item.getUserId());
|
||||||
if (sysUserVo != null) {
|
if (sysUserVo != null) {
|
||||||
@ -560,6 +567,7 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
|||||||
.eq(GpsEquipment::getUserId, gpsEquipment.getUserId()));
|
.eq(GpsEquipment::getUserId, gpsEquipment.getUserId()));
|
||||||
if (equipment == null) {
|
if (equipment == null) {
|
||||||
gpsEquipment.setGpsType(1);
|
gpsEquipment.setGpsType(1);
|
||||||
|
gpsEquipment.setClientType(0);
|
||||||
// gpsEquipment.setClientId(jsonObject.getStr("deviceId"));
|
// gpsEquipment.setClientId(jsonObject.getStr("deviceId"));
|
||||||
baseMapper.insert(gpsEquipment);
|
baseMapper.insert(gpsEquipment);
|
||||||
}
|
}
|
||||||
@ -627,5 +635,15 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
|||||||
.isNull(GpsEquipment::getUserId).isNotNull(GpsEquipment::getClientId));
|
.isNull(GpsEquipment::getUserId).isNotNull(GpsEquipment::getClientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询GPS人员或设备定位日期信息列表
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<LocalDate> getRlList(GpsEquipmentSonBo bo) {
|
||||||
|
return gpsEquipmentSonService.getUserOrClientDate(bo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import org.dromara.gps.domain.GpsEquipmentSon;
|
|||||||
import org.dromara.gps.mapper.GpsEquipmentSonMapper;
|
import org.dromara.gps.mapper.GpsEquipmentSonMapper;
|
||||||
import org.dromara.gps.service.IGpsEquipmentSonService;
|
import org.dromara.gps.service.IGpsEquipmentSonService;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -247,4 +248,23 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
|
|||||||
.eq(GpsEquipmentSon::getTripId,bo.getTripId())
|
.eq(GpsEquipmentSon::getTripId,bo.getTripId())
|
||||||
.orderByDesc(GpsEquipmentSon::getCreateTime));
|
.orderByDesc(GpsEquipmentSon::getCreateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询GPS人员或设备定位日期信息列表
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<LocalDate> getUserOrClientDate(GpsEquipmentSonBo bo) {
|
||||||
|
if (bo.getProjectId() == null) {
|
||||||
|
throw new ServiceException("项目id不能为空!");
|
||||||
|
}
|
||||||
|
if (bo.getClientId() == null && bo.getUserId() == null) {
|
||||||
|
throw new ServiceException("设备id或用户id不能为空!");
|
||||||
|
}
|
||||||
|
if (bo.getStartTime() == null || bo.getEndTime() == null) {
|
||||||
|
throw new ServiceException("开始时间和结算时间不能为空!!!");
|
||||||
|
}
|
||||||
|
return baseMapper.getUserOrClientDate(bo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user