فهرست منبع

智能打标导出和标签分布统计 相关内容修改

2507040827 4 هفته پیش
والد
کامیت
ef11d80366

+ 12 - 2
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/config/DataDictionary.java

@@ -55,9 +55,19 @@ public class DataDictionary {
      *        day0正常数据; 1测试数据
      *
      */
-    public static final String TEST_DATA = "1";
+    public static final Integer TEST_DATA = 1;
 
-    public static final String PROD_DATA = "0";
+    public static final Integer PROD_DATA = 0;
+
+
+    /**
+     *    标签范围 tag_scope:
+     *        day0正常数据; 1测试数据
+     *
+     */
+    public static final Integer DELETE = 1;
+
+    public static final Integer NON_DELETE  = 0;
 
     /**
      *    画像系统 打标结果

+ 6 - 4
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AitagTagLogController.java

@@ -152,10 +152,12 @@ public class AitagTagLogController {
         StringBuilder stringBuilder = new StringBuilder();
         for (int i = 0 ;i<tagResultDtos.size();i++){
             TagResultDto resultMap = tagResultDtos.get(i);
-            String tagName = resultMap.getTag_name();
-            stringBuilder.append(tagName);
-            if(i < (tagResultDtos.size()-1) ){
-                stringBuilder.append(",");
+            if(resultMap.getPassr()){
+                String tagName = resultMap.getTag_name();
+                stringBuilder.append(tagName);
+                if(i < (tagResultDtos.size()-1) ){
+                    stringBuilder.append(",");
+                }
             }
         }
         return stringBuilder.toString();

+ 7 - 1
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagTagLogEntity.java

@@ -154,8 +154,14 @@ passr: true/false
     private String feedbackUserEndpoint;
 
     /**
+     * 0正常,1删除
+     **/
+    @ApiModelProperty(value = "0正常,1删除")
+    private Integer isDelete;
+
+    /**
      * 标签标识 0正常数据; 1测试数据
      **/
     @ApiModelProperty(value = "标签标识 0:正常数据; 1:测试数据")
-    private String tagScope;
+    private Integer tagScope;
 }

+ 3 - 11
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AitagTagLogServiceImpl.java

@@ -60,6 +60,7 @@ public class AitagTagLogServiceImpl extends ServiceImpl<AitagTagLogDao, AitagTag
         }
         queryWrapper.in(AitagTagLogEntity::getState, DataDictionary.RESULT_PUSHED,DataDictionary.MANAGER_CONFIRMED);
         queryWrapper.eq(AitagTagLogEntity::getTagScope, PROD_DATA);
+        queryWrapper.eq(AitagTagLogEntity::getIsDelete, NON_DELETE);
         Integer totalConfirmedCnt = this.baseMapper.selectCount(queryWrapper);
         log.info("查询出符合条件的打标完成数据:{} 条",totalConfirmedCnt);
 
@@ -116,6 +117,7 @@ public class AitagTagLogServiceImpl extends ServiceImpl<AitagTagLogDao, AitagTag
             queryWrapper.eq(AitagTagLogEntity::getBusinessAttr, transactionReqVo.getLoanApplicationNo());
         }
         queryWrapper.eq(AitagTagLogEntity::getTagScope, PROD_DATA);
+        queryWrapper.eq(AitagTagLogEntity::getIsDelete, NON_DELETE);
 
         Page<AitagTagLogEntity> page = this.page(new Page<>(transactionReqVo.getPage() == null ? 0 : transactionReqVo.getPage(),
                 transactionReqVo.getSize() == null ? 10 : transactionReqVo.getSize()), queryWrapper);
@@ -129,17 +131,6 @@ public class AitagTagLogServiceImpl extends ServiceImpl<AitagTagLogDao, AitagTag
     @Override
     public TagLogDto show(String id) {
         AitagTagLogEntity aitagTagLog = this.baseMapper.selectById(id);
-        if(aitagTagLog !=null){
-            String result = "";
-            String feedback = aitagTagLog.getFeedback();
-            if(FEEDBACK_RESULT_REJECT.equals(feedback)){
-                result = aitagTagLog.getFeedbackResult();
-                aitagTagLog.setFeedbackResult(result);
-            }else{
-                result = aitagTagLog.getResult();
-                aitagTagLog.setResult(result);
-            }
-        }
         return JSONObject.parseObject(JSONObject.toJSONString(aitagTagLog), TagLogDto.class);
     }
 
