Pārlūkot izejas kodu

商品资料part4

Aslee 3 gadi atpakaļ
vecāks
revīzija
f80186280c
19 mainītis faili ar 312 papildinājumiem un 185 dzēšanām
  1. 9 1
      pom.xml
  2. 2 1
      src/main/java/com/caimei/modules/archive/service/CmOrderArchiveService.java
  3. 4 139
      src/main/java/com/caimei/modules/archive/service/CmProductArchiveContentService.java
  4. 5 1
      src/main/java/com/caimei/modules/archive/utils/OssArchiveUtil.java
  5. 214 0
      src/main/java/com/thinkgem/jeesite/common/utils/HtmlGenerateUtils.java
  6. 3 0
      src/main/resources/config/beta/caimei.properties
  7. 4 0
      src/main/resources/config/dev/caimei.properties
  8. 3 9
      src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml
  9. 1 7
      src/main/resources/mappings/modules/archive/CmProductArchiveMapper.xml
  10. 5 2
      src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp
  11. 5 1
      src/main/webapp/WEB-INF/views/modules/archive/addVideoForm.jsp
  12. 1 1
      src/main/webapp/WEB-INF/views/modules/archive/archiveAddProduct.jsp
  13. 12 1
      src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveFileList.jsp
  14. 14 2
      src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveForm.jsp
  15. 18 15
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentForm.jsp
  16. 1 0
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp
  17. 6 4
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveForm.jsp
  18. 1 1
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveList.jsp
  19. 4 0
      src/main/webapp/WEB-INF/views/modules/user/cmUserbeanshistoryList.jsp

+ 9 - 1
pom.xml

@@ -665,7 +665,7 @@
 			<version>1.0</version>
 		</dependency>-->
 
-    </dependencies>
+	</dependencies>
 
 	<build>
 		<finalName>manager</finalName>
@@ -910,6 +910,14 @@
 				<artifactId>maven-dependency-plugin</artifactId>
 				<version>2.5.1</version>
 			</plugin>
+
+
+			<plugin>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<argLine> -XX:-UseSplitVerifier</argLine>
+				</configuration>
+			</plugin>
 		</plugins>
 	</build>
 

+ 2 - 1
src/main/java/com/caimei/modules/archive/service/CmOrderArchiveService.java

@@ -107,8 +107,9 @@ public class CmOrderArchiveService extends CrudService<CmOrderArchiveDao, CmOrde
             //保存本地
             File file = OssArchiveUtil.ossUpload(multipartFile);
             logger.info("默认路径>>>" + file.getAbsolutePath());
+            String contentDispositon = "pdf".equals(fileType) ? "inline" : "attachment";
             //上传oss
-            String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", file, contentType);
+            String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", file, contentType, contentDispositon);
             //删除本地文件
             OssArchiveUtil.deleteFile(file);
             //保存关联关系

+ 4 - 139
src/main/java/com/caimei/modules/archive/service/CmProductArchiveContentService.java

@@ -1,16 +1,13 @@
 package com.caimei.modules.archive.service;
 
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.*;
-import java.net.URI;
 import java.net.URL;
 import java.util.*;
 import java.util.List;
 
 import com.caimei.dfs.image.beens.ImageUploadInfo;
-import com.caimei.modules.archive.entity.CmOrderArchiveFile;
+import com.thinkgem.jeesite.common.utils.HtmlGenerateUtils;
 import com.caimei.modules.archive.entity.CmProductArchiveFile;
 import com.caimei.modules.archive.utils.OssArchiveUtil;
 import com.caimei.modules.common.utils.UploadUtils;
@@ -18,15 +15,6 @@ import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.utils.Encodes;
 import com.thinkgem.jeesite.common.utils.StringUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.poi.hslf.model.TextRun;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hwpf.HWPFDocument;
-import org.apache.poi.hwpf.converter.PicturesManager;
-import org.apache.poi.hwpf.converter.WordToHtmlConverter;
-import org.apache.poi.hwpf.usermodel.Picture;
-import org.apache.poi.hwpf.usermodel.PictureType;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -35,16 +23,9 @@ import com.thinkgem.jeesite.common.service.CrudService;
 import com.caimei.modules.archive.entity.CmProductArchiveContent;
 import com.caimei.modules.archive.dao.CmProductArchiveContentDao;
 import org.springframework.web.multipart.MultipartFile;
