viewLocation.js 9.2 KB
(function(angular) {
	function viewLocationInfo($scope,aiNicheService,param,$uibModal,$uibModalInstance,$sce) {
		$scope.titleStr = "车辆碰撞后,停留时间超过3分钟,建议去电回访";


		var lineData = [{
			label: "bar",
			data: []
		}];
		var lineOptions = {
				series: {
					valueLabels: {
						show: false,
						labelFormatter: function (v) {
							return v;
						}
					},
					lines: {
						show: true,
						lineWidth: 2,
						fill: true,
						fillColor: {
							colors: [{
								opacity: 0.3
							},
							{
								opacity: 0.3
							}
							]
						}
					},
					points: {show: true},
					stack: true
				},
				xaxis: {
					tickDecimals: 0,
					ticks: [],
					minTickSize: 1
				},
				yaxis: {
					min: 0,
					tickDecimals: 0
				},
				colors: ["#009944"],
				grid: {
					color: "#999999",
					hoverable: true,
					clickable: true,
					tickColor: "#D4D4D4",
					borderWidth: 0,
					mouseActiveRadius: 1000,
					autoHighlight: true
				},
				legend: {
					show: false
				}
		};
		$scope.flotLineData = lineData;
		$scope.flotLineOptions = lineOptions;

		$scope.cpInstance = {
				init: function () {

					//轨迹点信息
					var collisionInfo = {};
					aiNicheService.getAddressInfo(param,function(response) {
						// response.data = [{
						// 	ag: 30,
						// 	lnglat: [107.6666, 24.867754],
						// 	name: "55",
						// 	sp: 55,
						// 	time: "11:42:49",
						// 	tm: 1734147769,
						// 	x: 107.6666,
						// 	y: 24.867754
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.667121, 24.868009],
						// 	name: "51",
						// 	sp: 51,
						// 	time: "11:42:53",
						// 	tm: 4,
						// 	x: 107.667121,
						// 	y: 24.868009
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.667329, 24.868241],
						// 	name: "50",
						// 	sp: 50,
						// 	time: "11:42:55",
						// 	tm: 2,
						// 	x: 107.667329,
						// 	y: 24.868241,
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.667385, 24.86836],
						// 	name: "48",
						// 	sp: 48,
						// 	time: "11:42:56",
						// 	tm: 1,
						// 	x: 107.667385,
						// 	y: 24.86836,
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.667417, 24.86847],
						// 	name: "48",
						// 	sp: 48,
						// 	time: "11:42:57",
						// 	tm: 1,
						// 	x: 107.667417,
						// 	y: 24.86847,
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.654336, 24.872392],
						// 	name: "9",
						// 	sp: 9,
						// 	time: "11:45:09",
						// 	tm: 5,
						// 	x: 107.654336,
						// 	y: 24.872392,
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.654352, 24.872496],
						// 	name: "3",
						// 	sp: 3,
						// 	time: "11:46:59",
						// 	tm: 15,
						// 	x: 107.654352,
						// 	y: 24.872496,
						// }, {
						// 	ag: 30,
						// 	lnglat: [107.654352, 24.872496],
						// 	name: "3",
						// 	sp: 3,
						// 	time: "11:48:32",
						// 	tm: 15,
						// 	x: 107.654352,
						// 	y: 24.872496,
						// }]
						if(response.data.length > 0){
							collisionInfo = response.data;
							$scope.cpInstance.collisionPoints(collisionInfo)
						}

						var data = response.data;
						var lineData = [];
						var line_xticks = [];

						angular.forEach(data, function (o, i) {
							lineData.push([i, o.sp]);
							var date = o.time;
							var min = 0;
							var max = data.length-1;
							// 碰撞事件截取11到24位为碰撞点
							var collTime = param.collisionTime.substring(11,24);
							//碰撞点
							if(date == collTime){
								line_xticks.push([i, date+'碰撞点']);
							}
							//起点
							if(i == min){
								line_xticks.push([i, date+'起点']);
							}
							//终点
							if(i == max){
								line_xticks.push([i, date+'终点']);
							}
						});
						$scope.flotLineData[0].data = lineData;
						lineOptions.xaxis.ticks = line_xticks;
					});

					getCollisionPoint();
					// $scope.cpInstance.toggle();

				}
		};

		var getCollisionPoint = function () {
			var lngX,latY,infoSpeed;
			// 本地表
			aiNicheService.getCollisionPoint(param,function(response) {
				// response.data = {
				// 	address: "广西壮族自治区河池市南丹县车河镇长坡山",
				// 	areaName: "河池",
				// 	cityMerchantId: 44190242,
				// 	cityMerchantName: "广西大区-广西片区",
				// 	cityName: "河池",
				// 	collisionCount: null,
				// 	collisionShopCount: null,
				// 	collisionTime: "2024-12-14 11:45:42",
				// 	collisionType: 1,
				// 	createdBy: "5056zs",
				// 	createdDate: "2024-12-14 11:52:39",
				// 	deletedFlag: "N",
				// 	distance: 47.449,
				// 	eTime: null,
				// 	factoryMerchantId: 44189923,
				// 	factoryMerchantName: "广汇汽车",
				// 	followCount: null,
				// 	followId: null,
				// 	followRemarks: null,
				// 	followResult: null,
				// 	followTime: null,
				// 	id: 5246,
				// 	isNew: 1,
				// 	isNotarize: "1",
				// 	isSecondReview: null,
				// 	latitude: "24.869328772695525",
				// 	longitude: "107.65848936775599",
				// 	merchantId: 44190277,
				// 	merchantIds: null,
				// 	merchantName: "河池市弘池汽车销售服务有限公司",
				// 	mobile: "15277869216",
				// 	monthSelectsDate: null,
				// 	name: "罗艳兰",
				// 	notFollowCount: null,
				// 	numberOfShops: 1,
				// 	parentMerchantName: null,
				// 	precentage: null,
				// 	proportionPer: null,
				// 	provinceMerchantId: 44190083,
				// 	provinceMerchantName: "广西大区",
				// 	provinceName: "广西",
				// 	resource: 0,
				// 	sTime: null,
				// 	sap: null,
				// 	searchKey: null,
				// 	searchValue: null,
				// 	shopMerchantId: null,
				// 	shopWarningId: null,
				// 	sn: "1701018887",
				// 	speed: null,
				// 	standNo: "LGBH92E04LY869227",
				// 	status: 1,
				// 	updatedBy: "system",
				// 	updatedDate: "2024-12-14 11:52:39",
				// 	vehicleId: 2484501,
				// }
				$scope.collisionInfos = response.data;
				//$scope.collisionInfos.img=['images/wechatBody.png','images/wechatBottom.png']
				//$scope.collisionInfos.video=['http://data.vod.itc.cn/?new=/91/42/pZqBu6MSS6qxJ83Lg979vf.mp4&vid=103937904&plat=17&mkey=TsizBB_0aNkIwISTmpInX1aO5E_P_xYU&ch=null&user=api&uid=1608272337357415&SOHUSVP=hYUn0xTM-W04JHMScKFwNO7wmpi3zsDXfKNHPSL_udA&pt=1&prod=56&pg=1&eye=0&cv=1.0.0&qd=68000&src=11050001&ca=4&cateCode=133&_c=1&appid=tv'];
				if ($scope.collisionInfos.collisionType == 6) {
					$scope.titleStr = "用户发起SOS救援请求,建议去电回访";
				}
				lngX = $scope.collisionInfos.longitude;
				latY = $scope.collisionInfos.latitude;
				infoSpeed = $scope.collisionInfos.speed;
				$scope.cpInstance.collisionPoint(lngX,latY,infoSpeed)

				setTimeout(function () {
					setTime()
				}, 1000)

			});
			aiNicheService.getCollisionMedia({collisionId:param.id},function(response) {
				$scope.collisionMedia = response.data
				$scope.collisionMedia.duration = {
						minute: '00',
						second: '00'
				};
				// console.log($scope.collisionMedia)
			});
		};
		//查询车辆信息
		//aiNicheService.getMaintainCarDetailsInfo(param,function(response) {
		$scope.Video = function (url) {
			return $sce.trustAsResourceUrl(url)
		}
		aiNicheService.getCollisionCarDetailsInfo(param,function(response) {
			var bs = response.data;
			if(bs) {
				$scope.baseInfo = bs;
			}
		});

		var isChange = false;
		$scope.addFollowRecord = function () {
			var modalInstance = $uibModal
			.open({
				templateUrl: 'biz/AIniche/view/addCollisionFollowRecord.html',
				controller: 'AddCollisionFollowRecordInfo',
				size: 'md',
				resolve: {
					param: function () {
						return {
							id: param.id,
							followId: param.followId
						};
					}
				}
			});
			// 弹窗返回值
			modalInstance.result
			.then(function (data) {
				if (data) {
					getCollisionPoint(data);
					isChange = true;
				}
			})
		};
		function setTime() {
			if ((angular.element("#comment-video")[0])){
				console.log(angular.element("#comment-video")[0].duration)
				$scope.collisionMedia.duration = {
					minute: parseInt((angular.element("#comment-video")[0].duration % 3600) / 60) < 10 ? '0' + parseInt((angular.element("#comment-video")[0].duration % 3600) / 60) : parseInt((angular.element("#comment-video")[0].duration % 3600) / 60),
							second: Math.ceil(angular.element("#comment-video")[0].duration % 60) < 10 ? '0' + Math.ceil(angular.element("#comment-video")[0].duration % 60) : Math.ceil(angular.element("#comment-video")[0].duration % 60)
				}
			}

			$scope.$apply()
		}
		// 图片视频切换
		$scope.showMedia = (type,url) =>{
			var modalInstance = $uibModal
			.open({
				templateUrl: 'biz/AIniche/view/accidentPictures.html',
				controller: 'AccidentPicturesInfo',
				windowClass:'modal-class',
				size:'lg',
				backdrop:true,
				resolve: {
					param: function () {
						return {
							type : type,
							url:url
						};
					}
				}
			});
			modalInstance.result
			.then(function (data) {
				if (data) {
					getCollisionPoint(data);
					isChange = true;
				}
			})
		};
		$scope.hidePlayBox = () => {
			$scope.playBox = false;
			$scope.isMedia_img = false;
			$scope.isMedia_video = false;
		};

		//关闭
		$scope.cancel = function () {
			// $uibModalInstance.dismiss('cancel');
			/*关闭后返回true给前一页面*/
			$uibModalInstance.close(isChange);
		};

	}

	angular.module('AIniche').controller('viewLocationInfo', viewLocationInfo)

})(angular);