Forráskód Böngészése

1.修改邮件解析

Signed-off-by: wangt <wt9213@hotmail.com>
wangt 1 éve
szülő
commit
13a57d25d6

+ 21 - 3
.idea/workspace.xml

@@ -5,6 +5,7 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="12555237-475b-4aab-811e-0cafb2577a56" name="Changes" comment="1.梳理计算">
+      <changelist_data name="wangt" email="123456" />
       <change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_11.xml" beforeDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_11.xml" beforeDir="false" />
@@ -119,9 +120,11 @@
     <option name="PREVIOUS_COMMIT_AUTHORS">
       <list>
         <option value="wangt &lt;123456&gt;" />
+        <option value="wangt &lt;wt9213@hotmail.com&gt;" />
       </list>
     </option>
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+    <option name="SIGN_OFF_COMMIT" value="true" />
   </component>
   <component name="GitSEFilterConfiguration">
     <file-type-list>
@@ -181,6 +184,13 @@
     "spring.configuration.checksum": "11e2f58b52e83c10fcdf618b08664f48",
     "ts.external.directory.path": "D:\\soft\\idea\\IntelliJ IDEA 2023.2.4\\plugins\\javascript-impl\\jsLanguageServicesImpl\\external",
     "vue.rearranger.settings.migration": "true"
+  },
+  "keyToStringList": {
+    "GitStage.ChangesTree.GroupingKeys": [
+      "directory",
+      "module",
+      "repository"
+    ]
   }
 }]]></component>
   <component name="ReactorSettings">
@@ -198,7 +208,7 @@
       <recent name="com.jiayue.biz.job" />
     </key>
   </component>
-  <component name="RunManager" selected="Spring Boot.NeimApplication">
+  <component name="RunManager" selected="npm.dev">
     <configuration name="com.jiayue.biz.controller.HomePageController" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
       <option name="MAIN_CLASS_NAME" value="com.jiayue.biz.controller.HomePageController" />
       <module name="neim-biz" />
@@ -362,7 +372,7 @@
       <workItem from="1699338135589" duration="14000" />
       <workItem from="1699508603646" duration="95423000" />
       <workItem from="1700189240186" duration="11236000" />
-      <workItem from="1700555195308" duration="486000" />
+      <workItem from="1700555195308" duration="2964000" />
     </task>
     <task id="LOCAL-00001" summary="1.开启健康监控节点-用于迁移内网后往公司邮箱发送每日健康监控&#10;2.修改通道数据选择场站时,带入风机名称bug&#10;3.待做项和注意项备注">
       <created>1694163606551</created>
@@ -413,7 +423,15 @@
       <option name="project" value="LOCAL" />
       <updated>1696934345266</updated>
     </task>
-    <option name="localTasksCounter" value="8" />
+    <task id="LOCAL-00008" summary="1.梳理计算">
+      <option name="closed" value="true" />
+      <created>1700555978230</created>
+      <option name="number" value="00008" />
+      <option name="presentableId" value="LOCAL-00008" />
+      <option name="project" value="LOCAL" />
+      <updated>1700555978230</updated>
+    </task>
+    <option name="localTasksCounter" value="9" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">

+ 2 - 3
neim-biz/src/main/java/com/jiayue/biz/job/FileAnalysisJob.java

@@ -8,7 +8,6 @@ import com.jiayue.biz.service.impl.AnalysisDataImpl;
 import com.jiayue.biz.service.impl.EmailImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.stereotype.Service;
 
 
@@ -40,11 +39,11 @@ public class FileAnalysisJob {
     }
 
     //@Scheduled(fixedDelay = 60000)
