瀏覽代碼

excel导入任务

lwhhszx 1 年之前
父節點
當前提交
0286cdd5a0

+ 1 - 1
src/main/java/cn/cslg/pas/common/vo/business/ImportTaskVO.java

@@ -65,7 +65,7 @@ public class ImportTaskVO {
     private String createId;
 
     @Schema(description = "名称")
-    private String taskName;
+    private String name;
 
     private Integer projectId;
     private Integer projectType;

+ 5 - 0
src/main/java/cn/cslg/pas/domain/business/ImportTask.java

@@ -19,6 +19,11 @@ public class ImportTask extends BaseEntity<ImportTask> {
      */
     @TableField(value = "search_condition")
     private String searchCondition;
+    /**
+     * 名称
+     */
+    @TableField(value = "name")
+    private String name;
 
     /**
      * 导入总条数

+ 52 - 63
src/main/java/cn/cslg/pas/service/business/ImportTaskService.java

@@ -205,7 +205,10 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                 throw new XiaoShiException("文件错误");
             }
         }
+
         importTask.setProgress(0.0);
+    String taskName =    this.setImportTaskName(importTaskCondition,personnelVO.getName());
+         importTask.setName(taskName);
         importTask.insert();
 
         schedulingTaskService.startTask();
@@ -221,18 +224,10 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
 
     private void loadImportTask(List<ImportTaskVO> importTaskVOS) throws IOException {
         List<String> createIds = new ArrayList<>();
-        List<Integer> projectIds = new ArrayList<>();
-        List<Integer> productIds = new ArrayList<>();
         importTaskVOS.forEach(item -> {
             if (item.getCreateId() != null) {
                 createIds.add(item.getCreateId());
             }
-            if (item.getProductId() != null) {
-                productIds.add(item.getProductId());
-            }
-            if (item.getProjectId() != null) {
-                projectIds.add(item.getProjectId());
-            }
         });
         List<Personnel> personnels = new ArrayList<>();
         List<Product> products = new ArrayList<>();
@@ -244,20 +239,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
             personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
         }
 
-        //查询专题库或报告
-        if (projects.size() != 0) {
-            LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.in(Project::getId, projectIds);
-            projects = projectService.list(queryWrapper);
-        }
-
-        //查询专题库或报告
-        if (products.size() != 0) {
-            LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.in(Product::getId, productIds);
-            products = productService.list(queryWrapper);
-        }
-
 
         LambdaQueryWrapper<SystemDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
         lambdaQueryWrapper.eq(SystemDict::getGroupType, "IMPORT_TASK");
@@ -270,47 +251,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                 importTaskVO.setCreateName(personnel.getPersonnelName());
             }
 
-            //装载名称
-            String type = "";
-            String toName = "";
-            String to = "";
-            String taskName = "";
-            if (importTaskVO.getType().equals(2)) {
-//                    TaskCondition taskCondition = taskConditionService.getById(task.getTaskConditionId());
-//                    String conditions = taskCondition.getConditions();
-//                    String taskNameSuffix = conditions.substring(conditions.indexOf("AN=(") + 4, conditions.indexOf(")")).replace(" OR ", "|");
-//                    type = "专利号" + taskNameSuffix;
-                type = "【专利号】";
-            } else if (importTaskVO.getType().equals(3) || importTaskVO.getType().equals(4)) {
-                type = "【检索式】";
-            } else if (importTaskVO.getType().equals(1)) {
-                type = "【Excel】";
-            }
-            if (importTaskVO.getProjectId() != null && importTaskVO.getProjectType().equals(0)) {
-                to = "专题库";
-                Project project = projects.stream().filter(item -> item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
-                if (project != null) {
-                    toName = project.getName();
-                }
-            } else if (importTaskVO.getProjectId() != null && importTaskVO.getProjectType().equals(1)) {
-                to = "报告";
-                Project project = projects.stream().filter(item -> item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
-                if (project != null) {
-                    toName = project.getName();
-                }
-            } else if (importTaskVO.getProductId() != null) {
-                to = "产品";
-                Product product = products.stream().filter(item -> item.getId().equals(importTaskVO.getProductId())).findFirst().orElse(null);
-                if (product != null) {
-                    toName = product.getName();
-                }
-            }
-            //导入任务
-            taskName = type + "导入到" + to + "【" + toName + "】 - " + personnel.getPersonnelName();
-
-            importTaskVO.setTaskName(taskName);
-
-
             //装载状态
             SystemDict systemDict1 = systemDictList.stream()
                     .filter(item -> item.getType().equals("IMPORT_TASK_TYPE") && item.getType()
@@ -329,4 +269,53 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
 
 
     }
+
+
+    private String setImportTaskName(ImportTaskCondition importTaskCondition,String name){
+
+
+        //装载名称
+        String type = "";
+        String toName = "";
+        String to = "";
+        String taskName = "";
+        if (importTaskCondition.getType().equals(2)) {
+
+            type = "【专利号】";
+        } else if (importTaskCondition.getType().equals(3) || importTaskCondition.getType().equals(4)) {
+            type = "【检索式】";
+        } else if (importTaskCondition.getType().equals(1)) {
+            type = "【Excel】";
+        }
+        if (importTaskCondition.getProjectId() != null && importTaskCondition.getProjectType().equals(0)) {
+            to = "专题库";
+            LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(Project::getId, importTaskCondition.getProjectId());
+           List<Project> projects = projectService.list(queryWrapper);
+            if (projects.size()!=0) {
+                toName = projects.get(0).getName();
+            }
+        } else if (importTaskCondition.getProjectId() != null && importTaskCondition.getProjectType().equals(1)) {
+            to = "报告";
+            LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(Project::getId, importTaskCondition.getProjectId());
+            List<Project> projects = projectService.list(queryWrapper);
+            if (projects.size()!=0) {
+                toName = projects.get(0).getName();
+            }
+        } else if (importTaskCondition.getProductId() != null) {
+            to = "产品";
+            LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(Product::getId, importTaskCondition.getProductId());
+        List<Product>    products = productService.list(queryWrapper);
+            if (products.size()!=0) {
+                toName = products.get(0).getName();
+            }
+        }
+        //导入任务
+        taskName = type + "导入到" + to + "【" + toName + "】 - " + name;
+
+
+return taskName;
+    }
 }

+ 0 - 1
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -104,7 +104,6 @@ public class EsService {
         //设置查询索引
         builder.index("patent");
 
-
         //1. 解析检索条件
         treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
         //格式化检索式

+ 25 - 7
src/main/resources/jsons/customField.json

@@ -9,7 +9,8 @@
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"false"
+    "ifShow":"false",
+    "ifAsCondition": "true"
   },
   {"name":"名称",
   "type":"String",
@@ -21,7 +22,8 @@
     "groupClass":"getComGroup",
   "ifSearch":"true",
   "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"true",
+    "ifAsCondition": "true"
 },
   {"name":"创建人",
     "type":"String",
@@ -33,7 +35,8 @@
     "groupClass":"getComGroup",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"true",
+    "ifAsCondition": "true"
   },
   {"name":"创建时间",
     "type":"DateTime",
@@ -45,7 +48,8 @@
     "groupClass":"getTimeGroup",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"true",
+    "ifAsCondition": "true"
   },
   {"name":"描述",
     "type":"String",
@@ -56,7 +60,8 @@
     "orderClass": "getComOrder",
     "ifSearch":"false",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"true",
+    "ifAsCondition": "true"
   },
   {"name":"projectId",
     "type":"Integer",
@@ -68,6 +73,19 @@
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"false"
-  }
+    "ifShow":"false",
+    "ifAsCondition": "true"
+  },
+  {"name":"类型",
+  "type":"String",
+  "value":"type",
+  "field": "type",
+  "sqlField": "type",
+  "sqlClass": "getComSql",
+  "orderClass": "getComOrder",
+  "ifSearch":"false",
+  "ifGroup": "false",
+  "ifShow":"true",
+  "ifAsCondition": "true"
+}
 ]

+ 109 - 2
src/main/resources/jsons/importTask.json

@@ -1,6 +1,113 @@
 [
   {
-    "importTaskType":1,
-    "serviceName": "importPatentExcel"
+    "name": "Id",
+    "type": "Integer",
+    "value": "id",
+    "field": "id",
+    "sqlField": "it.id",
+    "sqlClass": "getComSql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "任务名称",
+    "type": "String",
+    "value": "name",
+    "field": "name",
+    "sqlField": "it.name",
+    "sqlClass": "getLikeSql",
+    "orderClass": "getComOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "导入方式",
+    "type": "Array",
+    "value": "type",
+    "field": "type",
+    "sqlField": "it.type",
+    "sqlClass": "getComType",
+    "orderClass": "getComOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "false"
+  },
+  {
+    "name": "导入方式",
+    "type": "String",
+    "value": "type",
+    "field": "type",
+    "sqlField": "it.type",
+    "sqlClass": "getComType",
+    "orderClass": "getComOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "任务状态",
+    "type": "String",
+    "value": "state",
+    "field": "state",
+    "sqlField": "it.state",
+    "sqlClass": "getComType",
+    "orderClass": "getComOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "任务状态",
+    "type": "Array",
+    "value": "state",
+    "field": "state",
+    "sqlField": "it.state",
+    "sqlClass": "getComType",
+    "orderClass": "getComOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "false"
+  },
+  {
+    "name": "创建人",
+    "type": "String",
+    "value": "createName",
+    "field": "createName",
+    "sqlField": "it.create_id",
+    "sqlClass": "getCreateNameSql",
+    "orderClass": "getCreateNameOrder",
+    "groupClass": "getComGroup",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "true"
+  },
+  {
+    "name": "创建时间",
+    "type": "DateTime",
+    "value": "createTime",
+    "field": "createTime",
+    "sqlField": "it.create_time",
+    "sqlClass": "getDateTimeSql",
+    "orderClass": "getComOrder",
+    "groupClass": "getTimeGroup",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "true"
   }
+
 ]

+ 4 - 0
src/main/resources/jsons/importTaskConfig.json

@@ -2,5 +2,9 @@
   {"taskType": 1,
     "importClass": "importFromExcelToEsService",
     "importTo": 1
+  },
+  {"taskType": 2,
+    "importClass": "importFromWebToEsService",
+    "importTo": 1
   }
 ]

+ 5 - 4
src/main/resources/jsons/patentProject.json

@@ -10,7 +10,8 @@
     "groupClass": "",
     "ifSearch": "false",
     "ifGroup": "false",
-    "ifShow": "false"
+    "ifShow": "false",
+    "ifAsCondition": "true"
   },
   {
     "name": "专利数据库名称",
@@ -150,9 +151,9 @@
   },
   {
     "name": "产品或产品类别名称",
-    "type": "String",
-    "value": "productOrCategoryName",
-    "field": "productOrCategoryName",
+    "type": "Object",
+    "value": "productOrCategory",
+    "field": "productOrCategory",
     "sqlField": "scenario_id",
     "sqlClass": "getComSql",
     "orderClass": "getProductOrCategoryOrder",

File diff suppressed because it is too large
+ 1265 - 0
src/main/resources/jsons/uploadSetting.json


+ 27 - 0
src/main/resources/mapper/ImportTaskMapper.xml

@@ -0,0 +1,27 @@
+<?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="cn.cslg.pas.mapper.ImportTaskMapper">
+    <select id="getImportTask" resultType="cn.cslg.pas.common.vo.business.ImportTaskVO">
+        select it.name as name, it.id,it.search_condition as searchCondition,it.all_num as allNum,it.success_num as successNum,
+               it.default_num as defaultNum,it.type as type,it.create_id as
+        createId,it.create_time as createTime ,it.state as  state from import_task it left join import_task_condition itc on
+        it.import_task_condition_id=itc.id
+        <if test="sql1!=''">
+
+            where ${sql1}
+        </if>
+
+
+        ${sql2} ${sql3}
+    </select>
+
+    <select id="getImportTaskCount" resultType="java.lang.Long">
+        select count(*) from import_task it left join import_task_condition itc on
+        it.import_task_condition_id=itc.id
+        <if test="sql!=''">
+
+            where ${sql}
+        </if>
+    </select>
+
+</mapper>