package com.platform.modules.ks.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.platform.common.exception.RRException;
import com.platform.common.utils.HttpClientHelper;
import com.platform.common.utils.MapUtils;
import com.platform.common.utils.ThirdConstant;
import com.platform.modules.ks.entity.PlmVideoDownloadLogEntity;
import com.platform.modules.ks.entity.PlmVideoSearchLogEntity;
import com.platform.modules.ks.service.PlmVideoDownloadLogService;
import com.platform.modules.ks.service.PlmVideoSearchLogService;
import com.platform.modules.ks.service.PlmVideoService;
import com.platform.modules.plm.entity.PlmMaterialEntity;
import com.platform.modules.plm.service.PlmMaterialService;
import com.platform.modules.plm.thread.MediaDownloadThread;
import com.platform.modules.plm.util.MateriaFileProperties;


@Service("PlmVideoService")
public class PlmVideoServiceImpl implements PlmVideoService{
	
	@Autowired
	private PlmVideoSearchLogService PlmVideoSearchLogService;
	@Autowired
	private PlmVideoDownloadLogService PlmVideoDownloadLogService;
	@Autowired
	private PlmMaterialService materialService;
	@Autowired
	private MateriaFileProperties materiaFileProperties;
	@Override
	public Map<String, Object> query(Map<String, Object> params)throws JSONException {
		
		Integer pageNo = params.get("page")==null ? 1 : Integer.valueOf(params.get("page").toString()); 
		Integer pageCount = params.get("limit")==null ? 40 : Integer.valueOf(params.get("limit").toString());
		String keyword = params.get("keyword")==null ? null : params.get("keyword").toString();
		Long startTime = params.get("startTime")==null ? null : Long.valueOf(params.get("startTime").toString());
		Long endTime = params.get("endTime")==null ? null : Long.valueOf(params.get("endTime").toString());
		String latlng = params.get("latlng")==null ? null : params.get("latlng").toString();
		Integer precision = params.get("precision")==null ? null : Integer.valueOf(params.get("precision").toString());
		Integer order = params.get("order")==null ? null : Integer.valueOf(params.get("order").toString());
		Boolean originalWork = params.get("originalWork")==null ? null : Boolean.valueOf(params.get("originalWork").toString());
		Long operatorId = params.get("operatorId")==null ? 1 : Long.valueOf(params.get("operatorId").toString());
		params.put("count", pageCount);
		params.remove("limit");
		System.out.println(pageCount+"-----------"+pageNo);
		
		String paramList = String.format("page=%d&count=%d&keyword=%s&startTime=%d&endTime=%d&latlng=%s&precision=%d&order=%d&originWork=%s&operatorId=%s&secret=%s",
				pageNo, pageCount, keyword, startTime, endTime, latlng, precision, order, originalWork,operatorId, ThirdConstant.KS_SECRET);
		String signature = DigestUtils.md5Hex(paramList);
		params.put("signature", signature);
		String result_json = HttpClientHelper.sendPost(ThirdConstant.QUERY_URL,params,"UTF-8",true);
//		String result_json = "{\"msg\": \"success\", 	\"result\": 1, 	\"code\": 0, 	\"totalPage\": 500, 	\"pageSize\": 20, 	\"searchLogId\": 134, 	\"host-name\": \"bjfk-rs8551.yz02\", 	\"currentPage\": 2, 	\"totalCount\": 10000, 	\"list\": [{ 			\"address\": \"广西.南宁.兴宁区\", 			\"photoId\": \"5203627903999616646\", 			\"viewCount\": 1204, 			\"time\": \"2018-11-26 22:02:41\", 			\"coverUrls\": [{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/26/22/BMjAxODExMjYyMjAyNDBfNDY2MjY3MjYzXzkwOTc4NzY4NzhfMl8z_Bd481b80133c178ef2366dc1c4f47fd40.jpg?tag=1-1544495445-unknown-0-xpet2m2vtm-a1ef1e88862cb8db\" 				}, 				{ 					\"cdn\": \"ali2.a.yximgs.com\", 					\"url\": \"http://ali2.a.yximgs.com/upic/2018/11/26/22/BMjAxODExMjYyMjAyNDBfNDY2MjY3MjYzXzkwOTc4NzY4NzhfMl8z_Bd481b80133c178ef2366dc1c4f47fd40.jpg?tag=1-1544495445-unknown-1-qmpdemolzl-a7d8f5b85097f898\" 				} 			], 			\"title\": \"交通跆拳道😏😏\", 			\"mainMvUrls\": [{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/26/22/BMjAxODExMjYyMjAyNDBfNDY2MjY3MjYzXzkwOTc4NzY4NzhfMl8z_B8da57c6b75a5d3db1618d5df53097241.mp4?tag=1-1544495445-unknown-0-jempnr0txo-8c0260c4f671f4e1\" 				}, 				{ 					\"cdn\": \"alimov2.a.yximgs.com\", 					\"url\": \"http://alimov2.a.yximgs.com/upic/2018/11/26/22/BMjAxODExMjYyMjAyNDBfNDY2MjY3MjYzXzkwOTc4NzY4NzhfMl8z_B8da57c6b75a5d3db1618d5df53097241.mp4?tag=1-1544495445-unknown-1-zviij9sciy-65aed050f646ccd9\" 				} 			] 		}, 		{ 			\"address\": \"广东.广州.白云区\", 			\"photoId\": \"5191805956065736953\", 			\"viewCount\": 558, 			\"time\": \"2018-11-28 20:44:27\", 			\"coverUrls\": [{ 					\"cdn\": \"ali2.a.yximgs.com\", 					\"url\": \"http://ali2.a.yximgs.com/upic/2018/11/28/20/BMjAxODExMjgyMDQ0MjRfMTYxMTYxNzkzXzkxMjI3NTgyMDZfMl8z_B777c18bce03df4b206b43b1b1a8720c8.jpg?tag=1-1544495445-unknown-0-gizdj1qk2h-945cece1be92d069\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/28/20/BMjAxODExMjgyMDQ0MjRfMTYxMTYxNzkzXzkxMjI3NTgyMDZfMl8z_B777c18bce03df4b206b43b1b1a8720c8.jpg?tag=1-1544495445-unknown-1-uflaqunmry-cc15bf1bc5d09982\" 				} 			], 			\"title\": \"交通还是拍照好看🌚🌝\", 			\"mainMvUrls\": [{ 					\"cdn\": \"alimov2.a.yximgs.com\", 					\"url\": \"http://alimov2.a.yximgs.com/upic/2018/11/28/20/BMjAxODExMjgyMDQ0MjRfMTYxMTYxNzkzXzkxMjI3NTgyMDZfMl8z_b_Bd7f6a4c4966804046629b6158b220f4f.mp4?tag=1-1544495445-unknown-0-emc7ojitnm-f25776c3d6813f9e\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/28/20/BMjAxODExMjgyMDQ0MjRfMTYxMTYxNzkzXzkxMjI3NTgyMDZfMl8z_b_Bd7f6a4c4966804046629b6158b220f4f.mp4?tag=1-1544495445-unknown-1-gculru6a2j-2b250e4c83f9aa79\" 				} 			] 		}, 		{ 			\"address\": \"广西.柳州.柳南区\", 			\"photoId\": \"5207287081660682853\", 			\"viewCount\": 1335, 			\"time\": \"2018-12-02 07:31:53\", 			\"coverUrls\": [{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/12/02/07/BMjAxODEyMDIwNzMxNTJfMTA2OTA0MjM3Ml85MTc1MDkzMzc4XzJfMw==_B51a0f7c5811777ae67666eaf70abfe00.jpg?tag=1-1544495445-unknown-0-krozrfari5-9f7653c41c6e61c0\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/12/02/07/BMjAxODEyMDIwNzMxNTJfMTA2OTA0MjM3Ml85MTc1MDkzMzc4XzJfMw==_B51a0f7c5811777ae67666eaf70abfe00.jpg?tag=1-1544495445-unknown-1-f4ggxeaujz-c10376e6ff2e52bd\" 				} 			], 			\"title\": \"我在交通mou街\", 			\"mainMvUrls\": [{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/12/02/07/BMjAxODEyMDIwNzMxNTJfMTA2OTA0MjM3Ml85MTc1MDkzMzc4XzJfMw==_b_Be52489747e793cd8e24c69fda41804fb.mp4?tag=1-1544495445-unknown-0-tur2aro4nr-6782242b090b2b7b\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/12/02/07/BMjAxODEyMDIwNzMxNTJfMTA2OTA0MjM3Ml85MTc1MDkzMzc4XzJfMw==_b_Be52489747e793cd8e24c69fda41804fb.mp4?tag=1-1544495445-unknown-1-88dtsiik4y-826989ed534bdce5\" 				} 			] 		}, 		{ 			\"address\": \"广东.广州.白云区\", 			\"photoId\": \"5192087433087956973\", 			\"viewCount\": 169, 			\"time\": \"2018-11-27 09:03:32\", 			\"coverUrls\": [{ 					\"cdn\": \"gx.a.yximgs.com\", 					\"url\": \"http://gx.a.yximgs.com/upic/2018/11/27/09/BMjAxODExMjcwOTAzMzFfMjAxNjAzNzYzXzkxMDA4NDY2NzdfMl8z_B91239e9acb67720ff8e81fb091b81fc8.jpg?tag=1-1544495445-unknown-0-mqjzvugovh-1671b4fd3877d206\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/27/09/BMjAxODExMjcwOTAzMzFfMjAxNjAzNzYzXzkxMDA4NDY2NzdfMl8z_B91239e9acb67720ff8e81fb091b81fc8.jpg?tag=1-1544495445-unknown-1-xkj86h5c4c-b88af2b48cf7757a\" 				} 			], 			\"title\": \"哇，我们的交通学校漂亮\", 			\"mainMvUrls\": [{ 					\"cdn\": \"gxmov.a.yximgs.com\", 					\"url\": \"http://gxmov.a.yximgs.com/upic/2018/11/27/09/BMjAxODExMjcwOTAzMzFfMjAxNjAzNzYzXzkxMDA4NDY2NzdfMl8z_b_B650ad84588abc6d8053882e4502ea75b.mp4?tag=1-1544495445-unknown-0-fxwcdji1nt-f60009a7aae05ef8\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/27/09/BMjAxODExMjcwOTAzMzFfMjAxNjAzNzYzXzkxMDA4NDY2NzdfMl8z_b_B650ad84588abc6d8053882e4502ea75b.mp4?tag=1-1544495445-unknown-1-exuaa724ri-9fc32db05817000b\" 				} 			] 		}, 		{ 			\"address\": \"山东.临沂.罗庄区\", 			\"photoId\": \"5226990328013566877\", 			\"viewCount\": 220, 			\"time\": \"2018-11-12 09:32:03\", 			\"coverUrls\": [{ 					\"cdn\": \"up.a.yximgs.com\", 					\"url\": \"http://up.a.yximgs.com/upic/2018/11/12/09/BMjAxODExMTIwOTMyMDJfNTM3MDIzODM5Xzg4Nzk0ODE1OThfMl8z_B894d80f6ff458097c3ccaef4ff9836e5.jpg?tag=1-1544495445-unknown-0-av8tvjq0vq-dd58f5977e22d331\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/12/09/BMjAxODExMTIwOTMyMDJfNTM3MDIzODM5Xzg4Nzk0ODE1OThfMl8z_B894d80f6ff458097c3ccaef4ff9836e5.jpg?tag=1-1544495445-unknown-1-irznonzxlt-1de419a96a9e13b7\" 				} 			], 			\"title\": \"交通技师❤️\", 			\"mainMvUrls\": [{ 					\"cdn\": \"upmov.a.yximgs.com\", 					\"url\": \"http://upmov.a.yximgs.com/upic/2018/11/12/09/BMjAxODExMTIwOTMyMDJfNTM3MDIzODM5Xzg4Nzk0ODE1OThfMl8z_b_B7d71c4faabd3ddb21cb66dc05ba050b5.mp4?tag=1-1544495445-unknown-0-nxxpedn6ae-98fa121407e68b41\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/12/09/BMjAxODExMTIwOTMyMDJfNTM3MDIzODM5Xzg4Nzk0ODE1OThfMl8z_b_B7d71c4faabd3ddb21cb66dc05ba050b5.mp4?tag=1-1544495445-unknown-1-3twg4sz9zd-ac02af26d5f40dae\" 				} 			] 		}, 		{ 			\"address\": \"河北.邢台.广宗县\", 			\"photoId\": \"5208412978059830226\", 			\"viewCount\": 188, 			\"time\": \"2018-11-23 14:03:47\", 			\"coverUrls\": [{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/23/14/BMjAxODExMjMxNDAzNDZfNzc5MzI0NzFfOTAzOTY4NzA0NF8yXzM=_B3e1acad960cd37e839f1dbbdf413e0ef.jpg?tag=1-1544495445-unknown-0-jaqj961rnm-6db77ff7711b6a69\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/23/14/BMjAxODExMjMxNDAzNDZfNzc5MzI0NzFfOTAzOTY4NzA0NF8yXzM=_B3e1acad960cd37e839f1dbbdf413e0ef.jpg?tag=1-1544495445-unknown-1-ylscal4z7f-bf79137ee50f0330\" 				} 			], 			\"title\": \"小孩说交通，大家要遵守交通规则\", 			\"mainMvUrls\": [{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/23/14/BMjAxODExMjMxNDAzNDZfNzc5MzI0NzFfOTAzOTY4NzA0NF8yXzM=_b_B0be9a257efc7dc2d3ae972aebd3aa90d.mp4?tag=1-1544495445-unknown-0-kzdvcreawx-2e313f8150be2b1a\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/23/14/BMjAxODExMjMxNDAzNDZfNzc5MzI0NzFfOTAzOTY4NzA0NF8yXzM=_b_B0be9a257efc7dc2d3ae972aebd3aa90d.mp4?tag=1-1544495445-unknown-1-abhimqbcwv-cbf9e05cf0648c68\" 				} 			] 		}, 		{ 			\"address\": \"山东.临沂.兰山区\", 			\"photoId\": \"5197716928704807623\", 			\"viewCount\": 244, 			\"time\": \"2018-11-17 19:51:13\", 			\"coverUrls\": [{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/17/19/BMjAxODExMTcxOTUxMTJfODQ2MDI1NDAxXzg5NTk4MjkzMTBfMl8z_Bff6f8f5b9ea717f0b4c78e4423cdf97f.jpg?tag=1-1544495445-unknown-0-aycoki9r97-47292f0a6cb61814\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/17/19/BMjAxODExMTcxOTUxMTJfODQ2MDI1NDAxXzg5NTk4MjkzMTBfMl8z_Bff6f8f5b9ea717f0b4c78e4423cdf97f.jpg?tag=1-1544495445-unknown-1-j1nu5ndmdt-fc23b4dfe5409233\" 				} 			], 			\"title\": \"山东交通  无聊，转着玩😂😂\", 			\"mainMvUrls\": [{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/17/19/BMjAxODExMTcxOTUxMTJfODQ2MDI1NDAxXzg5NTk4MjkzMTBfMl8z_b_Ba773c7e4a8e52da3ea906f74677f584f.mp4?tag=1-1544495445-unknown-0-w8anveifxo-28ed494aaaeef8f1\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/17/19/BMjAxODExMTcxOTUxMTJfODQ2MDI1NDAxXzg5NTk4MjkzMTBfMl8z_b_Ba773c7e4a8e52da3ea906f74677f584f.mp4?tag=1-1544495445-unknown-1-jjndneb2rf-fa16b4d6cc6ab11b\" 				} 			] 		}, 		{ 			\"address\": \"北京.北京.延庆县\", 			\"photoId\": \"5230368028629431314\", 			\"viewCount\": 536, 			\"time\": \"2018-11-28 12:26:57\", 			\"coverUrls\": [{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/28/12/BMjAxODExMjgxMjI2NTVfOTAyMjQ2NDVfOTExNTg5MDA3NF8yXzM=_B5142ca5fd0df397b0edd9918bd05d0ab.jpg?tag=1-1544495445-unknown-0-dwbqdjigsl-1481d2ee0ff11aa8\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/28/12/BMjAxODExMjgxMjI2NTVfOTAyMjQ2NDVfOTExNTg5MDA3NF8yXzM=_B5142ca5fd0df397b0edd9918bd05d0ab.jpg?tag=1-1544495445-unknown-1-gy7x5jv7wa-d376830401bd65cb\" 				} 			], 			\"title\": \"交通事故\", 			\"mainMvUrls\": [{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/28/12/BMjAxODExMjgxMjI2NTVfOTAyMjQ2NDVfOTExNTg5MDA3NF8yXzM=_b_B4e32807ceb886ecc87d2b484641a9b1b.mp4?tag=1-1544495445-unknown-0-qlumabtup9-b289b0cbd71dfdd8\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/28/12/BMjAxODExMjgxMjI2NTVfOTAyMjQ2NDVfOTExNTg5MDA3NF8yXzM=_b_B4e32807ceb886ecc87d2b484641a9b1b.mp4?tag=1-1544495445-unknown-1-b7zecphqod-2daddce155c3e2c2\" 				} 			] 		}, 		{ 			\"address\": \"辽宁.营口.西市区\", 			\"photoId\": \"5241627027571469960\", 			\"viewCount\": 3367, 			\"time\": \"2018-12-07 15:09:33\", 			\"coverUrls\": [{ 					\"cdn\": \"up.a.yximgs.com\", 					\"url\": \"http://up.a.yximgs.com/upic/2018/12/07/15/BMjAxODEyMDcxNTA5MzJfMjYwMTYyOTJfOTI1MzYyMDU5Ml8xXzM=_B5690846e951d92cd2326b7cefa645d0c.jpg?tag=1-1544495445-unknown-0-l9xp4dd43f-667bcfeff0dd89ae\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/12/07/15/BMjAxODEyMDcxNTA5MzJfMjYwMTYyOTJfOTI1MzYyMDU5Ml8xXzM=_B5690846e951d92cd2326b7cefa645d0c.jpg?tag=1-1544495445-unknown-1-isojindnvu-6fce4ddf9b49163a\" 				} 			], 			\"title\": \"一个小交通事故\", 			\"mainMvUrls\": [{ 					\"cdn\": \"upmov.a.yximgs.com\", 					\"url\": \"http://upmov.a.yximgs.com/upic/2018/12/07/15/BMjAxODEyMDcxNTA5MzJfMjYwMTYyOTJfOTI1MzYyMDU5Ml8xXzM=_b_B1c71edee6276af914d65bd764afec557.mp4?tag=1-1544495445-unknown-0-xtuzsiesnn-ee1d55abf52acbc5\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/12/07/15/BMjAxODEyMDcxNTA5MzJfMjYwMTYyOTJfOTI1MzYyMDU5Ml8xXzM=_b_B1c71edee6276af914d65bd764afec557.mp4?tag=1-1544495445-unknown-1-yoniyiwaxs-499d980d5efab054\" 				} 			] 		}, 		{ 			\"address\": \"青海.黄南藏族自治州.泽库县\", 			\"photoId\": \"5244723252266387341\", 			\"viewCount\": 240, 			\"time\": \"2018-12-07 17:21:01\", 			\"coverUrls\": [{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/12/07/17/BMjAxODEyMDcxNzIxMDBfMzMyMDQ4MjUzXzkyNTU0NzAzNzVfMl8z_Ba513251d0a8ffdb6534f49a72412b8e7.jpg?tag=1-1544495445-unknown-0-srryql7r5m-9eaea6e4369ada5a\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/12/07/17/BMjAxODEyMDcxNzIxMDBfMzMyMDQ4MjUzXzkyNTU0NzAzNzVfMl8z_Ba513251d0a8ffdb6534f49a72412b8e7.jpg?tag=1-1544495445-unknown-1-zypmc2lqfy-6a77b3cb21242522\" 				} 			], 			\"title\": \"交通严重堵塞\", 			\"mainMvUrls\": [{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/12/07/17/BMjAxODEyMDcxNzIxMDBfMzMyMDQ4MjUzXzkyNTU0NzAzNzVfMl8z_b_Bc135ff590c20d228bf2e9ea9699491d2.mp4?tag=1-1544495445-unknown-0-yhy9l2f2k2-6578ec98e2048e51\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/12/07/17/BMjAxODEyMDcxNzIxMDBfMzMyMDQ4MjUzXzkyNTU0NzAzNzVfMl8z_b_Bc135ff590c20d228bf2e9ea9699491d2.mp4?tag=1-1544495445-unknown-1-snvziuream-197f285e4d77b483\" 				} 			] 		}, 		{ 			\"address\": \"山东.临沂.罗庄区\", 			\"photoId\": \"5189554157615703150\", 			\"viewCount\": 205, 			\"time\": \"2018-11-25 12:42:53\", 			\"coverUrls\": [{ 					\"cdn\": \"yd.a.yximgs.com\", 					\"url\": \"http://yd.a.yximgs.com/upic/2018/11/25/12/BMjAxODExMjUxMjQyNTFfOTEyMTY0MTFfOTA3Mzk3MzU1MF8yXzM=_Ba1f3cac6edbc1d60491222418737bcf6.jpg?tag=1-1544495445-unknown-0-dpaisk0kwm-fd82100eda695a8c\" 				}, 				{ 					\"cdn\": \"ali2.a.yximgs.com\", 					\"url\": \"http://ali2.a.yximgs.com/upic/2018/11/25/12/BMjAxODExMjUxMjQyNTFfOTEyMTY0MTFfOTA3Mzk3MzU1MF8yXzM=_Ba1f3cac6edbc1d60491222418737bcf6.jpg?tag=1-1544495445-unknown-1-cmnjaqapte-a0eb570b93dfe332\" 				} 			], 			\"title\": \"交通校门口偶遇。\", 			\"mainMvUrls\": [{ 					\"cdn\": \"ydmov.a.yximgs.com\", 					\"url\": \"http://ydmov.a.yximgs.com/upic/2018/11/25/12/BMjAxODExMjUxMjQyNTFfOTEyMTY0MTFfOTA3Mzk3MzU1MF8yXzM=_b_Bce6ef98788863931b471b5bf602308e7.mp4?tag=1-1544495445-unknown-0-5dvnuge9y5-bcf63d0f91796f46\" 				}, 				{ 					\"cdn\": \"alimov2.a.yximgs.com\", 					\"url\": \"http://alimov2.a.yximgs.com/upic/2018/11/25/12/BMjAxODExMjUxMjQyNTFfOTEyMTY0MTFfOTA3Mzk3MzU1MF8yXzM=_b_Bce6ef98788863931b471b5bf602308e7.mp4?tag=1-1544495445-unknown-1-scfzgv46mi-de81b1b93869218b\" 				} 			] 		}, 		{ 			\"address\": \"广东.茂名.茂南区\", 			\"photoId\": \"5231775403153183545\", 			\"viewCount\": 1502, 			\"time\": \"2018-11-27 12:41:16\", 			\"coverUrls\": [{ 					\"cdn\": \"qn.a.yximgs.com\", 					\"url\": \"http://qn.a.yximgs.com/upic/2018/11/27/12/BMjAxODExMjcxMjQxMTRfNzc2NzAxODFfOTEwMzE1OTIxMl8yXzM=_B2ea9ebe67f9a96345a15b64fb9f075e6.jpg?tag=1-1544495445-unknown-0-ih2pll945r-906e49ba87cceb3f\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/27/12/BMjAxODExMjcxMjQxMTRfNzc2NzAxODFfOTEwMzE1OTIxMl8yXzM=_B2ea9ebe67f9a96345a15b64fb9f075e6.jpg?tag=1-1544495445-unknown-1-tfle05oijg-080acd2781ab3a96\" 				} 			], 			\"title\": \"交通，龙狮协会\", 			\"mainMvUrls\": [{ 					\"cdn\": \"qnmov.a.yximgs.com\", 					\"url\": \"http://qnmov.a.yximgs.com/upic/2018/11/27/12/BMjAxODExMjcxMjQxMTRfNzc2NzAxODFfOTEwMzE1OTIxMl8yXzM=_b_B83dd59d498371c5da7eb76d59f81764a.mp4?tag=1-1544495445-unknown-0-rrzftph2be-3a5505536d0ad4e3\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/27/12/BMjAxODExMjcxMjQxMTRfNzc2NzAxODFfOTEwMzE1OTIxMl8yXzM=_b_B83dd59d498371c5da7eb76d59f81764a.mp4?tag=1-1544495445-unknown-1-6ijdggsqla-1e56b1678e6c3a62\" 				} 			] 		}, 		{ 			\"address\": \"江苏.苏州.太仓市\", 			\"photoId\": \"5255982251704822654\", 			\"viewCount\": 832, 			\"time\": \"2018-11-30 15:52:05\", 			\"coverUrls\": [{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/30/15/BMjAxODExMzAxNTUyMDRfNjY0NDgwNDlfOTE0NTAwMDg0NV8yXzM=_B1a2af779fa9c8ce6d503480957613af5.jpg?tag=1-1544495445-unknown-0-ybieojq49m-039c43e887585728\" 				}, 				{ 					\"cdn\": \"ali2.a.yximgs.com\", 					\"url\": \"http://ali2.a.yximgs.com/upic/2018/11/30/15/BMjAxODExMzAxNTUyMDRfNjY0NDgwNDlfOTE0NTAwMDg0NV8yXzM=_B1a2af779fa9c8ce6d503480957613af5.jpg?tag=1-1544495445-unknown-1-234slfs4py-3fe9a6e7aed1d391\" 				} 			], 			\"title\": \"特大交通事故\", 			\"mainMvUrls\": [{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/30/15/BMjAxODExMzAxNTUyMDRfNjY0NDgwNDlfOTE0NTAwMDg0NV8yXzM=_b_B4ed24a042ac8e93e32c9bceb07c125ff.mp4?tag=1-1544495445-unknown-0-7eaa7iddro-9e098dce1ded6fa1\" 				}, 				{ 					\"cdn\": \"alimov2.a.yximgs.com\", 					\"url\": \"http://alimov2.a.yximgs.com/upic/2018/11/30/15/BMjAxODExMzAxNTUyMDRfNjY0NDgwNDlfOTE0NTAwMDg0NV8yXzM=_b_B4ed24a042ac8e93e32c9bceb07c125ff.mp4?tag=1-1544495445-unknown-1-lzxcmevu6r-cb4602b43edbe95d\" 				} 			] 		}, 		{ 			\"address\": \"山东.临沂.罗庄区\", 			\"photoId\": \"5221642305237162082\", 			\"viewCount\": 454, 			\"time\": \"2018-12-02 20:59:43\", 			\"coverUrls\": [{ 					\"cdn\": \"up.a.yximgs.com\", 					\"url\": \"http://up.a.yximgs.com/upic/2018/12/02/20/BMjAxODEyMDIyMDU5NDJfMTI0OTc1NDEwXzkxODk2NjI0ODVfMV8z_B13e1f55c54bd6b9b87da239348d13466.jpg?tag=1-1544495445-unknown-0-tv6z5gkjrw-b704298be58dc1ef\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/12/02/20/BMjAxODEyMDIyMDU5NDJfMTI0OTc1NDEwXzkxODk2NjI0ODVfMV8z_B13e1f55c54bd6b9b87da239348d13466.jpg?tag=1-1544495445-unknown-1-p3nutmli0t-67c514824d4f870e\" 				} 			], 			\"title\": \"交通艾瑞巴蒂！\", 			\"mainMvUrls\": [{ 					\"cdn\": \"upmov.a.yximgs.com\", 					\"url\": \"http://upmov.a.yximgs.com/upic/2018/12/02/20/BMjAxODEyMDIyMDU5NDJfMTI0OTc1NDEwXzkxODk2NjI0ODVfMV8z_b_B0e32e05bb02c167d0ff42343858b49c7.mp4?tag=1-1544495445-unknown-0-atoxsusidc-dac925eb2ce4a64b\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/12/02/20/BMjAxODEyMDIyMDU5NDJfMTI0OTc1NDEwXzkxODk2NjI0ODVfMV8z_b_B0e32e05bb02c167d0ff42343858b49c7.mp4?tag=1-1544495445-unknown-1-y4hjgrz8av-145563283ca9e6f0\" 				} 			] 		}, 		{ 			\"address\": \"广西.河池.罗城仫佬族自治县\", 			\"photoId\": \"5240782603760712444\", 			\"viewCount\": 382, 			\"time\": \"2018-12-06 11:36:14\", 			\"coverUrls\": [{ 					\"cdn\": \"gx.a.yximgs.com\", 					\"url\": \"http://gx.a.yximgs.com/upic/2018/12/06/11/BMjAxODEyMDYxMTM2MTJfNTk5Mjg4MzczXzkyMzc2Nzg3MThfMl8z_B1745e76f27515210d769c96e4713be21.jpg?tag=1-1544495445-unknown-0-uhzv5uep56-29a902f95031e311\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/12/06/11/BMjAxODEyMDYxMTM2MTJfNTk5Mjg4MzczXzkyMzc2Nzg3MThfMl8z_B1745e76f27515210d769c96e4713be21.jpg?tag=1-1544495445-unknown-1-okkwevthyt-0186dc8dcf26fe03\" 				} 			], 			\"title\": \"交通不方便\", 			\"mainMvUrls\": [{ 					\"cdn\": \"gxmov.a.yximgs.com\", 					\"url\": \"http://gxmov.a.yximgs.com/upic/2018/12/06/11/BMjAxODEyMDYxMTM2MTJfNTk5Mjg4MzczXzkyMzc2Nzg3MThfMl8z_b_B8cfa0dd1a26b4df5a86910fe83b4c7b6.mp4?tag=1-1544495445-unknown-0-rgnnideoet-53740b15063bd9be\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/12/06/11/BMjAxODEyMDYxMTM2MTJfNTk5Mjg4MzczXzkyMzc2Nzg3MThfMl8z_b_B8cfa0dd1a26b4df5a86910fe83b4c7b6.mp4?tag=1-1544495445-unknown-1-cqrtk5jojt-095115b6adfb3732\" 				} 			] 		}, 		{ 			\"address\": \"广西.南宁.兴宁区\", 			\"photoId\": \"5245004724861109697\", 			\"viewCount\": 725, 			\"time\": \"2018-11-16 18:08:20\", 			\"coverUrls\": [{ 					\"cdn\": \"gx.a.yximgs.com\", 					\"url\": \"http://gx.a.yximgs.com/upic/2018/11/16/18/BMjAxODExMTYxODA4MTlfNDM3MDAzNzAyXzg5Mzg5Mjc3MTVfMl8z_Bd1871d0bf7302f8c21f63b3fdfec123a.jpg?tag=1-1544495445-unknown-0-xhtt6h7s5r-87161c37bd53536e\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/16/18/BMjAxODExMTYxODA4MTlfNDM3MDAzNzAyXzg5Mzg5Mjc3MTVfMl8z_Bd1871d0bf7302f8c21f63b3fdfec123a.jpg?tag=1-1544495445-unknown-1-cvirzbenz0-274ad2d303420cc7\" 				} 			], 			\"title\": \"交通码神在这里！😂😂\", 			\"mainMvUrls\": [{ 					\"cdn\": \"gxmov.a.yximgs.com\", 					\"url\": \"http://gxmov.a.yximgs.com/upic/2018/11/16/18/BMjAxODExMTYxODA4MTlfNDM3MDAzNzAyXzg5Mzg5Mjc3MTVfMl8z_b_B1e4dbf78394f0fe705ab5693e7b48e8d.mp4?tag=1-1544495445-unknown-0-vwtsqdvl77-171c22a4aec6b783\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/16/18/BMjAxODExMTYxODA4MTlfNDM3MDAzNzAyXzg5Mzg5Mjc3MTVfMl8z_b_B1e4dbf78394f0fe705ab5693e7b48e8d.mp4?tag=1-1544495445-unknown-1-kfitkrqnmo-f8875ebb6b324191\" 				} 			] 		}, 		{ 			\"address\": \"云南.昆明.安宁市\", 			\"photoId\": \"5201657580006659046\", 			\"viewCount\": 710, 			\"time\": \"2018-12-02 19:08:34\", 			\"coverUrls\": [{ 					\"cdn\": \"up.a.yximgs.com\", 					\"url\": \"http://up.a.yximgs.com/upic/2018/12/02/19/BMjAxODEyMDIxOTA4MzNfMTM5NDA3NjA5XzkxODc0MjQ1NzBfMl8z_Bc1248bf4311cedf8f7b8a00ce7693eb6.jpg?tag=1-1544495445-unknown-0-uut2wgbapp-4609a23280b2525f\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/12/02/19/BMjAxODEyMDIxOTA4MzNfMTM5NDA3NjA5XzkxODc0MjQ1NzBfMl8z_Bc1248bf4311cedf8f7b8a00ce7693eb6.jpg?tag=1-1544495445-unknown-1-u0uivdll0y-fcd32482f946e22e\" 				} 			], 			\"title\": \"交通晚自习🤘🏼🤘🏼❗❗\", 			\"mainMvUrls\": [{ 					\"cdn\": \"upmov.a.yximgs.com\", 					\"url\": \"http://upmov.a.yximgs.com/upic/2018/12/02/19/BMjAxODEyMDIxOTA4MzNfMTM5NDA3NjA5XzkxODc0MjQ1NzBfMl8z_b_B877b816dfc863a56070e888152551e0e.mp4?tag=1-1544495445-unknown-0-pp5wlvi16a-6adca616e3b7d55c\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/12/02/19/BMjAxODEyMDIxOTA4MzNfMTM5NDA3NjA5XzkxODc0MjQ1NzBfMl8z_b_B877b816dfc863a56070e888152551e0e.mp4?tag=1-1544495445-unknown-1-smqlhjlvys-dfc15af858314a30\" 				} 			] 		}, 		{ 			\"address\": \"广西.南宁.兴宁区\", 			\"photoId\": \"5192087431663562704\", 			\"viewCount\": 2059, 			\"time\": \"2018-11-23 10:18:43\", 			\"coverUrls\": [{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/11/23/10/BMjAxODExMjMxMDE4NDJfMzUyNDk4NzgxXzkwMzY4NzEzODRfMl8z_B20000587b3b0743194af7beb7da2f952.jpg?tag=1-1544495445-unknown-0-vok4h1invg-66d2dd8c7f64ef9b\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/23/10/BMjAxODExMjMxMDE4NDJfMzUyNDk4NzgxXzkwMzY4NzEzODRfMl8z_B20000587b3b0743194af7beb7da2f952.jpg?tag=1-1544495445-unknown-1-fyjycopl1y-e262054e034eaba2\" 				} 			], 			\"title\": \"交通校运会😂😂\", 			\"mainMvUrls\": [{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/11/23/10/BMjAxODExMjMxMDE4NDJfMzUyNDk4NzgxXzkwMzY4NzEzODRfMl8z_b_B69b280129ba872fd5816e68c5e41f84f.mp4?tag=1-1544495445-unknown-0-d4em8pluue-c86a53d275022052\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/23/10/BMjAxODExMjMxMDE4NDJfMzUyNDk4NzgxXzkwMzY4NzEzODRfMl8z_b_B69b280129ba872fd5816e68c5e41f84f.mp4?tag=1-1544495445-unknown-1-zdfnlkc8nt-f0684e6bdd99f409\" 				} 			] 		}, 		{ 			\"address\": \"辽宁.营口.大石桥市\", 			\"photoId\": \"5252041599584097994\", 			\"viewCount\": 863, 			\"time\": \"2018-11-22 12:52:24\", 			\"coverUrls\": [{ 					\"cdn\": \"ali2.a.yximgs.com\", 					\"url\": \"http://ali2.a.yximgs.com/upic/2018/11/22/12/BMjAxODExMjIxMjUyMjJfMzAxNTQzMzEwXzkwMjU0NjUxMDdfMl8z_B5145e2a95537c6942df20eda7cd4bcfe.jpg?tag=1-1544495445-unknown-0-ytydsmsok2-8b9cda3352f8cbaf\" 				}, 				{ 					\"cdn\": \"tx2.a.yximgs.com\", 					\"url\": \"http://tx2.a.yximgs.com/upic/2018/11/22/12/BMjAxODExMjIxMjUyMjJfMzAxNTQzMzEwXzkwMjU0NjUxMDdfMl8z_B5145e2a95537c6942df20eda7cd4bcfe.jpg?tag=1-1544495445-unknown-1-8sdafsxziu-6061ed15d723a48a\" 				} 			], 			\"title\": \"交通楼一楼\", 			\"mainMvUrls\": [{ 					\"cdn\": \"alimov2.a.yximgs.com\", 					\"url\": \"http://alimov2.a.yximgs.com/upic/2018/11/22/12/BMjAxODExMjIxMjUyMjJfMzAxNTQzMzEwXzkwMjU0NjUxMDdfMl8z_b_Ba9d8f7fad80e057592266f585b783ce5.mp4?tag=1-1544495445-unknown-0-klvbouvuh7-1e489fb4cada344e\" 				}, 				{ 					\"cdn\": \"txmov2.a.yximgs.com\", 					\"url\": \"http://txmov2.a.yximgs.com/upic/2018/11/22/12/BMjAxODExMjIxMjUyMjJfMzAxNTQzMzEwXzkwMjU0NjUxMDdfMl8z_b_Ba9d8f7fad80e057592266f585b783ce5.mp4?tag=1-1544495445-unknown-1-egdsw2pb1e-a9160dc3b5f90a13\" 				} 			] 		}, 		{ 			\"address\": \"山东.聊城.东昌府区\", 			\"photoId\": \"5222205255243639458\", 			\"viewCount\": 144, 			\"time\": \"2018-12-02 09:44:09\", 			\"coverUrls\": [{ 					\"cdn\": \"gx.a.yximgs.com\", 					\"url\": \"http://gx.a.yximgs.com/upic/2018/12/02/09/BMjAxODEyMDIwOTQ0MDhfNDU1OTM1MzNfOTE3NjM3MDYzOF8yXzM=_B58315988c66eb2239e8fb5fa8b82af92.jpg?tag=1-1544495445-unknown-0-uf9onhnka4-5ad7b58fca2742cc\" 				}, 				{ 					\"cdn\": \"js2.a.yximgs.com\", 					\"url\": \"http://js2.a.yximgs.com/upic/2018/12/02/09/BMjAxODEyMDIwOTQ0MDhfNDU1OTM1MzNfOTE3NjM3MDYzOF8yXzM=_B58315988c66eb2239e8fb5fa8b82af92.jpg?tag=1-1544495445-unknown-1-hgxtofxqkp-69a34fa5d4d817d0\" 				} 			], 			\"title\": \"交通安全日\", 			\"mainMvUrls\": [{ 					\"cdn\": \"gxmov.a.yximgs.com\", 					\"url\": \"http://gxmov.a.yximgs.com/upic/2018/12/02/09/BMjAxODEyMDIwOTQ0MDhfNDU1OTM1MzNfOTE3NjM3MDYzOF8yXzM=_b_B63b36cc18e218c4957ad7f4815eb91db.mp4?tag=1-1544495445-unknown-0-jwlr60unyh-bc054d9553934948\" 				}, 				{ 					\"cdn\": \"jsmov2.a.yximgs.com\", 					\"url\": \"http://jsmov2.a.yximgs.com/upic/2018/12/02/09/BMjAxODEyMDIwOTQ0MDhfNDU1OTM1MzNfOTE3NjM3MDYzOF8yXzM=_b_B63b36cc18e218c4957ad7f4815eb91db.mp4?tag=1-1544495445-unknown-1-bomhacyb5v-7c24fc553e33273b\" 				} 			] 		} 	] }";
		//检索记录
		PlmVideoSearchLogEntity PlmVideoSearchLog = new PlmVideoSearchLogEntity();
		PlmVideoSearchLog.setCreateDate(new Date());
		PlmVideoSearchLog.setCreateUser(operatorId.longValue());
		PlmVideoSearchLog.setParamlist(paramList);
		PlmVideoSearchLog.setResultJson(result_json);
		PlmVideoSearchLog.setSignature(signature);
		PlmVideoSearchLogService.save(PlmVideoSearchLog);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		if(StringUtils.isNotBlank(result_json)){
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			JSONObject resultJson = JSONObject.fromObject(result_json);
			if(resultJson!=null && !resultJson.get("result").equals(1)){
				resultMap = MapUtils.json2map(result_json);
			}else{
				resultMap.put("result", resultJson.get("result"));
				resultMap.put("searchLogId", PlmVideoSearchLog.getId());
				resultMap.put("totalPage", resultJson.get("totalPage"));
				resultMap.put("pageSize", resultJson.get("pageSize"));
				resultMap.put("host-name", resultJson.get("host-name"));
				resultMap.put("currentPage", resultJson.get("currentPage"));
				resultMap.put("totalCount", resultJson.get("totalCount"));
//				JSONArray jsonArray = resultJson.getJSONArray("list");
				JSONArray jsonArray = resultJson.getJSONArray("photos");
				System.out.println(resultJson.get("pageSize")+"-----------"+resultJson.get("currentPage")+"----------------"+jsonArray.size());
				List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
				if(jsonArray!=null && jsonArray.size()>0){
					for(int i=0;i<jsonArray.size();i++){// 遍历 jsonarray 数组，把每一个对象转成 json 对象
						JSONObject json = jsonArray.getJSONObject(i); 
//						Map<String, Object> map = new HashMap<String, Object>();
//						map.put("photoId", json.get("photoId"));
//						map.put("title", json.get("title"));
//						map.put("viewCount", json.get("viewCount"));
//						map.put("time", json.get("time"));
//						map.put("address",json.get("address"));
//						map.put("mainMvUrls", json.get("mainMvUrls"));
//						map.put("coverUrls", json.get("coverUrls"));
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("photoId", json.get("photoId"));
						map.put("title", json.get("caption"));
						map.put("viewCount", json.get("viewCount"));
						map.put("time", json.get("timestamp")==null ? null : sdf.format(new Date(new Long(json.get("timestamp").toString()))));
						map.put("photoId", json.get("photoId"));
						JSONObject locationJson = json.getJSONObject("location");
						String addres = "";
						if(locationJson.get("province")!=null){
							addres = locationJson.get("province")+".";
						}
						if(locationJson.get("city")!=null){
							addres += locationJson.get("city")+".";
						}
						if(locationJson.get("district")!=null){
							addres += locationJson.get("district")+".";
						}
						map.put("address", StringUtils.isEmpty(addres) ? "" : addres.substring(0, addres.length()-1));
						map.put("photoId", json.get("photoId"));
						map.put("mainMvUrls", json.get("mainMvUrls"));
						map.put("coverUrls", json.get("coverUrls"));
						list.add(map);
					}
				}
				resultMap.put("list", list);
			}
		}
		
		return resultMap;
	}
	@Override
	public Map<String, Object> download(Map<String, Object> params)throws JSONException {
		
		Long operatorId = params.get("operatorId")==null ? 1 : Long.valueOf(params.get("operatorId").toString());
		String downloadUrl = params.get("downloadUrl")==null ? null : params.get("downloadUrl").toString();
		String newsUrl = params.get("newsUrl")==null ? null : params.get("newsUrl").toString();
		String newsTitle = params.get("newsTitle")==null ? null : params.get("newsTitle").toString();
		Long queryLogId = params.get("queryLogId")==null ? null : Long.valueOf(params.get("queryLogId").toString());
		String photoId = params.get("photoId")==null ? null : params.get("photoId").toString();
		String coverUrl = null;
		params.remove("queryLogId");
		params.remove("photoId");
		String result_json = "";
		try {
			String requestJson="";
			PlmVideoSearchLogEntity entity = PlmVideoSearchLogService.selectById(queryLogId);
			if(entity==null || StringUtils.isBlank(entity.getResultJson())){
				return new HashMap<String, Object>();
			}
			JSONObject json = JSONObject.fromObject(entity.getResultJson());
			JSONArray jsonArray = json.getJSONArray("photos");
			JSONObject resultJson =  new JSONObject();
			String addres = "";
			String title = "";
			if(jsonArray.size()>0){
	            for(int i=0;i<jsonArray.size();i++){
	                JSONObject job = jsonArray.getJSONObject(i);
	                String pId=job.getString("photoId"); 
	                if(pId==photoId || pId.equals(photoId)){
	                	requestJson = job.toString();
	                	JSONArray mainMvUrls = job.getJSONArray("mainMvUrls");
	                	downloadUrl = JSONObject.fromObject(mainMvUrls.getString(0)).getString("url");
	                	downloadUrl = (downloadUrl.indexOf("?")>0 ? downloadUrl.substring(0, downloadUrl.lastIndexOf("?")) : downloadUrl);
//	                	String serverVideoPath = "media" + File.separator + VideoUtils.getDateDir() + "/" + FileUtils.createFileName() + "." + FileUtils.getSuffix(downloadUrl); // 存放在服务器地址
//	                    String newFilePath = FileUtils.BASE_PATH + "/" + serverVideoPath;
//	                	HttpClientHelper.sendGetAndSaveFile(downloadUrl, null, newFilePath,true);
//	                	params.put("downloadUrl", downloadUrl);
	                	resultJson =  JSONObject.fromObject(requestJson);
	                	JSONObject locationJson = job.getJSONObject("location");
						if(locationJson!=null && locationJson.get("province")!=null){
							addres = locationJson.get("province")+".";
						}
						if(locationJson!=null && locationJson.get("city")!=null){
							addres += locationJson.get("city")+".";
						}
						if(locationJson!=null && locationJson.get("district")!=null){
							addres += locationJson.get("district")+".";
						}
	                	title = job.get("caption")==null ? null : job.get("caption").toString();
	                	coverUrl = JSONObject.fromObject(job.getJSONArray("coverUrls").getString(0)).getString("url");
	                	coverUrl = (coverUrl.indexOf("?")>0 ? coverUrl.substring(0, coverUrl.lastIndexOf("?")) : coverUrl);
//	                	resultJson.put("mediaUrl", serverVideoPath);
//	                	file = new File(newFilePath);
//	                	addres = job.get("addres")==null ? null : job.get("addres").toString();
//	                	title = job.get("title")==null ? null : job.get("title").toString();
//	                	coverUrl = JSONObject.fromObject(job.getJSONArray("coverUrls").getString(0)).getString("url");
//	                	coverUrl = (coverUrl.indexOf("?")>0 ? coverUrl.substring(0, coverUrl.lastIndexOf("?")) : coverUrl);
//	                	serverVideoPath = "media" +"/" + VideoUtils.getDateDir() + "/" + FileUtils.createFileName() + "." + FileUtils.getSuffix(coverUrl); // 存放在服务器地址
//	                    newFilePath = FileUtils.BASE_PATH + "/" + serverVideoPath;
//	                	HttpClientHelper.sendGetAndSaveFile(coverUrl, null, newFilePath,true);
//	                	resultJson.put("coverUrl", serverVideoPath);
	                	break;
	                }
	            }
			}
			String paramList = String.format("operatorId=%s&downloadUrl=%s&newsUrl=%s&newsTitle=%s&secret=%s",operatorId, downloadUrl, newsUrl, newsTitle, ThirdConstant.KS_SECRET);
			String signature = DigestUtils.md5Hex(paramList);
//			params.put("signature", signature);
//			result_json = HttpClientHelper.sendPost(ThirdConstant.REPORT_DOWNLOAD_URL,params,"UTF-8",true);
			
			
			
			//下载记录记录
			PlmVideoDownloadLogEntity PlmVideoDownloadLog = new PlmVideoDownloadLogEntity();
			PlmVideoDownloadLog.setCreateDate(new Date());
			PlmVideoDownloadLog.setCreateUser(operatorId.longValue());
			PlmVideoDownloadLog.setParamlist(paramList);
			PlmVideoDownloadLog.setRequestJson(resultJson.toString());
			PlmVideoDownloadLog.setResultJson(result_json);
			PlmVideoDownloadLog.setSignature(signature);
			PlmVideoDownloadLog.setHeadUrl(coverUrl);
			PlmVideoDownloadLog.setMediaUrl(downloadUrl);
			PlmVideoDownloadLogService.insert(PlmVideoDownloadLog);
		
        	PlmMaterialEntity plmMaterial = new PlmMaterialEntity();
    		plmMaterial.setMaterialTitle(title);
    		plmMaterial.setMaterialDescription(addres);
    		plmMaterial.setMaterialSrcId(photoId);
    		plmMaterial.setMaterialType(1);
    		plmMaterial.setCreateUser(operatorId);
            plmMaterial.setCreateDate(new Date());
            plmMaterial.setMaterialSources(2);
            plmMaterial.setMaterialCoverOriUrl(coverUrl);
            plmMaterial.setMaterialOriUrl(downloadUrl);
            plmMaterial.setMaterialStatus(0);
            plmMaterial.setIsDelete(0);
            this.materialService.insert(plmMaterial);
            
            MediaDownloadThread thread = new MediaDownloadThread(plmMaterial.getId(),materiaFileProperties.getMediaPath(),materiaFileProperties.getMateriaPath());
			thread.start();
        } catch (Exception e) {
        	e.printStackTrace();
        	throw new RRException("下载失败!");
        }
		return MapUtils.json2map(result_json);
	}
}
