SmartDataTaskMapper.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package com.template.mapper;
  2. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  3. import com.template.model.pojo.SmartDataTask;
  4. import com.template.model.pojo.SmartDataTaskErr;
  5. import org.apache.ibatis.annotations.*;
  6. import org.springframework.stereotype.Repository;
  7. /**
  8. * <p>
  9. * 数据源任务 Mapper 接口
  10. * </p>
  11. *
  12. * @author ceshi
  13. * @since 2023-12-05
  14. */
  15. @Repository
  16. public interface SmartDataTaskMapper extends BaseMapper<SmartDataTask> {
  17. @Select("SELECT " +
  18. " COUNT(tk_id) " +
  19. "FROM " +
  20. " smart_data_task " +
  21. "WHERE " +
  22. " tk_name = #{tkName} " +
  23. " AND tk_id != #{tkId} "
  24. )
  25. int isRepeatTaskName(SmartDataTask smartDataTask);
  26. @Update("UPDATE smart_data_task " +
  27. "SET tk_activation = #{tkActivation} " +
  28. " ,tk_next_exe_time = #{tkNextExeTime} " +
  29. "WHERE " +
  30. " tk_id = #{tkId} "
  31. )
  32. int markTaskById(SmartDataTask smartDataTask);
  33. @Insert({
  34. "<script>",
  35. "INSERT INTO smart_data_task ",
  36. " <trim prefix='(' suffix=')' suffixOverrides=','> ",
  37. " <if test='tkName != null'>tk_name,</if> ",
  38. " <if test='tkDtId != null'>tk_dt_id,</if> ",
  39. " <if test='tkDsIdSource != null'>tk_ds_id_source,</if> ",
  40. " <if test='tkSyncPolicy != null'>tk_sync_policy,</if> ",
  41. " <if test='tkExchangeType != null'>tk_exchange_type,</if> ",
  42. " <if test='tkSql != null'>tk_sql,</if> ",
  43. " <if test='tkDsIdDestination != null'>tk_ds_id_destination,</if> ",
  44. " <if test='tkDestTable != null'>tk_dest_table,</if> ",
  45. " <if test='tkExchangeServer != null'>tk_exchange_server,</if> ",
  46. " <if test='tkExchangeServerId != null'>tk_exchange_server_id,</if> ",
  47. " <if test='tkOptCfgAutoManual != null'>tk_opt_cfg_auto_manual,</if> ",
  48. " <if test='tkOptCfgRsNum != null'>tk_opt_cfg_rs_num,</if> ",
  49. " <if test='tkOptCfgThreadsNum != null'>tk_opt_cfg_threads_num,</if> ",
  50. " <if test='tkRsIncorrectData != null'>tk_rs_incorrect_data,</if> ",
  51. " <if test='tkDsSourceCharset != null'>tk_ds_source_charset,</if> ",
  52. " <if test='tkDsDestinationCharset != null'>tk_ds_destination_charset,</if> ",
  53. " <if test='tkCron != null'>tk_cron,</if> ",
  54. " <if test='tkManualOrAuto != null'>tk_manual_or_auto,</if> ",
  55. " <if test='tkExeType != null'>tk_exe_type,</if> ",
  56. " <if test='tkRepetTime != null'>tk_repet_time,</if> ",
  57. " <if test='tkActivation != null'>tk_activation,</if> ",
  58. " <if test='tkDescrition != null'>tk_descrition,</if> ",
  59. " <if test='tkDeleted != null'>tk_deleted,</if> ",
  60. " <if test='tkNextExeTime != null'>tk_next_exe_time,</if> ",
  61. " </trim> ",
  62. "VALUES ",
  63. " <trim prefix='(' suffix=')' suffixOverrides=','>",
  64. " <if test='tkName != null'>#{tkName},</if> ",
  65. " <if test='tkDtId != null'>#{tkDtId},</if> ",
  66. " <if test='tkDsIdSource != null'>#{tkDsIdSource},</if> ",
  67. " <if test='tkSyncPolicy != null'>#{tkSyncPolicy},</if> ",
  68. " <if test='tkExchangeType != null'>#{tkExchangeType},</if> ",
  69. " <if test='tkSql != null'>#{tkSql},</if> ",
  70. " <if test='tkDsIdDestination != null'>#{tkDsIdDestination},</if> ",
  71. " <if test='tkDestTable != null'>#{tkDestTable},</if> ",
  72. " <if test='tkExchangeServer != null'>#{tkExchangeServer},</if> ",
  73. " <if test='tkExchangeServerId != null'>#{tkExchangeServerId},</if> ",
  74. " <if test='tkOptCfgAutoManual != null'>#{tkOptCfgAutoManual},</if> ",
  75. " <if test='tkOptCfgRsNum != null'>#{tkOptCfgRsNum},</if> ",
  76. " <if test='tkOptCfgThreadsNum != null'>#{tkOptCfgThreadsNum},</if> ",
  77. " <if test='tkRsIncorrectData != null'>#{tkRsIncorrectData},</if> ",
  78. " <if test='tkDsSourceCharset != null'>#{tkDsSourceCharset},</if> ",
  79. " <if test='tkDsDestinationCharset != null'>#{tkDsDestinationCharset},</if> ",
  80. " <if test='tkColRelationship != null'>#{tkColRelationship},</if> ",
  81. " <if test='tkCron != null'>#{tkCron},</if> ",
  82. " <if test='tkManualOrAuto != null'>#{tkManualOrAuto},</if> ",
  83. " <if test='tkExeType != null'>#{tkExeType},</if> ",
  84. " <if test='tkRepetTime != null'>#{tkRepetTime},</if> ",
  85. " <if test='tkActivation != null'>#{tkActivation},</if> ",
  86. " <if test='tkDeleted != null'>#{tkDeleted},</if> ",
  87. " <if test='tkNextExeTime != null'>#{tkNextExeTime},</if> ",
  88. " </trim>",
  89. "</script>"
  90. })
  91. @Options(useGeneratedKeys = true, keyProperty = "tk_id")
  92. int insert(SmartDataTask smartDataTask);
  93. @Update("UPDATE smart_data_task " +
  94. " SET tk_col_relationship = #{colRelationship} " +
  95. "WHERE " +
  96. " tk_id = #{tkId}")
  97. int insertColRelationship(int tkId, String colRelationship);
  98. @Select("SELECT " +
  99. " COUNT(id) " +
  100. "FROM " +
  101. " smart_department " +
  102. "WHERE " +
  103. " id = #{tkDtId} ")
  104. int isHaveDepartmentById(Integer tkDtId);
  105. @Select("SELECT " +
  106. " tk_id " +
  107. " ,tk_col_relationship " +
  108. "FROM " +
  109. " smart_data_task " +
  110. "WHERE " +
  111. " tk_id = #{tkId} "
  112. )
  113. SmartDataTask selectColRelationship(int tkId);
  114. @Select("SELECT " +
  115. " tk_id " +
  116. " ,tk_swapped_primary_keys " +
  117. "FROM " +
  118. " smart_data_task " +
  119. "WHERE " +
  120. " tk_id = #{tkId} "
  121. )
  122. SmartDataTask selectColSwappedPrimaryKeys(int tkId);
  123. @Select({
  124. "<script>",
  125. " SELECT " +
  126. " COUNT(*) " +
  127. " FROM smart_data_task ",
  128. " <where>",
  129. " <if test='tkId != null'>AND tk_id = #{tkId}</if> ",
  130. " <if test='tkName != null'>AND tk_name = #{tkName}</if> ",
  131. " <if test='tkDtId != null'>AND tk_dt_id = #{tkDtId}</if> ",
  132. " <if test='tkDsIdSource != null'>AND tk_ds_id_source = #{tkDsIdSource}</if> ",
  133. " <if test='tkSyncPolicy != null'>AND tk_sync_policy = #{tkSyncPolicy}</if> ",
  134. " <if test='tkExchangeType != null'>AND tk_exchange_type = #{tkExchangeType}</if> ",
  135. " <if test='tkSql != null'>AND tk_sql = #{tkSql}</if> ",
  136. " <if test='tkDsIdDestination != null'>AND tk_ds_id_destination = #{tkDsIdDestination}</if> ",
  137. " <if test='tkDestTable != null'>AND tk_dest_table = #{tkDestTable}</if> ",
  138. " <if test='tkExchangeServer != null'>AND tk_exchange_server = #{tkExchangeServer}</if> ",
  139. " <if test='tkExchangeServerId != null'>AND tk_exchange_server_id = #{tkExchangeServerId}</if> ",
  140. " <if test='tkOptCfgAutoManual != null'>AND tk_opt_cfg_auto_manual = #{tkOptCfgAutoManual}</if> ",
  141. " <if test='tkOptCfgRsNum != null'>AND tk_opt_cfg_rs_num = #{tkOptCfgRsNum}</if> ",
  142. " <if test='tkOptCfgThreadsNum != null'>AND tk_opt_cfg_threads_num = #{tkOptCfgThreadsNum}</if> ",
  143. " <if test='tkRsIncorrectData != null'>AND tk_rs_incorrect_data = #{tkRsIncorrectData}</if> ",
  144. " <if test='tkDsSourceCharset != null'>AND tk_ds_source_charset = #{tkDsSourceCharset}</if> ",
  145. " <if test='tkDsDestinationCharset != null'>AND tk_ds_destination_charset = #{tkDsDestinationCharset}</if> ",
  146. " <if test='tkColRelationship != null'>AND tk_name = #{tkColRelationship}</if> ",
  147. " <if test='tkCron != null'>AND tk_cron = #{tkCron}</if> ",
  148. " <if test='tkManualOrAuto != null'>AND tk_manual_or_auto = #{tkManualOrAuto}</if> ",
  149. " <if test='tkExeType != null'>AND tk_exe_type = #{tkExeType}</if> ",
  150. " <if test='tkRepetTime != null'>AND tk_repet_time = #{tkRepetTime}</if> ",
  151. " <if test='tkActivation != null'>AND tk_activation = #{tkActivation}</if> ",
  152. " <if test='tkDeleted != null'>AND tk_deleted = #{tkDeleted}</if> ",
  153. " <if test='tkNextExeTime != null'>AND tk_next_exe_time = #{tkNextExeTime}</if> ",
  154. " </where>",
  155. "</script>"
  156. })
  157. int isRepeatTask(SmartDataTask smartDataTask);
  158. @Update("UPDATE smart_data_task " +
  159. "SET tk_deleted = 1 " +
  160. "WHERE " +
  161. " tk_id = #{id} "
  162. )
  163. int logicDeleteMarkTaskById(int id);
  164. @Delete("DELETE FROM smart_data_task "+
  165. "WHERE "+
  166. " tk_id = #{id} "
  167. )
  168. int physicsDeleteMarkTaskById(int id);
  169. @Update("UPDATE smart_data_task " +
  170. "SET tk_deleted = 0 " +
  171. "WHERE " +
  172. " tk_id = #{id} "
  173. )
  174. int restoreLogicDeleteMarkTaskById(int id);
  175. @Update("UPDATE smart_data_task " +
  176. "SET tk_swapped_primary_keys = #{tkSwappedPrimaryKeys} " +
  177. "WHERE " +
  178. " tk_id = #{tkId} "
  179. )
  180. int saveSwappedPrimaryKeys(SmartDataTask smartDataTask);
  181. @Insert({
  182. "<script>",
  183. "INSERT INTO smart_data_task_err ",
  184. " <trim prefix='(' suffix=')' suffixOverrides=','> ",
  185. " <if test='eTaskId != null'>e_task_id,</if> ",
  186. " <if test='eDateTime != null'>e_date_time,</if> ",
  187. " <if test='eMsg != null'>e_msg,</if> ",
  188. " </trim> ",
  189. "VALUES ",
  190. " <trim prefix='(' suffix=')' suffixOverrides=','>",
  191. " <if test='eTaskId != null'>#{eTaskId},</if> ",
  192. " <if test='eDateTime != null'>#{eDateTime},</if> ",
  193. " <if test='eMsg != null'>#{eMsg},</if> ",
  194. " </trim>",
  195. "</script>"
  196. })
  197. int insertErrorMsg(SmartDataTaskErr smartDataTaskErr);
  198. @Select({
  199. "<script>",
  200. " SELECT " +
  201. " * " +
  202. " FROM smart_data_task_err ",
  203. " <where>",
  204. " <if test='eTaskId != null'>AND e_task_id = #{eTaskId}</if> ",
  205. " <if test='eMsg != null'>AND e_msg = #{eMsg}</if> ",
  206. " </where>",
  207. "</script>"
  208. })
  209. SmartDataTaskErr selectErrorMsg(SmartDataTaskErr smartDataTaskErr);
  210. @Update("UPDATE smart_data_task_err " +
  211. "SET e_task_id = #{eTaskId} " +
  212. " ,e_msg = #{eMsg} " +
  213. " ,e_num = e_num + 1 " +
  214. " ,e_date_time = #{eDateTime} " +
  215. "WHERE " +
  216. " e_id = #{eId} "
  217. )
  218. int updateErrorMsg(SmartDataTaskErr smartDataTaskErr);
  219. @Select({
  220. "<script>",
  221. " SELECT " +
  222. " tk_col_relationship " +
  223. " FROM smart_data_task ",
  224. " <where>",
  225. " <if test='tkId != null'>AND tk_id = #{tkId}</if> ",
  226. " </where>",
  227. "</script>"
  228. })
  229. String getColRelationship(SmartDataTask smartDataTask);
  230. }