当前位置:   article > 正文

Maven 项目依赖问题解决--ZipException: invalid LOC header (bad signature)_zipexception: unexpected record signature: 0x622f2

zipexception: unexpected record signature: 0x622f2123
报错日志
  1. 六月 09, 2018 6:38:46 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
  2. 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:PocketScoreWeb' did not find a matching property.
  3. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  4. 信息: Server version: Apache Tomcat/8.5.31
  5. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  6. 信息: Server built: Apr 27 2018 20:24:25 UTC
  7. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  8. 信息: Server number: 8.5.31.0
  9. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  10. 信息: OS Name: Windows 7
  11. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  12. 信息: OS Version: 6.1
  13. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  14. 信息: Architecture: amd64
  15. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  16. 信息: Java Home: F:\soft\Java\jdk1.8.0_144\jre
  17. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  18. 信息: JVM Version: 1.8.0_144-b01
  19. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  20. 信息: JVM Vendor: Oracle Corporation
  21. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  22. 信息: CATALINA_BASE: F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
  23. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  24. 信息: CATALINA_HOME: F:\soft\apache-tomcat-8.5.31
  25. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  26. 信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:51632
  27. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  28. 信息: Command line argument: -Dcatalina.base=F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
  29. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  30. 信息: Command line argument: -Dcatalina.home=F:\soft\apache-tomcat-8.5.31
  31. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  32. 信息: Command line argument: -Dwtp.deploy=F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
  33. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  34. 信息: Command line argument: -Djava.endorsed.dirs=F:\soft\apache-tomcat-8.5.31\endorsed
  35. 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
  36. 信息: Command line argument: -Dfile.encoding=UTF-8
  37. 六月 09, 2018 6:38:46 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
  38. 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [F:\soft\Java\jdk1.8.0_144\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:/soft/Java/jdk1.8.0_144/bin/../jre/bin/server;F:/soft/Java/jdk1.8.0_144/bin/../jre/bin;F:/soft/Java/jdk1.8.0_144/bin/../jre/lib/amd64;.;F:\soft\Java\jdk1.8.0_144\bin;F:\soft\Java\jdk1.8.0_144\lib;C:\ProgramData\Oracle\Java\javapath;F:\soft\Java\jdk1.8.0_144\bin;F:\soft\Java\jdk1.8.0_144\jre\bin;C:\Software\apache-maven-3.5.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\Program Files (x86)\Tesseract-OCR;F:\soft\Git\cmd;F:\soft\nodejs\;C:\Users\Administrator\AppData\Roaming\npm;F:\soft\eclipseneon;;.]
  39. 六月 09, 2018 6:38:47 下午 org.apache.coyote.AbstractProtocol init
  40. 信息: Initializing ProtocolHandler ["http-nio-8080"]
  41. 六月 09, 2018 6:38:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
  42. 信息: Using a shared selector for servlet write/read
  43. 六月 09, 2018 6:38:47 下午 org.apache.coyote.AbstractProtocol init
  44. 信息: Initializing ProtocolHandler ["ajp-nio-8009"]
  45. 六月 09, 2018 6:38:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
  46. 信息: Using a shared selector for servlet write/read
  47. 六月 09, 2018 6:38:47 下午 org.apache.catalina.startup.Catalina load
  48. 信息: Initialization processed in 1719 ms
  49. 六月 09, 2018 6:38:47 下午 org.apache.catalina.core.StandardService startInternal
  50. 信息: Starting service [Catalina]
  51. 六月 09, 2018 6:38:47 下午 org.apache.catalina.core.StandardEngine startInternal
  52. 信息: Starting Servlet Engine: Apache Tomcat/8.5.31
  53. 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.ContainerBase startInternal
  54. 严重: A child container failed during start
  55. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
  56. at java.util.concurrent.FutureTask.report(FutureTask.java:122)
  57. at java.util.concurrent.FutureTask.get(FutureTask.java:192)
  58. at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
  59. at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
  60. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  61. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
  62. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
  63. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  64. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  65. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  66. at java.lang.Thread.run(Thread.java:748)
  67. Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
  68. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  69. ... 6 more
  70. Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@6e9d3c2]
  71. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  72. at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4907)
  73. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5042)
  74. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  75. ... 6 more
  76. Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@43734660]
  77. at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
  78. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
  79. at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
  80. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  81. ... 9 more
  82. Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
  83. at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:142)
  84. at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
  85. ... 12 more
  86. Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
  87. at java.util.zip.ZipFile.read(Native Method)
  88. at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
  89. at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734)
  90. at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434)
  91. at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
  92. at sun.misc.IOUtils.readFully(IOUtils.java:65)
  93. at java.util.jar.JarFile.getBytes(JarFile.java:425)
  94. at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
  95. at java.util.jar.JarFile.getManifest(JarFile.java:180)
  96. at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:140)
  97. ... 13 more
  98. 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.ContainerBase startInternal
  99. 严重: A child container failed during start
  100. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
  101. at java.util.concurrent.FutureTask.report(FutureTask.java:122)
  102. at java.util.concurrent.FutureTask.get(FutureTask.java:192)
  103. at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
  104. at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
  105. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  106. at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
  107. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  108. at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
  109. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  110. at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
  111. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  112. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  113. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  114. at java.lang.reflect.Method.invoke(Method.java:498)
  115. at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
  116. at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
  117. Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
  118. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  119. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
  120. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
  121. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  122. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  123. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  124. at java.lang.Thread.run(Thread.java:748)
  125. Caused by: org.apache.catalina.LifecycleException: A child container failed during start
  126. at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
  127. at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
  128. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  129. ... 6 more
  130. 六月 09, 2018 6:38:48 下午 org.apache.catalina.startup.Catalina start
  131. 严重: The required Server component failed to start so Tomcat is unable to start.
  132. org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
  133. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  134. at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
  135. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  136. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  137. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  138. at java.lang.reflect.Method.invoke(Method.java:498)
  139. at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
  140. at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
  141. Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
  142. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  143. at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
  144. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  145. ... 7 more
  146. Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
  147. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
  148. at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
  149. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  150. ... 9 more
  151. Caused by: org.apache.catalina.LifecycleException: A child container failed during start
  152. at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
  153. at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
  154. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  155. ... 11 more
  156. 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol pause
  157. 信息: Pausing ProtocolHandler ["http-nio-8080"]
  158. 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol pause
  159. 信息: Pausing ProtocolHandler ["ajp-nio-8009"]
  160. 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.StandardService stopInternal
  161. 信息: Stopping service [Catalina]
  162. 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol destroy
  163. 信息: Destroying ProtocolHandler ["http-nio-8080"]
  164. 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol destroy
  165. 信息: Destroying ProtocolHandler ["ajp-nio-8009"]


具体看这几行就行了


出现问题的原委:

首先需要弄一份excel导入导出功能,用poi去实现,项目结构具体如下

B依赖C ,C依赖A(图好像描述错了,看这里描述为准),之前poi包是放在C中去依赖,所以,闹出了很多问题

问题一:C中原来有个poi-3.15包,现在不知情的情况下(整个项目中途接手),现在在B的导入导出Excel中增加了

poi-3.17包

poi-ooxml-3.17包

poi-ooxml-schemas-3.17包

发现只能<scope>provided<scope>情况能把整个web跑起来,但是运行时,却发现ClassNoFoundException

无奈改成<scope>compile<scope>,可以跑,但是,一跑起来就报文章开头上边的错误

问题二: 查看pom.xml,发现Dependency Hierarchy有如下的冲突,orimitted complict  with...(好像是这样,忘记截图了),就是

jar冲突了,原来poi-ooxml已经包含了三个jar中其余的两个

结果保留下边的配置在A中

  1. <dependency>
  2. <groupId>org.apache.poi</groupId>
  3. <artifactId>poi-ooxml</artifactId>
  4. <version>3.15</version>
  5. </dependency>

问题三:就是所有问题都存在,把三个jar包丢进tomcat的lib中,是可以跑起来的,但是报错了

 就是运行到下边代码的最后一行,我导入的是xlsx2010格式的excel,报XSSFWorkbook,没有实现org.apache.poi.ss.usermodel.Workbook接口
  1. org.apache.poi.ss.usermodel.Workbook workBook = null;
  2.         if (is2010)
  3.             workBook = new XSSFWorkbook(is); //2010
  4.         else
  5.             workBook = new HSSFWorkbook(is); //2003-2007
  6.         
  7.         if (workBook.getNumberOfSheets() < 1) throw new RuntimeException("excel没有表格存在");

