Commit 5b78622f authored by 赵啸非's avatar 赵啸非

更改解压方法

parent cc390cc1
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<div class="page"> <div class="page">
<LayoutTable :data="tableData" :config="tableConfig"> <LayoutTable :data="tableData" :config="tableConfig">
</LayoutTable> </LayoutTable>
<drawer-show ref="drawerform" @ok="getData" /> <drawer-show ref="drawerform" @ok="getData" />
</div> </div>
</template> </template>
......
...@@ -13,12 +13,12 @@ module.exports = { ...@@ -13,12 +13,12 @@ module.exports = {
devServer: { devServer: {
inline: true, inline: true,
disableHostCheck: true, disableHostCheck: true,
port: 8084, port: 8085,
hot: true,//自动保存 hot: true,//自动保存
proxy: { proxy: {
'/m': { '/m': {
// target: 'http://192.168.0.98:11078', target: 'http://192.168.0.98:11078',
target: 'http://127.0.0.1:18222', //target: 'http://127.0.0.1:18222',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
cookieDomainRewrite: 'plm.testnew.com', cookieDomainRewrite: 'plm.testnew.com',
......
package com.mortals.xhx.common.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.*;
@Slf4j
public class ZipUtils {
public static void main(String[] args) throws Exception {
unzip(new File("F:\\1664176173348.zip"), "F:\\tmp");
// String path = "F:\\Users\\Isuzu\\Desktop\\test.zip";
// unzip(new File(path), "D:\\data");
}
public static void unzip(File zipFile, String descDir) {
try (ZipArchiveInputStream inputStream = getZipFile(zipFile)) {
File pathFile = new File(descDir);
if (!pathFile.exists()) {
pathFile.mkdirs();
}
ZipArchiveEntry entry = null;
while ((entry = inputStream.getNextZipEntry()) != null) {
if (entry.isDirectory()) {
File directory = new File(descDir, entry.getName());
directory.mkdirs();
} else {
OutputStream os = null;
try {
os = new BufferedOutputStream(new FileOutputStream(new File(descDir, entry.getName())));
//输出文件路径信息
log.info("解压文件的当前路径为:{}", descDir + entry.getName());
IOUtils.copy(inputStream, os);
} finally {
IOUtils.closeQuietly(os);
}
}
}
final File[] files = pathFile.listFiles();
if (files != null && files.length == 1 && files[0].isDirectory()) {
// 说明只有一个文件夹
FileUtils.copyDirectory(files[0], pathFile);
//免得删除错误, 删除的文件必须在/data/demand/目录下。
// boolean isValid = files[0].getPath().contains("/data/www/");
// if (isValid) {
// FileUtils.forceDelete(files[0]);
// }
}
log.info("******************解压完毕********************");
} catch (Exception e) {
log.error("[unzip] 解压zip文件出错", e);
}
}
private static ZipArchiveInputStream getZipFile(File zipFile) throws Exception {
return new ZipArchiveInputStream(new BufferedInputStream(new FileInputStream(zipFile)));
}
}
package com.mortals.xhx.daemon.netty.server.controlserver.handler; package com.mortals.xhx.daemon.netty.server.controlserver.handler;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -17,7 +16,6 @@ import io.netty.channel.SimpleChannelInboundHandler; ...@@ -17,7 +16,6 @@ import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
...@@ -69,9 +67,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -69,9 +67,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
//EncryptUtil.decrypt(content, ENCRYPT_STR); //EncryptUtil.decrypt(content, ENCRYPT_STR);
log.info("receive->UDPafter:{}", packet.sender().toString() + "," + content); log.info("receive->UDPafter:{}", packet.sender().toString() + "," + content);
JSONObject jsonObject = JSON.parseObject(content); JSONObject jsonObject = JSON.parseObject(content);
String action = jsonObject.getString("action"); String action = jsonObject.getString("action");
resp.setMsg("获取服务端地址成功!"); resp.setMsg("获取服务端地址成功!");
if (!ObjectUtils.isEmpty(action) && "findserver".equals(action)) { if (!ObjectUtils.isEmpty(action) && "findserver".equals(action)) {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
...@@ -97,7 +93,6 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -97,7 +93,6 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
String sa = EncryptUtil.myEnscrt(JSON.toJSONString(resp), 9, DES_STR, ENCRYPT_STR); String sa = EncryptUtil.myEnscrt(JSON.toJSONString(resp), 9, DES_STR, ENCRYPT_STR);
// log.info("enStr:{}",sa); // log.info("enStr:{}",sa);
// log.info("deEncrypt:{}", EncryptUtil.myReEnscrt(sa, 9, DES_STR, ENCRYPT_STR)); // log.info("deEncrypt:{}", EncryptUtil.myReEnscrt(sa, 9, DES_STR, ENCRYPT_STR));
//
DatagramPacket sendpacket = new DatagramPacket(Unpooled.copiedBuffer(sa, CharsetUtil.UTF_8), remoteAddress); DatagramPacket sendpacket = new DatagramPacket(Unpooled.copiedBuffer(sa, CharsetUtil.UTF_8), remoteAddress);
//ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), packet.sender())); //ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), packet.sender()));
ctx.writeAndFlush(sendpacket); ctx.writeAndFlush(sendpacket);
......
...@@ -5,22 +5,22 @@ import cn.hutool.core.util.ZipUtil; ...@@ -5,22 +5,22 @@ import cn.hutool.core.util.ZipUtil;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.ImageReEnum; import com.mortals.xhx.common.code.ImageReEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.ZipUtils;
import com.mortals.xhx.module.device.dao.DeviceModuleDistributeDao;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import com.mortals.xhx.module.product.model.ProductEntity; import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceModuleDistributeDao;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;
import java.util.zip.ZipEntry;
/** /**
* DeviceModuleDistributeService * DeviceModuleDistributeService
...@@ -86,14 +86,20 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D ...@@ -86,14 +86,20 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D
FileUtil.del(disPath); FileUtil.del(disPath);
} }
ZipUtil.unzip(targetFilePath, disPath); ZipUtils.unzip(new File(targetFilePath), disPath);
// ZipUtil.unzip(targetFilePath, disPath);
//更新 //更新
distributeEntity.setDistributeFilePath(disPath); distributeEntity.setDistributeFilePath(disPath);
distributeEntity.setDistribute(YesNoEnum.YES.getValue()); distributeEntity.setDistribute(YesNoEnum.YES.getValue());
distributeEntity.setUpdateTime(new Date()); distributeEntity.setUpdateTime(new Date());
this.update(distributeEntity, context); this.update(distributeEntity, context);
}
public static void main(String[] args) {
ZipUtil.unzip("F:\\1664176173348.zip", "F:\\tmp");
} }
} }
\ No newline at end of file
{ {
"local": { "local": {
"baseUrl": "http://127.0.0.1:18222/m", "baseUrl": "http://127.0.0.1:18228/m",
"baseLogin": "http://127.0.0.1:18222/m" "baseLogin": "http://127.0.0.1:18228/m"
}, },
"dev": { "dev": {
"baseUrl": "http://192.168.0.217:18222/m", "baseUrl": "http://192.168.0.217:18222/m",
"baseLogin": "http://192.168.0.98:11078/base" "baseLogin": "http://192.168.0.98:11078/base"
}, },
"test": { "test": {
"baseUrl": "http://192.168.0.98:11091/m", "baseUrl": "http://192.168.0.98:11078/m",
"baseLogin": "http://192.168.0.98:11078/base" "baseLogin": "http://192.168.0.98:11078/base"
}, },
"portal": { "portal": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment