离线数据上传

This commit is contained in:
hzj
2024-10-08 20:51:58 +08:00
parent 867176d8a0
commit 105a5314cb

View File

@@ -1,7 +1,10 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
@@ -83,6 +86,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
private final EvtDataMapper evtDataMapper;
private final MqttPublisher publisher;
@Override
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
Page<PortableOfflLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
@@ -238,8 +243,9 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
boolean minFlag = true;
//开始上传文件、记录上传日志、解析的文件结果入库
//最外层便利所有文件确保所有文件都上传及记录上传日志
int nowStep = 0;
for(MultipartFile file : uploadDataParam.getFiles()){
//初始上传日志基本信息
PortableOfflLog portableOfflLog = new PortableOfflLog();
portableOfflLog.setName(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("/")+1));
@@ -433,6 +439,10 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
}
}
nowStep++;
String json = "{allStep:"+uploadDataParam.getFiles().size()+",nowStep:"+nowStep+"}";
publisher.send("/dataOnlineRecruitment/Progress/" + uploadDataParam.getLineId(), new Gson().toJson(json), 1, false);
this.baseMapper.insert(portableOfflLog);
}
}