-import org.w3c.dom.Document;
 
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
 /**
  * 商品资料内容Service
@@ -153,18 +134,9 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
             //保存本地
             File file = OssArchiveUtil.ossUpload(multipartFile);
 			logger.info("默认路径>>>" + file.getAbsolutePath());
-            //上传oss
-            String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", file, contentType);
-			String htmlUrl = null;
-            //doc和ppt文件生成html文件
-			/*if (fileType.contains("doc") || fileType.contains("ppt")) {
-				String htmluuid = UUID.randomUUID().toString().replaceAll("-", "");
-				String htmlFilePath = htmluuid + ".html";
-				String htmlPath = generateHtml(file, fileShortName, fileType);
-				File htmlFile = new File(htmlPath);
-				htmlUrl = OssArchiveUtil.ossUpload(htmlFilePath, "archiveFile/", htmlFile, "text/html");
-				htmlFile.delete();
-			}*/
+			String contentDispositon = "pdf".equals(fileType) ? "inline" : "attachment";
+			//上传oss
+			String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", file, contentType, contentDispositon);
 			//删除本地文件
 			OssArchiveUtil.deleteFile(file);
             //保存关联关系
@@ -172,7 +144,6 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
             archiveFile.setFileName(fileName);
             archiveFile.setOssName(filePath);
             archiveFile.setOssUrl(url);
-//			archiveFile.setHtmlUrl(htmlUrl);
             archiveFile.setUploadTime(new Date());
             cmProductArchiveContentDao.insertFile(archiveFile);
             map.put("success", true);
@@ -186,110 +157,4 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
         }
         return map;
     }
-
-	private String generateHtml(File file, String fileShortName, String fileType) throws Exception {
-//		String filePath = "/mnt/newdatadrive/data/runtime/tomcat-instance/manager/temp/tempHtml/";
-//		String filePath = "D:\\poi-test\\wordToHtml\\";
-        if (fileType.contains("doc")) {
-            InputStream input = new FileInputStream(file);
-            HWPFDocument wordDocument = new HWPFDocument(input);
-            WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(
-                    DocumentBuilderFactory.newInstance().newDocumentBuilder()
-                            .newDocument());
-            wordToHtmlConverter.setPicturesManager((content, pictureType, suggestedName, widthInches, heightInches) -> suggestedName);
-            wordToHtmlConverter.processDocument(wordDocument);
-            List<Picture> pics = wordDocument.getPicturesTable().getAllPictures();
-            for (Picture pic : pics) {
-                try {
-                    pic.writeImageContent(new FileOutputStream(htmlTempPath
-                            + pic.suggestFullFileName()));
-                } catch (FileNotFoundException e) {
-                    e.printStackTrace();
-                }
-            }
-            Document htmlDocument = wordToHtmlConverter.getDocument();
-            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-            DOMSource domSource = new DOMSource(htmlDocument);
-            StreamResult streamResult = new StreamResult(outStream);
-            TransformerFactory tf = TransformerFactory.newInstance();
-            Transformer serializer = tf.newTransformer();
-            serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
-            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
-            serializer.setOutputProperty(OutputKeys.METHOD, "html");
-            serializer.transform(domSource, streamResult);
-            outStream.close();
-            String content = new String(outStream.toByteArray());
-            FileUtils.writeStringToFile(new File(htmlTempPath, fileShortName + ".html"), content, "utf-8");
-            return htmlTempPath + fileShortName + ".html";
-        } else {
-            boolean isppt = checkFile(file);
-            if (!isppt) {
-                System.out.println("The image you specify don't exit!");
-                return null;
-            }
-            try {
-                FileInputStream is = new FileInputStream(file);
-                SlideShow ppt = new SlideShow(is);
-                is.close();
-                Dimension pgsize = ppt.getPageSize();
-                org.apache.poi.hslf.model.Slide[] slide = ppt.getSlides();
-                for (int i = 0; i < slide.length; i++) {
-                    System.out.print("第" + i + "页。");
-                    TextRun[] truns = slide[i].getTextRuns();
-                    for ( int k=0;k<truns.length;k++){
-                        RichTextRun[] rtruns = truns[k].getRichTextRuns();
-                        for(int l=0;l<rtruns.length;l++){
-                            int index = rtruns[l].getFontIndex();
-                            String name = rtruns[l].getFontName();
-                            rtruns[l].setFontIndex(1);
-                            rtruns[l].setFontName("宋体");
-//            System.out.println(rtruns[l].getText());
-                        }
-                    }
-                    BufferedImage img = new BufferedImage(pgsize.width,pgsize.height, BufferedImage.TYPE_INT_RGB);
-                    Graphics2D graphics = img.createGraphics();
-                    graphics.setPaint(Color.BLUE);
-                    graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
-                    slide[i].draw(graphics);
-                    // 这里设置图片的存放路径和图片的格式(jpeg,png,bmp等等),注意生成文件路径
-                    FileOutputStream out = new FileOutputStream("D:/poi-test/pptToImg/pict_"+ (i + 1) + ".jpeg");
-                    javax.imageio.ImageIO.write(img, "jpeg", out);
-                    out.close();
-                }
-                System.out.println("success!!");
-                return null;
-            } catch (FileNotFoundException e) {
-                System.out.println(e);
-                // System.out.println("Can't find the image!");
-            } catch (IOException e) {
-            }
-            return null;
-        }
-
-    }
-    // function 检查文件是否为PPT
-    public static boolean checkFile(File file) {
-        boolean isppt = false;
-        String filename = file.getName();
-        String suffixname = null;
-        if (filename != null && filename.indexOf(".") != -1) {
-            suffixname = filename.substring(filename.indexOf("."));
-            if (suffixname.equals(".ppt")) {
-                isppt = true;
-            }
-            return isppt;
-        } else {
-            return isppt;
-        }
-    }
-
-    /*@Transactional(readOnly = false)
-    public void deleteFile(Integer fileId) {
-        CmOrderArchiveFile archiveFile = cmOrderArchiveDao.getArchiveFileById(fileId);
-        if (archiveFile != null) {
-            //删除oss服务器上的文件
-            OssArchiveUtil.deleteSingleFile("archiveFile/", archiveFile.getOssName());
-            cmOrderArchiveDao.deleteArchiveFile(fileId);
-        }
-    }*/
 }

