Ver Fonte

headId 问题

lgs há 11 meses atrás
pai
commit
2cdc12003e

+ 18 - 15
src/main/java/com/kexun/service/impl/FileServiceImpl.java

@@ -44,11 +44,12 @@ public class FileServiceImpl {
 
     /**
      * 上传文件
+     *
      * @param context
      * @param filename
      * @param path
      */
-    private void writeFile(String context, String filename,String path) {
+    private void writeFile(String context, String filename, String path) {
         try {
             IOUtils.write(context, new FileOutputStream(path + filename), "UTF-8");
         } catch (IOException e) {
@@ -58,46 +59,48 @@ public class FileServiceImpl {
 
     /**
      * 保存xml文件和json文件
+     *
      * @param reportInfo
      * @param xmlContext
      * @param jsonContext
      * @param fileName
      */
-    public void saveAndWriteFile(ReportInfo reportInfo,String xmlContext,String jsonContext,String fileName){
+    public void saveAndWriteFile(ReportInfo reportInfo, String xmlContext, String jsonContext, String fileName) {
         //根据HeadInfId查询是否存在
         ReportFileEntity reportFileEntity = new ReportFileEntity();
-        if (reportInfo.getHeadInfId()!=null){
+        if (reportInfo.getHeadInfId() != null) {
             QueryWrapper<ReportFileEntity> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("head_inf_id",reportInfo.getHeadInfId());
+            queryWrapper.eq("head_inf_id", reportInfo.getHeadInfId());
             ReportFileEntity reportFileEntityResult = reportFileService.getOne(queryWrapper);
-            reportFileEntity.setId(reportFileEntityResult.getId());
+            if (reportFileEntityResult != null) {
+                reportFileEntity.setId(reportFileEntityResult.getId());
+            }
         }
         reportFileEntity.setHeadInfId(reportInfo.getHeadInfId());
         reportFileEntity.setRptNo(reportInfo.getRptNo());
         reportFileEntity.setBusinessId(reportInfo.getBusinessId());
         reportFileEntity.setBusinessNum(reportInfo.getBusinessNum());
-        String dateName = DateUtils.format(new Date(),DateUtils.YYYYMMDD);
-        reportFileEntity.setFileNameXml(dateName+ File.separator+fileName+".xml");
-        reportFileEntity.setFileNameTxt(dateName+File.separator+fileName+".txt");
+        String dateName = DateUtils.format(new Date(), DateUtils.YYYYMMDD);
+        reportFileEntity.setFileNameXml(dateName + File.separator + fileName + ".xml");
+        reportFileEntity.setFileNameTxt(dateName + File.separator + fileName + ".txt");
         //保存文件信息表
         reportFileService.saveOrUpdate(reportFileEntity);
         //上传文件到服务器的目录
         //xml文件
-        xmlTargetPath = xmlTargetPath+File.separator+dateName+File.separator;
+        xmlTargetPath = xmlTargetPath + File.separator + dateName + File.separator;
         File file = new File(xmlTargetPath);
-        if (!file.exists()){
+        if (!file.exists()) {
             file.mkdirs();
         }
-        jsonTargetPath = jsonTargetPath+File.separator+dateName+File.separator;
+        jsonTargetPath = jsonTargetPath + File.separator + dateName + File.separator;
         File targetPathFile = new File(jsonTargetPath);
-        if (!targetPathFile.exists()){
+        if (!targetPathFile.exists()) {
             targetPathFile.mkdirs();
         }
-        writeFile(xmlContext,fileName+".xml",xmlTargetPath);
+        writeFile(xmlContext, fileName + ".xml", xmlTargetPath);
         //json文件
-        writeFile(jsonContext,fileName+".txt",jsonTargetPath);
+        writeFile(jsonContext, fileName + ".txt", jsonTargetPath);
     }
 
 
-
 }

+ 1 - 0
src/main/java/com/kexun/service/impl/XmlFileHandlerServiceImpl.java

@@ -165,6 +165,7 @@ public class XmlFileHandlerServiceImpl implements XmlFileHandlerService {
         //报文文件信息
         ReportFileEntity reportFileEntity = new ReportFileEntity();
         reportFileEntity.setHeadInfId(headInfoId);
+        reportFileEntity.setFileName(reportInfo.getFileName());
         reportFileService.saveOrUpdate(reportFileEntity);
         //保存报文信息
         reportInfo.setHeadInfId(headInfoId);

+ 6 - 5
src/main/java/com/kexun/service/xml/ParseHandleService.java

@@ -6,10 +6,7 @@ import com.alibaba.fastjson.annotation.JSONField;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.kexun.constant.BaseConsts;
 import com.kexun.constant.XmlNodeConsts;
-import com.kexun.entity.FieldDefineEntity;
-import com.kexun.entity.FieldParamEntity;
-import com.kexun.entity.IBaseEntity;
-import com.kexun.entity.ReportInfo;
+import com.kexun.entity.*;
 import com.kexun.factory.HandleXmlFactory;
 import com.kexun.factory.HandleXmlFactoryBean;
 import com.kexun.model.dto.CommonParam;
@@ -19,6 +16,7 @@ import com.kexun.model.xml.IXmlBase;
 import com.kexun.service.CrHeadInfService;
 import com.kexun.service.FieldDefineService;
 import com.kexun.service.FieldParamService;
+import com.kexun.utils.DateUtils;
 import com.kexun.utils.ParseXmlUtils;
 import com.kexun.utils.SpringContextUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -296,7 +294,10 @@ public class ParseHandleService {
         commonParam.setRptNo(rptNo);
         HeadInfo headInfo = headJsonObject.toJavaObject(HeadInfo.class);
         //返回主键ID
-        Long id = crHeadInfService.saveHeadInfo(headInfo);
+        CrHeadInfEntity crHeadInfEntity = new CrHeadInfEntity();
+        BeanUtils.copyProperties(headInfo,crHeadInfEntity);
+        crHeadInfEntity.setRptTime(DateUtils.convertStrToDate(DateUtils.convertTDate(headInfo.getRptTime()),DateUtils.DATE_YYYY_MM_DD_HH_MM_SS));
+        Long id = crHeadInfService.saveUpdateHeadInfo(crHeadInfEntity);
         commonParam.setHeadInfId(id);
     }
 

+ 1 - 1
src/main/java/com/kexun/task/ReportParseJobHandler.java

@@ -84,7 +84,7 @@ public class ReportParseJobHandler {
                     //解析xml文件
                     fileName = fileName.substring(0, fileName.indexOf("."));
                     ReportParseDTO reportParseDTO = parseHandleService.parseHandle(reportInfo,xmlContext);
-                    reportInfo.setHeadInfId(reportParseDTO.getHeadInfId());
+                    reportInfo.setHeadInfId(reportInfo.getHeadInfId());
                     reportInfo.setRptNo(reportParseDTO.getRptNo());
                     //保存xml文件和解析文件
                     fileService.saveAndWriteFile(reportInfo,xmlContext,reportParseDTO.getPrdJson(),fileName);

+ 1 - 1
src/main/resources/application-dev.yml

@@ -5,7 +5,7 @@ spring:
   ####redis
   redis:
     database: 0
-    host: 127.0.0.1
+    host: 39.101.189.130
     jedis:
       pool:
         max-active: 8