-    public void fileAnalysis() {
+    public void fileAnalysis(String str) {
 
         log.info("文件解析定时任务执行开始");
 
-        this.emailImpl.readMail();
+        this.emailImpl.readMail(str);
 
         log.info("文件解析定时任务执行完成");
 

+ 14 - 19
neim-biz/src/main/java/com/jiayue/biz/service/impl/AnalysisDataImpl.java

@@ -8,19 +8,16 @@ import cn.hutool.core.text.csv.CsvUtil;
 import cn.hutool.core.util.ZipUtil;
 import cn.hutool.poi.excel.ExcelReader;
 import cn.hutool.poi.excel.ExcelUtil;
-import com.jiayue.biz.domain.*;
-import com.jiayue.biz.service.EmailService;
-import com.jiayue.biz.service.EmailWindTowerInfoService;
+import com.jiayue.biz.domain.EmailWindTowerInfo;
+import com.jiayue.biz.domain.WindTowerInfo;
 import com.jiayue.biz.util.CalculationUtil;
 import com.jiayue.biz.util.CoordinateUtil;
 import com.jiayue.common.utils.file.FileUtils;
-import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.xssf.streaming.SXSSFRow;
 import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -32,8 +29,6 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 /**
  * 采集数据解析实现类
@@ -660,7 +655,7 @@ public class AnalysisDataImpl {
         List<Map<String, Object>> filterData = new CheckDataRecode().checkValue(allData, type);
         String equipmentId = file.getName().substring(0, 4);
         String eTime = file.getName().substring(4, 12);
-        windTowerDataParentTableService.packageData(filterData, equipmentId, eTime, type, "");
+        windTowerDataParentTableService.packageData(filterData, equipmentId, eTime, type, "", null);
         reader.close();
 
     }
@@ -716,7 +711,7 @@ public class AnalysisDataImpl {
         List<Map<String, Object>> filterData = new CheckDataRecode().checkValue(allData, type);
 
         String eTime = file.getName().split("_")[1];
-        windTowerDataParentTableService.packageData(filterData, eqId, eTime, type, "");
+        windTowerDataParentTableService.packageData(filterData, eqId, eTime, type, "", null);
         reader.close();
     }
 
@@ -940,7 +935,7 @@ public class AnalysisDataImpl {
             //过滤数据
             List<Map<String, Object>> mapList1 = new CheckDataRecode().checkValue(mapList, "sld");
 
-            windTowerDataParentTableService.packageData(mapList1, eqId, time1, "sld", "");
+            windTowerDataParentTableService.packageData(mapList1, eqId, time1, "sld", "", null);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -1086,7 +1081,7 @@ public class AnalysisDataImpl {
                 String s1 = this.assembleWind(str, wsHeight, wdHeight);
                 //修改表头
                 csvRow.set(i, s1);
-                if(str.equals("-")){
+                if (str.equals("-")) {
                     str = "-0.99";
                 }
                 hashMap.put(row.get(i), str);
@@ -1098,15 +1093,15 @@ public class AnalysisDataImpl {
         }
         this.emailWindTowerInfoSave(eqNo);
         List<WindTowerInfo> list = windTowerInfoService.list();
-        List<WindTowerInfo> collect = list.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList());
-        if (collect.size() > 0) {
-            if (collect.get(0).getRecorderNo() == null) {
+        List<WindTowerInfo> windTowerInfos = list.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList());
+        if (windTowerInfos.size() > 0) {
+            if (windTowerInfos.get(0).getRecorderNo() == null) {
                 String wsH = this.heightReverseOrder(wsHeight);
                 String wdH = this.heightReverseOrder(wdHeight);
                 WindTowerInfo windTowerInfo = new WindTowerInfo();
                 windTowerInfo.setEquipmentNo(eqNo);
                 windTowerInfo.setName(eqNo);
-                windTowerInfo.setId(collect.get(0).getId());
+                windTowerInfo.setId(windTowerInfos.get(0).getId());
                 windTowerInfo.setType("email");
                 windTowerInfo.setHeights(wsH);
                 windTowerInfo.setWdHeights(wdH);
@@ -1123,7 +1118,7 @@ public class AnalysisDataImpl {
                     e.printStackTrace();
                 }
 
-                windTowerDataParentTableService.packageData(dataList, eqNo, "", "eol", "");
+                windTowerDataParentTableService.packageData(dataList, eqNo, "", "eol", "", windTowerInfos.get(0));
             }
 
         }
@@ -1200,9 +1195,9 @@ public class AnalysisDataImpl {
             //层高
             String height = "";
             if (!s.contains("TI")) {
-                if(s.contains("K620Ab")){
+                if (s.contains("K620Ab")) {
                     height = "160A";
-                }else {
+                } else {
                     String[] strSp = wsAndType.split("_");
                     if (strSp.length > 0) {
                         height = CalculationUtil.getNumberFromString(strSp[1]);
@@ -1235,7 +1230,7 @@ public class AnalysisDataImpl {
         } else if (s.contains("TEM")) {
             String type = this.assembleProperty(s);
             str = "t" + type;
-        }else if (s.contains("RH")) {
+        } else if (s.contains("RH")) {
             String type = this.assembleProperty(s);
             str = "rh" + type;
         }

+ 3 - 3
neim-biz/src/main/java/com/jiayue/biz/service/impl/DataRecalculationImpl.java

@@ -506,7 +506,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
         List<Map<String, Object>> filterData = new CheckDataRecode().checkValue(allData, type);
         String eqId = file.getName().split("_")[0];
         String eTime = file.getName().split("_")[1];
-        windTowerDataParentTableService.packageData(filterData, eqId, eTime, type, "");
+        windTowerDataParentTableService.packageData(filterData, eqId, eTime, type, "", null);
         reader.close();
     }
 
@@ -579,7 +579,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
                 log.info("正在进行数据过滤");
                 //重新走一遍数据过滤 然后存库
                 List<Map<String, Object>> mapList = new CheckDataRecode().checkValue(maps, list.get(0).getModelNumber());
-                windTowerDataParentTableService.packageData(mapList, equipmentNo, sdf.format(new Date(startDate)), list.get(0).getModelNumber(), "DataRecalculation");
+                windTowerDataParentTableService.packageData(mapList, equipmentNo, sdf.format(new Date(startDate)), list.get(0).getModelNumber(), "DataRecalculation", null);
                 log.warn("数据筛选完成");
                 return AjaxResult.success("数据筛选完成");
             } else {
@@ -637,7 +637,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
             log.info("计算统计数据保存执行完毕");
             return AjaxResult.success("数据已经重新统计");
         } catch (Exception e) {
-            log.info("数据统计计算时异常:{}",e);
+            log.info("数据统计计算时异常:{}", e);
             return AjaxResult.error("数据统计计算时异常");
         }
     }

+ 12 - 6
neim-biz/src/main/java/com/jiayue/biz/service/impl/EmailImpl.java

@@ -72,7 +72,7 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
         return emailService.list();
     }
 
-    public void readMail() {
+    public void readMail(String str) {
         List<Email> emails = this.selectEmail();
         for (Email email : emails) {
 
@@ -110,12 +110,18 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
                 // 获得收件箱中的未读邮件数
                 log.warn("未读邮件数: {}", folder.getUnreadMessageCount());
                 log.warn("总邮件个数: {}", folder.getMessageCount());
-                Calendar cal = Calendar.getInstance();
-                cal.add(Calendar.DAY_OF_MONTH, -10);
-                SearchTerm term = new SentDateTerm(ComparisonTerm.GE, cal.getTime());
+                Message[] messages1 = null;
                 FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false); //false代表未读,true代表已读
-                SearchTerm comparisonAndTerm = new AndTerm(term, ft);
-                Message[] messages1 = folder.search(comparisonAndTerm);
+                if ("all".equals(str)) {
+                    Calendar cal = Calendar.getInstance();
+                    cal.add(Calendar.DAY_OF_MONTH, -10);
+                    SearchTerm term = new SentDateTerm(ComparisonTerm.GE, cal.getTime());
+                    SearchTerm comparisonAndTerm = new AndTerm(term, ft);
+                    messages1 = folder.search(comparisonAndTerm);
+                } else {
+                    messages1 = folder.search(ft);
+                }
+
 
                 for (Message message : messages1) {
                     //存在附件返回true 不存在返回false

+ 10 - 17
neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerDataParentTableServiceImpl.java

@@ -4,20 +4,14 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.lang.TypeReference;
 import cn.hutool.db.Entity;
 import cn.hutool.json.JSONArray;
-import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jiayue.biz.conf.RequestDataHelper;
 import com.jiayue.biz.domain.*;
-import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
-import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
 import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
 import com.jiayue.biz.service.*;
 import com.jiayue.biz.util.CalculationUtil;
 import com.jiayue.biz.util.CommonUtil;
-import com.jiayue.biz.util.DateTimeUtil;
 import com.jiayue.biz.util.FileUtil;
 import com.jiayue.common.core.text.Convert;
 import com.jiayue.common.utils.DateUtil;
@@ -81,7 +75,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
      * @param type        文件类型
      * @param operation   操作类型(DataRecalculation数据重算)
      */
-    public void packageData(List<Map<String, Object>> allData, String equipmentId, String eTime, String type, String operation) {
+    public void packageData(List<Map<String, Object>> allData, String equipmentId, String eTime, String type, String operation, WindTowerInfo windTowerInfo) {
 
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
         if (type.equals("rld")) {
@@ -94,18 +88,17 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
             simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
         }
         String eqNo = equipmentId;
-        List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
-        List<WindTowerInfo> windTowerInfo = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList());
-        String windTowerInfoHeights = windTowerInfo.get(0).getHeights();
-        String windTowerInfoWdHeights = windTowerInfo.get(0).getWdHeights();
+        if (null == windTowerInfo) {
+            List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
+            windTowerInfo = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList()).get(0);
+        }
+        String windTowerInfoHeights = windTowerInfo.getHeights();
+        String windTowerInfoWdHeights = windTowerInfo.getWdHeights();
         String[] wdHeight = windTowerInfoWdHeights.split(",");
         String[] heights = windTowerInfoHeights.split(",");
         HashSet<String> heightAll = new HashSet<>();
         heightAll.addAll(Arrays.asList(wdHeight));
         heightAll.addAll(Arrays.asList(heights));
-        //层高
-//        ArrayList<ProphaseAnemometryData> prophaseAnemometryDataArrayList = new ArrayList<>();
-//        ArrayList<ProphaseWeatherData> prophaseAnemometryPublicDataArrayList = new ArrayList<>();
         try {
             //所有数据
             for (Map<String, Object> m : allData) {
@@ -126,7 +119,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
                 this.packageOrgData(m, heightAll, simpleDateFormat, eqNo, "noOrg");
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("处理文件数据入库错误:{}", e);
         }
 
     }
@@ -201,7 +194,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
                 prophaseAnemometryPublicData.getTAve() != -99 && prophaseAnemometryPublicData.getPaAve() > 0) {
             BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(BigDecimal.valueOf(prophaseAnemometryPublicData.getTAve())), 2, RoundingMode.HALF_UP)).multiply(BigDecimal.valueOf(prophaseAnemometryPublicData.getPaAve())).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
             prophaseAnemometryPublicData.setAirDensity(Convert.toFloat(airDensity));
-        }else{
+        } else {
             //随机数 上限1.28 下限1.15
             Random random = new Random();
             int randNumber = random.nextInt(128 - 115 + 1) + 115;
@@ -309,7 +302,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
             BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(dataMap.get("tAve")), 2, RoundingMode.HALF_UP)).multiply(dataMap.get("paAve")).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
             prophaseWeatherData.setAirDensity(Convert.toFloat(airDensity));
         }
-        log.info("dataMap.get(tAve):{} ,,, {}",dataMap.get("tAve"),dataMap.get("paAve"));
+        log.info("dataMap.get(tAve):{} ,,, {}", dataMap.get("tAve"), dataMap.get("paAve"));
         //设置时间
         prophaseWeatherData.setTs(curentTimestamp);
         prophaseWeatherDataService.insertOne(prophaseWeatherData);