2025-09-05 17:43:45 +08:00
|
|
|
|
package com.mosty.yjzl.controller;
|
|
|
|
|
|
|
2025-09-08 20:00:30 +08:00
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
2026-03-25 13:26:24 +08:00
|
|
|
|
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwSaveDTO;
|
2025-09-05 17:43:45 +08:00
|
|
|
|
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
|
2025-09-08 20:00:30 +08:00
|
|
|
|
import com.mosty.base.model.query.yjzl.TbZdxlFgdwQuery;
|
2025-09-05 17:43:45 +08:00
|
|
|
|
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
|
|
|
|
|
|
import com.mosty.base.utils.MessageUtils;
|
|
|
|
|
|
import com.mosty.base.utils.spring.SpringValidUtils;
|
|
|
|
|
|
import com.mosty.common.base.domain.ResponseResult;
|
|
|
|
|
|
import com.mosty.common.base.entity.log.BusinessType;
|
|
|
|
|
|
import com.mosty.common.base.entity.log.Log;
|
|
|
|
|
|
import com.mosty.common.base.util.StringUtils;
|
|
|
|
|
|
import com.mosty.common.token.JwtSysUser;
|
|
|
|
|
|
import com.mosty.yjzl.service.TbZdxlFgdwService;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
2026-03-25 13:26:24 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2025-09-05 17:43:45 +08:00
|
|
|
|
import java.util.List;
|
2026-03-25 13:26:24 +08:00
|
|
|
|
import java.util.Map;
|
2025-09-05 17:43:45 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author zhangzhao
|
|
|
|
|
|
* @description 指导巡逻方格点位接口
|
|
|
|
|
|
* @modifier zhangzhao
|
|
|
|
|
|
* @modifiedTime 2025/05/15 21:53
|
|
|
|
|
|
* @since 2025/05/15 21:53
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Api(tags = {"指导巡逻-方格点位接口"})
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
|
@RequestMapping("/tbZdxlFgdw")
|
|
|
|
|
|
public class TbZdxlFgdwController {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 指导巡逻方格点位表Service
|
|
|
|
|
|
*/
|
|
|
|
|
|
private final TbZdxlFgdwService tbZdxlFgdwService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询单条(根据主键ID)
|
|
|
|
|
|
* @param id 主键ID
|
|
|
|
|
|
* @return ResponseResult 实体信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "查询单条(根据主键ID)")
|
|
|
|
|
|
@GetMapping("{id}")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-查询单条(根据主键ID)", businessType = BusinessType.OTHER)
|
2025-09-08 20:00:30 +08:00
|
|
|
|
public ResponseResult<TbZdxlFgdwVO> selectById(@PathVariable("id") Long id) {
|
2025-09-05 17:43:45 +08:00
|
|
|
|
return ResponseResult.success(tbZdxlFgdwService.selectById(id));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询全量列表
|
|
|
|
|
|
* @return ResponseResult 实体信息列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "查询全量列表")
|
|
|
|
|
|
@GetMapping("/selectAllList")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-查询全量列表", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public ResponseResult<List<TbZdxlFgdwVO>> selectAllList() {
|
|
|
|
|
|
return ResponseResult.success(tbZdxlFgdwService.selectAllList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-08 20:00:30 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询分页
|
|
|
|
|
|
* @param query 实体查询对象
|
|
|
|
|
|
* @return ResponseResult 实体信息分页列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "查询分页")
|
|
|
|
|
|
@GetMapping("/selectPage")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-查询分页", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public ResponseResult<IPage<TbZdxlFgdwVO>> selectPage(TbZdxlFgdwQuery query) {
|
|
|
|
|
|
return ResponseResult.success(tbZdxlFgdwService.selectPage(query));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询列表
|
|
|
|
|
|
* @param query 实体查询对象
|
|
|
|
|
|
* @return ResponseResult 实体信息列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "查询列表")
|
|
|
|
|
|
@GetMapping("/selectList")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-查询列表", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public ResponseResult<List<TbZdxlFgdwVO>> selectList(TbZdxlFgdwQuery query) {
|
|
|
|
|
|
return ResponseResult.success(tbZdxlFgdwService.selectList(query));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-25 13:26:24 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 新增单条
|
|
|
|
|
|
* @param dto 保存DTO对象
|
|
|
|
|
|
* @param bindResult 校验对象
|
|
|
|
|
|
* @return ResponseResult 实体主键ID
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "新增单条")
|
|
|
|
|
|
@PostMapping("/save")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-新增单条", businessType = BusinessType.INSERT)
|
|
|
|
|
|
public ResponseResult<Long> save(@RequestBody @Valid TbZdxlFgdwSaveDTO dto, BindingResult bindResult){
|
|
|
|
|
|
try {
|
|
|
|
|
|
//基础信息校验
|
|
|
|
|
|
String message = SpringValidUtils.getErrorsMsg(bindResult);
|
|
|
|
|
|
if (StringUtils.isNotBlank(message)) {
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//新增
|
|
|
|
|
|
Long resultId = tbZdxlFgdwService.saveEntity(dto);
|
|
|
|
|
|
if(ObjectUtils.isNotEmpty(resultId)){
|
|
|
|
|
|
return ResponseResult.success(resultId);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getSaveFailMsg());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getSaveServerErrorMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-05 17:43:45 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 修改单条
|
|
|
|
|
|
* @param dto 修改DTO对象
|
|
|
|
|
|
* @param bindResult 校验对象
|
|
|
|
|
|
* @return ResponseResult 实体主键ID
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "修改单条")
|
|
|
|
|
|
@PostMapping("update")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-修改单条", businessType = BusinessType.UPDATE)
|
2025-09-08 20:00:30 +08:00
|
|
|
|
public ResponseResult<Long> update(@RequestBody @Valid TbZdxlFgdwUpdateDTO dto, BindingResult bindResult){
|
2025-09-05 17:43:45 +08:00
|
|
|
|
try {
|
|
|
|
|
|
//基础信息校验
|
|
|
|
|
|
String message = SpringValidUtils.getErrorsMsg(bindResult);
|
|
|
|
|
|
if (StringUtils.isNotBlank(message)) {
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//修改
|
2025-09-08 20:00:30 +08:00
|
|
|
|
Long resultId = tbZdxlFgdwService.updateEntity(dto);
|
2025-09-05 17:43:45 +08:00
|
|
|
|
if(ObjectUtils.isNotEmpty(resultId)){
|
|
|
|
|
|
return ResponseResult.success(resultId);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getEditFailMsg());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
return ResponseResult.fail(MessageUtils.getEditServerErrorMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-25 13:26:24 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据经纬度获取正方形四个点位
|
|
|
|
|
|
* @param longitude 经度
|
|
|
|
|
|
* @param latitude 纬度
|
|
|
|
|
|
* @param distance 范围(米),半径
|
|
|
|
|
|
* @return ResponseResult 正方形四个角点坐标
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "根据经纬度获取正方形四个点位")
|
|
|
|
|
|
@GetMapping("/getSquarePoints")
|
|
|
|
|
|
@JwtSysUser
|
|
|
|
|
|
@Log(title = "指导巡逻-方格点位接口-获取正方形点位", businessType = BusinessType.OTHER)
|
|
|
|
|
|
public ResponseResult<Map<String, BigDecimal>> getSquarePoints(
|
|
|
|
|
|
@RequestParam("longitude") Double longitude,
|
|
|
|
|
|
@RequestParam("latitude") Double latitude,
|
|
|
|
|
|
@RequestParam(value = "distance", defaultValue = "500") Double distance) {
|
|
|
|
|
|
return ResponseResult.success(tbZdxlFgdwService.getSquarePoints(longitude, latitude, distance));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-05 17:43:45 +08:00
|
|
|
|
}
|