Browse Source

代码提交

lgs 1 year ago
parent
commit
0c6128b8b1

+ 3 - 2
src/main/java/com/kexun/controller/ReportInfoController.java

@@ -4,6 +4,7 @@ package com.kexun.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.kexun.annotation.HisModifyLog;
 import com.kexun.common.utils.Result;
+import com.kexun.entity.ReportInfo;
 import com.kexun.model.dto.ReportInfoDTO;
 import com.kexun.model.ro.ReportInfoRO;
 import com.kexun.service.ReportInfoService;
@@ -68,9 +69,9 @@ public class ReportInfoController {
         String fileName = "TestInfo.xml";
         File file = new File(path + fileName);
         String xmlContext = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
-
+        ReportInfo reportInfo = new ReportInfo();
         log.info(xmlContext);
-        parseHandleService.parseHandle(xmlContext);
+        parseHandleService.parseHandle(reportInfo,xmlContext);
         return Result.success("ok", "");
 
     }

+ 0 - 2
src/main/java/com/kexun/service/FieldDefineService.java

@@ -33,8 +33,6 @@ public interface FieldDefineService extends IService<FieldDefineEntity> {
      */
     void saveOrUpdate(FiledUpdateRO filedUpdateRO);
 
-
-
     /**
      * 修改字段类型状态
      * @param id

+ 6 - 17
src/main/java/com/kexun/service/field/BaseFieldPackageJsonService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.kexun.constant.BaseConsts;
 import com.kexun.entity.FieldDefineEntity;
+import com.kexun.entity.ReportInfo;
 import com.kexun.exception.RRException;
 import com.kexun.service.FieldDefineService;
 import com.kexun.utils.BaseUtils;
@@ -29,31 +30,18 @@ public class BaseFieldPackageJsonService implements IBaseFieldPackageJsonService
     @Autowired
     FieldDefineService fieldDefineService;
 
-
-    /**
-     * 衍生字段组装JSON的处理方法
-     * @param jsonMap 汇总各定义字段的计算结果
-     * @param json 原始的xml报文
-     * @param oneLevel 各个信息段配置的字段定义表标识
-     * @param nodeType 节点类型
-     */
-    @Override
-    public void deriveFieldPackageJson(Map jsonMap, String json, String oneLevel, String nodeType){
-
-    }
-
-
     /**
      * 基础字段组装JSON处理方法
      *
+     * @param reportInfo 报文信息
      * @param jsonMap  汇总各定义字段的计算结果
      * @param json     原始的xml报文
      * @param oneLevel 各个信息段配置的字段定义表标识
      * @param nodeType 节点类型
      */
     @Override
-    public void packageJson(Map jsonMap, String json, String oneLevel, String nodeType) throws Exception {
-        //根据oneLevel定义表示,获取数据库里定义的基础字段
+    public void packageJson(ReportInfo reportInfo,Map jsonMap, String json, String oneLevel, String nodeType) throws Exception {
+        //根据oneLevel定义表示,获取数据库里定义的所有的基础字段
         List<FieldDefineEntity> fieldDefineEntities = fieldDefineService.listFieldInfoByLevel(oneLevel,"1");
         //根据List聚合出该信息段的json的key
         Set<String> jsonSet = fieldDefineEntities.stream()
@@ -64,6 +52,8 @@ public class BaseFieldPackageJsonService implements IBaseFieldPackageJsonService
         }
         String jsonKey = jsonSet.iterator().next();
         JSONObject jsonObject = JSONObject.parseObject(json);
+        //查询出来和合作产品关联的基础字段,然后从整个的基础字段里取出来放到合作产品对应的信息段中去
+
 
         //节点类型是正常类型,直接循环各个定义字段
         if (BaseConsts.NODE_TYPE_NORMAL.equals(nodeType)) {
@@ -137,6 +127,5 @@ public class BaseFieldPackageJsonService implements IBaseFieldPackageJsonService
             }
         }
         String jsonString = JSON.toJSONString(jsonMap);
-        log.info(jsonString);
     }
 }

+ 3 - 9
src/main/java/com/kexun/service/field/IBaseFieldPackageJsonService.java

@@ -1,5 +1,7 @@
 package com.kexun.service.field;
 
