Commit ea47958b authored by 耿迪迪's avatar 耿迪迪

巡检人员初始化及路线 gengdidi

parent 2c13f5f5
package com.zehong.web.controller.inspectorLocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.system.domain.vo.TUserLocationVo;
import com.zehong.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TUserLocation;
import com.zehong.system.service.ITUserLocationService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 巡检员定位Controller
*
* @author zehong
* @date 2021-07-31
*/
@RestController
@RequestMapping("/system/location")
public class TUserLocationController extends BaseController
{
@Autowired
private ITUserLocationService tUserLocationService;
@Autowired
private ISysUserService userService;
/**
* 查询巡检员定位列表
*/
@PreAuthorize("@ss.hasPermi('system:location:list')")
@GetMapping("/list")
public TableDataInfo list(TUserLocation tUserLocation)
{
startPage();
List<TUserLocation> list = tUserLocationService.selectTUserLocationList(tUserLocation);
return getDataTable(list);
}
/**
* 初始化巡检员位置及巡检员路线
* @param tUserLocationVo
* @return
*/
@GetMapping("/getInspectorLocations")
public AjaxResult getInspectorLocations(TUserLocationVo tUserLocationVo){
if(null == tUserLocationVo.getUserId()){
List<SysUser> inspectors = userService.selectInspectorList();
List<TUserLocation> inspectorLocations = new ArrayList<>();
Map<String,Object> map = new HashMap<>(16);
for(SysUser sysUser : inspectors){
map.put("userId",sysUser.getUserId());
map.put("initInspectors","initInspectors");
inspectorLocations.addAll(tUserLocationService.selectTUserLocationListByMap(map));
}
return AjaxResult.success(inspectorLocations);
}
Map<String,Object> map = new HashMap<>(16);
map.put("userId",tUserLocationVo.getUserId());
map.put("beginTime",tUserLocationVo.getBeginTime());
map.put("endTime",tUserLocationVo.getEndTime());
return AjaxResult.success(tUserLocationService.selectTUserLocationListByMap(map));
}
/**
* 导出巡检员定位列表
*/
@PreAuthorize("@ss.hasPermi('system:location:export')")
@Log(title = "巡检员定位", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TUserLocation tUserLocation)
{
List<TUserLocation> list = tUserLocationService.selectTUserLocationList(tUserLocation);
ExcelUtil<TUserLocation> util = new ExcelUtil<TUserLocation>(TUserLocation.class);
return util.exportExcel(list, "巡检员定位数据");
}
/**
* 获取巡检员定位详细信息
*/
@PreAuthorize("@ss.hasPermi('system:location:query')")
@GetMapping(value = "/{locationId}")
public AjaxResult getInfo(@PathVariable("locationId") Long locationId)
{
return AjaxResult.success(tUserLocationService.selectTUserLocationById(locationId));
}
/**
* 新增巡检员定位
*/
@PreAuthorize("@ss.hasPermi('system:location:add')")
@Log(title = "巡检员定位", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TUserLocation tUserLocation)
{
return toAjax(tUserLocationService.insertTUserLocation(tUserLocation));
}
/**
* 修改巡检员定位
*/
@PreAuthorize("@ss.hasPermi('system:location:edit')")
@Log(title = "巡检员定位", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TUserLocation tUserLocation)
{
return toAjax(tUserLocationService.updateTUserLocation(tUserLocation));
}
/**
* 删除巡检员定位
*/
@PreAuthorize("@ss.hasPermi('system:location:remove')")
@Log(title = "巡检员定位", businessType = BusinessType.DELETE)
@DeleteMapping("/{locationIds}")
public AjaxResult remove(@PathVariable Long[] locationIds)
{
return toAjax(tUserLocationService.deleteTUserLocationByIds(locationIds));
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 巡检员定位对象 t_user_location
*
* @author zehong
* @date 2021-07-31
*/
public class TUserLocation extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 巡检定位表id */
private Long locationId;
/** 人员id */
@Excel(name = "人员id")
private Long userId;
/** 经度 */
@Excel(name = "经度")
private BigDecimal longitude;
/** 纬度 */
@Excel(name = "纬度")
private BigDecimal latitude;
public void setLocationId(Long locationId)
{
this.locationId = locationId;
}
public Long getLocationId()
{
return locationId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public BigDecimal getLatitude()
{
return latitude;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("locationId", getLocationId())
.append("userId", getUserId())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("createTime", getCreateTime())
.toString();
}
}
package com.zehong.system.domain.vo;
import java.util.Date;
public class TUserLocationVo {
/**
*巡检人员id
*/
private Long userId;
/**
* 巡检开始时间
*/
private Date beginTime;
/**
* 巡检结束时间
*/
private Date endTime;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
package com.zehong.system.mapper;
import com.zehong.system.domain.TUserLocation;
import java.util.List;
import java.util.Map;
/**
* 巡检员定位Mapper接口
*
* @author zehong
* @date 2021-07-31
*/
public interface TUserLocationMapper
{
/**
* 查询巡检员定位
*
* @param locationId 巡检员定位ID
* @return 巡检员定位
*/
public TUserLocation selectTUserLocationById(Long locationId);
/**
* 查询巡检员定位列表
*
* @param tUserLocation 巡检员定位
* @return 巡检员定位集合
*/
public List<TUserLocation> selectTUserLocationList(TUserLocation tUserLocation);
/**
* 查询巡检员定位byMap
* @param map
* @return
*/
List<TUserLocation> selectTUserLocationListByMap(Map<String,Object> map);
/**
* 新增巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
public int insertTUserLocation(TUserLocation tUserLocation);
/**
* 修改巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
public int updateTUserLocation(TUserLocation tUserLocation);
/**
* 删除巡检员定位
*
* @param locationId 巡检员定位ID
* @return 结果
*/
public int deleteTUserLocationById(Long locationId);
/**
* 批量删除巡检员定位
*
* @param locationIds 需要删除的数据ID
* @return 结果
*/
public int deleteTUserLocationByIds(Long[] locationIds);
}
package com.zehong.system.service;
import java.util.List;
import java.util.Map;
import com.zehong.system.domain.TUserLocation;
/**
* 巡检员定位Service接口
*
* @author zehong
* @date 2021-07-31
*/
public interface ITUserLocationService
{
/**
* 查询巡检员定位
*
* @param locationId 巡检员定位ID
* @return 巡检员定位
*/
public TUserLocation selectTUserLocationById(Long locationId);
/**
* 查询巡检员定位列表
*
* @param tUserLocation 巡检员定位
* @return 巡检员定位集合
*/
public List<TUserLocation> selectTUserLocationList(TUserLocation tUserLocation);
/**
* 查询巡检员定位列表ByMap
* @param map
* @return
*/
List<TUserLocation> selectTUserLocationListByMap(Map<String,Object> map);
/**
* 新增巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
public int insertTUserLocation(TUserLocation tUserLocation);
/**
* 修改巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
public int updateTUserLocation(TUserLocation tUserLocation);
/**
* 批量删除巡检员定位
*
* @param locationIds 需要删除的巡检员定位ID
* @return 结果
*/
public int deleteTUserLocationByIds(Long[] locationIds);
/**
* 删除巡检员定位信息
*
* @param locationId 巡检员定位ID
* @return 结果
*/
public int deleteTUserLocationById(Long locationId);
}
package com.zehong.system.service.impl;
import java.util.List;
import java.util.Map;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TUserLocationMapper;
import com.zehong.system.domain.TUserLocation;
import com.zehong.system.service.ITUserLocationService;
/**
* 巡检员定位Service业务层处理
*
* @author zehong
* @date 2021-07-31
*/
@Service
public class TUserLocationServiceImpl implements ITUserLocationService
{
@Autowired
private TUserLocationMapper tUserLocationMapper;
/**
* 查询巡检员定位
*
* @param locationId 巡检员定位ID
* @return 巡检员定位
*/
@Override
public TUserLocation selectTUserLocationById(Long locationId)
{
return tUserLocationMapper.selectTUserLocationById(locationId);
}
/**
* 查询巡检员定位列表
*
* @param tUserLocation 巡检员定位
* @return 巡检员定位
*/
@Override
public List<TUserLocation> selectTUserLocationList(TUserLocation tUserLocation)
{
return tUserLocationMapper.selectTUserLocationList(tUserLocation);
}
@Override
public List<TUserLocation> selectTUserLocationListByMap(Map<String,Object> map){
return tUserLocationMapper.selectTUserLocationListByMap(map);
}
/**
* 新增巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
@Override
public int insertTUserLocation(TUserLocation tUserLocation)
{
tUserLocation.setCreateTime(DateUtils.getNowDate());
return tUserLocationMapper.insertTUserLocation(tUserLocation);
}
/**
* 修改巡检员定位
*
* @param tUserLocation 巡检员定位
* @return 结果
*/
@Override
public int updateTUserLocation(TUserLocation tUserLocation)
{
return tUserLocationMapper.updateTUserLocation(tUserLocation);
}
/**
* 批量删除巡检员定位
*
* @param locationIds 需要删除的巡检员定位ID
* @return 结果
*/
@Override
public int deleteTUserLocationByIds(Long[] locationIds)
{
return tUserLocationMapper.deleteTUserLocationByIds(locationIds);
}
/**
* 删除巡检员定位信息
*
* @param locationId 巡检员定位ID
* @return 结果
*/
@Override
public int deleteTUserLocationById(Long locationId)
{
return tUserLocationMapper.deleteTUserLocationById(locationId);
}
}
<?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.zehong.system.mapper.TUserLocationMapper">
<resultMap type="TUserLocation" id="TUserLocationResult">
<result property="locationId" column="location_id" />
<result property="userId" column="user_id" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectTUserLocationVo">
select location_id, user_id, longitude, latitude, create_time from t_user_location
</sql>
<select id="selectTUserLocationList" parameterType="TUserLocation" resultMap="TUserLocationResult">
<include refid="selectTUserLocationVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="longitude != null "> and longitude = #{longitude}</if>
<if test="latitude != null "> and latitude = #{latitude}</if>
</where>
</select>
<select id="selectTUserLocationListByMap" parameterType="java.util.Map" resultMap="TUserLocationResult">
<include refid="selectTUserLocationVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="longitude != null "> and longitude = #{longitude}</if>
<if test="latitude != null "> and latitude = #{latitude}</if>
<if test="beginTime != null and endTime != null"> and create_time BETWEEN #{beginTime} AND #{endTime}</if>
</where>
ORDER BY create_time DESC
<if test="initInspectors == 'initInspectors'">
LIMIT 1
</if>
</select>
<select id="selectTUserLocationById" parameterType="Long" resultMap="TUserLocationResult">
<include refid="selectTUserLocationVo"/>
where location_id = #{locationId}
</select>
<insert id="insertTUserLocation" parameterType="TUserLocation" useGeneratedKeys="true" keyProperty="locationId">
insert into t_user_location
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateTUserLocation" parameterType="TUserLocation">
update t_user_location
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where location_id = #{locationId}
</update>
<delete id="deleteTUserLocationById" parameterType="Long">
delete from t_user_location where location_id = #{locationId}
</delete>
<delete id="deleteTUserLocationByIds" parameterType="String">
delete from t_user_location where location_id in
<foreach item="locationId" collection="array" open="(" separator="," close=")">
#{locationId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询巡检员定位列表
export function listLocation(query) {
return request({
url: '/system/location/list',
method: 'get',
params: query
})
}
//初始化巡检员位置及路线
export function getInspectorLocations(query){
return request({
url: '/system/location/getInspectorLocations',
method: 'get',
params: query
})
}
// 查询巡检员定位详细
export function getLocation(locationId) {
return request({
url: '/system/location/' + locationId,
method: 'get'
})
}
// 新增巡检员定位
export function addLocation(data) {
return request({
url: '/system/location',
method: 'post',
data: data
})
}
// 修改巡检员定位
export function updateLocation(data) {
return request({
url: '/system/location',
method: 'put',
data: data
})
}
// 删除巡检员定位
export function delLocation(locationId) {
return request({
url: '/system/location/' + locationId,
method: 'delete'
})
}
// 导出巡检员定位
export function exportLocation(query) {
return request({
url: '/system/location/export',
method: 'get',
params: query
})
}
......@@ -105,7 +105,7 @@ import { pipeAllInfoList, countPipeLength } from "@/api/device/pipe.js";
import gaodeMap, { map, DEVICE_TYPE, mapOperateType } from "utils/gaodeMapView.js";
import { getAllDeviceInfo, countDeviceByType } from "@/api/device/deviceInfo";
import RightBototmData from "./components/RightBototmData.vue";
import { getInspectionDataByInspector } from "@/api/deviceInspection/inspectionData"
import { getInspectorLocations } from "@/api/inspectorLocation/location"
export default {
components: {
......@@ -183,7 +183,7 @@ export default {
gaoMap.searchTips("tipinput");
this.getDeviceInfo();
this.getPipeList();
this.getInspectionDataByInspector();
this.getInspectorLocations();
},
// 左边的Bar修改值
leftBarChange(item) {
......@@ -374,25 +374,17 @@ export default {
}
});
},
getInspectionDataByInspector(){
this.gaoMap.addMarker(
DEVICE_TYPE.INSPECTOR,
{longitude:114.525243,latitude:38.035002}
);
/* getInspectionDataByInspector().then((res) =>{
getInspectorLocations(){
getInspectorLocations().then((res) =>{
if(res.code == 200){
console.log(res.data);
for(var i =0; i<res.data.length; i++){
console.log(res.data[i].inspectionDataVo[0],"fdafdsfd================")
this.gaoMap.addMarker(
DEVICE_TYPE.INSPECTOR,
res.data[i].inspectionDataVo[0]
res.data[i]
);
}
}
});*/
});
},
searchClear() {
this.iconClass = "icon-create";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment