智慧保安后台管理-外网项目备份
tangzy
2021-07-30 780ec2ea0b558c5603012abbfb8c1fa9845e6734
Merge branch 'master' of http://192.168.0.105:10010/r/zhba_management_w
14 files modified
15 files added
1215 ■■■■■ changed files
src/main/java/org/springblade/modules/directive/controller/DirectiveController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/dispatcher/controller/DispatcherController.java 27 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/controller/LiveLocationController.java 163 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/controller/LocusController.java 87 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/entity/LiveLocation.java 69 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/entity/Locus.java 56 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/mapper/LiveLocationMapper.java 75 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/mapper/LiveLocationMapper.xml 223 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/mapper/LocusMapper.java 32 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/mapper/LocusMapper.xml 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/service/LiveLocationService.java 51 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/service/LocusService.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/service/impl/LiveLocationServiceImpl.java 84 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/service/impl/LocusServiceImpl.java 39 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/vo/LiveLocationVo.java 57 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/location/vo/LocusVo.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/DeptController.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml 69 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.java 3 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 11 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IDeptService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IUserService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/vo/DeptAndUserVO.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/vo/UserVO.java 10 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/directive/controller/DirectiveController.java
@@ -14,6 +14,8 @@
import org.springblade.modules.directive.vo.DirectiveVo;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
/**
 * @author zhongrj
 * @time 2021-07-21
@@ -55,9 +57,10 @@
    @PostMapping("/saveDirectiveAndFile")
    public R saveDirectiveAndFile(@RequestBody DirectiveVo directive) {
        //新增指令信息
        boolean save = directiveService.save(directive);
        boolean status = false;
        if (save){
        directive.setSendTime(new Date());
        status = directiveService.save(directive);
        if (status){
            //新增图片
            if (null!=directive.getUrl() && directive.getUrl()!=""){
                String[] directiveUrl = directive.getUrl().split(",");
@@ -68,7 +71,7 @@
                    directiveFile.setUrl(url);
                    status = directiveService.saveDirectiveFile(directiveFile);
                    if (!status){
                        R.status(false);
                        return R.status(false);
                    }
                }
            }
src/main/java/org/springblade/modules/dispatcher/controller/DispatcherController.java
@@ -29,6 +29,8 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.dispatcher.service.IDispatcherUnitService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.dispatcher.entity.Dispatcher;
@@ -37,6 +39,7 @@
import org.springblade.core.boot.ctrl.BladeController;
import java.util.Arrays;
import java.util.List;
/**
 *  控制器
@@ -53,6 +56,8 @@
    private final IDispatcherService dispatcherService;
    private final IDispatcherUnitService dispatcherUnitService;
    private final IUserService userService;
    /**
     * 详情
@@ -116,21 +121,37 @@
    public R submit(@Valid @RequestBody Dispatcher dispatcher) throws Exception {
        if (dispatcher.getId()==null){
            if (null!=dispatcher.getUserIds() && dispatcher.getUserIds()!=""){
                List<String> list = Arrays.asList(dispatcher.getUserIds().split(","));
                //计算派遣人数
                dispatcher.setNum(Arrays.asList(dispatcher.getUserIds().split(",")).size());
                dispatcher.setNum(list.size());
                //修改保安人员的派遣状态
                list.forEach(id -> {
                    User user = new User();
                    user.setId(Long.parseLong(id));
                    user.setDispatch("0");
                    userService.updateById(user);
                });
                //查询派遣单位的信息,设置行政区
                dispatcher.setJurisdiction(dispatcherUnitService.getById(dispatcher.getDispatcherUnitId()).getJurisdiction().toString());
            }
            arg arg = new arg();
            arg.test01(arg.url+"/dispatcher/save",dispatcher);
        }
        else {
            if (null != dispatcher.getUserIds() && dispatcher.getUserIds() != "") {
                List<String> list = Arrays.asList(dispatcher.getUserIds().split(","));
                //计算派遣人数
                dispatcher.setNum(Arrays.asList(dispatcher.getUserIds().split(",")).size());
                dispatcher.setNum(list.size());
                //修改保安人员的派遣状态
                list.forEach(id -> {
                    User user = new User();
                    user.setId(Long.parseLong(id));
                    user.setDispatch("0");
                    userService.updateById(user);
                });
                //查询派遣单位的信息,设置行政区
                dispatcher.setJurisdiction(dispatcherUnitService.getById(dispatcher.getDispatcherUnitId()).getJurisdiction().toString());
            }
            arg.test01(arg.url+"/dispatcher/update",dispatcher);
        }
        return R.status(dispatcherService.saveOrUpdate(dispatcher));
    }
src/main/java/org/springblade/modules/location/controller/LiveLocationController.java
New file
@@ -0,0 +1,163 @@
package org.springblade.modules.location.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.location.entity.LiveLocation;
import org.springblade.modules.location.entity.Locus;
import org.springblade.modules.location.service.LiveLocationService;
import org.springblade.modules.location.service.LocusService;
import org.springblade.modules.location.vo.LiveLocationVo;
import org.springblade.modules.location.vo.LocusVo;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
 * @author zhongrj
 * @time 2021-07-21
 * @desc 实时位置控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/liveLocation")
public class LiveLocationController {
    private final LiveLocationService liveLocationService;
    private final LocusService locusService;
    /**
     * 自定义分页
     * @param query page,size
     * @param liveLocation 实时位置信息对象
     */
    @GetMapping("/page")
    public R<IPage<LiveLocationVo>> page(LiveLocationVo liveLocation, Query query) {
        IPage<LiveLocationVo> pages = liveLocationService.selectLiveLocationPage(Condition.getPage(query), liveLocation);
        return R.data(pages);
    }
    /**
     * 新增
     * @param liveLocation 实时位置信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入liveLocation")
    public R save(@RequestBody LiveLocation liveLocation) {
        return R.status(liveLocationService.save(liveLocation));
    }
    /**
     * 实时位置信息新增,同时新增到轨迹表中
     * @param liveLocation 实时位置信息对象
     */
    @PostMapping("/saveLiveLocationAndLocus")
    @ApiOperation(value = "新增", notes = "传入liveLocation")
    public R saveLiveLocationAndLocus(@RequestBody LiveLocation liveLocation) {
        //先查询是否已有实时位置信息,如果有,则更新,没有则插入
        LiveLocation liveLocationInfo = liveLocationService.getLiveLocationInfo(liveLocation);
        boolean status = false;
        if (null == liveLocationInfo){
            //新增
            liveLocation.setRecordTime(new Date());
            status = liveLocationService.save(liveLocation);
        }else {
            //更新
            liveLocationInfo.setRecordTime(new Date());
            liveLocationInfo.setLongitude(liveLocation.getLongitude());
            liveLocationInfo.setLatitude(liveLocation.getLatitude());
            status = liveLocationService.updateById(liveLocationInfo);
        }
        if (status){
            //新增轨迹
            Locus locus = new Locus();
            //封装数据
            if (null!=liveLocationInfo){
                locus.setLiveLocationId(liveLocationInfo.getId());
            }else {
                locus.setLiveLocationId(liveLocation.getId());
            }
            if (null!= liveLocation.getLatitude() && null!=liveLocation.getLongitude()){
                locus.setLatitude(liveLocation.getLatitude());
                locus.setLongitude(liveLocation.getLongitude());
            }
            locus.setRecordTime(new Date());
            //新增轨迹
            boolean save1 = locusService.save(locus);
            if (save1){
                //返回数据
                return R.status(true);
            }
        }
        //返回数据
        return R.status(false);
    }
    /**
     * 修改
     * @param liveLocation 实时位置信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody LiveLocation liveLocation) {
        return R.status(liveLocationService.updateById(liveLocation));
    }
    /**
     * 新增或修改
     * @param liveLocation 实时位置信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody LiveLocation liveLocation) {
        return R.status(liveLocationService.saveOrUpdate(liveLocation));
    }
    /**
     * 删除
     * @param ids 实时位置信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(liveLocationService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     * @param liveLocation 实时位置信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入liveLocation")
    public R<LiveLocation> detail(LiveLocation liveLocation) {
        LiveLocation detail = liveLocationService.getOne(Condition.getQueryWrapper(liveLocation));
        return R.data(detail);
    }
    /**
     * 获取轨迹数据
     * @param liveLocationVo 实时对象信息
     * @return
     */
    @GetMapping("/getLocusInfoList")
    public R<List<LocusVo>> getLocusInfoList(LiveLocationVo liveLocationVo){
        return R.data(liveLocationService.getLocusInfoList(liveLocationVo));
    }
    /**
     * 首页实时定位
     * @return
     */
    @GetMapping("/getLiveLocationVoList")
    public R<List<LiveLocationVo>> getLiveLocationVoList(LiveLocationVo liveLocationVo){
        return R.data(liveLocationService.getLiveLocationVoList(liveLocationVo));
    }
}
src/main/java/org/springblade/modules/location/controller/LocusController.java
New file
@@ -0,0 +1,87 @@
package org.springblade.modules.location.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.location.entity.Locus;
import org.springblade.modules.location.service.LocusService;
import org.springblade.modules.location.vo.LocusVo;
import org.springframework.web.bind.annotation.*;
/**
 * @author zhongrj
 * @time 2021-07-06
 * @desc 轨迹管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/locus")
public class LocusController {
    private final LocusService locusService;
    /**
     * 自定义分页
     * @param query page,size
     * @param locus 轨迹信息对象
     */
    @GetMapping("/page")
    public R<IPage<LocusVo>> page(LocusVo locus, Query query) {
        IPage<LocusVo> pages = locusService.selectLocusPage(Condition.getPage(query), locus);
        return R.data(pages);
    }
    /**
     * 新增
     * @param locus 轨迹信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入locus")
    public R save(@RequestBody Locus locus) {
        return R.status(locusService.save(locus));
    }
    /**
     * 修改
     * @param locus 轨迹信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody Locus locus) {
        return R.status(locusService.updateById(locus));
    }
    /**
     * 新增或修改
     * @param locus 轨迹信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Locus locus) {
        return R.status(locusService.saveOrUpdate(locus));
    }
    /**
     * 删除
     * @param ids 轨迹信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(locusService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     * @param locus 轨迹信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入locus")
    public R<LocusVo> detail(Locus locus) {
        LocusVo detail = locusService.selectLocusInfo(locus);
        return R.data(detail);
    }
}
src/main/java/org/springblade/modules/location/entity/LiveLocation.java
New file
@@ -0,0 +1,69 @@
package org.springblade.modules.location.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 实时位置实体类
 * @author zhongrj
 * @time 2021-07-21
 */
@Data
@TableName("sys_live_location")
public class LiveLocation implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 实时位置主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 类型  1:押运人员  2:押运车辆  3:枪支
     */
    @TableField("type")
    private Integer type;
    /**
     * 押运人员/车辆/枪支id
     */
    @TableField("worker_id")
    private Long workerId;
    /**
     * 记录时间/上传时间
     */
    @TableField("record_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date recordTime;
    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
    /**
     * 实时位置地址
     */
    private String location;
}
src/main/java/org/springblade/modules/location/entity/Locus.java
New file
@@ -0,0 +1,56 @@
package org.springblade.modules.location.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 轨迹实体类
 * @author zhongrj
 * @time 2021-07-21
 */
@Data
@TableName("sys_locus")
public class Locus implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 轨迹主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 实时位置id
     */
    @TableField("live_location_id")
    private Long liveLocationId;
    /**
     * 记录时间/上传时间
     */
    @TableField("record_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date recordTime;
    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
}
src/main/java/org/springblade/modules/location/mapper/LiveLocationMapper.java
New file
@@ -0,0 +1,75 @@
package org.springblade.modules.location.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.location.entity.LiveLocation;
import org.springblade.modules.location.vo.LiveLocationVo;
import org.springblade.modules.location.vo.LocusVo;
import java.util.List;
/**
 * 实时位置Mapper 接口
 * @author zhongrj
 */
public interface LiveLocationMapper extends BaseMapper<LiveLocation> {
    /**
     * 自定义分页
     *
     * @param page   分页
     * @param liveLocation 实体
     * @return
     */
    List<LiveLocationVo> selectLiveLocationPage(IPage page, @Param("liveLocation") LiveLocationVo liveLocation);
    /**
     * 详情
     * @param liveLocation 实时位置信息对象
     * @return
     */
    LiveLocationVo selectLiveLocationInfo(@Param("liveLocation") LiveLocation liveLocation);
    /**
     * 获取轨迹数据
     * @param liveLocationVo 实时对象信息
     * @return
     */
    List<LocusVo> getLocusInfoList(@Param("liveLocation") LiveLocationVo liveLocationVo);
    /**
     * 获取实时位置信息
     * @param liveLocation
     * @return
     */
    LiveLocation getLiveLocationInfo(@Param("liveLocation") LiveLocation liveLocation);
    /**
     * 获取保安人员实时位置信息
     * @param liveLocationVo
     * @return
     */
    List<LiveLocationVo> getSecurityLocusInfoList(LiveLocationVo liveLocationVo);
    /**
     * 获取车辆实时位置信息
     * @param liveLocationVo
     * @return
     */
    List<LiveLocationVo> getCarLocusInfoList(LiveLocationVo liveLocationVo);
    /**
     * 获取枪支实时位置信息
     * @param liveLocationVo
     * @return
     */
    List<LiveLocationVo> getGunLocusInfoList(LiveLocationVo liveLocationVo);
    /**
     * 获取保安人员,车辆,枪支实时位置信息
     * @param liveLocationVo
     * @return
     */
    List<LiveLocationVo> selectSecurityAndCarAndGunLiveLocationPage(LiveLocationVo liveLocationVo);
}
src/main/java/org/springblade/modules/location/mapper/LiveLocationMapper.xml
New file
@@ -0,0 +1,223 @@
<?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="org.springblade.modules.location.mapper.LiveLocationMapper">
    <!--实时位置分页信息-->
    <select id="selectLiveLocationPage" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        SELECT
            *
        FROM
            sys_live_location
        WHERE
            1=1
        <if test="liveLocation.startTime!=null and liveLocation.startTime!=''">
            and record_time &gt;= #{liveLocation.startTime}
        </if>
        <if test="liveLocation.endTime!=null and liveLocation.endTime!=''">
            and record_time &lt;= #{liveLocation.endTime}
        </if>
    </select>
    <!--实时位置详情信息-->
    <select id="selectLiveLocationInfo" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        SELECT
            *
        FROM
            sys_live_location
        WHERE
            1=1
        <if test="liveLocation.type!=null">
            and type = #{liveLocation.type}
        </if>
        <if test="liveLocation.workerId!=null and liveLocation.workerId!=''">
            and worker_id = #{liveLocation.workerId}
        </if>
    </select>
    <!--获取实时位置信息-->
    <select id="getLiveLocationInfo" resultType="org.springblade.modules.location.entity.LiveLocation">
        SELECT
        *
        FROM
        sys_live_location
        WHERE
        1=1
        <if test="liveLocation.type!=null">
            and type = #{liveLocation.type}
        </if>
        <if test="liveLocation.workerId!=null and liveLocation.workerId!=''">
            and worker_id = #{liveLocation.workerId}
        </if>
    </select>
    <!--获取轨迹数据-->
    <select id="getLocusInfoList" resultType="org.springblade.modules.location.vo.LocusVo">
        select
            sl.*
        from
            sys_locus sl
        left join
            sys_live_location sll
        on
            sll.id = sl.live_location_id
        where
            1=1
        <if test="liveLocation.type!=null and liveLocation.type!=''">
            and sll.type = #{liveLocation.type}
        </if>
        <if test="liveLocation.workerId!=null and liveLocation.workerId!=''">
            and sll.worker_id = #{liveLocation.workerId}
        </if>
        <if test="liveLocation.startTime!=null and liveLocation.startTime!=''">
            and sl.record_time &gt;= #{liveLocation.startTime}
        </if>
        <if test="liveLocation.endTime!=null and liveLocation.endTime!=''">
            and sl.record_time &lt;= #{liveLocation.endTime}
        </if>
        order by sl.record_time desc
    </select>
    <!--保安人员的实时位置信息-->
    <select id="getSecurityLocusInfoList" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        SELECT
            sll.*,
            bu.real_name name,bu.phone tel,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            blade_user bu
        on
            sll.worker_id = bu.id
        left join
            blade_dept bd
        on
            bu.dept_id = bd.id
        where
            sll.type=1
    </select>
    <!--车辆的实时位置信息-->
    <select id="getCarLocusInfoList" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        SELECT
            sll.*,
            sc.car_number carNum,sc.person_in_charge linkman,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            sys_car sc
        on
            sll.worker_id = sc.id
        left join
            blade_dept bd
        on
            sc.dept_id = bd.id
        where
            sll.type=2
    </select>
    <!--枪支的实时位置信息-->
    <select id="getGunLocusInfoList" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        SELECT
            sll.*,
            sg.gun_card_number number,sg.person_in_charge linkman,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            sys_gun sg
        on
            sll.worker_id = sg.id
        left join
            blade_dept bd
        on
            sg.dept_id = bd.id
        where
            sll.type=3
    </select>
    <!--枪支的实时位置信息-->
    <select id="selectSecurityAndCarAndGunLiveLocationPage" resultType="org.springblade.modules.location.vo.LiveLocationVo">
        (SELECT
            sll.*,
            bu.real_name name,
            null as number,
            null as linkman,
            null as carNum,
            bu.phone tel,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            blade_user bu
        on
            sll.worker_id = bu.id
        left join
            blade_dept bd
        on
            bu.dept_id = bd.id
        where
            sll.type=1)
        union all
        (SELECT
            sll.*,
            null as name,
            null as number,
            sc.person_in_charge linkman,
            sc.car_number carNum,
            null as tel,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            sys_car sc
        on
            sll.worker_id = sc.id
        left join
            blade_dept bd
        on
            sc.dept_id = bd.id
        where
            sll.type=2)
        union all
       (SELECT
            sll.*,
            null as name,
            sg.gun_card_number number,
            sg.person_in_charge linkman,
            null as carNum,
            null as tel,
            bd.dept_name company
        FROM
            sys_live_location sll
        left join
            sys_gun sg
        on
            sll.worker_id = sg.id
        left join
            blade_dept bd
        on
            sg.dept_id = bd.id
        where
            sll.type=3)
    </select>
</mapper>
src/main/java/org/springblade/modules/location/mapper/LocusMapper.java
New file
@@ -0,0 +1,32 @@
package org.springblade.modules.location.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.location.entity.Locus;
import org.springblade.modules.location.vo.LocusVo;
import java.util.List;
/**
 * 轨迹Mapper 接口
 * @author zhongrj
 */
public interface LocusMapper extends BaseMapper<Locus> {
    /**
     * 自定义分页
     *
     * @param page   分页
     * @param locus 实体
     * @return
     */
    List<LocusVo> selectLocusPage(IPage page, @Param("locus") LocusVo locus);
    /**
     * 详情
     * @param locus 轨迹信息对象
     * @return
     */
    LocusVo selectLocusInfo(@Param("locus") Locus locus);
}
src/main/java/org/springblade/modules/location/mapper/LocusMapper.xml
New file
@@ -0,0 +1,27 @@
<?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="org.springblade.modules.location.mapper.LocusMapper">
    <!--轨迹分页信息-->
    <select id="selectLocusPage" resultType="org.springblade.modules.location.vo.LocusVo">
        SELECT
            *
        FROM
            sys_locus
        WHERE
            1=1
    </select>
    <!--轨迹详情信息-->
    <select id="selectLocusInfo" resultType="org.springblade.modules.location.vo.LocusVo">
        SELECT
            *
        FROM
            sys_locus
        WHERE
            1=1
        <if test="locus.id!=null">
            and id = #{locus.id}
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/location/service/LiveLocationService.java
New file
@@ -0,0 +1,51 @@
package org.springblade.modules.location.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.location.entity.LiveLocation;
import org.springblade.modules.location.vo.LiveLocationVo;
import org.springblade.modules.location.vo.LocusVo;
import java.util.List;
/**
 * @author zhongrj
 */