解决方法,就是不要把XSSFWorkbook和HSSFWorkbook都用Workbook来接收,分开两个方法去实现,效果也能实现

但是导出的war包,解压缩后,没有发现三个jar都是3.17版本,有个是3.15(存在于C中,原先项目的依赖pom.xml)

========================================================================

开始解决问题:

首先新建一个仓库目录(otherRepository201806091944)

其次,新建一个settings.xml,这个配置,从原来旧的里头拷贝,修改仓库地址指向新的仓库目录


这是基于eclipse Neon.2 Release (4.6.2)版的,IDEA也是在settings里头改maven,或者在默认的settings里头改全局的

改完后,alt+f5更新下库,或者项目选择要更新的,右键

所有的maven 配置清单pom.xml里头的依赖就会下载下来,入股,下载下来的jar没有存在,就去旧的里头复制粘贴过来

回到本文开始报错的Maven 项目依赖问题解决--ZipException: invalid LOC header (bad signature)

我的问题就解决了。


写完这篇文章,感觉逻辑阐述还是有点问题,下次努力,各位看官挑重点能帮助到你的看,忽略瑕疵。

nutz更加方便快捷的实现方式:还没完全实现通:https://github.com/nutzam/nutzmore/tree/master/nutz-integration-json4excel

下边是所需的jar依赖,可能还需要poi-ooxml-3.17   /  poi-ooxml-3.15包

  1. <dependency>
  2. <groupId>org.nutz</groupId>
  3. <artifactId>nutz-integration-json4excel</artifactId>
  4. <version>1.r.66-SNAPSHOT</version>
  5. <scope>provided</scope>
  6. </dependency>

附上excel导入参考demo,逻辑关联一般,还没完全测试通过,可以使用,具体可以拿来参考下

  1. package cn.wizzer.app.web.modules.controllers.platform.cms;
  2. import java.io.InputStream;
  3. import java.util.Date;
  4. import java.util.LinkedList;
  5. import java.util.List;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  8. import org.apache.poi.ss.usermodel.Cell;
  9. import org.apache.poi.ss.usermodel.Row;
  10. import org.apache.poi.ss.usermodel.Sheet;
  11. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  12. import org.apache.shiro.authz.annotation.RequiresAuthentication;
  13. import org.nutz.dao.Dao;
  14. import org.nutz.dao.Sqls;
  15. import org.nutz.dao.entity.Record;
  16. import org.nutz.dao.sql.Sql;
  17. import org.nutz.ioc.loader.annotation.Inject;
  18. import org.nutz.ioc.loader.annotation.IocBean;
  19. import org.nutz.lang.Strings;
  20. import org.nutz.lang.random.R;
  21. import org.nutz.lang.util.NutMap;
  22. import org.nutz.log.Log;
  23. import org.nutz.log.Logs;
  24. import org.nutz.mvc.adaptor.WhaleAdaptor;
  25. import org.nutz.mvc.annotation.AdaptBy;
  26. import org.nutz.mvc.annotation.At;
  27. import org.nutz.mvc.annotation.Ok;
  28. import org.nutz.mvc.annotation.POST;
  29. import org.nutz.mvc.annotation.Param;
  30. import org.nutz.mvc.impl.AdaptorErrorContext;
  31. import org.nutz.mvc.upload.TempFile;
  32. import org.nutz.mvc.upload.UploadAdaptor;
  33. import com.alibaba.druid.util.StringUtils;
  34. import cn.wizzer.app.cms.modules.models.ChangXinYunModel;
  35. import cn.wizzer.app.cms.modules.services.ChangXinYunService;
  36. import cn.wizzer.app.sys.modules.services.SysMenuService;
  37. import cn.wizzer.app.web.commons.base.Globals;
  38. import cn.wizzer.app.web.commons.slog.annotation.SLog;
  39. import cn.wizzer.app.web.modules.controllers.httputils.HttpClient4;
  40. import cn.wizzer.framework.base.Result;
  41. import cn.wizzer.framework.page.datatable.DataTableColumn;
  42. import cn.wizzer.framework.page.datatable.DataTableOrder;
  43. import cn.wizzer.framework.util.DateUtil;
  44. /**
  45. * Created by William 2018年6月5日09:55:33
  46. */
  47. @IocBean
  48. @At("/platform/changxinyun")
  49. public class ChangXinYunController {
  50. @SuppressWarnings("unused")
  51. private static final Log log = Logs.get();
  52. @Inject
  53. private SysMenuService menuService;
  54. @Inject
  55. private ChangXinYunService changXinYunService;
  56. @Inject
  57. private Dao dao;
  58. //dao.create(ChangXinYunModel.class, true);
  59. @At({"", "/index/","/index/?"})
  60. @Ok("beetl:/changxinyun/index.html")
  61. @RequiresAuthentication
  62. public void index() {
  63. }
  64. @At
  65. @Ok("json:full")
  66. @RequiresAuthentication
  67. public Object data(@Param("name") String name,@Param("length") int length, @Param("start") int start, @Param("draw") int draw, @Param("::order") List<DataTableOrder> order, @Param("::columns") List<DataTableColumn> columns,
  68. HttpServletRequest req) {
  69. String whereName = "";
  70. if (!Strings.isBlank(name)){
  71. whereName = "and t.title LIKE '%"+name+"%' or kolName like '%"+name+"%'";
  72. }
  73. String sqlCount ="SELECT t.* from YZF_ChangXinYun t order by orderBy desc";// WHERE type='0'"+whereName+"ORDER BY isTop DESC";
  74. Sql sql = Sqls.create(sqlCount);
  75. NutMap re = changXinYunService.data(length, start, draw,sql,sql);
  76. @SuppressWarnings("rawtypes")
  77. LinkedList dataList = (LinkedList) re.get("data");
  78. for (int i=0;i<dataList.size();i++) {
  79. Record record = (Record) dataList.get(i);
  80. //map.keySet()返回的是所有key的值
  81. String str = record.getString("id");//得到每个key多对用value的值
  82. Sql sqlCount2 = Sqls.create("select count(*) as putScore from YZF_ChangXinYun");// WHERE leaveRoomDate IS NULL and roomId='"+str+"'");
  83. sqlCount2.setCallback(Sqls.callback.integer());
  84. int putScore=dao.execute(sqlCount2).getInt();
  85. record.put("putscore", putScore);
  86. }
  87. req.setAttribute("lists", re);
  88. System.out.println("re:"+re);
  89. return re;
  90. }
  91. @At
  92. @Ok("beetl:/changxinyun/add.html")
  93. @RequiresAuthentication
  94. @AdaptBy(type = WhaleAdaptor.class)
  95. public void add(HttpServletRequest req) {
  96. // // 美女与嘉宾列表
  97. // List<Member> memberList = changXinYunService.query(Cnd.where("ship","in","1,5"));
  98. // req.setAttribute("list1", memberList);
  99. // // 房间管理员列表
  100. // List<Member> memberList2 = changXinYunService.query(Cnd.where("ship","=","3"));
  101. // req.setAttribute("list2", memberList2);
  102. // // 赛事列表
  103. // List<GameMatchMain> re= changXinYunService.query(Cnd.where("isHot", "=", 1).orderBy("ABS(id)","desc"));
  104. // // 专家列表
  105. // List<Member> memberList4 = changXinYunService.query(Cnd.where("ship","=","1"));
  106. // req.setAttribute("list4", memberList4);
  107. // GameMatchMain gGameMatchMain=new GameMatchMain();
  108. // gGameMatchMain.setId("100");
  109. // gGameMatchMain.setMatchName("热门比赛");
  110. // re.add(0, gGameMatchMain);
  111. // req.setAttribute("list3", re);
  112. }
  113. @At
  114. @Ok("json")
  115. @SLog(tag = "新建测试", msg = "")
  116. @AdaptBy(type = WhaleAdaptor.class)
  117. public Object addDo(@Param("path") String path,@Param("key") String[] key,@Param("value") String[] value,@Param("methodName") String methodName,@Param("..") ChangXinYunModel chxyun,HttpServletRequest req) {
  118. System.out.println("");
  119. //String tokenString = HttpClient4.doPost(path,"");
  120. String result = HttpClient4.doGet(path);
  121. try {
  122. // room.setIsTop(StringUtils.isEmpty(isTopChoice) ? 0 : 1);
  123. // RongCloud rongCloud = RongCloud.getInstance();
  124. // // 创建聊天室方法
  125. // ChatRoomInfo[] chatroomCreateChatRoomInfo = {new ChatRoomInfo(room.getId(),room.getTitle())};
  126. // CodeSuccessResult chatroomCreateResult = rongCloud.chatroom.create(chatroomCreateChatRoomInfo);
  127. // System.out.println("chatroomCreateResult: " + chatroomCreateResult.toString());
  128. // if (chatroomCreateResult.getCode()==200 ){
  129. // room=addPushAndLive(room,room.getRoomMasterId()+(new Date().getTime()/1000));
  130. // // 创建数据库本地房间
  131. // room.setBanState(0);
  132. // room.setQuizType(0);
  133. // room.setType(0);
  134. // room.setDelFlag(false);
  135. // room.setMatchId("0264A18B938647D7ADFE1D70853D73D6");
  136. // room=roomService.insert(room);
  137. //
  138. // //清除缓存赛事首页房间缓存
  139. // RoomListCache roomListCache=RoomListCache.instanct;
  140. // Integer isTop=room.getIsTop();
  141. //
  142. // if(isTop==1){
  143. // String id=room.getId();
  144. // String sqlCount ="UPDATE room_room SET isTop='0' WHERE type='0' AND id<>'"+id+"';";
  145. // Sql sql = Sqls.create(sqlCount);
  146. // dao.execute(sql);
  147. //
  148. // }
  149. // roomListCache.clear();
  150. // return Result.success("system.success");
  151. // }
  152. return Result.success("success:"+result,result);
  153. } catch (Exception e) {
  154. return Result.error("system.error");
  155. }
  156. }
  157. @At
  158. @Ok("beetl:/changxinyun/importExcel.html")
  159. @SLog(tag = "新建测试", msg = "")
  160. @AdaptBy(type = WhaleAdaptor.class)
  161. public void doImportExcel() {
  162. }
  163. @AdaptBy(type = UploadAdaptor.class, args = {"ioc:videoExcel"})
  164. @POST
  165. @At
  166. @Ok("json")
  167. @RequiresAuthentication
  168. public Object dealWithExcel(@Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err) {
  169. try {
  170. if (err != null && err.getAdaptorErr() != null) return NutMap.NEW().addv("code", 1).addv("msg", "上传文件不合法");
  171. if (tf == null) return Result.error("请选择要上传的excelwenj");
  172. String f = Globals.AppUploadPath + "/image/" + DateUtil.format(new Date(), "yyyyMMdd") + "/" + R.UU32() + tf.getSubmittedFileName().substring(tf.getSubmittedFileName().indexOf("."));
  173. InputStream in = tf.getInputStream();
  174. String suffix = f.substring(f.lastIndexOf("."));
  175. if (StringUtils.isEmpty(suffix) || suffix.indexOf("xlsx") == -1)
  176. //2003-2007版本的excel
  177. readExcel(in,false);
  178. else
  179. //2010版excel
  180. readExcel(in,true);
  181. return Result.success("上传成功", Globals.AppBase+f);
  182. } catch (Exception e) {
  183. e.printStackTrace();
  184. return Result.error("系统错误");
  185. }
  186. }
  187. /**
  188. * 插入数据对象到数据库中
  189. * @param order
  190. * @param name
  191. * @param pid
  192. * @param phone
  193. * @return
  194. */
  195. private ChangXinYunModel doChangXinYunModel(int order,String name,String pid,String phone) {
  196. ChangXinYunModel cxyModel = new ChangXinYunModel();
  197. cxyModel.setOrderBy(order);
  198. cxyModel.setName(name);
  199. cxyModel.setPid(pid);
  200. cxyModel.setPhone(phone);
  201. StringBuilder sb = new StringBuilder();
  202. sb.append("https://api.--------?");
  203. sb.append("name="+name+"&");
  204. sb.append("pid="+pid+"&");
  205. sb.append("phone="+phone+"&");
  206. sb.append("type="+1+"&");
  207. String token = "cqixikuf5nkfmewd";
  208. sb.append("token="+token);
  209. String result = HttpClient4.doGet(sb.toString());
  210. cxyModel.setToken(token);
  211. cxyModel.setMethodName("GET");
  212. cxyModel.setOpAt(Integer.parseInt(System.currentTimeMillis()/1000+""));
  213. cxyModel.setPath(sb.toString());
  214. cxyModel.setRequestAt(""+System.currentTimeMillis());
  215. cxyModel.setResult(result);
  216. cxyModel.setDelFlag(false);
  217. cxyModel.setBank_card("");
  218. cxyModel.setComment("三要素认证");
  219. cxyModel.setHead("");
  220. cxyModel.setOtherInfo("");
  221. cxyModel.setPhone(phone);
  222. cxyModel.setPid(pid);
  223. dao.insert(cxyModel);
  224. return cxyModel;
  225. }
  226. @SuppressWarnings("deprecation")
  227. private String getValue(Cell cell) {
  228. if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN)
  229. return String.valueOf(cell.getBooleanCellValue()); // 返回布尔类型的值
  230. else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
  231. return String.valueOf(cell.getNumericCellValue()); // 返回数值类型的值
  232. else
  233. return String.valueOf(cell.getStringCellValue()); // 返回字符串类型的值
  234. }
  235. @SuppressWarnings("resource")
  236. private void readExcel(InputStream in,boolean is2010) throws Exception {
  237. InputStream is = in;
  238. org.apache.poi.ss.usermodel.Workbook workBook = null;
  239. if (is2010)
  240. workBook = new XSSFWorkbook(is); //2010
  241. else
  242. workBook = new HSSFWorkbook(is); //2003-2007
  243. if (workBook.getNumberOfSheets() < 1) throw new RuntimeException("excel没有表格存在");
  244. // 循环工作表Sheet
  245. for (int numSheet = 0; numSheet < workBook.getNumberOfSheets(); numSheet++) {
  246. Sheet sheet = workBook.getSheetAt(numSheet);
  247. if (sheet == null) {
  248. continue;
  249. }
  250. //校验表头 序号 姓名 身份证 手机号
  251. if (sheet.getLastRowNum() < 1) throw new RuntimeException(sheet.getSheetName() + ",不存在数据");
  252. Row headRow = sheet.getRow(0);
  253. if (headRow.getCell(0) == null || StringUtils.isEmpty(getValue(headRow.getCell(0))) || !getValue(headRow.getCell(0)).trim().equals("序号")) throw new RuntimeException("表头第一列必须为[序号]");
  254. if (headRow.getCell(1) == null || StringUtils.isEmpty(getValue(headRow.getCell(1))) || !getValue(headRow.getCell(1)).trim().equals("姓名")) throw new RuntimeException("表头第一列必须为[姓名]");
  255. if (headRow.getCell(2) == null || StringUtils.isEmpty(getValue(headRow.getCell(2))) || !getValue(headRow.getCell(2)).trim().equals("身份证")) throw new RuntimeException("表头第一列必须为[身份证]");
  256. if (headRow.getCell(3) == null || StringUtils.isEmpty(getValue(headRow.getCell(3))) || !getValue(headRow.getCell(3)).trim().equals("手机号")) throw new RuntimeException("表头第一列必须为[手机号]");
  257. //校验表格数据必须大于1条
  258. if (sheet.getLastRowNum() < 2) throw new RuntimeException(sheet.getSheetName() + ",没有需要导入的数据");
  259. // 循环行Row
  260. for (int rowNum = 3; rowNum <= sheet.getLastRowNum(); rowNum++) {
  261. Row row = sheet.getRow(rowNum);
  262. if (row == null) {
  263. continue;
  264. }
  265. //init Model
  266. doChangXinYunModel((int)Double.parseDouble(getValue(row.getCell(0))), getValue(row.getCell(1)), getValue(row.getCell(2)), getValue(row.getCell(3)));
  267. }
  268. }
  269. }
  270. }














声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号