| | |
| | | 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.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.springblade.modules.location.vo.LiveLocationVOTest; |
| | | import org.springblade.modules.location.vo.LiveLocationVo; |
| | | import org.springblade.modules.location.vo.LocusVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | //新增 |
| | | liveLocation.setRecordTime(new Date()); |
| | | status = liveLocationService.save(liveLocation); |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time,location) " + |
| | | "values(" + "'" + liveLocation.getId() + "'" + "," + |
| | | "'" + liveLocation.getType() + "'" + "," + |
| | | "'" + liveLocation.getWorkerId() + "'" + "," + |
| | | "'" + liveLocation.getLongitude() + "'" + "," + |
| | | "'" + liveLocation.getLatitude() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + "," + |
| | | "'" +liveLocation.getLocation() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | //更新 |
| | | liveLocationInfo.setRecordTime(new Date()); |
| | | liveLocationInfo.setLongitude(liveLocation.getLongitude()); |
| | | liveLocationInfo.setLatitude(liveLocation.getLatitude()); |
| | | status = liveLocationService.updateById(liveLocationInfo); |
| | | |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_live_location set type = " + "'" + liveLocation.getType() + "'" + |
| | | ",worker_id = " + "'" + liveLocation.getWorkerId() + "'" + |
| | | ",longitude = " + "'" + liveLocation.getLongitude() + "'" + |
| | | ",latitude = " + "'" + liveLocation.getLatitude() + "'" + |
| | | ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + |
| | | ",location = " + "'" + liveLocation.getLocation() + "'" + |
| | | " " +"where id = " + "'" + liveLocation.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | |
| | | if (status){ |
| | |
| | | locus.setRecordTime(new Date()); |
| | | //新增轨迹 |
| | | boolean save1 = locusService.save(locus); |
| | | //数据推送 |
| | | String s2 = |
| | | "insert into sys_locus(id,live_location_id,record_time,longitude,latitude) " + |
| | | "values(" + "'" + locus.getId() + "'" + "," + |
| | | "'" + locus.getLiveLocationId() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + "," + |
| | | "'" + locus.getLongitude() + "'" + "," + |
| | | "'" +locus.getLatitude() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | |
| | | if (save1){ |
| | | //返回数据 |
| | | return R.status(true); |
| | | } |
| | | } |
| | | //返回数据 |
| | | return R.status(false); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 实时位置信息新增,同时新增到轨迹表中 |
| | | * @param locationVOTest 实时位置信息对象 |
| | | */ |
| | | @PostMapping("/saveLiveLocationAndLocusAsTest") |
| | | @ApiOperation(value = "新增", notes = "传入liveLocation") |
| | | public R saveLiveLocationAndLocusAsTest(@RequestBody LiveLocationVOTest locationVOTest) { |
| | | //获取数据 |
| | | LiveLocation liveLocation = new LiveLocation(); |
| | | liveLocation.setLongitude(locationVOTest.getLongitude().toString()); |
| | | liveLocation.setLatitude(locationVOTest.getLatitude().toString()); |
| | | liveLocation.setType(2); |
| | | liveLocation.setWorkerId(16L); |
| | | |
| | | //先查询是否已有实时位置信息,如果有,则更新,没有则插入 |
| | | LiveLocation liveLocationInfo = liveLocationService.getLiveLocationInfo(liveLocation); |
| | | boolean status = false; |
| | | if (null == liveLocationInfo){ |
| | | //新增 |
| | | liveLocation.setRecordTime(new Date()); |
| | | status = liveLocationService.save(liveLocation); |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time,location) " + |
| | | "values(" + "'" + liveLocation.getId() + "'" + "," + |
| | | "'" + liveLocation.getType() + "'" + "," + |
| | | "'" + liveLocation.getWorkerId() + "'" + "," + |
| | | "'" + liveLocation.getLongitude() + "'" + "," + |
| | | "'" + liveLocation.getLatitude() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + "," + |
| | | "'" +liveLocation.getLocation() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | //更新 |
| | | liveLocationInfo.setRecordTime(new Date()); |
| | | liveLocationInfo.setLongitude(liveLocation.getLongitude()); |
| | | liveLocationInfo.setLatitude(liveLocation.getLatitude()); |
| | | status = liveLocationService.updateById(liveLocationInfo); |
| | | |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_live_location set type = " + "'" + liveLocation.getType() + "'" + |
| | | ",worker_id = " + "'" + liveLocation.getWorkerId() + "'" + |
| | | ",longitude = " + "'" + liveLocation.getLongitude() + "'" + |
| | | ",latitude = " + "'" + liveLocation.getLatitude() + "'" + |
| | | ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + |
| | | ",location = " + "'" + liveLocation.getLocation() + "'" + |
| | | " " +"where id = " + "'" + liveLocation.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | |
| | | if (status){ |
| | | //新增轨迹 |
| | | Locus locus = new Locus(); |
| | | //封装数据 |
| | | if (null!=liveLocationInfo){ |
| | | locus.setLiveLocationId(liveLocationInfo.getId()); |
| | | }else { |
| | | locus.setLiveLocationId(liveLocation.getId()); |
| | | } |
| | | if (null!= liveLocation.getLatitude() && null!=liveLocation.getLongitude()){ |
| | | locus.setLatitude(liveLocation.getLatitude()); |
| | | locus.setLongitude(liveLocation.getLongitude()); |
| | | } |
| | | locus.setRecordTime(new Date()); |
| | | //新增轨迹 |
| | | boolean save1 = locusService.save(locus); |
| | | //数据推送 |
| | | String s2 = |
| | | "insert into sys_locus(id,live_location_id,record_time,longitude,latitude) " + |
| | | "values(" + "'" + locus.getId() + "'" + "," + |
| | | "'" + locus.getLiveLocationId() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + "," + |
| | | "'" + locus.getLongitude() + "'" + "," + |
| | | "'" +locus.getLatitude() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | |
| | | if (save1){ |
| | | //返回数据 |
| | | return R.status(true); |