| | |
| | | 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 |
| | |
| | | public class GunController { |
| | | |
| | | private final GunService gunService; |
| | | |
| | | |
| | | private final LiveLocationService liveLocationService; |
| | | |
| | | private final LocusService locusService; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |