赞
踩
- 六月 09, 2018 6:38:46 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
- 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:PocketScoreWeb' did not find a matching property.
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Server version: Apache Tomcat/8.5.31
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Server built: Apr 27 2018 20:24:25 UTC
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Server number: 8.5.31.0
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: OS Name: Windows 7
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: OS Version: 6.1
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Architecture: amd64
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Java Home: F:\soft\Java\jdk1.8.0_144\jre
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: JVM Version: 1.8.0_144-b01
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: JVM Vendor: Oracle Corporation
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: CATALINA_BASE: F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: CATALINA_HOME: F:\soft\apache-tomcat-8.5.31
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:51632
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -Dcatalina.base=F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -Dcatalina.home=F:\soft\apache-tomcat-8.5.31
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -Dwtp.deploy=F:\study\project\server\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -Djava.endorsed.dirs=F:\soft\apache-tomcat-8.5.31\endorsed
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.startup.VersionLoggerListener log
- 信息: Command line argument: -Dfile.encoding=UTF-8
- 六月 09, 2018 6:38:46 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
- 信息: 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;;.]
- 六月 09, 2018 6:38:47 下午 org.apache.coyote.AbstractProtocol init
- 信息: Initializing ProtocolHandler ["http-nio-8080"]
- 六月 09, 2018 6:38:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
- 信息: Using a shared selector for servlet write/read
- 六月 09, 2018 6:38:47 下午 org.apache.coyote.AbstractProtocol init
- 信息: Initializing ProtocolHandler ["ajp-nio-8009"]
- 六月 09, 2018 6:38:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
- 信息: Using a shared selector for servlet write/read
- 六月 09, 2018 6:38:47 下午 org.apache.catalina.startup.Catalina load
- 信息: Initialization processed in 1719 ms
- 六月 09, 2018 6:38:47 下午 org.apache.catalina.core.StandardService startInternal
- 信息: Starting service [Catalina]
- 六月 09, 2018 6:38:47 下午 org.apache.catalina.core.StandardEngine startInternal
- 信息: Starting Servlet Engine: Apache Tomcat/8.5.31
- 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.ContainerBase startInternal
- 严重: A child container failed during start
- java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
- at java.util.concurrent.FutureTask.report(FutureTask.java:122)
- at java.util.concurrent.FutureTask.get(FutureTask.java:192)
- at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
- at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
- at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
- at java.util.concurrent.FutureTask.run(FutureTask.java:266)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- ... 6 more
- Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@6e9d3c2]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4907)
- at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5042)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 6 more
- Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@43734660]
- at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
- at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 9 more
- Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
- at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:142)
- at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
- ... 12 more
- Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
- at java.util.zip.ZipFile.read(Native Method)
- at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
- at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734)
- at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434)
- at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
- at sun.misc.IOUtils.readFully(IOUtils.java:65)
- at java.util.jar.JarFile.getBytes(JarFile.java:425)
- at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
- at java.util.jar.JarFile.getManifest(JarFile.java:180)
- at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:140)
- ... 13 more
-
- 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.ContainerBase startInternal
- 严重: A child container failed during start
- java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
- at java.util.concurrent.FutureTask.report(FutureTask.java:122)
- at java.util.concurrent.FutureTask.get(FutureTask.java:192)
- at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
- at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:498)
- at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
- at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
- Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
- at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
- at java.util.concurrent.FutureTask.run(FutureTask.java:266)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: org.apache.catalina.LifecycleException: A child container failed during start
- at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
- at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 6 more
-
- 六月 09, 2018 6:38:48 下午 org.apache.catalina.startup.Catalina start
- 严重: The required Server component failed to start so Tomcat is unable to start.
- org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:498)
- at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
- at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
- Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 7 more
- Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
- at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 9 more
- Caused by: org.apache.catalina.LifecycleException: A child container failed during start
- at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
- at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- ... 11 more
-
- 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol pause
- 信息: Pausing ProtocolHandler ["http-nio-8080"]
- 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol pause
- 信息: Pausing ProtocolHandler ["ajp-nio-8009"]
- 六月 09, 2018 6:38:48 下午 org.apache.catalina.core.StandardService stopInternal
- 信息: Stopping service [Catalina]
- 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol destroy
- 信息: Destroying ProtocolHandler ["http-nio-8080"]
- 六月 09, 2018 6:38:48 下午 org.apache.coyote.AbstractProtocol destroy
- 信息: 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中
- <dependency>
- <groupId>org.apache.poi</groupId>
- <artifactId>poi-ooxml</artifactId>
- <version>3.15</version>
- </dependency>
问题三:就是所有问题都存在,把三个jar包丢进tomcat的lib中,是可以跑起来的,但是报错了
就是运行到下边代码的最后一行,我导入的是xlsx2010格式的excel,报XSSFWorkbook,没有实现org.apache.poi.ss.usermodel.Workbook接口- org.apache.poi.ss.usermodel.Workbook workBook = null;
- if (is2010)
- workBook = new XSSFWorkbook(is); //2010
- else
- workBook = new HSSFWorkbook(is); //2003-2007
-
- 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包
- <dependency>
- <groupId>org.nutz</groupId>
- <artifactId>nutz-integration-json4excel</artifactId>
- <version>1.r.66-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
附上excel导入参考demo,逻辑关联一般,还没完全测试通过,可以使用,具体可以拿来参考下
- package cn.wizzer.app.web.modules.controllers.platform.cms;
-
- import java.io.InputStream;
- import java.util.Date;
- import java.util.LinkedList;
- import java.util.List;
-
- import javax.servlet.http.HttpServletRequest;
-
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.ss.usermodel.Sheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.apache.shiro.authz.annotation.RequiresAuthentication;
- import org.nutz.dao.Dao;
- import org.nutz.dao.Sqls;
- import org.nutz.dao.entity.Record;
- import org.nutz.dao.sql.Sql;
- import org.nutz.ioc.loader.annotation.Inject;
- import org.nutz.ioc.loader.annotation.IocBean;
- import org.nutz.lang.Strings;
- import org.nutz.lang.random.R;
- import org.nutz.lang.util.NutMap;
- import org.nutz.log.Log;
- import org.nutz.log.Logs;
- import org.nutz.mvc.adaptor.WhaleAdaptor;
- import org.nutz.mvc.annotation.AdaptBy;
- import org.nutz.mvc.annotation.At;
- import org.nutz.mvc.annotation.Ok;
- import org.nutz.mvc.annotation.POST;
- import org.nutz.mvc.annotation.Param;
- import org.nutz.mvc.impl.AdaptorErrorContext;
- import org.nutz.mvc.upload.TempFile;
- import org.nutz.mvc.upload.UploadAdaptor;
-
- import com.alibaba.druid.util.StringUtils;
-
- import cn.wizzer.app.cms.modules.models.ChangXinYunModel;
- import cn.wizzer.app.cms.modules.services.ChangXinYunService;
- import cn.wizzer.app.sys.modules.services.SysMenuService;
- import cn.wizzer.app.web.commons.base.Globals;
- import cn.wizzer.app.web.commons.slog.annotation.SLog;
- import cn.wizzer.app.web.modules.controllers.httputils.HttpClient4;
- import cn.wizzer.framework.base.Result;
- import cn.wizzer.framework.page.datatable.DataTableColumn;
- import cn.wizzer.framework.page.datatable.DataTableOrder;
- import cn.wizzer.framework.util.DateUtil;
-
- /**
- * Created by William 2018年6月5日09:55:33
- */
- @IocBean
- @At("/platform/changxinyun")
- public class ChangXinYunController {
- @SuppressWarnings("unused")
- private static final Log log = Logs.get();
-
- @Inject
- private SysMenuService menuService;
-
- @Inject
- private ChangXinYunService changXinYunService;
-
- @Inject
- private Dao dao;
- //dao.create(ChangXinYunModel.class, true);
-
- @At({"", "/index/","/index/?"})
- @Ok("beetl:/changxinyun/index.html")
- @RequiresAuthentication
- public void index() {
- }
-
- @At
- @Ok("json:full")
- @RequiresAuthentication
- 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,
- HttpServletRequest req) {
- String whereName = "";
- if (!Strings.isBlank(name)){
- whereName = "and t.title LIKE '%"+name+"%' or kolName like '%"+name+"%'";
- }
- String sqlCount ="SELECT t.* from YZF_ChangXinYun t order by orderBy desc";// WHERE type='0'"+whereName+"ORDER BY isTop DESC";
- Sql sql = Sqls.create(sqlCount);
- NutMap re = changXinYunService.data(length, start, draw,sql,sql);
- @SuppressWarnings("rawtypes")
- LinkedList dataList = (LinkedList) re.get("data");
- for (int i=0;i<dataList.size();i++) {
- Record record = (Record) dataList.get(i);
- //map.keySet()返回的是所有key的值
- String str = record.getString("id");//得到每个key多对用value的值
- Sql sqlCount2 = Sqls.create("select count(*) as putScore from YZF_ChangXinYun");// WHERE leaveRoomDate IS NULL and roomId='"+str+"'");
- sqlCount2.setCallback(Sqls.callback.integer());
- int putScore=dao.execute(sqlCount2).getInt();
- record.put("putscore", putScore);
- }
- req.setAttribute("lists", re);
- System.out.println("re:"+re);
- return re;
- }
-
- @At
- @Ok("beetl:/changxinyun/add.html")
- @RequiresAuthentication
- @AdaptBy(type = WhaleAdaptor.class)
- public void add(HttpServletRequest req) {
- // // 美女与嘉宾列表
- // List<Member> memberList = changXinYunService.query(Cnd.where("ship","in","1,5"));
- // req.setAttribute("list1", memberList);
- // // 房间管理员列表
- // List<Member> memberList2 = changXinYunService.query(Cnd.where("ship","=","3"));
- // req.setAttribute("list2", memberList2);
- // // 赛事列表
- // List<GameMatchMain> re= changXinYunService.query(Cnd.where("isHot", "=", 1).orderBy("ABS(id)","desc"));
- // // 专家列表
- // List<Member> memberList4 = changXinYunService.query(Cnd.where("ship","=","1"));
- // req.setAttribute("list4", memberList4);
- // GameMatchMain gGameMatchMain=new GameMatchMain();
- // gGameMatchMain.setId("100");
- // gGameMatchMain.setMatchName("热门比赛");
- // re.add(0, gGameMatchMain);
- // req.setAttribute("list3", re);
- }
-
- @At
- @Ok("json")
- @SLog(tag = "新建测试", msg = "")
- @AdaptBy(type = WhaleAdaptor.class)
- public Object addDo(@Param("path") String path,@Param("key") String[] key,@Param("value") String[] value,@Param("methodName") String methodName,@Param("..") ChangXinYunModel chxyun,HttpServletRequest req) {
- System.out.println("");
- //String tokenString = HttpClient4.doPost(path,"");
- String result = HttpClient4.doGet(path);
- try {
- // room.setIsTop(StringUtils.isEmpty(isTopChoice) ? 0 : 1);
- // RongCloud rongCloud = RongCloud.getInstance();
- // // 创建聊天室方法
- // ChatRoomInfo[] chatroomCreateChatRoomInfo = {new ChatRoomInfo(room.getId(),room.getTitle())};
- // CodeSuccessResult chatroomCreateResult = rongCloud.chatroom.create(chatroomCreateChatRoomInfo);
- // System.out.println("chatroomCreateResult: " + chatroomCreateResult.toString());
- // if (chatroomCreateResult.getCode()==200 ){
- // room=addPushAndLive(room,room.getRoomMasterId()+(new Date().getTime()/1000));
- // // 创建数据库本地房间
- // room.setBanState(0);
- // room.setQuizType(0);
- // room.setType(0);
- // room.setDelFlag(false);
- // room.setMatchId("0264A18B938647D7ADFE1D70853D73D6");
- // room=roomService.insert(room);
- //
- // //清除缓存赛事首页房间缓存
- // RoomListCache roomListCache=RoomListCache.instanct;
- // Integer isTop=room.getIsTop();
- //
- // if(isTop==1){
- // String id=room.getId();
- // String sqlCount ="UPDATE room_room SET isTop='0' WHERE type='0' AND id<>'"+id+"';";
- // Sql sql = Sqls.create(sqlCount);
- // dao.execute(sql);
- //
- // }
- // roomListCache.clear();
- // return Result.success("system.success");
- // }
- return Result.success("success:"+result,result);
- } catch (Exception e) {
- return Result.error("system.error");
- }
-
- }
-
-
- @At
- @Ok("beetl:/changxinyun/importExcel.html")
- @SLog(tag = "新建测试", msg = "")
- @AdaptBy(type = WhaleAdaptor.class)
- public void doImportExcel() {
- }
-
- @AdaptBy(type = UploadAdaptor.class, args = {"ioc:videoExcel"})
- @POST
- @At
- @Ok("json")
- @RequiresAuthentication
- public Object dealWithExcel(@Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err) {
- try {
- if (err != null && err.getAdaptorErr() != null) return NutMap.NEW().addv("code", 1).addv("msg", "上传文件不合法");
- if (tf == null) return Result.error("请选择要上传的excelwenj");
-
- String f = Globals.AppUploadPath + "/image/" + DateUtil.format(new Date(), "yyyyMMdd") + "/" + R.UU32() + tf.getSubmittedFileName().substring(tf.getSubmittedFileName().indexOf("."));
- InputStream in = tf.getInputStream();
- String suffix = f.substring(f.lastIndexOf("."));
-
- if (StringUtils.isEmpty(suffix) || suffix.indexOf("xlsx") == -1)
- //2003-2007版本的excel
- readExcel(in,false);
- else
- //2010版excel
- readExcel(in,true);
-
-
- return Result.success("上传成功", Globals.AppBase+f);
-
- } catch (Exception e) {
-
- e.printStackTrace();
- return Result.error("系统错误");
-
- }
-
- }
-
- /**
- * 插入数据对象到数据库中
- * @param order
- * @param name
- * @param pid
- * @param phone
- * @return
- */
- private ChangXinYunModel doChangXinYunModel(int order,String name,String pid,String phone) {
- ChangXinYunModel cxyModel = new ChangXinYunModel();
- cxyModel.setOrderBy(order);
- cxyModel.setName(name);
- cxyModel.setPid(pid);
- cxyModel.setPhone(phone);
- StringBuilder sb = new StringBuilder();
- sb.append("https://api.--------?");
- sb.append("name="+name+"&");
- sb.append("pid="+pid+"&");
- sb.append("phone="+phone+"&");
- sb.append("type="+1+"&");
- String token = "cqixikuf5nkfmewd";
- sb.append("token="+token);
- String result = HttpClient4.doGet(sb.toString());
- cxyModel.setToken(token);
- cxyModel.setMethodName("GET");
- cxyModel.setOpAt(Integer.parseInt(System.currentTimeMillis()/1000+""));
- cxyModel.setPath(sb.toString());
- cxyModel.setRequestAt(""+System.currentTimeMillis());
- cxyModel.setResult(result);
- cxyModel.setDelFlag(false);
- cxyModel.setBank_card("");
- cxyModel.setComment("三要素认证");
- cxyModel.setHead("");
- cxyModel.setOtherInfo("");
- cxyModel.setPhone(phone);
- cxyModel.setPid(pid);
- dao.insert(cxyModel);
- return cxyModel;
- }
-
- @SuppressWarnings("deprecation")
- private String getValue(Cell cell) {
- if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN)
- return String.valueOf(cell.getBooleanCellValue()); // 返回布尔类型的值
- else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
- return String.valueOf(cell.getNumericCellValue()); // 返回数值类型的值
- else
- return String.valueOf(cell.getStringCellValue()); // 返回字符串类型的值
- }
-
- @SuppressWarnings("resource")
- private void readExcel(InputStream in,boolean is2010) throws Exception {
- InputStream is = in;
- org.apache.poi.ss.usermodel.Workbook workBook = null;
- if (is2010)
- workBook = new XSSFWorkbook(is); //2010
- else
- workBook = new HSSFWorkbook(is); //2003-2007
-
- if (workBook.getNumberOfSheets() < 1) throw new RuntimeException("excel没有表格存在");
-
- // 循环工作表Sheet
- for (int numSheet = 0; numSheet < workBook.getNumberOfSheets(); numSheet++) {
- Sheet sheet = workBook.getSheetAt(numSheet);
- if (sheet == null) {
- continue;
- }
-
- //校验表头 序号 姓名 身份证 手机号
- if (sheet.getLastRowNum() < 1) throw new RuntimeException(sheet.getSheetName() + ",不存在数据");
- Row headRow = sheet.getRow(0);
-
- if (headRow.getCell(0) == null || StringUtils.isEmpty(getValue(headRow.getCell(0))) || !getValue(headRow.getCell(0)).trim().equals("序号")) throw new RuntimeException("表头第一列必须为[序号]");
- if (headRow.getCell(1) == null || StringUtils.isEmpty(getValue(headRow.getCell(1))) || !getValue(headRow.getCell(1)).trim().equals("姓名")) throw new RuntimeException("表头第一列必须为[姓名]");
- if (headRow.getCell(2) == null || StringUtils.isEmpty(getValue(headRow.getCell(2))) || !getValue(headRow.getCell(2)).trim().equals("身份证")) throw new RuntimeException("表头第一列必须为[身份证]");
- if (headRow.getCell(3) == null || StringUtils.isEmpty(getValue(headRow.getCell(3))) || !getValue(headRow.getCell(3)).trim().equals("手机号")) throw new RuntimeException("表头第一列必须为[手机号]");
-
- //校验表格数据必须大于1条
- if (sheet.getLastRowNum() < 2) throw new RuntimeException(sheet.getSheetName() + ",没有需要导入的数据");
-
- // 循环行Row
- for (int rowNum = 3; rowNum <= sheet.getLastRowNum(); rowNum++) {
- Row row = sheet.getRow(rowNum);
- if (row == null) {
- continue;
- }
-
- //init Model
- doChangXinYunModel((int)Double.parseDouble(getValue(row.getCell(0))), getValue(row.getCell(1)), getValue(row.getCell(2)), getValue(row.getCell(3)));
- }
- }
- }
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。