feat: 新增流水标签规则结果任务Mapper
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.ccdi.project.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ccdi.project.domain.entity.CcdiBankTagResult;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流水标签结果 Mapper
|
||||
*/
|
||||
public interface CcdiBankTagResultMapper extends BaseMapper<CcdiBankTagResult> {
|
||||
|
||||
/**
|
||||
* 按项目和可选模型删除历史结果
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @param modelCode 模型编码
|
||||
* @return 删除条数
|
||||
*/
|
||||
int deleteByProjectAndModel(@Param("projectId") Long projectId, @Param("modelCode") String modelCode);
|
||||
|
||||
/**
|
||||
* 批量插入结果
|
||||
*
|
||||
* @param list 结果列表
|
||||
* @return 插入条数
|
||||
*/
|
||||
int insertBatch(@Param("list") List<CcdiBankTagResult> list);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.ccdi.project.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ccdi.project.domain.entity.CcdiBankTagRule;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流水标签规则 Mapper
|
||||
*/
|
||||
public interface CcdiBankTagRuleMapper extends BaseMapper<CcdiBankTagRule> {
|
||||
|
||||
/**
|
||||
* 查询启用规则
|
||||
*
|
||||
* @param modelCode 模型编码
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<CcdiBankTagRule> selectEnabledRules(@Param("modelCode") String modelCode);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.ccdi.project.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ccdi.project.domain.entity.CcdiBankTagTask;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 流水标签任务 Mapper
|
||||
*/
|
||||
public interface CcdiBankTagTaskMapper extends BaseMapper<CcdiBankTagTask> {
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
*
|
||||
* @param task 任务实体
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertTask(CcdiBankTagTask task);
|
||||
|
||||
/**
|
||||
* 更新任务
|
||||
*
|
||||
* @param task 任务实体
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updateTask(CcdiBankTagTask task);
|
||||
|
||||
/**
|
||||
* 查询项目运行中的任务
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 任务实体
|
||||
*/
|
||||
CcdiBankTagTask selectRunningTaskByProjectId(@Param("projectId") Long projectId);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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="com.ruoyi.ccdi.project.mapper.CcdiBankTagResultMapper">
|
||||
|
||||
<resultMap id="CcdiBankTagResultMap" type="com.ruoyi.ccdi.project.domain.entity.CcdiBankTagResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="projectId" column="project_id"/>
|
||||
<result property="modelCode" column="model_code"/>
|
||||
<result property="modelName" column="model_name"/>
|
||||
<result property="ruleCode" column="rule_code"/>
|
||||
<result property="ruleName" column="rule_name"/>
|
||||
<result property="indicatorCode" column="indicator_code"/>
|
||||
<result property="resultType" column="result_type"/>
|
||||
<result property="riskLevel" column="risk_level"/>
|
||||
<result property="bankStatementId" column="bank_statement_id"/>
|
||||
<result property="objectType" column="object_type"/>
|
||||
<result property="objectKey" column="object_key"/>
|
||||
<result property="groupId" column="group_id"/>
|
||||
<result property="logId" column="log_id"/>
|
||||
<result property="reasonDetail" column="reason_detail"/>
|
||||
<result property="businessCaliberSnapshot" column="business_caliber_snapshot"/>
|
||||
<result property="hitValueSnapshot" column="hit_value_snapshot"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<delete id="deleteByProjectAndModel">
|
||||
delete from ccdi_bank_statement_tag_result
|
||||
where project_id = #{projectId}
|
||||
<if test="modelCode != null and modelCode != ''">
|
||||
and model_code = #{modelCode}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into ccdi_bank_statement_tag_result (
|
||||
project_id, model_code, model_name, rule_code, rule_name, indicator_code,
|
||||
result_type, risk_level, bank_statement_id, object_type, object_key, group_id,
|
||||
log_id, reason_detail, business_caliber_snapshot, hit_value_snapshot,
|
||||
create_by, create_time, update_by, update_time, remark
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.projectId}, #{item.modelCode}, #{item.modelName}, #{item.ruleCode}, #{item.ruleName}, #{item.indicatorCode},
|
||||
#{item.resultType}, #{item.riskLevel}, #{item.bankStatementId}, #{item.objectType}, #{item.objectKey}, #{item.groupId},
|
||||
#{item.logId}, #{item.reasonDetail}, #{item.businessCaliberSnapshot}, #{item.hitValueSnapshot},
|
||||
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
reason_detail = values(reason_detail),
|
||||
business_caliber_snapshot = values(business_caliber_snapshot),
|
||||
hit_value_snapshot = values(hit_value_snapshot),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time),
|
||||
remark = values(remark)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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="com.ruoyi.ccdi.project.mapper.CcdiBankTagRuleMapper">
|
||||
|
||||
<resultMap id="CcdiBankTagRuleResultMap" type="com.ruoyi.ccdi.project.domain.entity.CcdiBankTagRule">
|
||||
<id property="id" column="id"/>
|
||||
<result property="modelCode" column="model_code"/>
|
||||
<result property="modelName" column="model_name"/>
|
||||
<result property="ruleCode" column="rule_code"/>
|
||||
<result property="ruleName" column="rule_name"/>
|
||||
<result property="indicatorCode" column="indicator_code"/>
|
||||
<result property="resultType" column="result_type"/>
|
||||
<result property="riskLevel" column="risk_level"/>
|
||||
<result property="businessCaliber" column="business_caliber"/>
|
||||
<result property="enabled" column="enabled"/>
|
||||
<result property="sortOrder" column="sort_order"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectEnabledRules" resultMap="CcdiBankTagRuleResultMap">
|
||||
select id, model_code, model_name, rule_code, rule_name, indicator_code, result_type,
|
||||
risk_level, business_caliber, enabled, sort_order, create_by, create_time,
|
||||
update_by, update_time, remark
|
||||
from ccdi_bank_tag_rule
|
||||
where enabled = 1
|
||||
<if test="modelCode != null and modelCode != ''">
|
||||
and model_code = #{modelCode}
|
||||
</if>
|
||||
order by sort_order asc, id asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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="com.ruoyi.ccdi.project.mapper.CcdiBankTagTaskMapper">
|
||||
|
||||
<resultMap id="CcdiBankTagTaskResultMap" type="com.ruoyi.ccdi.project.domain.entity.CcdiBankTagTask">
|
||||
<id property="id" column="id"/>
|
||||
<result property="projectId" column="project_id"/>
|
||||
<result property="triggerType" column="trigger_type"/>
|
||||
<result property="modelCode" column="model_code"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="needRerun" column="need_rerun"/>
|
||||
<result property="successRuleCount" column="success_rule_count"/>
|
||||
<result property="failedRuleCount" column="failed_rule_count"/>
|
||||
<result property="hitCount" column="hit_count"/>
|
||||
<result property="errorMessage" column="error_message"/>
|
||||
<result property="startTime" column="start_time"/>
|
||||
<result property="endTime" column="end_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertTask" parameterType="com.ruoyi.ccdi.project.domain.entity.CcdiBankTagTask" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ccdi_bank_tag_task (
|
||||
project_id, trigger_type, model_code, status, need_rerun, success_rule_count,
|
||||
failed_rule_count, hit_count, error_message, start_time, end_time,
|
||||
create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{projectId}, #{triggerType}, #{modelCode}, #{status}, #{needRerun}, #{successRuleCount},
|
||||
#{failedRuleCount}, #{hitCount}, #{errorMessage}, #{startTime}, #{endTime},
|
||||
#{createBy}, #{createTime}, #{updateBy}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateTask" parameterType="com.ruoyi.ccdi.project.domain.entity.CcdiBankTagTask">
|
||||
update ccdi_bank_tag_task
|
||||
<set>
|
||||
<if test="triggerType != null">trigger_type = #{triggerType},</if>
|
||||
<if test="modelCode != null">model_code = #{modelCode},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="needRerun != null">need_rerun = #{needRerun},</if>
|
||||
<if test="successRuleCount != null">success_rule_count = #{successRuleCount},</if>
|
||||
<if test="failedRuleCount != null">failed_rule_count = #{failedRuleCount},</if>
|
||||
<if test="hitCount != null">hit_count = #{hitCount},</if>
|
||||
<if test="errorMessage != null">error_message = #{errorMessage},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="endTime != null">end_time = #{endTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectRunningTaskByProjectId" resultMap="CcdiBankTagTaskResultMap">
|
||||
select id, project_id, trigger_type, model_code, status, need_rerun, success_rule_count,
|
||||
failed_rule_count, hit_count, error_message, start_time, end_time,
|
||||
create_by, create_time, update_by, update_time
|
||||
from ccdi_bank_tag_task
|
||||
where project_id = #{projectId}
|
||||
and status = 'RUNNING'
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ruoyi.ccdi.project.mapper;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class CcdiBankTagResultMapperXmlTest {
|
||||
|
||||
private static final String RESOURCE = "mapper/ccdi/project/CcdiBankTagResultMapper.xml";
|
||||
|
||||
@Test
|
||||
void deleteByProjectAndOptionalModel_shouldRenderScopedDelete() throws Exception {
|
||||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE)) {
|
||||
String xml = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||
assertTrue(xml.contains("delete from ccdi_bank_statement_tag_result"));
|
||||
assertTrue(xml.contains("project_id = #{projectId}"));
|
||||
assertTrue(xml.contains("model_code = #{modelCode}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user