修改bug
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2024/10/15 10:43【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "portable_off_main_log")
|
||||
public class PortableOffMainLog extends BaseEntity {
|
||||
/**
|
||||
* 批次id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 导入开始时间
|
||||
*/
|
||||
@TableField(value = "start_time")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
@TableField(value = "project_name")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 导入结束时间
|
||||
*/
|
||||
@TableField(value = "end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 成功解析数
|
||||
*/
|
||||
@TableField(value = "success_count")
|
||||
private Integer successCount;
|
||||
|
||||
/**
|
||||
* 状态(0:删除 1:正常)
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private String status;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<PortableOfflLog> portableOfflLogList;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Getter;
|
||||
@@ -21,6 +22,8 @@ public class PortableOfflLog extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String logsIndex;
|
||||
@TableField( value = "log_main_id")
|
||||
private String logMainId;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
@@ -38,7 +41,7 @@ public class PortableOfflLog extends BaseEntity {
|
||||
private String dataPath;
|
||||
|
||||
/**
|
||||
* 0-未解析 1-解析成功 2-解析失败 3-文件不存在
|
||||
* 0-无需解析解析 1-解析成功 2-解析失败 3-文件不存在
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
@@ -56,9 +56,10 @@ public class CsLogController extends BaseController {
|
||||
@ApiOperation("查询日志")
|
||||
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
|
||||
public HttpResult<IPage<CsLogsPO>> queryLog(@RequestBody BaseParam baseParam){
|
||||
IPage<CsLogsPO> list = csLogsPOService.queryPage(baseParam);
|
||||
String methodDescribe = getMethodDescribe("queryLog");
|
||||
|
||||
IPage<CsLogsPO> list = csLogsPOService.queryPage(baseParam);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.WlRecordTemplete;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
@@ -80,6 +81,15 @@ public class PortableOfflLogController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryMainLogPage")
|
||||
@ApiOperation("便携式设备解析日志")
|
||||
public HttpResult<Page<PortableOffMainLog>> queryMainLogPage(@RequestBody BaseParam baseParam){
|
||||
String methodDescribe = getMethodDescribe("queryMainLogPage");
|
||||
Page<PortableOffMainLog> list = iPortableOfflLogService.queryMainLogPage(baseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("离线数据导入")
|
||||
@PostMapping(value = "importEquipment")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2024/10/15 10:43【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface PortableOffMainLogMapper extends BaseMapper<PortableOffMainLog> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csdevice.mapper.PortableOffMainLogMapper">
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, start_time, project_name, end_time, success_count, create_by, create_time, update_by,
|
||||
update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||
import com.njcn.csdevice.param.UploadDataParam;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
@@ -19,4 +20,6 @@ public interface IPortableOfflLogService extends IService<PortableOfflLog> {
|
||||
Page<PortableOfflLog> queryPage(BaseParam baseParam);
|
||||
|
||||
void importEquipment(UploadDataParam uploadDataParam);
|
||||
|
||||
Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2024/10/15 10:43【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface PortableOffMainLogService extends IService<PortableOffMainLog>{
|
||||
|
||||
|
||||
}
|
||||
@@ -46,8 +46,9 @@ public class CsLogsPOServiceImpl extends ServiceImpl<CsLogsPOMapper, CsLogsPO> i
|
||||
String userRole = RequestUtil.getUserRole();
|
||||
List<String> strings = JSONArray.parseArray(userRole, String.class);
|
||||
QueryWrapper<CsLogsPO> csLogsPOQueryWrapper = new QueryWrapper<>();
|
||||
csLogsPOQueryWrapper.lambda().eq(!strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()),CsLogsPO::getUserName, username).
|
||||
ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()),CsLogsPO::getCreateTime,baseParam.getSearchBeginTime()).
|
||||
csLogsPOQueryWrapper.lambda()
|
||||
// .eq(!strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()),CsLogsPO::getUserName, username)
|
||||
.ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()),CsLogsPO::getCreateTime,baseParam.getSearchBeginTime()).
|
||||
le(StringUtils.isNotBlank(baseParam.getSearchEndTime()),CsLogsPO::getCreateTime,baseParam.getSearchEndTime()).orderByDesc(CsLogsPO::getCreateTime);
|
||||
IPage<CsLogsPO> list = this.getBaseMapper().selectPage(returnpage,csLogsPOQueryWrapper);
|
||||
return list;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.njcn.csdevice.mapper.PortableOffMainLogMapper;
|
||||
import com.njcn.csdevice.service.PortableOffMainLogService;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2024/10/15 10:43【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class PortableOffMainLogServiceImpl extends ServiceImpl<PortableOffMainLogMapper, PortableOffMainLog> implements PortableOffMainLogService{
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
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.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -11,10 +11,12 @@ import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.param.UploadDataParam;
|
||||
import com.njcn.csdevice.service.PortableOffMainLogService;
|
||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||
import com.njcn.csharmonic.api.EventFeignClient;
|
||||
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
|
||||
@@ -28,7 +30,6 @@ import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
|
||||
import com.njcn.csharmonic.offline.vo.Response;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.influx.imapper.CommonMapper;
|
||||
import com.njcn.influx.imapper.EvtDataMapper;
|
||||
import com.njcn.influx.imapper.PqdDataMapper;
|
||||
import com.njcn.influx.pojo.po.cs.EntData;
|
||||
@@ -41,6 +42,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -48,6 +50,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -87,6 +90,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
private final EvtDataMapper evtDataMapper;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
private final PortableOffMainLogService portableOffMainLogService;
|
||||
|
||||
@Override
|
||||
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
||||
@@ -244,10 +248,21 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
//开始上传文件、记录上传日志、解析的文件结果入库
|
||||
//最外层便利所有文件确保所有文件都上传及记录上传日志
|
||||
int nowStep = 0;
|
||||
PortableOffMainLog portableOffMainLog = new PortableOffMainLog();
|
||||
portableOffMainLog.setId(IdUtil.fastSimpleUUID());
|
||||
portableOffMainLog.setStartTime(LocalDateTime.now());
|
||||
portableOffMainLog.setProjectName(uploadDataParam.getPaths().stream()
|
||||
.reduce((s1, s2) -> getCommonPrefix(s1, s2))
|
||||
.orElse(null));
|
||||
int successcCount = 0;
|
||||
portableOffMainLog.setStatus("1");
|
||||
|
||||
|
||||
for(MultipartFile file : uploadDataParam.getFiles()){
|
||||
|
||||
//初始上传日志基本信息
|
||||
PortableOfflLog portableOfflLog = new PortableOfflLog();
|
||||
portableOfflLog.setLogMainId(portableOffMainLog.getId());
|
||||
portableOfflLog.setName(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("/")+1));
|
||||
portableOfflLog.setPath(file.getOriginalFilename());
|
||||
portableOfflLog.setDataPath(fileStorageUtil.uploadMultipart(file, DataParam.wlRecordPath+uploadDataParam.getDevId()+"/"+uploadDataParam.getLineId()+"/"+getFolderName()+"/"));
|
||||
@@ -443,8 +458,32 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
String json = "{allStep:"+uploadDataParam.getFiles().size()+",nowStep:"+nowStep+"}";
|
||||
|
||||
publisher.send("/dataOnlineRecruitment/Progress/" + uploadDataParam.getLineId(), new Gson().toJson(json), 1, false);
|
||||
this.baseMapper.insert(portableOfflLog);
|
||||
//无需解析的不需要记录
|
||||
if(portableOfflLog.getState()!=0){
|
||||
this.baseMapper.insert(portableOfflLog);
|
||||
successcCount++;
|
||||
}
|
||||
|
||||
}
|
||||
portableOffMainLog.setEndTime(LocalDateTime.now());
|
||||
portableOffMainLog.setSuccessCount(successcCount);
|
||||
portableOffMainLogService.save(portableOffMainLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam) {
|
||||
Page<PortableOffMainLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
|
||||
QueryWrapper<PortableOffMainLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda()
|
||||
.ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()), PortableOffMainLog::getCreateTime,baseParam.getSearchBeginTime())
|
||||
.le(StringUtils.isNotBlank(baseParam.getSearchEndTime()),PortableOffMainLog::getCreateTime,baseParam.getSearchEndTime()).orderByDesc(PortableOffMainLog::getCreateTime);
|
||||
Page<PortableOffMainLog> portableOffMainLogPage = portableOffMainLogService.getBaseMapper().selectPage(returnpage, queryWrapper);
|
||||
portableOffMainLogPage.getRecords().forEach(temp->{
|
||||
List<PortableOfflLog> list = this.lambdaQuery().eq(PortableOfflLog::getLogMainId, temp.getId()).list();
|
||||
temp.setPortableOfflLogList(list);
|
||||
});
|
||||
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
//根据文件全路径(包含文件夹)解析文件的分类
|
||||
@@ -461,4 +500,13 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
private static String getCommonPrefix(String s1, String s2) {
|
||||
for (int i = 0; i <= s1.length() && i <= s2.length(); i++) {
|
||||
if (i == s1.length() || i == s2.length() || s1.charAt(i) != s2.charAt(i)) {
|
||||
return s1.substring(0, i);
|
||||
}
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user