@@ -172,6 +163,7 @@ public class AitagTagLogServiceImpl extends ServiceImpl<AitagTagLogDao, AitagTag
         }
         query.in(AitagTagLogEntity::getState, DataDictionary.RESULT_PUSHED,DataDictionary.MANAGER_CONFIRMED);
         query.eq(AitagTagLogEntity::getTagScope, PROD_DATA);
+        query.eq(AitagTagLogEntity::getIsDelete, NON_DELETE);
         return this.baseMapper.selectList(query);
     }
 

+ 39 - 13
server/yusp-tagging-core/src/main/resources/mapper/AitagTagLogMapper.xml

@@ -29,6 +29,7 @@
         FROM aitag_tag_log
         WHERE
             tag_scope = 0
+        AND is_delete = 0
             <if test="startTaggingTime != null and startTaggingTime != ''">
                 AND insert_time >= #{startTaggingTime}
             </if>
@@ -47,6 +48,7 @@
         FROM aitag_tag_log
         WHERE
         tag_scope = 0
+        AND is_delete = 0
             <if test="startTaggingTime != null and startTaggingTime != ''">
                 AND insert_time >= #{startTaggingTime}
             </if>
@@ -67,6 +69,7 @@
         FROM aitag_tag_log
         WHERE
         tag_scope = 0
+        AND is_delete = 0
             <if test="startTaggingTime != null and startTaggingTime != ''">
                 AND insert_time >= #{startTaggingTime}
             </if>
@@ -87,6 +90,7 @@
         FROM aitag_tag_log
         WHERE
         tag_scope = 0
+        AND is_delete = 0
             <if test="startTaggingTime != null and  startTaggingTime != ''">
                 AND insert_time >= #{startTaggingTime}
             </if>
@@ -105,6 +109,7 @@
         FROM aitag_tag_log
         WHERE
             tag_scope = 0
+        AND is_delete = 0
         AND DATE(insert_time) = #{insertTime}
         AND state in ('2','3')
     </select>
@@ -112,31 +117,52 @@
 
     <select id="selectTagDistStats" resultType="cn.com.yusys.yusp.domain.vo.IconResVo" parameterType="cn.com.yusys.yusp.domain.vo.TagDistStatsReqVo">
         SELECT
-        elem->>'tag_name' AS stat,
+        tag_name AS stat,
         COUNT(1) AS val
-        FROM
-        aitag_tag_log t,
-        jsonb_array_elements(result) AS elem
-        WHERE
-        t.tag_scope = 0
+        FROM (
+        -- 从feedback_result获取
+        SELECT elem->>'tag_name' AS tag_name
+        FROM ai_tagging.aitag_tag_log t
+        CROSS JOIN LATERAL jsonb_array_elements(t.feedback_result) elem
+        WHERE t.is_delete = 0
+        AND t.tag_scope = 0
         AND t.state in ('2','3')
+        AND t.feedback_result IS NOT NULL
+        AND jsonb_array_length(t.feedback_result) > 0
+        AND elem->>'passr' = 'true'
+        <if test="categoryId != null and categoryId != '' ">
+            AND elem->>'category_id' = #{categoryId}
+        </if>
         <if test="startTaggingTime != null and startTaggingTime != ''">
             AND insert_time >= #{startTaggingTime}
         </if>
         <if test="endTaggingTime != null and endTaggingTime != ''">
             AND #{endTaggingTime} >= insert_time
         </if>
+        UNION ALL
+        SELECT elem->>'tag_name' AS tag_name
+        FROM ai_tagging.aitag_tag_log t
+        CROSS JOIN LATERAL jsonb_array_elements(t.result) elem
+        WHERE t.is_delete = 0
+        AND t.tag_scope = 0
+        AND t.state in ('2','3')
+        AND t.feedback_result IS NULL
+        AND t.result IS NOT null
+        AND jsonb_array_length(t.result) > 0
+        AND elem->>'passr' = 'true'
         <if test="categoryId != null and categoryId != '' ">
-            AND elem.value->>'category_id' = #{categoryId}
+            AND elem->>'category_id' = #{categoryId}
         </if>
-        GROUP BY
-        elem->>'tag_name'
-        <if test="sort == 'ase'">
-            order by val
+        <if test="startTaggingTime != null and startTaggingTime != ''">
+            AND insert_time >= #{startTaggingTime}
         </if>
-        <if test="sort == 'desc' ">
-            order by val desc
+        <if test="endTaggingTime != null and endTaggingTime != ''">
+            AND #{endTaggingTime} >= insert_time
         </if>
+        ) valid_tags
+        WHERE tag_name IS NOT NULL
+        GROUP BY tag_name
+        ORDER BY val desc
         Limit 6
     </select>