Browse Source

图片压缩包批量导入

2510966293@qq.com 5 years ago
parent
commit
403ec50b6b

+ 10 - 0
pom.xml

@@ -434,6 +434,16 @@
       <version>2.5.1</version>
     </dependency>
 
+    <!-- org.apache.tools -->
+    <dependency>
+
+      <groupId>org.apache.ant</groupId>
+
+      <artifactId>ant</artifactId>
+
+      <version>1.9.7</version>
+
+    </dependency>
 
 
 

+ 92 - 1
src/main/java/com/yc/education/controller/admin/AdminsBackController.java

@@ -6,6 +6,7 @@ import com.yc.education.service.AdminsService;
 import com.yc.education.util.AjaxMessage;
 import com.yc.education.util.AppConst;
 import com.yc.education.util.SM4;
+import com.yc.education.util.ZipRarUtil;
 import net.sf.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -260,8 +261,98 @@ public class AdminsBackController extends BaseController {
 				}
 			}
 		}
-		// pathString="cao";
 		return allpath;
 	}
 
+	/**
+	 * @Description: 图片导入
+	 * @Author: BlueSky
+	 * @CreateTime: 2019/9/26 11:52
+	 */
+	@ResponseBody
+	@RequestMapping("imgadd.html")
+	public AjaxMessage<Object> addimg(String url,HttpServletRequest request, String type) throws Exception {
+		String rootPath = request.getSession().getServletContext().getRealPath("/");
+		String contextPath = request.getSession().getServletContext().getContextPath();
+		System.out.println(url);
+
+		// 上传服务器时把下面注释去除
+//        url = url.substring(8, url.length());
+		int num = rootPath.split("\\\\").length;
+		System.out.println(num);
+		if ("zip".equals(type)) {
+			ZipRarUtil.unzip(rootPath + url, rootPath + "/upload/img/");
+		} else {
+			ZipRarUtil.unrar(rootPath + url, rootPath + "/upload/img/", num);
+		}
+
+		AjaxMessage<Object> ajax = new AjaxMessage<>();
+
+		ajax.setMsg("所有文件已经正确导入!");
+		File file = new File(rootPath + url);
+		if(file!=null){
+			file.delete();
+		}
+		return ajax;
+	}
+
+
+	/**
+	 * @Description: ajax异步上传
+	 * @Author: BlueSky
+	 * @CreateTime: 2019/9/26 14:01
+	 */
+	@ResponseBody
+	@RequestMapping(value = "uploadImages.html", method = RequestMethod.POST)
+	public String uploadImages(HttpServletRequest request)
+			throws IllegalStateException, IOException {
+		System.out.println("进入控制层");
+		String pathString="";
+		@SuppressWarnings("unused")
+		String allpath="";
+		List<String> paths = new ArrayList<>();
+		// 设置上下文
+		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
+				request.getSession().getServletContext());
+		// 检查form是否有enctype="multipart/form-data"
+		if (multipartResolver.isMultipart(request)) {
+			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
+			Iterator<String> iter = multiRequest.getFileNames();
+			while (iter.hasNext()) {
+				// 由CommonsMultipartFile继承而来,拥有上面的方法.
+				MultipartFile file = multiRequest.getFile(iter.next());
+				System.out.println("file:" + file.getSize());
+				// 如果文件不为空,则进行处理
+				if (!file.isEmpty()) {
+					// 存放产生的随机数
+					String sms = getRandomone();
+					// 对图片文件名进行处理,取得最后的6个字符,然后以"."为分隔符取得文件后缀
+					String originalFileName = file.getOriginalFilename();
+					// 取得后缀
+					String suffixString = originalFileName
+							.substring(originalFileName.lastIndexOf(".") + 1);
+					// 设定文件名称
+					String fileName =  sms+new Date().getTime() + "." + suffixString;
+					//
+					String path = request.getSession().getServletContext().getRealPath("/");
+					String contextPath = request.getSession().getServletContext().getContextPath();
+					File localFile = new File(path+"ajaxupload\\"+fileName);
+					System.err.println(path+"ajaxupload\\"+fileName);
+					try {
+						file.transferTo(localFile);
+						// 将图片名称和相对路径存到数据库中
+						paths.add("/pic/chat/" + fileName);
+						pathString = contextPath+"/ajaxupload/"+fileName;
+						allpath = path+"ajaxupload/"+fileName;
+					} catch (IllegalStateException e) {
+						e.printStackTrace();
+					} catch (IOException e) {
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+		return pathString;
+	}
+
 }

+ 4 - 4
src/main/java/com/yc/education/controller/admin/OwnerServiceTypeController.java

@@ -203,12 +203,12 @@ public class OwnerServiceTypeController {
                 if (hssfRow != null) {
                     OwnerServiceType own = new OwnerServiceType();
                     own.setTypeName(getValue(hssfRow.getCell(0)));
+                    own.setTypeImage("/upload/img/"+getValue(hssfRow.getCell(1)));
                     try {
-                        own.setTypeSort(Integer.parseInt(hssfRow.getCell(1).toString()));
+                        own.setTypeSort(Integer.parseInt(hssfRow.getCell(2).toString()));
                     }catch (Exception e){
                         own.setTypeSort(0);
                     }
-                    own.setTypeImage("url");
 
                     if (own.getTypeName() != null && !"".equals(own.getTypeName())) {
                         list.add(own);
@@ -232,12 +232,12 @@ public class OwnerServiceTypeController {
                 //获取表格数据
                 OwnerServiceType own = new OwnerServiceType();
                 own.setTypeName(getValue(row.getCell((short)0)));
+                own.setTypeImage("/upload/img/"+getValue(row.getCell((short)1)));
                 try {
-                    own.setTypeSort(Integer.valueOf(getValue(row.getCell((short)1))));
+                    own.setTypeSort(Integer.valueOf(getValue(row.getCell((short)2))));
                 }catch (Exception e){
                     own.setTypeSort(0);
                 }
-                own.setTypeImage("url");
                 if (own.getTypeName() != null && !"".equals(own.getTypeName()) ) {
                     list.add(own);
                 }

+ 20 - 5
src/main/java/com/yc/education/controller/admin/ServiceCategoryAdminController.java

@@ -203,9 +203,22 @@ public class ServiceCategoryAdminController {
         return ViewUtil.returnview(rows, "serviceCategoryList.html?typeid=" + service.getpId(), "服务列表");
     }
 
+    /**
+    * @Description: 图片导入 -- 跳转
+    * @Author: BlueSky
+    * @CreateTime: 2019/9/26 14:23
+    */
+    @RequestMapping("serviceCategoryImg.html")
+    public ModelAndView serviceCategoryImg() {
+        return new ModelAndView();
+    }
 
 
-    // 进入导入数据 页面
+    /**
+    * @Description: 进入导入数据页面 -- 跳转
+    * @Author: BlueSky
+    * @CreateTime: 2019/9/26 14:23
+    */
     @RequestMapping("serviceCategoryExcel.html")
     public ModelAndView serviceCategoryExcel() {
         return new ModelAndView();
@@ -244,9 +257,10 @@ public class ServiceCategoryAdminController {
                         car.setpId(1);  //出错默认第一大类
                     }
                     car.setName(getValue(hssfRow.getCell(1)));
-                    car.setServeType(getValue(hssfRow.getCell(2)));
+                    car.setImg("/upload/img/"+getValue(hssfRow.getCell(2)));
+                    car.setServeType(getValue(hssfRow.getCell(3)));
                     try {
-                        car.setpSort(Short.valueOf(getValue(hssfRow.getCell(3))));
+                        car.setpSort(Short.valueOf(getValue(hssfRow.getCell(4))));
                     }catch (Exception e){
                         car.setpSort((short)0);
                     }
@@ -287,9 +301,10 @@ public class ServiceCategoryAdminController {
                     car.setpId(1);  //出错默认第一大类
                 }
                 car.setName(getValue(row.getCell((short)1)));
-                car.setServeType(getValue(row.getCell((short)2)));
+                car.setImg("/upload/img/"+getValue(row.getCell((short)2)));
+                car.setServeType(getValue(row.getCell((short)3)));
                 try {
-                    car.setpSort(Short.valueOf(getValue(row.getCell((short)3))));
+                    car.setpSort(Short.valueOf(getValue(row.getCell((short)4))));
                 }catch (Exception e){
                     car.setpSort((short)0);
                 }

+ 423 - 0
src/main/java/com/yc/education/util/ZipRarUtil.java

@@ -0,0 +1,423 @@
+package com.yc.education.util;
+
+import de.innosystec.unrar.Archive;
+import de.innosystec.unrar.rarfile.FileHeader;
+import org.apache.tools.zip.ZipEntry;
+import org.apache.tools.zip.ZipFile;
+import org.apache.tools.zip.ZipOutputStream;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  解压zip与Rar文件
+ * @author YaoShiHang
+ *
+ */
+public class ZipRarUtil {
+	private static final int BUFFEREDSIZE = 1024;
+
+	
+
+	/**
+	 * 解压zip格式的压缩文件到当前文件夹
+	 * @param zipFileName
+	 * @throws Exception
+	 */
+	@SuppressWarnings("unchecked")
+	public  static  synchronized void unzipFile(String zipFileName) throws Exception {
+		try {
+			File f = new File(zipFileName);
+			ZipFile zipFile = new ZipFile(zipFileName);
+			if ((!f.exists()) && (f.length() <= 0)) {
+				throw new Exception("要解压的文件不存在!");
+			}
+			String strPath, gbkPath, strtemp;
+			File tempFile = new File(f.getParent());
+			strPath = tempFile.getAbsolutePath();
+			java.util.Enumeration e = zipFile.getEntries();
+			while (e.hasMoreElements()) {
+				org.apache.tools.zip.ZipEntry zipEnt = (ZipEntry) e.nextElement();
+				gbkPath = zipEnt.getName();
+				if (zipEnt.isDirectory()) {
+					strtemp = strPath + "/" + gbkPath;
+					File dir = new File(strtemp);
+					dir.mkdirs();
+					continue;
+				} else {
+					// 读写文件
+					InputStream is = zipFile.getInputStream(zipEnt);
+					BufferedInputStream bis = new BufferedInputStream(is);
+					gbkPath = zipEnt.getName();
+					strtemp = strPath + "/" + gbkPath;
+
+					// 建目录
+					String strsubdir = gbkPath;
+					for (int i = 0; i < strsubdir.length(); i++) {
+						if (strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
+							String temp = strPath + "/" + strsubdir.substring(0, i);
+							File subdir = new File(temp);
+							if (!subdir.exists())
+								subdir.mkdir();
+						}
+					}
+					FileOutputStream fos = new FileOutputStream(strtemp);
+					BufferedOutputStream bos = new BufferedOutputStream(fos);
+					int c;
+					while ((c = bis.read()) != -1) {
+						bos.write((byte) c);
+					}
+					bos.close();
+					fos.close();
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
+	/**
+	 * 解压zip格式的压缩文件到指定位置
+	 * 
+	 * @param zipFileName
+	 *            压缩文件
+	 * @param extPlace
+	 *            解压目录
+	 * @throws Exception
+	 */
+	@SuppressWarnings("unchecked")
+	public  static  synchronized List<String> unzip(String zipFileName, String extPlace) throws Exception {
+		try {
+			(new File(extPlace)).mkdirs();
+			File f = new File(zipFileName);
+			List<String> nameList=new ArrayList<>();
+			ZipFile zipFile = new ZipFile(zipFileName);
+			if ((!f.exists()) && (f.length() <= 0)) {
+				throw new Exception("要解压的文件不存在!");
+			}
+			String strPath, gbkPath, strtemp;
+			File tempFile = new File(extPlace);
+			strPath = tempFile.getAbsolutePath();
+			java.util.Enumeration e = zipFile.getEntries();
+			while (e.hasMoreElements()) {
+				org.apache.tools.zip.ZipEntry zipEnt = (ZipEntry) e.nextElement();
+				gbkPath = zipEnt.getName();
+				System.err.println(gbkPath);
+				String [] name =gbkPath.split("/");
+				
+				System.err.println(name.length);
+				for (String names : name) {
+					if(name.length==1){
+						
+						nameList.add(names);
+						
+						/*
+						String [] name2 =names.split("\\.");
+						if(name2.length>0){
+							nameList.add(name2[0]);
+						}else{
+							nameList.add(names);
+						}*/
+					}
+					System.err.println(names);
+				}
+				
+				
+				
+				if (zipEnt.isDirectory()) {
+					strtemp = strPath + File.separator + gbkPath;
+					File dir = new File(strtemp);
+					dir.mkdirs();
+					continue;
+				} else {
+					// 读写文件
+					InputStream is = zipFile.getInputStream(zipEnt);
+					BufferedInputStream bis = new BufferedInputStream(is);
+					gbkPath = zipEnt.getName();
+					strtemp = strPath + File.separator + gbkPath;
+
+					
+					// 建目录
+					String strsubdir = gbkPath;
+					for (int i = 0; i < strsubdir.length(); i++) {
+						if (strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
+							String temp = strPath + File.separator + strsubdir.substring(0, i);
+							File subdir = new File(temp);
+							if (!subdir.exists())
+								subdir.mkdir();
+						}
+					}
+					FileOutputStream fos = new FileOutputStream(strtemp);
+					BufferedOutputStream bos = new BufferedOutputStream(fos);
+					int c;
+					while ((c = bis.read()) != -1) {
+						bos.write((byte) c);
+					}
+					bos.close();
+					fos.close();
+				}
+			}
+			
+			return nameList;
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
+	/**
+	 * 解压zip格式的压缩文件到指定位置
+	 * 
+	 * @param zipFileName
+	 *            压缩文件
+	 * @param extPlace
+	 *            解压目录
+	 * @throws Exception
+	 */
+	@SuppressWarnings("unchecked")
+	public  static  synchronized void unzip(String zipFileName, String extPlace, boolean whether) throws Exception {
+		try {
+			(new File(extPlace)).mkdirs();
+			File f = new File(zipFileName);
+			ZipFile zipFile = new ZipFile(zipFileName);
+			if ((!f.exists()) && (f.length() <= 0)) {
+				throw new Exception("要解压的文件不存在!");
+			}
+			String strPath, gbkPath, strtemp;
+			File tempFile = new File(extPlace);
+			strPath = tempFile.getAbsolutePath();
+			java.util.Enumeration e = zipFile.getEntries();
+			while (e.hasMoreElements()) {
+				org.apache.tools.zip.ZipEntry zipEnt = (ZipEntry) e.nextElement();
+				gbkPath = zipEnt.getName();
+				if (zipEnt.isDirectory()) {
+					strtemp = strPath + File.separator + gbkPath;
+					File dir = new File(strtemp);
+					dir.mkdirs();
+					continue;
+				} else {
+					
+					InputStream is = zipFile.getInputStream(zipEnt);
+					BufferedInputStream bis = new BufferedInputStream(is);
+					gbkPath = zipEnt.getName();
+					strtemp = strPath + File.separator + gbkPath;
+
+					// 建目录
+					String strsubdir = gbkPath;
+					for (int i = 0; i < strsubdir.length(); i++) {
+						if (strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
+							String temp = strPath + File.separator + strsubdir.substring(0, i);
+							File subdir = new File(temp);
+							if (!subdir.exists())
+								subdir.mkdir();
+						}
+					}
+					FileOutputStream fos = new FileOutputStream(strtemp);
+					BufferedOutputStream bos = new BufferedOutputStream(fos);
+					int c;
+					while ((c = bis.read()) != -1) {
+						bos.write((byte) c);
+					}
+					bos.close();
+					fos.close();
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
+	/**
+	 * 压缩zip格式的压缩文件
+	 * 
+	 * @param inputFilename
+	 *            压缩的文件或文件夹及详细路径
+	 * @param zipFilename
+	 *            输出文件名称及详细路径
+	 * @throws IOException
+	 */
+	public  static synchronized void zip(String inputFilename, String zipFilename) throws IOException {
+		zip(new File(inputFilename), zipFilename);
+	}
+
+	/**
+	 * 压缩zip格式的压缩文件
+	 * 
+	 * @param inputFile
+	 *            需压缩文件
+	 * @param zipFilename
+	 *            输出文件及详细路径
+	 * @throws IOException
+	 */
+	public synchronized static void zip(File inputFile, String zipFilename) throws IOException {
+		ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFilename));
+		try {
+			zip(inputFile, out, "");
+		} catch (IOException e) {
+			throw e;
+		} finally {
+			out.close();
+		}
+	}
+
+	/**
+	 * 压缩zip格式的压缩文件
+	 * 
+	 * @param inputFile
+	 *            需压缩文件
+	 * @param out
+	 *            输出压缩文件
+	 * @param base
+	 *            结束标识
+	 * @throws IOException
+	 */
+	@SuppressWarnings("unused")
+	private synchronized static void zip(File inputFile, ZipOutputStream out, String base) throws IOException {
+		if (inputFile.isDirectory()) {
+			File[] inputFiles = inputFile.listFiles();
+			out.putNextEntry(new ZipEntry(base + "/"));
+			base = base.length() == 0 ? "" : base + "/";
+			for (int i = 0; i < inputFiles.length; i++) {
+				zip(inputFiles[i], out, base + inputFiles[i].getName());
+			}
+		} else {
+			if (base.length() > 0) {
+				out.putNextEntry(new ZipEntry(base));
+			} else {
+				out.putNextEntry(new ZipEntry(inputFile.getName()));
+			}
+			FileInputStream in = new FileInputStream(inputFile);
+			try {
+				int c;
+				byte[] by = new byte[BUFFEREDSIZE];
+				while ((c = in.read(by)) != -1) {
+					out.write(by, 0, c);
+				}
+			} catch (IOException e) {
+				throw e;
+			} finally {
+				in.close();
+			}
+		}
+	}
+
+	
+
+	/**
+	 * 执行实例
+	 * 
+	 * @param args
+	 */
+	public static void main(String[] args) throws Exception {
+		ZipRarUtil decompression = new ZipRarUtil();
+		//decompression.unzipFile("G:/tomcat.zip");
+		 //decompression.unzip("G:/img.zip","G://img");
+		// decompression.zip("c:/Inetpub", "c:/Inetpub.zip");
+		//decompression.unrar("G:/1.rar", "G:/t/");
+
+	}
+
+	/**
+	 * 解压 rar 
+	 * @param sourceRar
+	 * @param destDir
+	 * @throws Exception
+	 */
+	public static List<String>  unrar(String sourceRar, String destDir,int num) throws Exception {
+		Archive archive = null;
+		FileOutputStream fos = null;
+		List<String> nameList=new ArrayList<>();
+	
+		try {
+			archive = new Archive(new File(sourceRar));
+			FileHeader fh = archive.nextFileHeader();
+			while (fh != null) {
+				if (!fh.isDirectory()) {
+					// 根据不同的操作系统拿到相应的 destDirName 和 destFileName
+					String compressFileName = fh.getFileNameString().trim();
+					String [] name =compressFileName.split("\\\\");
+					System.out.println(name.length);
+					
+					if(!nameList.contains(name[0])){
+						nameList.add(name[0]);
+					}
+					/*if(name.length==2){
+						if(!nameList.contains(name[0])){
+							nameList.add(name[0]);
+						}
+					}else{		
+						String [] name2 =name[0].split("\\.");
+						nameList.add(name2[0]);
+					}*/
+					String destFileName = "";
+					String destDirName = "";
+					// 非windows系统
+					if (File.separator.equals("/")) {
+						destFileName = destDir + compressFileName.replaceAll("\\\\", "/");
+						destDirName = destFileName.substring(0, destFileName.lastIndexOf("/")); // windows系统
+					} else {
+						destFileName = destDir + compressFileName.replaceAll("/", "\\\\");
+						String [] str=destFileName.split("\\\\");
+						if(str.length>num+1){
+							destDirName =  destFileName.substring(0, destFileName.lastIndexOf("\\"));;
+							
+						}else{
+							destDirName = destDir;
+						}
+						System.out.println(str[str.length-1]);
+					}
+					
+					File dir = new File(destDirName);
+					
+					
+					if (!dir.exists() || !dir.isDirectory()) {
+						dir.mkdirs();
+					} // 解压文件
+					fos = new FileOutputStream(new File(destFileName));
+					archive.extractFile(fh, fos);
+					fos.close();
+					fos = null;
+				}
+				fh = archive.nextFileHeader();
+			}
+			archive.close();
+			return nameList;
+		} catch (Exception e) {
+			
+			throw e;
+			
+		} finally {
+			if (fos != null) {
+				try {
+					fos.close();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+			if (archive != null) {
+				try {
+					archive.close();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	
+	
+	
+	
+	
+	 
+	
+	
+	
+	
+	
+	
+
+}

+ 3 - 2
src/main/resources/mapper/WServiceCategorymapper.xml

@@ -14,16 +14,17 @@
         <result column="is_delete" property="isDelete" jdbcType="CHAR"/>
         <result column="is_top" property="isTop" jdbcType="CHAR"/>
         <result column="is_show" property="isShow" jdbcType="CHAR"/>
+        <result column="img" property="img" jdbcType="VARCHAR"/>
         <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
         <result column="modified_date" property="modifiedDate" jdbcType="TIMESTAMP"/>
     </resultMap>
     <!-- 添加集合数据 -->
     <insert id="addByList" useGeneratedKeys="true" parameterType="java.util.List">
         insert into
-        service_category(`name`,p_id,g_sort,p_sort,s_sort,serve_type,status,is_delete,is_top,is_show,create_date,modified_date)
+        service_category(`name`,p_id,g_sort,p_sort,s_sort,serve_type,status,is_delete,is_top,is_show,img,create_date,modified_date)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.name},#{item.pId},#{item.gSort},#{item.pSort},#{item.sSort},#{item.serveType},#{item.status},#{item.isDelete},#{item.isTop},#{item.isShow},#{item.createDate},#{item.modifiedDate})
+            (#{item.name},#{item.pId},#{item.gSort},#{item.pSort},#{item.sSort},#{item.serveType},#{item.status},#{item.isDelete},#{item.isTop},#{item.isShow},#{item.img},#{item.createDate},#{item.modifiedDate})
         </foreach>
     </insert>
 

+ 2 - 0
src/main/webapp/WEB-INF/jsp/admin/index.jsp

@@ -87,6 +87,7 @@
 					<ul>
 						<li><a data-href="serviceCategoryList.html" data-title="服务列表" href="javascript:void(0)">服务列表</a></li>
 						<li><a data-href="serviceCategoryExcel.html" data-title="服务导入" href="javascript:void(0)">服务导入</a></li>
+						<li><a data-href="serviceCategoryImg.html" data-title="图片导入" href="javascript:void(0)">图片导入</a></li>
 					</ul>
 				</dd>
 			</dl>
@@ -100,6 +101,7 @@
 						<li><a data-href="ownerServiceTypeList.html" data-title="类型列表" href="javascript:void(0)">类型列表</a></li>
 						<li><a data-href="ownerServiceList.html" data-title="信息列表" href="javascript:void(0)">信息列表</a></li>
 						<li><a data-href="carServiceCategoryExcel.html" data-title="车主服务导入" href="javascript:void(0)">车主服务导入</a></li>
+						<li><a data-href="serviceCategoryImg.html" data-title="图片导入" href="javascript:void(0)">图片导入</a></li>
 					</ul>
 				</dd>
 			</dl>

+ 2 - 0
src/main/webapp/WEB-INF/jsp/admin/ownerServiceTypeList.jsp

@@ -64,6 +64,7 @@
             <tr class="text-c">
                 <th width="80" ><input  id="checked_all"   type="checkbox"  >全选</th>
                 <th width="80">ID</th>
+                <th width="120">类型图标</th>
                 <th width="120">类型名称</th>
                 <th width="120">排序</th>
                 <th width="200">操作</th>
@@ -74,6 +75,7 @@
                 <tr class="text-c">
                     <th><input   name="ck_pro"    value="${item.id }"   type="checkbox"  ></th>
                     <td>${item.id}</td>
+                    <td><img src="${item.typeImage}" style="width: 50px;height: 50px"></td>
                     <td class="text-l">${item.typeName}</td>
                     <%--<td><fmt:formatDate value="${item.createDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>--%>
                     <td>${item.typeSort}</td>

+ 224 - 0
src/main/webapp/WEB-INF/jsp/admin/serviceCategoryImg.jsp

@@ -0,0 +1,224 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/h-ui/css/H-ui.min.css"/>
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/css/H-ui.admin.css"/>
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/Hui-iconfont/1.0.7/iconfont.css"/>
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/icheck/icheck.css"/>
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/skin/default/skin.css" id="skin"/>
+    <link rel="stylesheet" type="text/css"
+          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/css/style.css"/>
+    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/css/jquery.mloading.css">
+    <script type="text/javascript"
+            src="${pageContext.request.contextPath}/static/admin/manage/js/jquery.min.js"></script>
+    <script src="${pageContext.request.contextPath}/static/admin/js/jquery.mloading.js"></script>
+    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/js/ajaxfileupload.js"></script>
+    <script type="text/javascript"
+            src="${pageContext.request.contextPath}/static/admin/manage/js/jquery.validate.min.js"></script>
+    <script type="text/javascript"
+            src="${pageContext.request.contextPath}/static/admin/manage/js/validate-methods.js"></script>
+    <script type="text/javascript"
+            src="${pageContext.request.contextPath}/static/admin/manage/js/messages_zh.min.js"></script>
+    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/manage/js/layer.js"></script>
+    <title>后台管理</title>
+</head>
+<body>
+<nav class="breadcrumb">
+    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
+       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
+</nav>
+<div>
+    <div class="page-container">
+
+        <form action="imgadd.html" method="post" onsubmit="return check()" enctype="multipart/form-data"
+              class="form form-horizontal" id="form-admin-add">
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-2">选择文件:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+
+                    <input type="file" onchange="fileChange(this);" id="fileToUpload" class="input-text"
+                           name="fileToUpload">
+                    <input type="hidden" name="type" value="" id="type"/>
+                </div>
+            </div>
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-2">图片格式:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+
+                    <label class="text">说明:
+                        图片导入使用压缩文件格式(ZIP或RAR),确保图片名和Excel导入时填写的名称一致!
+                        <br/> 打包方式:将需要上传的图片全部选中,在选中图片上方点击鼠标右键,在右击弹出列表中点击“添加到XXX.zip”选项,最后选中刚生成的压缩包上传就好了。
+                        <br/> <br/>注意:* 多次上传相同文件名图片会导致数据覆盖!建议上传接近于正方形的图片效果最佳,建议尺寸300x300!
+                    </label>
+
+                </div>
+            </div>
+            <div class="row cl">
+                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
+                    <input class="btn btn-primary radius" type="button" onclick="$('#form-admin-add').submit();"
+                           value="提交">
+                </div>
+            </div>
+        </form>
+        <div class="moban">
+
+        </div>
+
+    </div>
+
+    <style>
+        .piclist {
+            width: 80%;
+            height: auto;
+            margin: 0 auto;
+        }
+
+        .
+        .piclist a {
+            display: block;
+            width: 100%;
+            height: 40px;
+            line-height: 40px;
+            text-align: right;
+            font-size: 16px;
+            color: #333;
+        }
+
+        .nypic {
+            width: 23%;
+            height: auto;
+            margin: 1% 0 0 1%;
+            float: left;
+        }
+
+        .nypic img {
+            display: block;
+            width: 100%;
+            height: auto;
+        }
+    </style>
+    <div class="page-container">
+
+        <div id="carimg" class="piclist clearfix">
+            <div class="nypic"><img alt="" src=""></div>
+        </div>
+    </div>
+</div>
+<script type="text/javascript">
+
+
+    var isfile = 0;
+
+    var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
+
+    function fileChange(target) {
+
+        var fileSize = 0;
+        if (isIE && !target.files) {
+            var filePath = target.value;
+            var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
+            var file = fileSystem.GetFile(filePath);
+            fileSize = file.Size;
+        } else {
+            fileSize = target.files[0].size;
+        }
+        var size = fileSize / 1024;
+        if (size > 100000) {
+            isfile = 0;
+            layer.msg("单次上传文件不能大于100M!", {icon: 2, time: 2000});
+            return;
+        }
+        var filepath = document.getElementById("fileToUpload").value;
+        //为了避免转义反斜杠出问题,这里将对其进行转换
+        var re = /(\\+)/g;
+        var filename = filepath.replace(re, "#");
+        //对路径字符串进行剪切截取
+        var one = filename.split("#");
+        //获取数组中最后一个,即文件名
+        var two = one[one.length - 1];
+        //再对文件名进行截取,以取得后缀名
+        var three = two.split(".");
+        //获取截取的最后一个字符串,即为后缀名
+        var last = three[three.length - 1];
+        //添加需要判断的后缀名类型
+        var tp = "zip,rar";
+        //返回符合条件的后缀名在字符串中的位置
+        var rs = tp.indexOf(last);
+        //如果返回的结果大于或等于0,说明包含允许上传的文件类型
+        if (rs >= 0) {
+
+            $("#type").val(last);
+            isfile = 1;
+        } else {
+
+            isfile = 0;
+            layer.msg("您上传的文件类型错误,请上传正确的格式!", {icon: 2, time: 2000});
+        }
+    }
+
+    function add() {
+        $(".moban").mLoading();
+    }
+
+    function rom() {
+        $(".moban").mLoading().remove();
+    }
+
+    function check() {
+        if (isfile == 0) {
+            layer.msg("您上传的文件类型错误,请上传正确的格式!", {icon: 2, time: 2000});
+            return false;
+        } else {
+            add();
+            //先ajax 上传文件 获取到 返回路径  在提交ajax
+            var f = document.getElementById('fileToUpload').files[0];
+            var filexlsc = $("#fileToUpload").val();
+            $("#filexls").html(filexlsc);
+            $.ajaxFileUpload({
+                fileElementId: 'fileToUpload',
+                url: 'uploadImages.html',
+                dataType: 'text',
+                data: {},
+                async: true,
+                error: function (data) {
+                    alert("网络异常,请重试");
+                },
+                success: function (message) {
+                    var url = message;
+                    var type = $("#type").val();
+                    $.ajax({
+                        type: "post",
+                        url: "imgadd.html",
+                        data: {
+                            url: url,
+                            type: type
+                        },
+                        dataType: "json",
+                        success: function (msg) {
+                            rom();
+                            layer.confirm(msg.msg, function (index) {
+                                window.location.href = "serviceCategoryImg.html";
+                            });
+                        }
+                    })
+                }
+            });
+            return false;
+        }
+    }
+
+
+</script>
+</body>
+</html>

BIN
src/main/webapp/ajaxexcel/excel/全部服务表格导入规范.xlsx


BIN
src/main/webapp/ajaxexcel/excel/车主服务表格导入规范.xlsx


+ 0 - 0
src/main/webapp/ajaxupload/none.txt


BIN
src/main/webapp/lib/unrar.jar