From ef33401f486d455a15059f2c89431df7021db0c6 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 30 Nov 2021 19:42:47 +0800
Subject: [PATCH] 枪支数据导入接口新增
---
src/main/java/org/springblade/modules/equipage/controller/GunController.java | 82 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/equipage/controller/GunController.java b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
index 6ee647d..0ce8988 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/GunController.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
@@ -8,10 +8,20 @@
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.FTP.FtpUtil;
import org.springblade.modules.equipage.entity.Gun;
import org.springblade.modules.equipage.service.GunService;
import org.springblade.modules.equipage.vo.GunVo;
+import org.springblade.modules.equipage.vo.LiveLocationVOTest;
+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.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
/**
* @author zhongrj
@@ -24,6 +34,11 @@
public class GunController {
private final GunService gunService;
+
+
+ private final LiveLocationService liveLocationService;
+
+ private final LocusService locusService;
/**
* 自定义分页
@@ -84,4 +99,71 @@
return R.data(detail);
}
+ /**
+ * 实时位置信息新增,同时新增到轨迹表中
+ * @param locationVOTest 实时位置信息对象
+ */
+ @PostMapping("/saveLiveLocationAndLocusAsTest")
+ @ApiOperation(value = "新增", notes = "传入liveLocation")
+ public R saveLiveLocationAndLocusAsTest(@RequestBody List<LiveLocationVOTest> locationVOTest) {
+ locationVOTest.forEach(liveLocationVOTest -> {
+ //查询是否已有枪支数据
+ Gun gun1 = new Gun();
+ gun1.setCardNumber(liveLocationVOTest.getQzbh());
+ Gun one = gunService.getOne(Condition.getQueryWrapper(gun1));
+ //如果不存在,则新增,已存在则不新增
+ if (null==one) {
+ //插入枪支数据
+ Gun gun = new Gun();
+ gun.setCardNumber(liveLocationVOTest.getQzbh());
+ gun.setGunMode(liveLocationVOTest.getQzxh());
+ gun.setPersonInCharge(liveLocationVOTest.getHwy());
+ gunService.save(gun);
+
+ //插入定位数据
+ LiveLocation liveLocation = new LiveLocation();
+ liveLocation.setWorkerId(gun.getId());
+ liveLocation.setType(3);
+ liveLocation.setLongitude(liveLocationVOTest.getDwjd().toString());
+ liveLocation.setLatitude(liveLocationVOTest.getDwwd().toString());
+ liveLocation.setRecordTime(liveLocationVOTest.getDwsj());
+// liveLocation.setLocation(liveLocationVOTest.getQzbh());
+ liveLocationService.save(liveLocation);
+
+ //插入轨迹数据
+ Locus locus = new Locus();
+ locus.setLiveLocationId(liveLocation.getId());
+ locus.setRecordTime(liveLocationVOTest.getDwsj());
+ locus.setLongitude(liveLocationVOTest.getDwjd().toString());
+ locus.setLatitude(liveLocationVOTest.getDwwd().toString());
+ locusService.save(locus);
+
+ }else {
+ //查询定位信息
+ LiveLocation liveLocation = new LiveLocation();
+ liveLocation.setWorkerId(one.getId());
+ liveLocation.setType(3);
+ LiveLocation one1 = liveLocationService.getOne(Condition.getQueryWrapper(liveLocation));
+
+ one1.setRecordTime(liveLocationVOTest.getDwsj());
+ one1.setLongitude(liveLocationVOTest.getDwjd().toString());
+ one1.setLatitude(liveLocationVOTest.getDwwd().toString());
+ //更新
+ liveLocationService.updateById(one1);
+
+ //新增轨迹记录
+ //插入轨迹数据
+ Locus locus = new Locus();
+ locus.setLiveLocationId(one1.getId());
+ locus.setRecordTime(liveLocationVOTest.getDwsj());
+ locus.setLongitude(liveLocationVOTest.getDwjd().toString());
+ locus.setLatitude(liveLocationVOTest.getDwwd().toString());
+ locusService.save(locus);
+ }
+ });
+
+ //返回数据
+ return R.status(false);
+ }
+
}
--
Gitblit v1.9.3