From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/LableAdminController.java |  925 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 463 insertions(+), 462 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LableAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LableAdminController.java
index fdaeb37..bdcfb89 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LableAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LableAdminController.java
@@ -1,462 +1,463 @@
-package com.yeshi.fanli.controller.admin;
-
-import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import net.sf.json.JSONObject;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
-import org.yeshi.utils.JsonUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-import com.yeshi.fanli.entity.bus.lable.Label;
-import com.yeshi.fanli.entity.common.AdminUser;
-import com.yeshi.fanli.exception.goods.quality.LabelException;
-import com.yeshi.fanli.service.AdminUserService;
-import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.lable.LabelGoodsService;
-import com.yeshi.fanli.service.inter.lable.LabelService;
-import com.yeshi.fanli.tag.PageEntity;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
-
-@Controller
-@RequestMapping("admin/new/api/v1/lable")
-public class LableAdminController {
-
-	@Resource
-	private LabelService labelService;
-	
-	@Resource
-	private ConfigService configService;
-	
-	@Resource
-	private AdminUserService adminUserService;
-	
-	@Resource
-	private LabelGoodsService labelGoodsService;
-	
-	/**
-	 * 娣诲姞鏍囩骞朵笂浼犲浘鐗�
-	 * @param callback
-	 * @param label
-	 * @param request
-	 * @param out
-	 */
-	@RequestMapping(value = "saveAdd")
-	public void saveAdd(String callback, Long uid, Label label, HttpServletRequest request, PrintWriter out) {
-		try {
-			String title = label.getTitle();
-			if (StringUtil.isNullOrEmpty(title)) {
-				out.print(JsonUtil.loadFalseResult("鏍囩鍚嶇О涓虹┖"));
-				return;
-			}
-
-			List<Label> labels = labelService.selectByTitle(title.trim());
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			if (labels == null || labels.size() == 0) {
-
-				label.setTitle(label.getTitle().trim());
-
-				if (request instanceof MultipartHttpServletRequest) {
-
-					List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
-
-					if (files != null && files.size() > 0) {
-						labelService.insertSingle(label, admin, files.get(0));
-					} else {
-						labelService.insertSingle(label, admin, null);
-					}
-
-				} else {
-					labelService.insertSingle(label, admin, null);
-				}
-
-				out.print(JsonUtil.loadTrueResult("娣诲姞鎴愬姛"));
-
-			} else {
-				out.print(JsonUtil.loadTrueResult("宸插瓨鍦ㄦ鏍囩"));
-			}
-		} catch (Exception e) {
-			out.print(JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-	
-	
-	
-	/**
-	 * 鎵归噺娣诲姞鏍囩
-	 * @param callback
-	 * @param label
-	 * @param request
-	 * @param out
-	 */
-	@RequestMapping(value = "addBatch")
-	public void addBatch(String callback, String param,	HttpServletRequest request, PrintWriter out) {
-
-		try {
-			Gson gson = new Gson();
-			List<Label> labs = gson.fromJson(param,	new TypeToken<ArrayList<Label>>() {}.getType());
-		
-			List<Label> newList = new ArrayList<Label>();
-			if (labs == null || labs.size() == 0) {
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁")));
-				return;
-			} 
-			
-			for (Label label: labs) {
-				String title = label.getTitle();
-				if (!StringUtil.isNullOrEmpty(title)) {
-					
-					List<Label> labels = labelService.selectByTitle(title.trim());
-					if (labels == null || labels.size() == 0) {
-						newList.add(label);
-					}
-				}
-			}
-			
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			labelService.insertList(newList, admin);
-
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛")));
-		} catch (LabelException e) {
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("娣诲姞寮傚父")));
-			e.printStackTrace();
-		}
-
-	}
-	
-	
-
-	
-	/**
-	 * 淇濆瓨淇敼鏍囩
-	 * @param callback
-	 * @param label
-	 * @param request
-	 * @param out
-	 */
-	@RequestMapping(value = "saveModify")
-	public void saveModify(String callback, Label label, PrintWriter out) {
-		
-		try {
-			Long id = label.getId();
-			Label resultObj = labelService.selectByPrimaryKey(id);
-			
-			if (resultObj == null) {
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�")));
-			} else {
-				Date nowTime = new Date();
-				label.setUpdatetime(nowTime);
-				// 閫夋嫨鎬ф洿鏂版暟鎹�
-				String title = label.getTitle();
-				if (StringUtil.isNullOrEmpty(title)) {
-					out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏍囩鍚嶇О涓嶈兘涓虹┖")));
-				} else {
-					List<Label> labels = labelService.selectByTitle(label.getTitle().trim());
-					
-					if (labels != null && labels.size() > 0) {
-						out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏍囩鍚嶇О閲嶅锛屼慨鏀瑰け璐�")));
-					} else {
-						
-						int result = labelService.updateByPrimaryKeySelective(label);
-						
-						if (result > 0) {
-							out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("淇敼鎴愬姛")));
-						} else {
-							out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("淇敼澶辫触")));
-						}
-					}
-					
-				}
-				
-			}
-			
-		} catch (LabelException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
-		}
-			
-	}
-	
-	
-	/**
-	 * 鎵归噺鍒犻櫎2--- 璺ㄥ煙
-	 * @param callback
-	 * @param ids
-	 * @param out
-	 */
-	@RequestMapping(value = "deleteLable")
-	public void deleteLable(String callback, String ids, PrintWriter out) {
-		try {
-			
-			Gson gson = new Gson();
-			List<Long> labs = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
-			
-			if (labs == null || labs.size() == 0) {
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�")));
-			} else {
-				
-				labelService.deleteBatchByPrimaryKey(labs);
-				
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")));
-			}
-			
-		} catch (LabelException e) {
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触")));
-			e.printStackTrace();
-		}
-		
-	}
-	
-
-	/**
-	 * 涓婁紶excel鏂囦欢
-	 * @param callback
-	 * @param file
-	 * @param request
-	 * @param out
-	 * @param response
-	 */
-	@RequestMapping(value = "uploadFile")
-	public void uploadFile(@RequestParam("file") CommonsMultipartFile file,	HttpServletRequest request,
-			PrintWriter out) {
-
-		if (file == null) {
-			out.print(JsonUtil.loadFalseResult("鏂囦欢涓嶈兘涓虹┖!"));
-			return;
-		}
-
-		try {
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			labelService.analysisExcel(file.getInputStream(), admin);
-
-			out.print((JsonUtil.loadTrueResult("涓婁紶鎴愬姛")));
-			// response.getWriter().print(JsonUtil.loadTrueResult("涓婁紶鎴愬姛"));
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print((JsonUtil.loadFalseResult("涓婁紶澶辫触")));
-		}
-
-	}
-	
-	
-	/**
-	 * 涓婁紶鏍囩鍥剧墖
-	 * @param callback
-	 * @param file
-	 * @param request
-	 * @param out
-	 * @param response
-	 */
-	@RequestMapping(value = "uploadImg")
-	public void uploadImg(Long id, @RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
-
-		try {
-			Label label = labelService.selectByPrimaryKey(id);
-
-			if (label == null) {
-				out.print(JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�"));
-			} else {
-
-				if (file == null) {
-					out.print(JsonUtil.loadFalseResult("鏂囦欢涓嶈兘涓虹┖!"));
-				} else {
-					int result = labelService.uploadPicture(file, label);
-
-					if (result == 0) {
-						out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶鎴愬姛,鏁版嵁鏇存柊澶辫触"));
-					} else if (result == 1) {
-						out.print(JsonUtil.loadTrueResult("鍥剧墖涓婁紶鎴愬姛"));
-					} else {
-						out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触"));
-					}
-				}
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
-		}
-
-	}
-	
-	/**
-	 * 鍒犻櫎鍥剧墖
-	 * @param callback
-	 * @param file
-	 * @param request
-	 * @param out
-	 * @param response
-	 */
-	@RequestMapping(value = "deleteImg")
-	public void deleteImg(String callback, Long id, PrintWriter out) {
-
-		try {
-			Label label = labelService.selectByPrimaryKey(id);
-
-			if (label == null) {
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�")));
-			} else {
-
-				
-				int result = labelService.deleteImg(label);
-				if (result == 0) {
-					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("鍥剧墖鍒犻櫎鎴愬姛,鏁版嵁鏇存柊澶辫触")));
-				} else if (result == 1) {
-					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult("鍥剧墖鍒犻櫎鎴愬姛")));
-				} else {
-					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("鍥剧墖鍒犻櫎澶辫触")));
-				}
-				
-			}
-
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
-		}
-
-	}
-	
-	
-	/**
-	 * 鏌ユ壘鎵�鏈夋爣绛�
-	 * @param callback
-	 * @param pageIndex
-	 * @param key
-	 * @param startTime
-	 * @param endTime
-	 * @param out
-	 */
-	@RequestMapping(value = "query")
-	public void query(String callback, Integer pageIndex, String key, String startTime,
-			String endTime, String orderMode, PrintWriter out) {
-
-		try {
-
-			// 璧峰鏃堕棿 涓虹┖璁剧疆榛樿鍊硷細
-			if (StringUtil.isNullOrEmpty(startTime)) {
-				startTime = "1970-01-01";
-			}
-
-			// 缁撴潫鏃堕棿 涓虹┖璁剧疆榛樿鍊煎綋鍓嶆棩鏈�
-			if (StringUtil.isNullOrEmpty(endTime)) {
-				Date curDate = new Date();
-				endTime = TimeUtil.getSimpleDate(curDate);
-			}
-
-			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-			Date enddate = sdf.parse(endTime);
-			Calendar c = Calendar.getInstance();
-			c.setTime(enddate);
-			c.add(Calendar.DAY_OF_MONTH, 1);// 浠婂ぉ+1澶�
-
-			endTime = sdf.format(c.getTime());
-
-			int pageSize = Constant.PAGE_SIZE;
-			
-			List<Label> labelList = labelService.query((pageIndex - 1) * pageSize, pageSize, key,
-					startTime, endTime,orderMode);
-			
-			if (labelList == null || labelList.size() == 0) {
-				
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈煡鎵惧埌鐩稿叧鏁版嵁")));
-			
-			} else {
-				
-				/* 缁熻姣忎釜鏍囩鍏宠仈鍟嗗搧鏁伴噺*/
-				for (Label label :labelList) {
-					Long relationNum = labelGoodsService.getRelationNum(label.getId());
-					if (relationNum == null)
-						relationNum = 0l;
-					
-					label.setCountRelation(relationNum); // 鍏宠仈鏍囩鍟嗗搧鏁伴噺
-					
-					Long iosClick = label.getIosClick();
-					if (iosClick == null)
-						iosClick = 0l;
-					
-					Long androidClick = label.getAndroidClick();
-					if (androidClick == null)
-						androidClick = 0l;
-					
-					
-					label.setCountClick(iosClick + androidClick);// 鎬荤偣鍑绘暟閲�
-					
-					label.setIosClick(0l);
-					label.setAndroidClick(0l);
-				}
-				
-				
-				int count = labelService.getQueryCount(key, startTime, endTime);
-				
-				int totalPage = count % pageSize == 0 ? count / pageSize : count
-						/ pageSize + 1;
-				PageEntity pe = new PageEntity(pageIndex, pageSize, count,
-						totalPage);
-				
-				GsonBuilder gsonBuilder = new GsonBuilder();  
-				gsonBuilder.serializeNulls(); //閲嶇偣
-				Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
-				
-				JSONObject data = new JSONObject();
-				data.put("pe", pe);
-				data.put("labelList", gson.toJson(labelList));
-				
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")));
-		}
-	}
-	
-	/**
-	 * 鏌ユ壘鎵�鏈夋爣绛�
-	 * @param callback
-	 * @param out
-	 */
-	@RequestMapping(value = "getCountToday")
-	public void getCountToday(String callback, PrintWriter out) {
-
-		try {
-			
-			long totalToday = labelService.getCountToday();
-			
-			Map<String, Object> count = labelService.getCountByEntryMode();
-					
-			JSONObject data = new JSONObject();
-			data.put("count", count);
-			data.put("totalToday", totalToday);
-				
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")));
-		}
-	}
-	
-
-}
+package com.yeshi.fanli.controller.admin;
+
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import com.yeshi.fanli.entity.accept.AdminAcceptData;
+import net.sf.json.JSONObject;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+import org.yeshi.utils.JsonUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.entity.bus.lable.Label;
+import com.yeshi.fanli.entity.common.AdminUser;
+import com.yeshi.fanli.exception.goods.quality.LabelException;
+import com.yeshi.fanli.service.AdminUserService;
+import com.yeshi.fanli.service.inter.config.ConfigService;
+import com.yeshi.fanli.service.inter.lable.LabelGoodsService;
+import com.yeshi.fanli.service.inter.lable.LabelService;
+import com.yeshi.common.entity.PageEntity;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
+
+@Controller
+@RequestMapping("admin/new/api/v1/lable")
+public class LableAdminController {
+
+	@Resource
+	private LabelService labelService;
+	
+	@Resource
+	private ConfigService configService;
+	
+	@Resource
+	private AdminUserService adminUserService;
+	
+	@Resource
+	private LabelGoodsService labelGoodsService;
+	
+	/**
+	 * 娣诲姞鏍囩骞朵笂浼犲浘鐗�
+	 * @param callback
+	 * @param label
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "saveAdd")
+	public void saveAdd(AdminAcceptData acceptData, String callback, Long uid, Label label, HttpServletRequest request, PrintWriter out) {
+		try {
+			String title = label.getTitle();
+			if (StringUtil.isNullOrEmpty(title)) {
+				out.print(JsonUtil.loadFalseResult("鏍囩鍚嶇О涓虹┖"));
+				return;
+			}
+
+			List<Label> labels = labelService.selectByTitle(title.trim());
+			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+			if (labels == null || labels.size() == 0) {
+
+				label.setTitle(label.getTitle().trim());
+
+				if (request instanceof MultipartHttpServletRequest) {
+
+					List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
+
+					if (files != null && files.size() > 0) {
+						labelService.insertSingle(label, admin, files.get(0));
+					} else {
+						labelService.insertSingle(label, admin, null);
+					}
+
+				} else {
+					labelService.insertSingle(label, admin, null);
+				}
+
+				out.print(JsonUtil.loadTrueResult("娣诲姞鎴愬姛"));
+
+			} else {
+				out.print(JsonUtil.loadTrueResult("宸插瓨鍦ㄦ鏍囩"));
+			}
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
+	/**
+	 * 鎵归噺娣诲姞鏍囩
+	 * @param callback
+	 * @param label
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "addBatch")
+	public void addBatch(AdminAcceptData acceptData,String callback, String param,	HttpServletRequest request, PrintWriter out) {
+
+		try {
+			Gson gson = new Gson();
+			List<Label> labs = gson.fromJson(param,	new TypeToken<ArrayList<Label>>() {}.getType());
+		
+			List<Label> newList = new ArrayList<Label>();
+			if (labs == null || labs.size() == 0) {
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁")));
+				return;
+			} 
+			
+			for (Label label: labs) {
+				String title = label.getTitle();
+				if (!StringUtil.isNullOrEmpty(title)) {
+					
+					List<Label> labels = labelService.selectByTitle(title.trim());
+					if (labels == null || labels.size() == 0) {
+						newList.add(label);
+					}
+				}
+			}
+			
+			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+			labelService.insertList(newList, admin);
+
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛")));
+		} catch (LabelException e) {
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("娣诲姞寮傚父")));
+			e.printStackTrace();
+		}
+
+	}
+	
+	
+
+	
+	/**
+	 * 淇濆瓨淇敼鏍囩
+	 * @param callback
+	 * @param label
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "saveModify")
+	public void saveModify(AdminAcceptData acceptData,String callback, Label label, PrintWriter out) {
+		
+		try {
+			Long id = label.getId();
+			Label resultObj = labelService.selectByPrimaryKey(id);
+			
+			if (resultObj == null) {
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�")));
+			} else {
+				Date nowTime = new Date();
+				label.setUpdatetime(nowTime);
+				// 閫夋嫨鎬ф洿鏂版暟鎹�
+				String title = label.getTitle();
+				if (StringUtil.isNullOrEmpty(title)) {
+					out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏍囩鍚嶇О涓嶈兘涓虹┖")));
+				} else {
+					List<Label> labels = labelService.selectByTitle(label.getTitle().trim());
+					
+					if (labels != null && labels.size() > 0) {
+						out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏍囩鍚嶇О閲嶅锛屼慨鏀瑰け璐�")));
+					} else {
+						
+						int result = labelService.updateByPrimaryKeySelective(label);
+						
+						if (result > 0) {
+							out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("淇敼鎴愬姛")));
+						} else {
+							out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("淇敼澶辫触")));
+						}
+					}
+					
+				}
+				
+			}
+			
+		} catch (LabelException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
+		}
+			
+	}
+	
+	
+	/**
+	 * 鎵归噺鍒犻櫎2--- 璺ㄥ煙
+	 * @param callback
+	 * @param ids
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteLable")
+	public void deleteLable(AdminAcceptData acceptData,String callback, String ids, PrintWriter out) {
+		try {
+			
+			Gson gson = new Gson();
+			List<Long> labs = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
+			
+			if (labs == null || labs.size() == 0) {
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�")));
+			} else {
+				
+				labelService.deleteBatchByPrimaryKey(labs);
+				
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")));
+			}
+			
+		} catch (LabelException e) {
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触")));
+			e.printStackTrace();
+		}
+		
+	}
+	
+
+	/**
+	 * 涓婁紶excel鏂囦欢
+	 * @param callback
+	 * @param file
+	 * @param request
+	 * @param out
+	 * @param response
+	 */
+	@RequestMapping(value = "uploadFile")
+	public void uploadFile(AdminAcceptData acceptData,@RequestParam("file") CommonsMultipartFile file,	HttpServletRequest request,
+			PrintWriter out) {
+
+		if (file == null) {
+			out.print(JsonUtil.loadFalseResult("鏂囦欢涓嶈兘涓虹┖!"));
+			return;
+		}
+
+		try {
+			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+			labelService.analysisExcel(file.getInputStream(), admin);
+
+			out.print((JsonUtil.loadTrueResult("涓婁紶鎴愬姛")));
+			// response.getWriter().print(JsonUtil.loadTrueResult("涓婁紶鎴愬姛"));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print((JsonUtil.loadFalseResult("涓婁紶澶辫触")));
+		}
+
+	}
+	
+	
+	/**
+	 * 涓婁紶鏍囩鍥剧墖
+	 * @param callback
+	 * @param file
+	 * @param request
+	 * @param out
+	 * @param response
+	 */
+	@RequestMapping(value = "uploadImg")
+	public void uploadImg(AdminAcceptData acceptData,Long id, @RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
+
+		try {
+			Label label = labelService.selectByPrimaryKey(id);
+
+			if (label == null) {
+				out.print(JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�"));
+			} else {
+
+				if (file == null) {
+					out.print(JsonUtil.loadFalseResult("鏂囦欢涓嶈兘涓虹┖!"));
+				} else {
+					int result = labelService.uploadPicture(file, label);
+
+					if (result == 0) {
+						out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶鎴愬姛,鏁版嵁鏇存柊澶辫触"));
+					} else if (result == 1) {
+						out.print(JsonUtil.loadTrueResult("鍥剧墖涓婁紶鎴愬姛"));
+					} else {
+						out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触"));
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+		}
+
+	}
+	
+	/**
+	 * 鍒犻櫎鍥剧墖
+	 * @param callback
+	 * @param file
+	 * @param request
+	 * @param out
+	 * @param response
+	 */
+	@RequestMapping(value = "deleteImg")
+	public void deleteImg(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
+
+		try {
+			Label label = labelService.selectByPrimaryKey(id);
+
+			if (label == null) {
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("璇ユ爣绛句笉瀛樺湪鎴栧凡琚垹闄�")));
+			} else {
+
+				
+				int result = labelService.deleteImg(label);
+				if (result == 0) {
+					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("鍥剧墖鍒犻櫎鎴愬姛,鏁版嵁鏇存柊澶辫触")));
+				} else if (result == 1) {
+					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult("鍥剧墖鍒犻櫎鎴愬姛")));
+				} else {
+					out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("鍥剧墖鍒犻櫎澶辫触")));
+				}
+				
+			}
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
+		}
+
+	}
+	
+	
+	/**
+	 * 鏌ユ壘鎵�鏈夋爣绛�
+	 * @param callback
+	 * @param pageIndex
+	 * @param key
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "query")
+	public void query(AdminAcceptData acceptData,String callback, Integer pageIndex, String key, String startTime,
+			String endTime, String orderMode, PrintWriter out) {
+
+		try {
+
+			// 璧峰鏃堕棿 涓虹┖璁剧疆榛樿鍊硷細
+			if (StringUtil.isNullOrEmpty(startTime)) {
+				startTime = "1970-01-01";
+			}
+
+			// 缁撴潫鏃堕棿 涓虹┖璁剧疆榛樿鍊煎綋鍓嶆棩鏈�
+			if (StringUtil.isNullOrEmpty(endTime)) {
+				Date curDate = new Date();
+				endTime = TimeUtil.getSimpleDate(curDate);
+			}
+
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+			Date enddate = sdf.parse(endTime);
+			Calendar c = Calendar.getInstance();
+			c.setTime(enddate);
+			c.add(Calendar.DAY_OF_MONTH, 1);// 浠婂ぉ+1澶�
+
+			endTime = sdf.format(c.getTime());
+
+			int pageSize = Constant.PAGE_SIZE;
+			
+			List<Label> labelList = labelService.query((pageIndex - 1) * pageSize, pageSize, key,
+					startTime, endTime,orderMode);
+			
+			if (labelList == null || labelList.size() == 0) {
+				
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏈煡鎵惧埌鐩稿叧鏁版嵁")));
+			
+			} else {
+				
+				/* 缁熻姣忎釜鏍囩鍏宠仈鍟嗗搧鏁伴噺*/
+				for (Label label :labelList) {
+					Long relationNum = labelGoodsService.getRelationNum(label.getId());
+					if (relationNum == null)
+						relationNum = 0l;
+					
+					label.setCountRelation(relationNum); // 鍏宠仈鏍囩鍟嗗搧鏁伴噺
+					
+					Long iosClick = label.getIosClick();
+					if (iosClick == null)
+						iosClick = 0l;
+					
+					Long androidClick = label.getAndroidClick();
+					if (androidClick == null)
+						androidClick = 0l;
+					
+					
+					label.setCountClick(iosClick + androidClick);// 鎬荤偣鍑绘暟閲�
+					
+					label.setIosClick(0l);
+					label.setAndroidClick(0l);
+				}
+				
+				
+				int count = labelService.getQueryCount(key, startTime, endTime);
+				
+				int totalPage = count % pageSize == 0 ? count / pageSize : count
+						/ pageSize + 1;
+				PageEntity pe = new PageEntity(pageIndex, pageSize, count,
+						totalPage);
+				
+				GsonBuilder gsonBuilder = new GsonBuilder();  
+				gsonBuilder.serializeNulls(); //閲嶇偣
+				Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+				
+				JSONObject data = new JSONObject();
+				data.put("pe", pe);
+				data.put("labelList", gson.toJson(labelList));
+				
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")));
+		}
+	}
+	
+	/**
+	 * 鏌ユ壘鎵�鏈夋爣绛�
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "getCountToday")
+	public void getCountToday(AdminAcceptData acceptData,String callback, PrintWriter out) {
+
+		try {
+			
+			long totalToday = labelService.getCountToday();
+			
+			Map<String, Object> count = labelService.getCountByEntryMode();
+					
+			JSONObject data = new JSONObject();
+			data.put("count", count);
+			data.put("totalToday", totalToday);
+				
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")));
+		}
+	}
+	
+
+}

--
Gitblit v1.8.0