提交地图与部门关联配置表接口
This commit is contained in:
@@ -81,6 +81,12 @@ public enum CommonResponseEnum {
|
||||
DELETE_PID_UNEXIST("A0095", "不存在子节点"),
|
||||
|
||||
FILE_EXIST("A0096", "文件已存在"),
|
||||
|
||||
DEPT_EXIST("A0097", "部门id已存在"),
|
||||
|
||||
DEPT_NOT_EXIST("A0098", "部门id不存在"),
|
||||
|
||||
DEPT_BINDED("A0099", "部门id已绑定"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 11:41
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_dept_map")
|
||||
public class DeptMap extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键Id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 中心点经度
|
||||
*/
|
||||
private Double longitude;
|
||||
/**
|
||||
* 中心点纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
private Integer maxValue;
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
private Integer minValue;
|
||||
/**
|
||||
* 当前值
|
||||
*/
|
||||
private Integer beValue;
|
||||
/**
|
||||
* 部门Id
|
||||
*/
|
||||
private String deptId;
|
||||
/**
|
||||
* 地图状态:0-离线 1-在线
|
||||
*/
|
||||
private Integer mapType;
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.system.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/05 14:53
|
||||
*/
|
||||
@Data
|
||||
public class Dept {
|
||||
|
||||
/**
|
||||
* 部门Id
|
||||
*/
|
||||
private String deptId;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.system.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 11:09
|
||||
*/
|
||||
@Data
|
||||
public class DeptConfigVO implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty("主键Id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 中心点经度
|
||||
*/
|
||||
@ApiModelProperty("中心点经度")
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 中心点纬度
|
||||
*/
|
||||
@ApiModelProperty("中心点纬度")
|
||||
private Double latitude;
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
@ApiModelProperty("最大值")
|
||||
private Integer maxValue;
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
@ApiModelProperty("最小值")
|
||||
private Integer minValue;
|
||||
|
||||
/**
|
||||
* 当前值
|
||||
*/
|
||||
@ApiModelProperty("当前值")
|
||||
private Integer beValue;
|
||||
|
||||
/**
|
||||
* 地图状态:0-离线 1-在线
|
||||
*/
|
||||
@ApiModelProperty("地图状态:0-离线 1-在线")
|
||||
private Integer mapType;
|
||||
|
||||
/**
|
||||
* 部门Id
|
||||
*/
|
||||
@ApiModelProperty("部门Id")
|
||||
private String deptId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@ApiModelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.system.pojo.vo.DeptConfigVO;
|
||||
import com.njcn.system.service.DeptMapService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 10:01
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/deptMap")
|
||||
@Api(tags = "部门与地图关联配置")
|
||||
@AllArgsConstructor
|
||||
public class DeptMapController extends BaseController {
|
||||
|
||||
private final DeptMapService deptMapService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getDeptMapConfig")
|
||||
@ApiOperation("查询地图与部门关联配置列表")
|
||||
public HttpResult<List<DeptConfigVO>> getDeptMapConfig() {
|
||||
String methodDescribe = getMethodDescribe("getDeptMapConfig");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||
List<DeptConfigVO> result = deptMapService.getDeptMapConfig();
|
||||
if (Objects.isNull(result)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getDeptMapConfigById")
|
||||
@ApiOperation("根据id查询地图与部门关联配置")
|
||||
@ApiImplicitParam(name = "id", value = "参数id", required = true)
|
||||
public HttpResult<DeptConfigVO> getDeptMapConfigById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getDeptMapConfigById");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||
DeptConfigVO result = deptMapService.getDeptMapConfigById(id);
|
||||
if (Objects.isNull(result)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getConfigByDeptId")
|
||||
@ApiOperation("根据部门id查询地图关联配置")
|
||||
@ApiImplicitParam(name = "deptId", value = "部门id", required = true)
|
||||
public HttpResult<DeptConfigVO> getConfigByDeptId(@RequestParam("deptId") String deptId) {
|
||||
String methodDescribe = getMethodDescribe("getConfigByDeptId");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||
DeptConfigVO result = deptMapService.getConfigByDeptId(deptId);
|
||||
if (Objects.isNull(result)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ResponseBody
|
||||
@PostMapping("/addDeptMapConfig")
|
||||
@ApiOperation("新增地图与部门关联配置")
|
||||
public HttpResult addDeptMapConfig(@RequestParam("longitude") Double longitude,
|
||||
@RequestParam("latitude") Double latitude,
|
||||
@RequestParam("maxValue") Integer maxValue,
|
||||
@RequestParam("minValue") Integer minValue,
|
||||
@RequestParam("beValue") Integer beValue,
|
||||
@RequestParam("mapType") Integer mapType,
|
||||
@RequestParam("deptId") String deptId) {
|
||||
String methodDescribe = getMethodDescribe("addDeptMapConfig");
|
||||
boolean res = deptMapService.addDeptMapConfig(longitude, latitude, maxValue, minValue, beValue, mapType, deptId);
|
||||
if (res) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.DeptMap;
|
||||
import com.njcn.system.pojo.vo.Dept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 11:40
|
||||
*/
|
||||
public interface DeptMapMapper extends BaseMapper<DeptMap> {
|
||||
|
||||
/**
|
||||
* 查询部门id是否存在
|
||||
*/
|
||||
int selectCountByDept(String deptId);
|
||||
/**
|
||||
* 查询部门名称
|
||||
*/
|
||||
String selectDeptName(String deptId);
|
||||
/**
|
||||
* 查询部门名称返回集合
|
||||
*/
|
||||
List<Dept> selectDeptListName(@Param("deptIndexes") List<String> deptIndexes);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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.njcn.system.mapper.DeptMapMapper">
|
||||
|
||||
<select id="selectCountByDept" resultType="int">
|
||||
SELECT count(Id) FROM sys_dept WHERE Id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="selectDeptName" resultType="java.lang.String">
|
||||
SELECT Name FROM sys_dept WHERE Id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="selectDeptListName" resultType="Dept">
|
||||
SELECT `Id` deptId, `Name` deptName
|
||||
FROM sys_dept
|
||||
WHERE Id IN
|
||||
<foreach item="item" collection="deptIndexes" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.njcn.system.pojo.vo.DeptConfigVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 10:58
|
||||
*/
|
||||
public interface DeptMapService {
|
||||
|
||||
List<DeptConfigVO> getDeptMapConfig();
|
||||
|
||||
DeptConfigVO getDeptMapConfigById(String id);
|
||||
|
||||
DeptConfigVO getConfigByDeptId(String deptId);
|
||||
|
||||
boolean addDeptMapConfig(Double longitude, Double latitude, Integer maxValue, Integer minValue, Integer beValue, Integer mapType, String deptId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.system.mapper.DeptMapMapper;
|
||||
import com.njcn.system.pojo.po.DeptMap;
|
||||
import com.njcn.system.pojo.vo.Dept;
|
||||
import com.njcn.system.pojo.vo.DeptConfigVO;
|
||||
import com.njcn.system.service.DeptMapService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/08/04 11:38
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DeptMapServiceImpl implements DeptMapService {
|
||||
|
||||
private final DeptMapMapper deptMapMapper;
|
||||
|
||||
@Override
|
||||
public List<DeptConfigVO> getDeptMapConfig() {
|
||||
List<DeptConfigVO> deptConfigVOS = new ArrayList<>();
|
||||
List<DeptMap> deptMaps = deptMapMapper.selectList(new QueryWrapper<DeptMap>().eq("sys_dept_map.State",1));
|
||||
if (!CollectionUtils.isEmpty(deptMaps)) {
|
||||
List<String> deptIndexes = deptMaps.stream().map(DeptMap::getDeptId).collect(Collectors.toList());
|
||||
List<Dept> deptList = deptMapMapper.selectDeptListName(deptIndexes);
|
||||
for (DeptMap dept: deptMaps) {
|
||||
DeptConfigVO configVO = new DeptConfigVO();
|
||||
BeanUtils.copyProperties(dept, configVO);
|
||||
configVO.setDeptName(
|
||||
deptList.stream().filter(item -> item.getDeptId().equals(configVO.getDeptId())).collect(Collectors.toList()).get(0).getDeptName());
|
||||
deptConfigVOS.add(configVO);
|
||||
}
|
||||
return deptConfigVOS;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptConfigVO getDeptMapConfigById(String id) {
|
||||
DeptConfigVO deptConfigVO = new DeptConfigVO();
|
||||
DeptMap deptMap = deptMapMapper.selectById(id);
|
||||
if (!Objects.isNull(deptMap) && deptMap.getState()==1) {
|
||||
BeanUtils.copyProperties(deptMap, deptConfigVO);
|
||||
deptConfigVO.setDeptName(deptMapMapper.selectDeptName(deptMap.getDeptId()));
|
||||
return deptConfigVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptConfigVO getConfigByDeptId(String deptId) {
|
||||
DeptConfigVO deptConfigVO = new DeptConfigVO();
|
||||
DeptMap deptMap = deptMapMapper.selectOne(new QueryWrapper<DeptMap>().eq("sys_dept_map.Dept_Id", deptId));
|
||||
if (!Objects.isNull(deptMap) && deptMap.getState()==1) {
|
||||
BeanUtils.copyProperties(deptMap, deptConfigVO);
|
||||
deptConfigVO.setDeptName(deptMapMapper.selectDeptName(deptMap.getDeptId()));
|
||||
return deptConfigVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDeptMapConfig(Double longitude, Double latitude, Integer maxValue, Integer minValue, Integer beValue, Integer mapType, String deptId) {
|
||||
if (deptMapMapper.selectCountByDept(deptId)==0) {
|
||||
throw new BusinessException(CommonResponseEnum.DEPT_NOT_EXIST);
|
||||
}
|
||||
QueryWrapper<DeptMap> deptMapQueryWrapper = new QueryWrapper<>();
|
||||
deptMapQueryWrapper.eq("sys_dept_map.Dept_Id",deptId);
|
||||
Integer count = deptMapMapper.selectCount(deptMapQueryWrapper);
|
||||
if (count==0) {
|
||||
DeptMap deptMap = new DeptMap();
|
||||
deptMap.setLongitude(longitude);
|
||||
deptMap.setLatitude(latitude);
|
||||
deptMap.setMaxValue(maxValue);
|
||||
deptMap.setMinValue(minValue);
|
||||
deptMap.setBeValue(beValue);
|
||||
deptMap.setMapType(mapType);
|
||||
deptMap.setDeptId(deptId);
|
||||
deptMap.setState(DataStateEnum.ENABLE.getCode());
|
||||
deptMap.setCreateBy(RequestUtil.getUserIndex());
|
||||
deptMap.setCreateTime(LocalDateTime.now());
|
||||
deptMap.setUpdateBy(RequestUtil.getUserIndex());
|
||||
deptMap.setUpdateTime(LocalDateTime.now());
|
||||
deptMapMapper.insert(deptMap);
|
||||
return true;
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.DEPT_BINDED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user