From 9d35ba657fa5e3add766405d76e3ff8c4dcd4ad4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 04 七月 2020 15:38:00 +0800
Subject: [PATCH] 多系统兼容优化

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java |   47 +++++++++++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java
index 1ebcc8a..881869b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java
@@ -9,6 +9,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.accept.AdminAcceptData;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.yeshi.utils.JsonUtil;
@@ -86,6 +87,31 @@
 		}
 	}
 
+	
+	/**
+	 * 鏂板/淇敼
+	 * 
+	 * @param callback
+	 * @param special
+	 * @param out
+	 */
+	@RequestMapping(value = "saveInfo")
+	public void saveInfo(String callback, PushGoods pushGoods, String arrayIOS,	String arrayAndroid, PrintWriter out) {
+		try {
+			// 鐗堟湰澶勭悊
+			convertVersion(pushGoods, arrayIOS, arrayAndroid);
+			// 淇濆瓨
+			pushGoodsService.saveInfo(pushGoods);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛"));
+		} catch (PushGoodsException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
 	/**
 	 * 鍒犻櫎
 	 * 
@@ -150,10 +176,8 @@
 			Date controlTime = pushGoods.getControlTime();
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 			if (controlTime == null) {
-				pushGoods.setTimeTask(false);
 				pushGoods.setControlTime_str("");
 			} else {
-				pushGoods.setTimeTask(true);
 				pushGoods.setControlTime_str(sdf.format(controlTime));
 			}
 			
@@ -203,7 +227,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "query")
-	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
+	public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
 
 		if (pageIndex == null || pageIndex < 1) {
 			pageIndex = 1;
@@ -215,22 +239,19 @@
 
 		try {
 
-			List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
-
+			List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem());
 			if (list == null || list.size() == 0) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
 				return;
 			}
 
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 			for (PushGoods pushGoods : list) {
 				
 				Date controlTime = pushGoods.getControlTime();
-				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 				if (controlTime == null) {
-					pushGoods.setTimeTask(false);
 					pushGoods.setControlTime_str("");
 				} else {
-					pushGoods.setTimeTask(true);
 					pushGoods.setControlTime_str(sdf.format(controlTime));
 				}
 				
@@ -241,7 +262,7 @@
 				convertVersionList(pushGoods);
 			}
 
-			long count = pushGoodsService.countQuery(key, state);
+			long count = pushGoodsService.countQuery(key, state,acceptData.getSystem());
 
 			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
 			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -266,23 +287,19 @@
 	/**
 	 *   鍟嗗搧鎺ㄩ��
 	 * 
-	 * @param id 鎺ㄩ�乮d
 	 * @param out
 	 * @throws Exception
 	 */
 	@RequestMapping(value = "push")
 	public void push(String callback, String idArray, PrintWriter out) throws Exception {
-
 		if (idArray == null || idArray.trim().length() == 0) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉鑳戒负绌�"));
 			return;
 		}
 		
 		try {
-			
 			Gson gson = new Gson();
 			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
-		
 			if (list == null || list.size() == 0) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉鑳戒负绌�"));
 				return;
@@ -291,9 +308,7 @@
 			for (Long id: list) {
 				pushGoodsService.handPush(id);
 			}
-			
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
-			
 		} catch (PushException e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
 		} catch (PushGoodsException e) {
@@ -370,7 +385,7 @@
 	  } else {
 		  JSONObject json = JSONObject.fromObject(versions);
 			
-			String versionsIOS = json.getString("IOS");
+			String versionsIOS = json.optString("IOS");
 			if (versionsIOS != null && versionsIOS.trim().length() > 0) {
 				listIOS = Arrays.asList(versionsIOS.split(","));
 			}

--
Gitblit v1.8.0