+import com.kexun.entity.ReportInfo;
+
 import java.util.Map;
 
 /**
@@ -18,15 +20,7 @@ public interface IBaseFieldPackageJsonService {
      * @param oneLevel 各个信息段配置的字段定义表标识
      * @param nodeType 节点类型
      */
-    void packageJson(Map jsonMap,String json, String oneLevel,String nodeType) throws Exception;
+    void packageJson(ReportInfo reportInfo, Map jsonMap, String json, String oneLevel, String nodeType) throws Exception;
 
-    /**
-     * 衍生字段组装JSON的处理方法
-     * @param jsonMap 汇总各定义字段的计算结果
-     * @param json 原始的xml报文
-     * @param oneLevel 各个信息段配置的字段定义表标识
-     * @param nodeType 节点类型
-     */
-    void deriveFieldPackageJson(Map jsonMap, String json, String oneLevel, String nodeType);
 
 }

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

@@ -43,7 +43,7 @@ public class ReportInfoServiceImpl extends ServiceImpl<ReportInfoMapper, ReportI
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateReportInfo(ReportInfoDTO reportInfoDTO){
-
+        reportInfoMapper.updateReportInfo(reportInfoDTO);
     }
 
     /**

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

@@ -8,6 +8,7 @@ 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.factory.HandleXmlFactory;
 import com.kexun.factory.HandleXmlFactoryBean;
 import com.kexun.model.dto.CommonParam;
@@ -52,9 +53,9 @@ public class ParseHandleService {
     /**
      * 解析处理xml的内容
      *
-     * @param xmlContent xml报文
+     * @param xmlContent xml报文的内容
      */
-    public ReportParseDTO parseHandle(String xmlContent) throws Exception {
+    public ReportParseDTO parseHandle(ReportInfo reportInfo,String xmlContent) throws Exception {
         //把xml转成Json格式,和XML保持一致的格式
         JSONObject jsonObject = ParseXmlUtils.xmlToJson(xmlContent);
         //定义Map 存放JSON
@@ -111,7 +112,7 @@ public class ParseHandleService {
                             factoryBean.getService().save(iBaseEntity);
                             //构建json
                             if (factoryBean.getBaseFieldPackageJsonService() != null) {
-                                factoryBean.getBaseFieldPackageJsonService().packageJson(jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
+                                factoryBean.getBaseFieldPackageJsonService().packageJson(reportInfo,jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
                             }
                         } else if (BaseConsts.NODE_TYPE_COMPOSE.equals(factoryBean.getNodeType())) {
                             //处理复杂类型
@@ -120,7 +121,7 @@ public class ParseHandleService {
                             reportXmlBaseService.handleXmlSgmt(commonParam, jsonBean);
                             //构建json
                             if (factoryBean.getBaseFieldPackageJsonService() != null) {
-                                factoryBean.getBaseFieldPackageJsonService().packageJson(jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
+                                factoryBean.getBaseFieldPackageJsonService().packageJson(reportInfo,jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
                             }
                         } else if (BaseConsts.NODE_TYPE_LIST.equals(factoryBean.getNodeType())) {
                             Map<String, String> paramMap = factoryBean.getParamMap();
@@ -149,7 +150,7 @@ public class ParseHandleService {
                                         }
                                         factoryBean.getService().saveBatch(iBaseEntities);
                                         if (factoryBean.getBaseFieldPackageJsonService() != null) {
-                                            factoryBean.getBaseFieldPackageJsonService().packageJson(jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
+                                            factoryBean.getBaseFieldPackageJsonService().packageJson(reportInfo,jsonMap, json, factoryBean.getXmlNodeName(), factoryBean.getNodeType());
                                         }
                                     }
                                 }

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

@@ -82,7 +82,7 @@ public class ReportParseJobHandler {
                 try {
                     //解析xml文件
                     fileName = fileName.substring(0, fileName.indexOf("."));
-                    ReportParseDTO reportParseDTO = parseHandleService.parseHandle(xmlContext);
+                    ReportParseDTO reportParseDTO = parseHandleService.parseHandle(reportInfo,xmlContext);
                     //保存xml文件和解析文件
                     fileService.saveAndWriteFile(reportInfo,xmlContext,reportParseDTO.getParseJson(),fileName);
                     //修改解析报文信息的状态