public interface LiveLocationService extends IService<LiveLocation> {
    /**
     * 实时位置详情
     * @param liveLocation 实时位置信息对象
     * @return
     */
    LiveLocationVo selectLiveLocationInfo(LiveLocation liveLocation);
    /**
     * 实时位置分页信息
     * @param page
     * @param liveLocation 实时位置信息对象
     * @return
     */
    IPage<LiveLocationVo> selectLiveLocationPage(IPage<LiveLocationVo> page, LiveLocationVo liveLocation);
    /**
     * 获取轨迹数据
     * @param liveLocationVo 实时对象信息
     * @return
     */
    List<LocusVo> getLocusInfoList(LiveLocationVo liveLocationVo);
    /**
     * 首页实时定位
     * @return
     */
    List<LiveLocationVo> getLiveLocationVoList(LiveLocationVo liveLocationVo);
    /**
     * 获取实时位置信息
     * @param liveLocation
     * @return
     */
    LiveLocation getLiveLocationInfo(LiveLocation liveLocation);
}
src/main/java/org/springblade/modules/location/service/LocusService.java
New file
@@ -0,0 +1,24 @@
package org.springblade.modules.location.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.location.entity.Locus;
import org.springblade.modules.location.vo.LocusVo;
public interface LocusService extends IService<Locus> {
    /**
     * 详情
     * @param locus 轨迹信息对象
     * @return
     */
    LocusVo selectLocusInfo(Locus locus);
    /**
     * 分页
     * @param page
     * @param locus
     * @return
     */
    IPage<LocusVo> selectLocusPage(IPage<LocusVo> page, LocusVo locus);
}
src/main/java/org/springblade/modules/location/service/impl/LiveLocationServiceImpl.java
New file
@@ -0,0 +1,84 @@
package org.springblade.modules.location.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.location.entity.LiveLocation;
import org.springblade.modules.location.mapper.LiveLocationMapper;
import org.springblade.modules.location.service.LiveLocationService;
import org.springblade.modules.location.vo.LiveLocationVo;
import org.springblade.modules.location.vo.LocusVo;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 实时位置服务实现类
 * @author zhongrj
 */
@Service
public class LiveLocationServiceImpl extends ServiceImpl<LiveLocationMapper, LiveLocation> implements LiveLocationService {
    /**
     * 实时位置分页信息
     * @param page
     * @param liveLocation 实时位置信息对象
     * @return
     */
    @Override
    public IPage<LiveLocationVo> selectLiveLocationPage(IPage<LiveLocationVo> page, LiveLocationVo liveLocation) {
        return page.setRecords(baseMapper.selectLiveLocationPage(page, liveLocation));
    }
    /**
     * 详情
     * @param liveLocation 实时位置信息对象
     */
    @Override
    public LiveLocationVo selectLiveLocationInfo(LiveLocation liveLocation) {
        return baseMapper.selectLiveLocationInfo(liveLocation);
    }
    /**
     * 获取轨迹数据
     * @param liveLocationVo 实时对象信息
     * @return
     */
    @Override
    public List<LocusVo> getLocusInfoList(LiveLocationVo liveLocationVo) {
        return baseMapper.getLocusInfoList(liveLocationVo);
    }
    /**
     * 首页实时定位
     * @return
     */
    @Override
    public List<LiveLocationVo> getLiveLocationVoList(LiveLocationVo liveLocationVo) {
        //保安人员
        if (liveLocationVo.getType()==1){
            return baseMapper.getSecurityLocusInfoList(liveLocationVo);
        }
        //车辆
        if (liveLocationVo.getType()==2){
            return baseMapper.getCarLocusInfoList(liveLocationVo);
        }
        //枪支
        if (liveLocationVo.getType()==3){
            return baseMapper.getGunLocusInfoList(liveLocationVo);
        }
        return baseMapper.selectSecurityAndCarAndGunLiveLocationPage(liveLocationVo);
    }
    /**
     * 获取实时位置信息
     * @param liveLocation
     * @return
     */
    @Override
    public LiveLocation getLiveLocationInfo(LiveLocation liveLocation) {
        return baseMapper.getLiveLocationInfo(liveLocation);
    }
}
src/main/java/org/springblade/modules/location/service/impl/LocusServiceImpl.java
New file
@@ -0,0 +1,39 @@
package org.springblade.modules.location.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.location.entity.Locus;
import org.springblade.modules.location.mapper.LocusMapper;
import org.springblade.modules.location.service.LocusService;
import org.springblade.modules.location.vo.LocusVo;
import org.springframework.stereotype.Service;
/**
 * 轨迹服务实现类
 * @author zhongrj
 */
@Service
public class LocusServiceImpl extends ServiceImpl<LocusMapper, Locus> implements LocusService {
    /**
     * 轨迹列表信息
     * @param page
     * @param rquipage
     * @return
     */
    @Override
    public IPage<LocusVo> selectLocusPage(IPage<LocusVo> page, LocusVo rquipage) {
        return page.setRecords(baseMapper.selectLocusPage(page, rquipage));
    }
    /**
     * 详情
     * @param rquipage 轨迹信息对象
     */
    @Override
    public LocusVo selectLocusInfo(Locus rquipage) {
        return baseMapper.selectLocusInfo(rquipage);
    }
}
src/main/java/org/springblade/modules/location/vo/LiveLocationVo.java
New file
@@ -0,0 +1,57 @@
package org.springblade.modules.location.vo;
import lombok.Data;
import org.springblade.modules.location.entity.LiveLocation;
import java.io.Serializable;
/**
 * @author zhongrj
 * @since 2021-07-21
 */
@Data
public class LiveLocationVo extends LiveLocation implements Serializable {
    /**
     * 开始时间
     */
    private String startTime;
    /**
     * 结束时间
     */
    private String endTime;
    /**
     * 保安人员姓名
     */
    private String name;
    /**
     * 枪的型号
     */
    private String number;
    /**
     * 联系人
     */
    private String linkman;
    /**
     * 公司名称
     */
    private String company;
    /**
     * 联系电话
     */
    private String tel;
    /**
     * 车牌号
     */
    private String carNum;
}
src/main/java/org/springblade/modules/location/vo/LocusVo.java
New file
@@ -0,0 +1,16 @@
package org.springblade.modules.location.vo;
import lombok.Data;
import org.springblade.modules.location.entity.Locus;
import java.io.Serializable;
/**
 * @author zhongrj
 */
@Data
public class LocusVo extends Locus implements Serializable {
}
src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -33,7 +33,9 @@
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.wrapper.DeptWrapper;
import org.springframework.web.bind.annotation.*;
@@ -59,6 +61,8 @@
public class DeptController extends BladeController {
    private final IDeptService deptService;
    private final IUserService userService;
    /**
     * 详情
@@ -135,6 +139,26 @@
        return R.data(tree);
    }
    /**
     * 懒加载获取部门树形结构(包含用户数据)app
     * @param type 1:保安对保安  2:保安向民警   3:民警向民警
     * @return
     */
    @GetMapping("/lazy-tree-user-app")
    public List<DeptVO> lazyTreeUser(Integer type,String userId) {
        if (null!=userId && userId!=""){
            //查询用户信息
            User user = userService.getById(userId);
            type = 4;
            if (null!=user.getJurisdiction() && user.getJurisdiction()!="") {
                return deptService.lazyTreeUserApp(type, user.getJurisdiction());
            }
            return deptService.lazyTreeUserApp(type,null);
        }
        return deptService.lazyTreeUserApp(type,null);
    }
    /**
     * 懒加载获取部门树形结构,不包含顶级管理员公安局
     */
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -124,8 +124,8 @@
    @ApiOperation(value = "列表", notes = "传入account和realName")
    //@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
    public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) {
        IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, "000000");
        return R.data(UserWrapper.build().pageVO(pages));
        IPage<UserVO> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, "000000");
        return R.data(pages);
    }
    /**
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -100,4 +100,12 @@
     * 懒加载获取部门树形结构(按分类查询)
     */
    List<DeptVO> lazyTreeType(String tenantId, String deptCategory, Long parentId);
    /**
     * 懒加载获取部门树形结构(包含用户数据)app
     * @param type 1:保安对保安  2:保安向民警   3:民警向民警
     * @return
     */
    @SqlParser(filter=true)
    List<DeptVO> lazyTreeUserApp(@Param("type")Integer type,@Param("jurisdiction")String jurisdiction);
}
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -157,6 +157,75 @@
        ORDER BY dept.sort
    </select>
    <!--懒加载获取部门树形结构(包含用户数据)app-->
    <select id="lazyTreeUserApp" resultType="org.springblade.modules.system.vo.DeptAndUserVO" >
        select DISTINCT  * from (
        (SELECT
        dept.id,
        dept.parent_id,
        dept.dept_name AS label,
        dept.id AS "key",
        dept.id AS "value",
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        blade_dept
        WHERE
        parent_id = dept.id and dept.is_deleted = 0
        ) AS "has_children"
        FROM
        blade_dept dept
        left join
        blade_user bu
        on
        bu.dept_id = dept.id
        WHERE
        dept.is_deleted = 0
        <if test="type==1">
            and dept_category=1
            AND dept.parent_id = "1413470343230877697"
        </if>
        <if test="type==2 or type==3">
            and dept_category=2
            AND dept.parent_id = "1123598813738675201"
        </if>
        <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
            and dept_category=1
            AND dept.parent_id = "1413470343230877697"
            and bu.jurisdiction = #{jurisdiction}
        </if>
        )
        union all
        (select
        bu.id,
        bu.dept_id  parent_id,
        bu.real_name AS label,
        bu.id AS "key",
        bu.id AS "value",
        0 as "has_children"
        from blade_user bu
        left join
        blade_dept bd
        on
        bd.id = bu.dept_id
        where 1=1
        <if test="type==1">
            and dept_category=1
        </if>
        <if test="type==2 or type==3">
            and dept_category=2
        </if>
        <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
            and dept_category=1
            and bu.jurisdiction = #{jurisdiction}
        </if>
        )
        )c
    </select>
    <!--懒加载获取部门树形结构(包含用户数据)-->
    <select id="lazyTreeUser" resultMap="treeNodeResultMap" >
        select DISTINCT  * from (
src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -22,6 +22,7 @@
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.system.excel.UserExcel;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.vo.UserVO;
import java.util.List;
@@ -41,7 +42,7 @@
     * @param tenantId
     * @return
     */
    List<User> selectUserPage(IPage<User> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId);
    List<UserVO> selectUserPage(IPage<UserVO> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId);
    /**
     * 获取用户
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.springblade.modules.system.mapper.UserMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="userResultMap" type="org.springblade.modules.system.entity.User">
    <resultMap id="userResultMap" type="org.springblade.modules.system.vo.UserVO">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="create_user" property="createUser"/>
@@ -43,12 +43,19 @@
    </resultMap>
    <select id="selectUserPage" resultMap="userResultMap">
        select bu.* from
        select
            bu.*,
            sll.longitude,sll.latitude
        from
            blade_user bu
        left join
            blade_dept bd
        on
            bu.dept_id = bd.id
        left join
            sys_live_location sll
        on
            sll.worker_id = bu.id
        where
            bu.is_deleted = 0
        <if test="tenantId!=null and tenantId != ''">
src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -143,4 +143,11 @@
     * 懒加载获取部门树形结构(按分类查询)
     */
    List<DeptVO> lazyTreeType(String deptCategory, Long parentId);
    /**
     * 懒加载获取部门树形结构(包含用户数据)app
     * @param type 1:保安对保安  2:保安向民警   3:民警向民警
     * @return
     */
    List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction);
}
src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -71,7 +71,7 @@
     * @param tenantId
     * @return
     */
    IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId);
    IPage<UserVO> selectUserPage(IPage<UserVO> page, User user, Long deptId, String tenantId);
    /**
     * 自定义分页
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -224,4 +224,15 @@
    public List<DeptVO> lazyTreeType(String deptCategory, Long parentId) {
        return ForestNodeMerger.merge(baseMapper.lazyTreeType("000000",deptCategory,parentId));
    }
    /**
     * 懒加载获取部门树形结构(包含用户数据)app
     * @param type 1:保安对保安  2:保安向民警   3:民警向民警
     * @param jurisdiction 辖区id
     * @return
     */
    @Override
    public List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction) {
        return ForestNodeMerger.merge(baseMapper.lazyTreeUserApp(type,jurisdiction));
    }
}
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -140,7 +140,7 @@
    }
    @Override
    public IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId) {
    public IPage<UserVO> selectUserPage(IPage<UserVO> page, User user, Long deptId, String tenantId) {
        List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
        return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId));
    }
src/main/java/org/springblade/modules/system/vo/DeptAndUserVO.java
New file
@@ -0,0 +1,23 @@
package org.springblade.modules.system.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.node.BaseNode;
/**
 * @author zhongrj
 */
@Data
public class DeptAndUserVO extends BaseNode<DeptAndUserVO> {
    private static final long serialVersionUID = 1L;
    private String label;
    @JsonSerialize(
        using = ToStringSerializer.class
    )
    private Long key;
    @JsonSerialize(
        using = ToStringSerializer.class
    )
    private Long value;
}
src/main/java/org/springblade/modules/system/vo/UserVO.java
@@ -81,4 +81,14 @@
     * 拓展信息
     */
    private String userExt;
    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
}
src/main/resources/application.yml
@@ -209,6 +209,8 @@
      - /trainExam/**
      - /blade-desk/**
      - /directive/**
      - /blade-system/**
      - /blade-resource/**
    #授权认证配置
    auth:
      - method: ALL