diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/OssPath.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/OssPath.java index eaddd037f..a8cb4cc44 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/OssPath.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/OssPath.java @@ -22,5 +22,15 @@ public interface OssPath { */ String HARMONIC_EXCEL_TEMPLATE="harmonic/excel/template"; + /*** + * 算法模块的上传路径 + */ + String ALGORITHM="algorithm/"; + + /*** + * process模块中干扰源入网报告的上传路径 + */ + String LOAD_TYPE_USER="loadTypeUser/"; + } diff --git a/pqs-common/common-minio/src/main/java/com/njcn/minio/utils/MinIoUtils.java b/pqs-common/common-minio/src/main/java/com/njcn/minio/utils/MinIoUtils.java index 04237d254..a2909f65e 100644 --- a/pqs-common/common-minio/src/main/java/com/njcn/minio/utils/MinIoUtils.java +++ b/pqs-common/common-minio/src/main/java/com/njcn/minio/utils/MinIoUtils.java @@ -536,7 +536,7 @@ public class MinIoUtils { * @author exe.wangtaotao * @date 2020/10/21 15:07 */ - private String minFileName(String originalFileName) { + public String minFileName(String originalFileName) { String suffix = originalFileName; if (originalFileName.contains(SEPARATOR_DOT)) { suffix = originalFileName.substring(originalFileName.lastIndexOf(SEPARATOR_DOT)); diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/algorithm/AlgorithmController.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/algorithm/AlgorithmController.java index 9d207035d..127e1318d 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/algorithm/AlgorithmController.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/algorithm/AlgorithmController.java @@ -1,7 +1,10 @@ package com.njcn.harmonic.controller.algorithm; import cn.hutool.core.bean.BeanUtil; +import com.njcn.common.config.GeneralInfo; import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.GeneralConstant; +import com.njcn.common.pojo.constant.OssPath; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; @@ -13,6 +16,7 @@ import com.njcn.harmonic.pojo.param.RStatFileVO; import com.njcn.harmonic.pojo.po.RStatFile; import com.njcn.harmonic.pojo.vo.PwRStatOrgVO; import com.njcn.harmonic.service.algorithm.RStatFileService; +import com.njcn.huawei.obs.util.OBSUtil; import com.njcn.minio.bo.MinIoUploadResDTO; import com.njcn.minio.config.MinIoProperties; import com.njcn.minio.utils.MinIoUtils; @@ -42,6 +46,12 @@ public class AlgorithmController extends BaseController { @Resource private MinIoProperties minIoProperties; + @Resource + private GeneralInfo generalInfo; + + @Resource + private OBSUtil obsUtil; + /** * 算法保存 * @@ -56,10 +66,10 @@ public class AlgorithmController extends BaseController { String methodDescribe = getMethodDescribe("getAlgorithmSave"); RStatFile rStatFile = BeanUtil.copyProperties(param, RStatFile.class); boolean b = rStatFileService.updateById(rStatFile); - if(b){ + if (b) { // minIoUtils.removeObjects( minIoProperties.getBucket(),param.getAddress()); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); - }else{ + } else { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); } } @@ -79,16 +89,19 @@ public class AlgorithmController extends BaseController { */ @PostMapping("/common/upload") @ResponseBody - public HttpResult uploadFile(MultipartFile file) - { - try - { - //把名称存入数据 - MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "algorithm/"); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, upload, null); - } - catch (Exception e) - { + public HttpResult uploadFile(MultipartFile file) { + try { + //为2则为:华为OBS + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + String fileName = file.getOriginalFilename(); + fileName = OssPath.ALGORITHM + minIoUtils.minFileName(fileName); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, obsUtil.multiFileUpload(file, fileName), null); + } else { + //把名称存入数据 + MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), OssPath.ALGORITHM); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, upload.getMinFileUrl(), null); + } + } catch (Exception e) { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, null); } } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CustomReportServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CustomReportServiceImpl.java index 0281d5fac..1df5ec05c 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CustomReportServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CustomReportServiceImpl.java @@ -8,6 +8,8 @@ import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.common.config.GeneralInfo; +import com.njcn.common.pojo.constant.GeneralConstant; +import com.njcn.common.pojo.constant.OssPath; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.harmonic.enums.HarmonicResponseEnum; @@ -26,6 +28,7 @@ import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.pojo.vo.ReportTreeVO; import com.njcn.harmonic.pojo.vo.SysDeptTempVO; import com.njcn.harmonic.service.CustomReportService; +import com.njcn.huawei.obs.util.OBSUtil; import com.njcn.influxdb.config.InfluxDbConfig; import com.njcn.influxdb.param.InfluxDBSqlConstant; import com.njcn.influxdb.param.InfluxDBTableConstant; @@ -98,21 +101,35 @@ public class CustomReportServiceImpl implements CustomReportService { @Resource private InfluxDbConfig influxDbConfig; + @Resource + private OBSUtil obsUtil; + + @Override public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) { checkName(reportTemplateParam, false); - + MultipartFile fileContent = reportTemplateParam.getFileContent(); + String fileName = fileContent.getName(); //检验模板json数据规范 try { - String content = MultipartFileToString(reportTemplateParam.getFileContent()); + String content = MultipartFileToString(fileContent); new JSONArray(content); } catch (Exception e) { throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON); } - //文件上传到Minio服务器,存入文件名 - MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent()); - reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName()); + //为2则为:华为OBS + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + fileName = OssPath.HARMONIC_EXCEL_TEMPLATE + minIoUtils.minFileName(fileName); + obsUtil.multiFileUpload(fileContent,fileName); + reportTemplateParam.setContent(fileName); + } else { + //否则认为是minioss + //文件上传到Minio服务器,存入文件名 + MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent(), OssPath.HARMONIC_EXCEL_TEMPLATE); + reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName()); + } + //新增模板表 ExcelRptTemp excelRptTemp = new ExcelRptTemp(); @@ -137,10 +154,11 @@ public class CustomReportServiceImpl implements CustomReportService { @Override public boolean updateCustomReportTemplate(ReportTemplateParam.UpdateReportTemplateParam reportTemplateParam) { checkName(reportTemplateParam, true); - + MultipartFile fileContent = reportTemplateParam.getFileContent(); + String fileName = fileContent.getName(); //检验模板json数据规范 try { - String content = MultipartFileToString(reportTemplateParam.getFileContent()); + String content = MultipartFileToString(fileContent); new JSONArray(content); } catch (Exception e) { throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON); @@ -148,12 +166,18 @@ public class CustomReportServiceImpl implements CustomReportService { //删除之前的文件 ExcelRptTemp excelRptTempOld = excelRptTempMapper.selectById(reportTemplateParam.getId()); - minIoUtils.removeObject(minIoProperties.getBucket(), excelRptTempOld.getContent()); - - //文件上传到Minio服务器,存入文件名 - MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent()); - reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName()); - + //为2则为:华为OBS + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + obsUtil.delete(excelRptTempOld.getContent()); + fileName = OssPath.HARMONIC_EXCEL_TEMPLATE + minIoUtils.minFileName(fileName); + obsUtil.multiFileUpload(fileContent,fileName); + reportTemplateParam.setContent(fileName); + }else{ + minIoUtils.removeObject(minIoProperties.getBucket(), excelRptTempOld.getContent()); + //文件上传到Minio服务器,存入文件名 + MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent(), OssPath.HARMONIC_EXCEL_TEMPLATE); + reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName()); + } //修改模板数据 ExcelRptTemp excelRptTemp = new ExcelRptTemp(); BeanUtils.copyProperties(reportTemplateParam, excelRptTemp); @@ -240,10 +264,10 @@ public class CustomReportServiceImpl implements CustomReportService { lambdaQuery.eq(ExcelRpt::getLineId, reportSearchParam.getLineId()).eq(ExcelRpt::getTempId, reportSearchParam.getTempId()); List excelRpts = excelRptMapper.selectList(lambdaQuery); String content; - if (excelRpts.size() > 0){ + if (excelRpts.size() > 0) { content = minIoUtils.getObjectUrl(minIoProperties.getBucket(), excelRpts.get(0).getContent(), 7 * 24 * 60 * 60); - }else{ - content = minIoUtils.getObjectUrl(minIoProperties.getBucket(), analyzeReport(reportSearchParam,excelRptTemp), 7 * 24 * 60 * 60); + } else { + content = minIoUtils.getObjectUrl(minIoProperties.getBucket(), analyzeReport(reportSearchParam, excelRptTemp), 7 * 24 * 60 * 60); } //拼接数据 @@ -364,7 +388,7 @@ public class CustomReportServiceImpl implements CustomReportService { /** * 解析报表数据 */ - private String analyzeReport(ReportSearchParam reportSearchParam,ExcelRptTemp excelRptTemp){ + private String analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp) { //根据content,获取v值并进行处理 List reportTemplateDTOList = new ArrayList<>(); JSONArray jsonArray = null; @@ -394,7 +418,7 @@ public class CustomReportServiceImpl implements CustomReportService { if (vItem.length == 4) { //$HA[_25]#B#max#classId$ reportTemplateDTO.setTemplateName(vItem[0]); - reportTemplateDTO.setPhase(vItem[1].substring(0,1)); + reportTemplateDTO.setPhase(vItem[1].substring(0, 1)); reportTemplateDTO.setStatMethod(vItem[2].toUpperCase()); reportTemplateDTO.setClassId(vItem[3]); } else if (vItem.length == 3) { @@ -462,11 +486,22 @@ public class CustomReportServiceImpl implements CustomReportService { }); } - //文件上传到Minio服务器,存入文件名 + String newContent; File newFile = stringToFile(jsonArray.toString()); MultipartFile newMultipartFile = getMultipartFile(newFile); - MinIoUploadResDTO minIoUploadResDTO = contentToMinio(newMultipartFile); - String newContent = minIoUploadResDTO.getMinFileName(); + //为2则为:华为OBS + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + newContent = newMultipartFile.getName(); + newContent = OssPath.HARMONIC_EXCEL_REPORT + minIoUtils.minFileName(newContent); + obsUtil.multiFileUpload(newMultipartFile,newContent); + }else{ + //否则认为是minioss + //文件上传到Minio服务器,存入文件名 + MinIoUploadResDTO minIoUploadResDTO = contentToMinio(newMultipartFile,OssPath.HARMONIC_EXCEL_REPORT); + newContent = minIoUploadResDTO.getMinFileName(); + } + + //存入报表库 ExcelRpt excelRpt = new ExcelRpt(); @@ -479,7 +514,7 @@ public class CustomReportServiceImpl implements CustomReportService { //根据模板激活状态,判断是否进库(修改State字段:0未进库 1已进库) if (DataStateEnum.ENABLE.getCode().equals(reportSearchParam.getActivation())) { excelRpt.setState(DataStateEnum.ENABLE.getCode()); - }else{ + } else { excelRpt.setState(DataStateEnum.DELETED.getCode()); } excelRptMapper.insert(excelRpt); @@ -496,9 +531,9 @@ public class CustomReportServiceImpl implements CustomReportService { //sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai') //cp95函数特殊处理 PERCENTILE(field_key, N) - if (InfluxDBSqlConstant.CP95.equals(method)){ + if (InfluxDBSqlConstant.CP95.equals(method)) { sql.append(method).append(InfluxDBSqlConstant.LBK).append(data.getTemplateName()).append(InfluxDBSqlConstant.NUM_95).append(InfluxDBSqlConstant.RBK).append(InfluxDBSqlConstant.AS_VALUE); - }else{ + } else { sql.append(method).append(InfluxDBSqlConstant.LBK).append(data.getTemplateName()).append(InfluxDBSqlConstant.RBK).append(InfluxDBSqlConstant.AS_VALUE); } sql.append(InfluxDBSqlConstant.FROM).append(data.getClassId()).append(InfluxDBSqlConstant.WHERE).append(InfluxDBTableConstant.LINE_ID).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(reportSearchParam.getLineId()).append(InfluxDBSqlConstant.QM); @@ -508,7 +543,7 @@ public class CustomReportServiceImpl implements CustomReportService { } //data_flicker、data_fluc、data_plt 无 value_type - if (!InfluxDBTableConstant.DATA_FLICKER.equals(data.getClassId()) && !InfluxDBTableConstant.DATA_FLUC.equals(data.getClassId()) && !InfluxDBTableConstant.DATA_PLT.equals(data.getClassId())){ + if (!InfluxDBTableConstant.DATA_FLICKER.equals(data.getClassId()) && !InfluxDBTableConstant.DATA_FLUC.equals(data.getClassId()) && !InfluxDBTableConstant.DATA_PLT.equals(data.getClassId())) { sql.append(InfluxDBSqlConstant.AND).append(InfluxDBTableConstant.VALUE_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(data.getStatMethod()).append(InfluxDBSqlConstant.QM); } sql.append(InfluxDBSqlConstant.TZ); @@ -520,7 +555,7 @@ public class CustomReportServiceImpl implements CustomReportService { List results = queryResult.getResults(); if (results.size() != 0) { QueryResult.Result result = results.get(0); - if (result.getSeries() != null){ + if (result.getSeries() != null) { List seriess = result.getSeries(); if (seriess.size() != 0) { QueryResult.Series series = seriess.get(0); @@ -545,10 +580,10 @@ public class CustomReportServiceImpl implements CustomReportService { * @param file 文件 * @return 成功标记 */ - private MinIoUploadResDTO contentToMinio(MultipartFile file) { + private MinIoUploadResDTO contentToMinio(MultipartFile file, String dir) { try { //把名称存入数据 - MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "report/"); + MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), dir); return upload; } catch (Exception e) { throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_FILE); @@ -566,7 +601,7 @@ public class CustomReportServiceImpl implements CustomReportService { BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); StringBuffer buffer = new StringBuffer(); String line = " "; - while ((line = in.readLine()) != null){ + while ((line = in.readLine()) != null) { buffer.append(line); } return buffer.toString(); @@ -575,7 +610,7 @@ public class CustomReportServiceImpl implements CustomReportService { /** * 字符串写入指定文件 * - * @param res 原字符串 + * @param res 原字符串 * @return 成功标记 */ public File stringToFile(String res) { @@ -584,7 +619,9 @@ public class CustomReportServiceImpl implements CustomReportService { String businessTempPath = generalInfo.getBusinessTempPath(); File distFile = new File(businessTempPath + File.separator + "temp.json"); try { - if (!distFile.getParentFile().exists()) distFile.getParentFile().mkdirs(); + if (!distFile.getParentFile().exists()){ + distFile.getParentFile().mkdirs(); + } bufferedReader = new BufferedReader(new StringReader(res)); bufferedWriter = new BufferedWriter(new FileWriter(distFile)); bufferedWriter.write(""); diff --git a/pqs-process/process-boot/pom.xml b/pqs-process/process-boot/pom.xml index fbd19f790..7b49be431 100644 --- a/pqs-process/process-boot/pom.xml +++ b/pqs-process/process-boot/pom.xml @@ -114,6 +114,12 @@ 1.0.0 compile + + + com.njcn + huawei-obs-springboot-starter + ${project.version} + diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/LoadTypeUserManageServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/LoadTypeUserManageServiceImpl.java index e6e8141e4..bce24b7ad 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/LoadTypeUserManageServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/LoadTypeUserManageServiceImpl.java @@ -4,8 +4,12 @@ import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.config.GeneralInfo; +import com.njcn.common.pojo.constant.GeneralConstant; +import com.njcn.common.pojo.constant.OssPath; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.device.pms.api.DistributionMonitorClient; +import com.njcn.huawei.obs.util.OBSUtil; import com.njcn.minio.bo.MinIoUploadResDTO; import com.njcn.minio.config.MinIoProperties; import com.njcn.minio.utils.MinIoUtils; @@ -60,16 +64,22 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService @Resource private MinIoUtils minIoUtils; + @Resource + private GeneralInfo generalInfo; + + @Resource + private OBSUtil obsUtil; @Resource private MinIoProperties minIoProperties; /** * 干扰源用户分页查询 + * * @param loadTypeUserSearchParam * @return */ @Override - public Page getLoadTypeUserList(LoadTypeUserSearchParam loadTypeUserSearchParam){ + public Page getLoadTypeUserList(LoadTypeUserSearchParam loadTypeUserSearchParam) { Page page = new Page<>(loadTypeUserSearchParam.getPageNum(), loadTypeUserSearchParam.getPageSize()); Page loadTypeUserPage = loadTypeUserManageMapper.getLoadTypeUserPage(page, loadTypeUserSearchParam); @@ -90,6 +100,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 根据id查询干扰源用户 + * * @param id * @return */ @@ -99,11 +110,11 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService RLoadTypeUserManageVO rLoadTypeUserManageVO = new RLoadTypeUserManageVO(); BeanUtils.copyProperties(rLoadTypeUserManage, rLoadTypeUserManageVO); //文件 - if (rLoadTypeUserManageVO.getIFilePath() != null){ + if (rLoadTypeUserManageVO.getIFilePath() != null) { String iFile = minIoUtils.getObjectUrl(minIoProperties.getBucket(), rLoadTypeUserManageVO.getIFilePath(), 7 * 24 * 60 * 60); rLoadTypeUserManageVO.setIFile(iFile); } - if (rLoadTypeUserManageVO.getAFilePath() != null){ + if (rLoadTypeUserManageVO.getAFilePath() != null) { String aFile = minIoUtils.getObjectUrl(minIoProperties.getBucket(), rLoadTypeUserManageVO.getAFilePath(), 7 * 24 * 60 * 60); rLoadTypeUserManageVO.setIFile(aFile); } @@ -112,6 +123,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 新增干扰源用户 + * * @param loadTypeUserParam * @return */ @@ -130,6 +142,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 上传干扰源用户入网报告 + * * @param loadTypeUserIUploadParam * @return */ @@ -138,19 +151,25 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService RLoadTypeUserManage rLoadTypeUserManage = new RLoadTypeUserManage(); BeanUtils.copyProperties(loadTypeUserIUploadParam, rLoadTypeUserManage); - + MultipartFile multipartFile = loadTypeUserIUploadParam.getFile(); //文件上传到Minio服务器,存入文件名 - if(loadTypeUserIUploadParam.getFile() != null){ - MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserIUploadParam.getFile()); - rLoadTypeUserManage.setIFilePath(minIoUploadResDTO.getMinFileName()); + if (Objects.nonNull(multipartFile)) { + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + String fileName = OssPath.LOAD_TYPE_USER + minIoUtils.minFileName(multipartFile.getOriginalFilename()); + obsUtil.multiFileUpload(multipartFile, fileName); + rLoadTypeUserManage.setIFilePath(fileName); + } else { + MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserIUploadParam.getFile(), OssPath.LOAD_TYPE_USER); + rLoadTypeUserManage.setIFilePath(minIoUploadResDTO.getMinFileName()); + } rLoadTypeUserManage.setIUploadTime(new Date()); } //提交:待审核/保存:新建 DictData dictData; - if(Objects.equals(Param.LOAD_TYPE_USER_SUBMIT,loadTypeUserIUploadParam.getStatus())){ + if (Objects.equals(Param.LOAD_TYPE_USER_SUBMIT, loadTypeUserIUploadParam.getStatus())) { dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.AUDIT.getCode()).getData(); - }else{ + } else { dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.NEWLY.getCode()).getData(); } rLoadTypeUserManage.setIStatus(dictData.getId()); @@ -162,6 +181,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 关联营销用户 + * * @param * @return */ @@ -176,13 +196,14 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 查询所有干扰源用户(与营销系统关联) + * * @param loadTypeUserSearchParam * @return */ @Override public Page getLoadTypeRelationList(LoadTypeUserSearchParam loadTypeUserSearchParam) { Page page = new Page<>(loadTypeUserSearchParam.getPageNum(), loadTypeUserSearchParam.getPageSize()); - Page loadTypeUserPage = loadTypeUserManageMapper.getLoadTypeRelationPage(page,loadTypeUserSearchParam); + Page loadTypeUserPage = loadTypeUserManageMapper.getLoadTypeRelationPage(page, loadTypeUserSearchParam); //部门处理:根据部门code取名称 List list = loadTypeUserPage.getRecords(); @@ -205,10 +226,10 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService * @param file 文件 * @return 成功标记 */ - private MinIoUploadResDTO fileToMinio(MultipartFile file) { + private MinIoUploadResDTO fileToMinio(MultipartFile file, String dir) { try { //把名称存入数据 - MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "loadTypeUser/"); + MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), dir); return upload; } catch (Exception e) { throw new BusinessException(ProcessResponseEnum.UPLOAD_FILE_ERROR); @@ -217,6 +238,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 上传干扰源用户入网报告 + * * @param loadTypeUserAUploadParam * @return */ @@ -225,19 +247,25 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService RLoadTypeUserManage rLoadTypeUserManage = new RLoadTypeUserManage(); BeanUtils.copyProperties(loadTypeUserAUploadParam, rLoadTypeUserManage); - - //文件上传到Minio服务器,存入文件名 - if(loadTypeUserAUploadParam.getFile() != null){ - MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserAUploadParam.getFile()); - rLoadTypeUserManage.setAFilePath(minIoUploadResDTO.getMinFileName()); + MultipartFile multipartFile = loadTypeUserAUploadParam.getFile(); + //文件上传到文件服务器,存入文件名 + if (Objects.nonNull(multipartFile)) { + if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) { + String fileName = OssPath.LOAD_TYPE_USER + minIoUtils.minFileName(multipartFile.getOriginalFilename()); + obsUtil.multiFileUpload(multipartFile, fileName); + rLoadTypeUserManage.setIFilePath(fileName); + } else { + MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserAUploadParam.getFile(), OssPath.LOAD_TYPE_USER); + rLoadTypeUserManage.setAFilePath(minIoUploadResDTO.getMinFileName()); + } rLoadTypeUserManage.setAUploadTime(new Date()); } //提交:待审核/保存:新建 DictData dictData; - if(Objects.equals(Param.LOAD_TYPE_USER_SUBMIT,loadTypeUserAUploadParam.getStatus())){ + if (Objects.equals(Param.LOAD_TYPE_USER_SUBMIT, loadTypeUserAUploadParam.getStatus())) { dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.AUDIT.getCode()).getData(); - }else{ + } else { dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.NEWLY.getCode()).getData(); } rLoadTypeUserManage.setAStatus(dictData.getId()); @@ -248,13 +276,14 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 导出未建档干扰源用户管理信息 + * * @param list * @return */ @Override public List exportLoadTypeUserList(List list) { //数据处理 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<> (); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(RLoadTypeUserManage::getId, list); List rLoadTypeUserManages = loadTypeUserManageMapper.selectList(queryWrapper); //1、部门数据 @@ -271,25 +300,25 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService List resultList = rLoadTypeUserManages.stream().map(item -> { LoadTypeUserExcel loadTypeUserExcel = new LoadTypeUserExcel(); - if (item.getUserName() != null){ + if (item.getUserName() != null) { loadTypeUserExcel.setUserName(item.getUserName()); } - if (item.getRecordTime() != null){ + if (item.getRecordTime() != null) { loadTypeUserExcel.setRecordTime(item.getRecordTime()); } - if (item.getAIsFileUpload() != null){ + if (item.getAIsFileUpload() != null) { loadTypeUserExcel.setIIsFileUpload(item.getIIsFileUpload() == 0 ? "否" : "是"); //实测报告是否上传 } - if (item.getOrgNo() != null){ + if (item.getOrgNo() != null) { loadTypeUserExcel.setOrgName(pvTerminalTreeVOMap.get(item.getOrgNo()).getName()); //单位 } - if (item.getLoadType() != null){ + if (item.getLoadType() != null) { loadTypeUserExcel.setLoadTypeName(loadTypeMap.get(item.getLoadType()).getName()); //入网报告状态 } - if (item.getIStatus() != null){ + if (item.getIStatus() != null) { loadTypeUserExcel.setIStatusName(iStatusMap.get(item.getIStatus()).getName()); //入网报告状态 } - if (item.getAIsFileUpload() != null){ + if (item.getAIsFileUpload() != null) { loadTypeUserExcel.setIIsFileUpload(item.getIIsFileUpload() == 0 ? "否" : "是"); //实测报告是否上传 } return loadTypeUserExcel; @@ -300,13 +329,14 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService /** * 导出干扰源用户常态化管理信息 + * * @param list * @return */ @Override public List exportLoadTypeRelationList(List list) { //数据处理 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<> (); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(RLoadTypeUserManage::getId, list); List rLoadTypeUserManages = loadTypeUserManageMapper.selectList(queryWrapper); //1、部门数据 @@ -323,19 +353,19 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService List resultList = rLoadTypeUserManages.stream().map(item -> { LoadTypeRelationExcel loadTypeRelationExcel = new LoadTypeRelationExcel(); - if (item.getOrgNo() != null){ + if (item.getOrgNo() != null) { loadTypeRelationExcel.setOrgName(pvTerminalTreeVOMap.get(item.getOrgNo()).getName()); } - if (item.getLoadType() != null){ + if (item.getLoadType() != null) { loadTypeRelationExcel.setLoadTypeName(loadTypeMap.get(item.getLoadType()).getName()); } - if (item.getUserName() != null){ + if (item.getUserName() != null) { loadTypeRelationExcel.setUserName(item.getUserName()); } - if (item.getRelationUserName() != null){ + if (item.getRelationUserName() != null) { loadTypeRelationExcel.setRelationUserName(item.getRelationUserName()); } - if (item.getAStatus() != null){ + if (item.getAStatus() != null) { loadTypeRelationExcel.setAStatusName(aStatusMap.get(item.getIStatus()).getName()); } return loadTypeRelationExcel; @@ -355,17 +385,17 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService @Override public Boolean checkLoadTypeUserI(LoadTypeUserCheckParam loadTypeUserCheckParam) { boolean result = true; - UpdateWrapper updateWrapper = new UpdateWrapper (); - updateWrapper.eq ("id", loadTypeUserCheckParam.getId ()); - updateWrapper.set ("i_check_comment", loadTypeUserCheckParam.getCheckComment ()); - updateWrapper.set ("i_check_person",loadTypeUserCheckParam.getCheckPerson ()); + UpdateWrapper updateWrapper = new UpdateWrapper(); + updateWrapper.eq("id", loadTypeUserCheckParam.getId()); + updateWrapper.set("i_check_comment", loadTypeUserCheckParam.getCheckComment()); + updateWrapper.set("i_check_person", loadTypeUserCheckParam.getCheckPerson()); - DictData fail = dicDataFeignClient.getDicDataByCode (DicDataEnum.FAIL.getCode ( )).getData ( ); - DictData finish = dicDataFeignClient.getDicDataByCode(DicDataEnum.SUCCESS.getCode()).getData(); + DictData fail = dicDataFeignClient.getDicDataByCode(DicDataEnum.FAIL.getCode()).getData(); + DictData finish = dicDataFeignClient.getDicDataByCode(DicDataEnum.SUCCESS.getCode()).getData(); - updateWrapper.set ("i_status", Objects.equals ("1", loadTypeUserCheckParam.getCheckResult ())?finish.getId ():fail.getId ()); - int i= loadTypeUserManageMapper.update (null,updateWrapper); - result = i==1; + updateWrapper.set("i_status", Objects.equals("1", loadTypeUserCheckParam.getCheckResult()) ? finish.getId() : fail.getId()); + int i = loadTypeUserManageMapper.update(null, updateWrapper); + result = i == 1; return result; } @@ -380,17 +410,17 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService @Override public Boolean checkLoadTypeUserA(LoadTypeUserCheckParam loadTypeUserCheckParam) { boolean result = true; - UpdateWrapper updateWrapper = new UpdateWrapper (); - updateWrapper.eq ("id", loadTypeUserCheckParam.getId ()); - updateWrapper.set ("a_check_comment", loadTypeUserCheckParam.getCheckComment ()); - updateWrapper.set ("a_check_person",loadTypeUserCheckParam.getCheckPerson ()); + UpdateWrapper updateWrapper = new UpdateWrapper(); + updateWrapper.eq("id", loadTypeUserCheckParam.getId()); + updateWrapper.set("a_check_comment", loadTypeUserCheckParam.getCheckComment()); + updateWrapper.set("a_check_person", loadTypeUserCheckParam.getCheckPerson()); - DictData fail = dicDataFeignClient.getDicDataByCode (DicDataEnum.FAIL.getCode ( )).getData ( ); - DictData finish = dicDataFeignClient.getDicDataByCode(DicDataEnum.SUCCESS.getCode()).getData(); + DictData fail = dicDataFeignClient.getDicDataByCode(DicDataEnum.FAIL.getCode()).getData(); + DictData finish = dicDataFeignClient.getDicDataByCode(DicDataEnum.SUCCESS.getCode()).getData(); - updateWrapper.set ("a_status", Objects.equals ("1", loadTypeUserCheckParam.getCheckResult ())?finish.getId ():fail.getId ()); - int i= loadTypeUserManageMapper.update (null,updateWrapper); - result = i==1; + updateWrapper.set("a_status", Objects.equals("1", loadTypeUserCheckParam.getCheckResult()) ? finish.getId() : fail.getId()); + int i = loadTypeUserManageMapper.update(null, updateWrapper); + result = i == 1; return result; } }