作者 王勇

功能基本完善

... ... @@ -19,9 +19,6 @@ public class MyWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/exit/**").addResourceLocations("file:" + dir + "/");
// registry.addResourceHandler("/exit/excel/**").addResourceLocations("file:excel/");
// registry.addResourceHandler("/exit/downExcel/**").addResourceLocations("file:excel/");
// registry.addResourceHandler("/exit/delete/**").addResourceLocations("file:excel/");
WebMvcConfigurer.super.addResourceHandlers(registry);
}
... ...
... ... @@ -154,7 +154,7 @@ public class NmsController {
String resultJs = GsonUtils.toJsonStr(resultWs);
sendMsgByWebsocket(resultJs, sid);
}
index = index + i - 1;
index = index + i;
//完成一次,就等待。每次减1,为0的时候往下执行
latch.await();
}
... ... @@ -182,7 +182,6 @@ public class NmsController {
log.error("获取数据出错", e);
}
final String endTime = sdf.format(new Date());
log.info("出港信息,获取完毕,index的值为:" + index);
log.info("结束时间:" + endTime);
String resultJs = GsonUtils.toJsonStr(new ResultWs("获取数据,完成", resultList, "200", resultList.size(), resultList.size()));
sendMsgByWebsocket(resultJs, sid);
... ... @@ -251,18 +250,18 @@ public class NmsController {
result.setAimStation(pm.get(0).getDestinationStation());
}
/**
* //获取数据仓库的对应数据
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
ResultExitData dataWareHouseInfo=new ResultExitData();
dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
//设置体积
result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
//设置计费重量
result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
* 获取数据仓库的对应数据
*/
ResultExitData dataWareHouseInfo = new ResultExitData();
dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
//设置体积
result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
//设置计费重量
result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
//获取运输工具的对应数据
/**
* 获取运输工具的对应数据
*/
ResultExitData transportInfo = new ResultExitData();
transportInfo = getTransportFeign.getInfo(result.getFlightNo(), result.getFlightDate());
//设置航班公司
... ... @@ -278,7 +277,9 @@ public class NmsController {
//设置航班计划时间
result.setFlightPlanTime(transportInfo.getFlightPlanTime());
//获取代理人的相关数据
/**
* 获取代理人的相关数据
*/
ResultExitData asmInfo = new ResultExitData();
asmInfo = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
//设置结算代理人
... ...
... ... @@ -17,11 +17,15 @@ import javax.annotation.Resource;
@RequestMapping("exit")
@RestController
public class DeleteExcel {
@Resource
private DeleteExpiredFile deleteExpiredFile;
// @Scheduled(cron="0 48 18 * * ? ")
/**
* 每天凌晨4点,执行定时任务,删除缓存的文件
*
* @return
*/
@Scheduled(cron = "0 0 4 * * ? ")
@GetMapping("/delete")
public ResultJson deleteExcel() {
... ...
... ... @@ -30,7 +30,6 @@ public class DeleteExpiredFile {
long timeInterval;
public void deleteExpiredFileTask() {
//File.separator
String path = dir + "/";
File file = new File(path);
deleteExpiredFile(file);
... ... @@ -70,7 +69,7 @@ public class DeleteExpiredFile {
// 当前时间的时间戳
long currentTime = System.currentTimeMillis();
// 设置时间范围
// long timeInterval = 7 * 24 * 60 * 60 * 1000;
// long timeInterval = 7 * 24 * 60 * 60 * 1000;
// 删除七天(一周)前的所有文件
if (currentTime - lastModifiedTime > timeInterval) {
file.delete();
... ...
... ... @@ -15,7 +15,7 @@ public class ExitThreadPoolFactory {
public static ThreadPoolExecutor instance() {
if (threadPool == null) {
ExitThreadFactory exitThreadFactory = new ExitThreadFactory("exit");
threadPool = new ThreadPoolExecutor(10, 100,
threadPool = new ThreadPoolExecutor(20, 100,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024),
exitThreadFactory,
... ...
package com.sunyo.wlpt.cgonms.provide.websocket;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.sunyo.wlpt.cgonms.provide.controller.NmsController;
... ... @@ -29,13 +28,17 @@ public class WebSocketServer {
static Log log = LogFactory.get(WebSocketServer.class);
//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
/**
* 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
*/
private static int onlineCount = 0;
//concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<WebSocketServer>();
//与某个客户端的连接会话,需要通过它来给客户端发送数据
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
private Session session;
//接收sid
... ... @@ -47,8 +50,10 @@ public class WebSocketServer {
@OnOpen
public void onOpen(Session session, @PathParam("sid") String sid) {
this.session = session;
webSocketSet.add(this); //加入set中
addOnlineCount(); //在线数加1
//加入set中
webSocketSet.add(this);
//在线数加1
addOnlineCount();
log.info("有新窗口开始监听:" + sid + ",当前在线人数为" + getOnlineCount());
this.sid = sid;
try {
... ... @@ -64,8 +69,10 @@ public class WebSocketServer {
*/
@OnClose
public void onClose() {
webSocketSet.remove(this); //从set中删除
subOnlineCount(); //在线数减1
//从set中删除
webSocketSet.remove(this);
//在线数减1
subOnlineCount();
log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
}
... ... @@ -76,11 +83,6 @@ public class WebSocketServer {
*/
@OnMessage
public void onMessage(String message, Session session) {
// JSONObject jsonObj = new JSONObject(message);
// String flightNo = jsonObj.get("flightNo").toString();
// String flightDate = jsonObj.get("flightDate").toString();
// nmsController.getData()
log.info("收到来自窗口" + sid + "的信息:" + message);
//群发消息
for (WebSocketServer item : webSocketSet) {
... ... @@ -114,7 +116,6 @@ public class WebSocketServer {
* 群发自定义消息
*/
public static void sendInfo(String message, @PathParam("sid") String sid) throws IOException {
//log.info("推送消息到窗口"+sid+",推送内容:"+message);
for (WebSocketServer item : webSocketSet) {
try {
//这里可以设定只推送给这个sid的,为null则全部推送
... ...