/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.modules.trar.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import lombok.AllArgsConstructor;
|
import org.springblade.core.boot.ctrl.BladeController;
|
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.trar.entity.Trar;
|
import org.springblade.modules.trar.service.ITrarService;
|
import org.springblade.modules.trar.vo.TrarVO;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 控制器
|
* 人员轨迹记录
|
*
|
* @author BladeX
|
* @since 2022-01-06
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/trar")
|
@Api(value = "", tags = "接口")
|
public class TrarController extends BladeController {
|
|
private final ITrarService trarService;
|
|
/**
|
* 详情
|
*/
|
@GetMapping("/detail")
|
@ApiOperationSupport(order = 1)
|
@ApiOperation(value = "详情", notes = "传入trar")
|
public R<Trar> detail(Trar trar) {
|
Trar detail = trarService.getOne(Condition.getQueryWrapper(trar));
|
return R.data(detail);
|
}
|
|
/**
|
* 分页
|
*/
|
@GetMapping("/list")
|
@ApiOperationSupport(order = 2)
|
@ApiOperation(value = "分页", notes = "传入trar")
|
public R<IPage<Trar>> list(Trar trar, Query query) {
|
IPage<Trar> pages = trarService.page(Condition.getPage(query), Condition.getQueryWrapper(trar));
|
return R.data(pages);
|
}
|
|
/**
|
* 自定义分页
|
*/
|
@GetMapping("/page")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入trar")
|
public R<IPage<TrarVO>> page(TrarVO trar, Query query) {
|
IPage<TrarVO> pages = trarService.selectTrarPage(Condition.getPage(query), trar);
|
return R.data(pages);
|
}
|
|
/**
|
* 新增
|
*/
|
@PostMapping("/save")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "新增", notes = "传入trar")
|
public R save(@Valid @RequestBody Trar trar) {
|
return R.status(trarService.save(trar));
|
}
|
|
/**
|
* 修改
|
*/
|
@PostMapping("/update")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入trar")
|
public R update(@Valid @RequestBody Trar trar) {
|
return R.status(trarService.updateById(trar));
|
}
|
|
/**
|
* 新增或修改
|
*/
|
@PostMapping("/submit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "传入trar")
|
public R submit(@Valid @RequestBody Trar trar) {
|
trar.setStarttime(new Date());
|
return R.status(trarService.saveOrUpdate(trar));
|
}
|
|
|
/**
|
* 删除
|
*/
|
@PostMapping("/remove")
|
@ApiOperationSupport(order = 8)
|
@ApiOperation(value = "删除", notes = "传入ids")
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
return R.status(trarService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 轨迹路线查询
|
*
|
* @param rid
|
* @param uid
|
* @return
|
*/
|
@PostMapping("/selectList")
|
public R selectList(String rid, String uid) {
|
return R.data(trarService.selectList(rid, uid));
|
}
|
|
/**
|
* 轨迹路线查询
|
*
|
* @param rid
|
* @param uid
|
* @return
|
*/
|
@GetMapping("/selectLists")
|
public String selectLists(String rid, String uid, HttpServletResponse response) {
|
//设置响应头
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
String begin="LINESTRING(";
|
String end=")";
|
String url ="";
|
List<Trar> list = trarService.selectList(rid, uid);
|
for (int i=0;i<list.size();i++){
|
String jd = list.get(i).getJd();
|
String wd = list.get(i).getWd();
|
url+=jd+" "+wd+",";
|
}
|
|
String s = "";
|
if (url.length() > 0){
|
String substring = url.substring(0, url.length() - 1);
|
s = begin + substring + end;
|
}
|
System.out.println(s);
|
return s;
|
}
|
|
|
}
|