+ 5 - 1
src/main/java/com/caimei/modules/archive/utils/OssArchiveUtil.java

@@ -2,9 +2,11 @@ package com.caimei.modules.archive.utils;
 
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.model.CannedAccessControlList;
 import com.aliyun.oss.model.GetObjectRequest;
 import com.aliyun.oss.model.ObjectMetadata;
 import com.aliyun.oss.model.UploadFileRequest;
+import com.caimei.utils.StringUtils;
 import com.thinkgem.jeesite.common.config.Global;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -20,7 +22,7 @@ public class OssArchiveUtil {
     private static String privateBucket = Global.getConfig("aliyun.bucketName");
     private static String config = Global.getConfig("cm.config");
 
-    public static String ossUpload(String fileName, String path, File file, String contentType) {
+    public static String ossUpload(String fileName, String path, File file, String contentType, String contentDisposition) {
         String url = null;
         try {
             if ("product".equals(config)) {
@@ -31,6 +33,8 @@ public class OssArchiveUtil {
             OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
             ObjectMetadata meta = new ObjectMetadata();
             meta.setContentType(contentType);
+            meta.setObjectAcl(CannedAccessControlList.PublicRead);
+            meta.setContentDisposition(StringUtils.isEmpty(contentDisposition) ? "inline" : contentDisposition);
             UploadFileRequest uploadFileRequest = new UploadFileRequest(privateBucket, fileName);
             // 指定上传的本地文件。
             uploadFileRequest.setUploadFile(file.toString());

+ 214 - 0
src/main/java/com/thinkgem/jeesite/common/utils/HtmlGenerateUtils.java

@@ -0,0 +1,214 @@
+package com.thinkgem.jeesite.common.utils;
+
+import com.caimei.dfs.image.beens.ImageUploadInfo;
+import com.caimei.modules.archive.entity.CmProductArchiveContent;
+import com.caimei.modules.archive.utils.OssArchiveUtil;
+import com.caimei.modules.common.utils.UploadUtils;
+import com.caimei.modules.oss.utils.OSSUtils;
+import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.thinkgem.jeesite.common.config.Global;
+import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
+import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.converter.PicturesManager;
+import org.apache.poi.hwpf.converter.WordToHtmlConverter;
+import org.apache.poi.hwpf.usermodel.Picture;
+import org.apache.poi.hwpf.usermodel.PictureType;
+//import org.apache.poi.xwpf.converter.core.BasicURIResolver;
+//import org.apache.poi.xwpf.converter.core.FileImageExtractor;
+//import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter;
+//import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.jsoup.Jsoup;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.util.List;
+import java.util.UUID;
+
+public class HtmlGenerateUtils {
+
+    private static final String htmlTempPath = Global.getConfig("archive.htmlTempPath");
+
+    public static void main(String argv[]) {
+        try {
+//            doc2Html("C:\\Users\\Aslee\\Desktop\\测试html生成.doc","二手html生成");
+//            docx2Html("C:\\Users\\Aslee\\Desktop\\docx上传.docx","二手html生成1");
+//            clearTempFile("二手html生成");
+//            docx2doc(new File("C:\\Users\\Aslee\\Desktop\\docx上传.docx"), "docx转doc");
+            docx2pdf(new File("C:\\Users\\Aslee\\Desktop\\docx上传.docx"), "docx转pdf");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * doc转换为html
+     *
+     * @param fileName
+     * @param fileName
+     * @throws TransformerException
+     * @throws IOException
+     * @throws ParserConfigurationException
+     */
+//    public static String doc2Html(String fileAllName,String fileName) throws TransformerException, IOException, ParserConfigurationException {
+    public static String doc2Html(File file,String fileName) throws TransformerException, IOException, ParserConfigurationException {
+        InputStream input = new FileInputStream(file);
+        HWPFDocument wordDocument = new HWPFDocument(input);
+//        HWPFDocument wordDocument = new HWPFDocument(new FileInputStream(fileAllName));
+        //图片文件夹
+        File imageDirectory = new File(htmlTempPath + fileName + "-images");
+        if (!imageDirectory.exists()) {
+            imageDirectory.getParentFile().mkdirs();
+            imageDirectory.mkdir();
+        }
+        // 保存图片
+        List<Picture> pics = wordDocument.getPicturesTable().getAllPictures();
+        if (pics != null) {
+            for (int i = 0; i < pics.size(); i++) {
+                Picture pic = pics.get(i);
+                try {
+                    String fileFullPath = htmlTempPath + fileName + "-images/" + fileName + "-" + pic.suggestFullFileName();
+                    pic.writeImageContent(new FileOutputStream(fileFullPath));
+                } catch (FileNotFoundException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
+        wordToHtmlConverter.setPicturesManager((content, pictureType, suggestedName, widthInches, heightInches) -> {
+            String imagePath = htmlTempPath + fileName + "-images\\" + fileName + "-" + suggestedName;
+            File imageFile = new File(imagePath);
+            String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+            String imageName = uuid + ".jpg";
+            String imageUrl = OssArchiveUtil.ossUpload(imageName, "archiveFile/", imageFile, OSSUtils.getContentType(".jpg"), "inline");
+            return imageUrl;
+        });
+        wordToHtmlConverter.processDocument(wordDocument);
+
+
+        Document htmlDocument = wordToHtmlConverter.getDocument();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        DOMSource domSource = new DOMSource(htmlDocument);
+        StreamResult streamResult = new StreamResult(out);
+
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer serializer = tf.newTransformer();
+        serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
+        serializer.setOutputProperty(OutputKeys.INDENT, "yes");
+        serializer.setOutputProperty(OutputKeys.METHOD, "html");
+        serializer.transform(domSource, streamResult);
+        out.close();
+        writeFile(new String(out.toByteArray()), htmlTempPath + fileName + ".html");
+//        System.out.println("Generate " + outPutFile + " with " + (System.currentTimeMillis() - startTime) + " ms.");
+        return htmlTempPath + fileName + ".html";
+    }
+    /**
+     * 写文件
+     *
+     * @param content
+     * @param path
+     */
+    public static void writeFile(String content, String path) {
+        FileOutputStream fos = null;
+        BufferedWriter bw = null;
+        try {
+            File file = new File(path);
+            fos = new FileOutputStream(file);
+            bw = new BufferedWriter(new OutputStreamWriter(fos, "utf-8"));
+            bw.write(content);
+        } catch (FileNotFoundException fnfe) {
+            fnfe.printStackTrace();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        } finally {
+            try {
+                if (bw != null) {
+                    bw.close();
+                }
+                if (fos != null) {
+                    fos.close();
+                }
+            } catch (IOException ie) {
+            }
+        }
+    }
+
+
+    /**
+     * docx格式word转换为html
+     *
+     * @param fileName   docx文件路径
+//     * @param outPutFile html输出文件路径
+     * @throws TransformerException
+     * @throws IOException
+     * @throws ParserConfigurationException
+     */
+//    public static String docx2Html(String fileAllName, String fileName) throws IOException {
+    /*public static String docx2Html(File file, String fileName) throws IOException {
+        InputStream input = new FileInputStream(file);
+        XWPFDocument document = new XWPFDocument(input);
+//        XWPFDocument document = new XWPFDocument(new FileInputStream(fileAllName));
+        String fileOutName = htmlTempPath + fileName +".html";
+        XHTMLOptions options = XHTMLOptions.create().indent(4);
+        // 导出图片
+        File imageFolder = new File(htmlTempPath+fileName+"-images/");
+        options.setExtractor(new FileImageExtractor(imageFolder));
+        // URI resolver  word的html中图片的目录路径
+        options.URIResolver(new BasicURIResolver(htmlTempPath));
+        File outFile = new File(fileOutName);
+        outFile.getParentFile().mkdirs();
+        OutputStream out = new FileOutputStream(outFile);
+        XHTMLConverter.getInstance().convert(document, out, options);
+//        System.out.println("Generate " + fileOutName + " with " + (System.currentTimeMillis() - startTime) + " ms.");
+        return htmlTempPath + fileName + ".html";
+    }*/
+
+    public static void clearTempFile(String fileName){
+        //清除html文件
+        File file = new File(htmlTempPath + fileName + ".html");
+        file.delete();
+        //清除图片
+        File imageFolder = new File(htmlTempPath + fileName + "-images");
+        deleteDir(imageFolder);
+    }
+
+
+    private static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            //递归删除目录中的子目录下
+            for (int i=0; i<children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+        // 目录此时为空,可以删除
+        return dir.delete();
+    }
+
+    public static File docx2pdf(File file, String fileName) throws IOException {
+        InputStream input = new FileInputStream(file);
+        XWPFDocument xwpfDocument = new XWPFDocument(input);
+        PdfOptions pdfOptions = PdfOptions.create();
+        OutputStream out = new FileOutputStream(new File(htmlTempPath + fileName + ".pdf"));
+        PdfConverter.getInstance().convert(xwpfDocument, out, pdfOptions);
+        return null;
+    }/*public static File docx2doc(File file, String fileName) throws IOException {
+        InputStream input = new FileInputStream(file);
+        XWPFDocument xwpfDocument = new XWPFDocument(input);
+
+        WordToHtmlConverter
+    }*/
+
+}

+ 3 - 0
src/main/resources/config/beta/caimei.properties

@@ -181,3 +181,6 @@ aliyun.accessKeyId=LTAI4GBL3o4YkWnbKYgf2Xia
 aliyun.accessKeySecret=dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK
 aliyun.bucketName=caimei-oss
 aliyun.endpoint=https://oss-cn-shenzhen.aliyuncs.com
+
+#商品资料库html文件临时路径
+archive.htmlTempPath=/mnt/newdatadrive/data/runtime/tomcat-instance/manager/temphtml/

+ 4 - 0
src/main/resources/config/dev/caimei.properties

@@ -194,3 +194,7 @@ aliyun.accessKeyId=LTAI4GBL3o4YkWnbKYgf2Xia
 aliyun.accessKeySecret=dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK
 aliyun.bucketName=caimei-oss
 aliyun.endpoint=https://oss-cn-shenzhen.aliyuncs.com
+
+#商品资料库html文件临时路径
+archive.htmlTempPath=D:\\poi-test\\wordToHtml\\
+

+ 3 - 9
src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml

@@ -41,13 +41,7 @@
                 and a.productArchiveId = #{productArchiveId}
             </if>
 		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
+		order by a.addTime desc
 	</select>
 	
 	<select id="findAllList" resultType="CmProductArchiveContent">
@@ -87,8 +81,8 @@
 		)
 	</insert>
 	<insert id="insertFile" parameterType="CmProductArchiveFile" keyProperty="id" useGeneratedKeys="true">
-		insert into cm_product_archive_file(archiveContentId, fileName, ossName, ossUrl, uploadTime)
-		values (#{archiveContentId}, #{fileName}, #{ossName}, #{ossUrl}, now())
+        insert into cm_product_archive_file(archiveContentId, fileName, ossName, ossUrl, htmlUrl, uploadTime)
+        values (#{archiveContentId}, #{fileName}, #{ossName}, #{ossUrl}, #{htmlUrl}, now());
 	</insert>
 
 	<update id="update">

+ 1 - 7
src/main/resources/mappings/modules/archive/CmProductArchiveMapper.xml

@@ -61,13 +61,7 @@
 				AND a.productClassify = #{productClassify}
 			</if>
 		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
+		order by a.addTime desc
 	</select>
 	
 	<select id="findAllList" resultType="CmProductArchive">

+ 5 - 2
src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp

@@ -178,6 +178,9 @@
         <div class="controls">
             <form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "  style="position:relative"/>
         </div>
+        <div style="margin:5px 0 0 180px">
+            <font color="red">标题输入不超过50个字</font>
+        </div>
     </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>文件路径:</label>
@@ -192,7 +195,7 @@
             <img alt="gif" src="/static/images/upload.gif" width="32px" border="none">
         </div>
         <div style="margin:5px 0 0 180px">
-            <font color="red">支持上传pdf丶word丶pptx文件格式</font>
+            <font color="red">支持上传pdf丶word丶ppt文件格式</font>
         </div>
     </div>
 </form:form>
@@ -225,7 +228,7 @@
             var files = $('#archiveFile');
             var fileList = files.prop('files');
             var fileName = $('#uploadFileName').val();
-            if (files === '' || files.length == 0 || fileName == '') {
+            if (files === '' || fileList.length == 0 || fileName == '') {
                 alertx('请选择上传文件');
                 return;
             }

+ 5 - 1
src/main/webapp/WEB-INF/views/modules/archive/addVideoForm.jsp

@@ -178,6 +178,9 @@
         <div class="controls">
             <form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "  style="position:relative"/>
         </div>
+        <div style="margin:5px 0 0 180px">
+            <font color="red">标题输入不超过50个字</font>
+        </div>
     </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>视频路径:</label>
@@ -221,11 +224,12 @@
 
         //点击上传按钮后上传文件
         $('#addSubmit').click(function () {
+            debugger
             var filesById = document.getElementById('archiveFile');
             var files = $('#archiveFile');
             var fileList = files.prop('files');
             var fileName = $('#uploadFileName').val();
-            if (files === '' || files.length == 0 || fileName == '') {
+            if (files === '' || fileList.length == 0 || fileName == '') {
                 alertx('请选择上传文件');
                 return;
             }

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/archive/archiveAddProduct.jsp

@@ -39,7 +39,7 @@
     <form:hidden path="ids"/>
     <form:hidden path="delProductIds"/>
     <div class="ul-form">
-        <label>商品编号:</label>
+        <label>商品ID:</label>
         <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
         <label>商品名称:</label>
         <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>

+ 12 - 1
src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveFileList.jsp

@@ -58,6 +58,17 @@
                     return;
             }
         }
+
+        function previewFile(url) {
+            var index = url.lastIndexOf(".");
+            var suffix = url.substring(index);
+            if (suffix.startsWith(".png") || suffix.startsWith(".jpg") || suffix.startsWith(".pdf")) {
+                window.open(url, '_blank');
+            } else {
+                var previewUrl = "https://view.officeapps.live.com/op/view.aspx?src="+encodeURIComponent(url);
+                window.open(previewUrl, '_blank');
+            }
+        }
     </script>
 </head>
 <body>
@@ -85,7 +96,7 @@
                     ${cmOrderArchiveFile.fileName}
             </td>
             <td>
-                <a href="${cmOrderArchiveFile.ossUrl}" target="_blank">预览</a>
+                <a onclick="previewFile('${cmOrderArchiveFile.ossUrl}')" target="_blank">预览</a>
                 <a href="${ctx}/archive/cmOrderArchive/downFile?fileId=${cmOrderArchiveFile.id}">下载</a>
             </td>
         </tr>

+ 14 - 2
src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveForm.jsp

@@ -277,7 +277,7 @@
 				<c:if test="${not empty archiveFileList}">
 					<c:forEach items="${archiveFileList}" var="archiveFile" varStatus="statusIndex">
 						<p>${archiveFile.fileName}
-							<span class="del"><a href="${archiveFile.ossUrl}" target="_blank">预览</a></span>
+							<span class="del"><a onclick="previewFile('${archiveFile.ossUrl}')" target="_blank">预览</a></span>
 							<span class="del" onclick="dataDelete(this,'${archiveFile.id}')">删除</span>
 						</p>
 					</c:forEach>
@@ -400,7 +400,7 @@
 				var viewFileUrl = document.createElement("a");
 				//预览链接
 				viewFileUrl.innerHTML = '预览';
-				viewFileUrl.setAttribute("href", file.ossUrl);
+				viewFileUrl.setAttribute("onclick", "previewFile('" + file.ossUrl + "')");
 				viewFileUrl.setAttribute("target", "_blank");
 				//预览按钮
 				viewFile.className = 'viewFile';
@@ -499,6 +499,18 @@
 			type: "POST"
 		});
 	}
+
+
+	function previewFile(url) {
+		var index = url.lastIndexOf(".");
+		var suffix = url.substring(index);
+		if (suffix.startsWith(".png") || suffix.startsWith(".jpg") || suffix.startsWith(".pdf")) {
+			window.open(url, '_blank');
+		} else {
+			var previewUrl = "https://view.officeapps.live.com/op/view.aspx?src="+encodeURIComponent(url);
+			window.open(previewUrl, '_blank');
+		}
+	}
 </script>
 </body>
 </html>

+ 18 - 15
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentForm.jsp

@@ -4,7 +4,7 @@
 <head>
 	<title>资料管理</title>
 	<meta name="decorator" content="default"/>
-	<%--<style>
+	<style>
 		.clearfix::after{
 			content: "";
 			display: block;
@@ -62,22 +62,27 @@
 			z-index: 100;
 		}
 		.upload-content .conList ol li {
-			width: 114px;
+      		width: 114px;
 			min-height: 80px;
 			text-align: center;
 			background: #fff;
 			position: relative;
 			top: 120px;
 			margin-left: 2px;
+			height: 100px;
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			box-sizing: border-box;
 		}
 		.hide-pic {
 			display: none !important;
 		}
 		.upload-image-list{
-			width: 600px;
+			width: 660px;
 			float: left;
 		}
-	</style>--%>
+	</style>
 	<style>
 		.iconBox{
 			font-size: 0;
@@ -127,15 +132,6 @@
 			cursor: pointer;
 			z-index: 100;
 		}
-		.upload-content .conList ol li {
-			width: 114px;
-			min-height: 80px;
-			text-align: center;
-			background: #fff;
-			position: relative;
-			top: 120px;
-			margin-left: 2px;
-		}
 		.hide-pic {
 			display: none !important;
 		}
@@ -145,6 +141,10 @@
 			//$("#name").focus();
 			$("#inputForm").validate({
 				submitHandler: function(form){
+					if ($('.cancel-upload:visible').length <= 0) {
+						alertx("至少上传一张图片");
+						return false;
+					}
 					loading('正在提交,请稍等...');
 					form.submit();
 				},
@@ -164,7 +164,7 @@
 <body>
 	<ul class="nav nav-tabs">
 		<li><a href="${ctx}/archive/cmProductArchiveContent/?type=1&productArchiveId=${cmProductArchiveContent.productArchiveId}">资料列表</a></li>
-		<li class="active"><a href="${ctx}/archive/cmProductArchiveContent/form?id=${cmProductArchiveContent.id}">资料${not empty cmProductArchiveContent.id?'编辑':'添加'}</a></li>
+		<li class="active"><a href="${ctx}/archive/cmProductArchiveContent/form?id=${cmProductArchiveContent.id}&productArchiveId=${cmProductArchiveContent.productArchiveId}&type=${cmProductArchiveContent.type}">${not empty cmProductArchiveContent.id?'编辑':'添加'}图片资料</a></li>
 	</ul><br/>
 	<form:form id="inputForm" modelAttribute="cmProductArchiveContent" action="${ctx}/archive/cmProductArchiveContent/save" method="post" class="form-horizontal">
 		<form:hidden path="id"/>
@@ -174,12 +174,15 @@
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>标题:</label>
 			<div class="controls">
-				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "  style="position:relative"/>
+				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge required" placeholder="输入图片标题"  style="position:relative"/>
 			</div>
 		</div>
 		<div class="control-group" style="width: 1000px">
 			<label class="control-label"><font color="red">*</font>图片:</label>
 <%--				<c:if test="${not empty cmProductArchiveContent.imageList}">--%>
+			<div style="display: flex">
+				<label style="color:#AEAEAE;margin-left: 20px">最多上传12张</label>
+			</div>
 			<div class="upload-image-list" style="display: flex;flex-wrap: wrap">
 				<c:forEach items="${cmProductArchiveContent.fileList}" var="image" varStatus="index">
 					<div class="controls upload-content iconBox" id="imageBox${index.index}">

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp

@@ -30,6 +30,7 @@
 		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
 		<div class="ul-form">
 			<form:hidden path="type"/>
+			<form:hidden path="productArchiveId"/>
 			 <label>标题:</label>
 				<form:input path="title" htmlEscape="false" maxlength="50" class="input-medium"/>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>

+ 6 - 4
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveForm.jsp

@@ -118,9 +118,9 @@
 			</div>
 		</div>
 		<div class="control-group custom">
-			<label class="control-label">商品名称:</label>
+			<label class="control-label"><font color="red">*</font>商品名称:</label>
 			<div class="controls">
-				<form:input path="productName" htmlEscape="false" maxlength="50" class="input-xlarge " placeholder="输入或选择商品" style="position:relative"/>
+				<form:input path="productName" htmlEscape="false" maxlength="50" class="input-xlarge required" placeholder="输入或选择商品" style="position:relative"/>
 			</div>
 		</div>
 		<div class="control-group custom">
@@ -137,9 +137,9 @@
 			</div>
 		</div>
 		<div class="control-group custom">
-			<label class="control-label">供应商名称:</label>
+			<label class="control-label"><font color="red">*</font>供应商名称:</label>
 			<div class="controls">
-				<form:input path="shopName" htmlEscape="false" maxlength="50" class="input-xlarge "/>
+				<form:input path="shopName" htmlEscape="false" maxlength="50" class="input-xlarge required"/>
 			</div>
 		</div>
 		<div class="control-group">
@@ -289,6 +289,8 @@
 						$(".productInfo").show();
 						if ('' == productType ) {
 							$(".productType").show();
+						}else {
+							$(".productType").hide();
 						}
 					} else {
 						top.$.jBox.tip("请先勾选商品...");

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveList.jsp

@@ -86,7 +86,7 @@
 					${cmProductArchive.shopName}
 				</td>
 				<td>
-					<img src="${cmProductArchive.productImage}" style="width: 80px">
+					<img src=" ${empty cmProductArchive.productImage?'https://www.caimei365.com/img/base/placeholder.png':cmProductArchive.productImage}" style="width: 80px">
 				</td>
 				<td>
 					${cmProductArchive.archiveLevel eq 1?'一类资料':(cmProductArchive.archiveLevel eq 2?'二类资料':'三类资料')}

+ 4 - 0
src/main/webapp/WEB-INF/views/modules/user/cmUserbeanshistoryList.jsp

@@ -51,6 +51,7 @@
 				<form:option value="10" label="抵用运费"/>
 				<form:option value="11" label="退款回收"/>
 				<form:option value="12" label="登录奖励"/>
+				<form:option value="13" label="查看商品资料"/>
 			</form:select>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
 			<div class="clearfix"></div>
@@ -112,6 +113,9 @@
 					<c:if test="${userBeansHistory.beansType eq 12}">
 						登录奖励
 					</c:if>
+					<c:if test="${userBeansHistory.beansType eq 13}">
+						查看商品资料
+					</c:if>
 				</td>
 			</tr>
 		</c:forEach>