PlanManageMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.huaxu.task.dao.PlanManageMapper" >
  4. <resultMap id="BaseResultMap" type="com.huaxu.task.dto.PlanManageDto" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="plan_id" property="planId" jdbcType="VARCHAR" />
  7. <result column="plan_name" property="planName" jdbcType="VARCHAR" />
  8. <result column="plan_user_id" property="planUserId" jdbcType="VARCHAR" />
  9. <result column="user_id" property="userId" jdbcType="VARCHAR" />
  10. <result column="plan_date" property="planDate" jdbcType="TIMESTAMP" />
  11. <result column="plan_start_date" property="planStartDate" jdbcType="TIMESTAMP" />
  12. <result column="plan_end_date" property="planEndDate" jdbcType="TIMESTAMP" />
  13. <result column="task_content" property="taskContent" jdbcType="VARCHAR" />
  14. <result column="task_area_shape" property="taskAreaShape" jdbcType="VARCHAR" />
  15. <result column="task_area_name" property="taskAreaName" jdbcType="VARCHAR" />
  16. <result column="task_type" property="taskType" jdbcType="INTEGER" />
  17. <result column="plan_status" property="planStatus" jdbcType="INTEGER" />
  18. <result column="tenant_id" property="tenantId" jdbcType="VARCHAR" />
  19. <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  20. <result column="process_def_id" property="processDefId" jdbcType="VARCHAR" />
  21. <result column="current_task_id" property="currentTaskId" jdbcType="VARCHAR" />
  22. <result column="current_users" property="currentUsers" jdbcType="VARCHAR" />
  23. <result column="current_task_name" property="currentTaskName" jdbcType="VARCHAR" />
  24. <result column="create_by" property="createBy" jdbcType="VARCHAR" />
  25. <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  26. <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
  27. <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  28. <result column="company_org_id" property="compa=nyOrgId" jdbcType="VARCHAR" />
  29. <result column="department_org_id" property="departmentOrgId" jdbcType="VARCHAR" />
  30. <result column="task_checked" property="taskChecked" jdbcType="VARCHAR" />
  31. <result column="flow_detail" property="flowDetail" jdbcType="VARCHAR" />
  32. </resultMap>
  33. <resultMap id="workFlowLogResultMap" type="com.huaxu.order.entity.WorkFlowLog">
  34. <id column="id" property="id" jdbcType="INTEGER" />
  35. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  36. <result column="log_process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  37. <result column="task_id" property="taskId" jdbcType="VARCHAR" />
  38. <result column="handle_user_id" property="handleUserId" jdbcType="VARCHAR" />
  39. <result column="handle_user_name" property="handleUserName" jdbcType="VARCHAR" />
  40. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  41. <result column="flow_result" property="flowResult" jdbcType="VARCHAR" />
  42. <result column="log_create_by" property="createBy" jdbcType="VARCHAR" />
  43. <result column="log_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  44. <result column="log_update_by" property="updateBy" jdbcType="VARCHAR" />
  45. <result column="log_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  46. </resultMap>
  47. <resultMap id="TaskResultMap" type="com.huaxu.task.dto.PlanManageDto" extends="BaseResultMap">
  48. <association property="workFlowDetail" javaType="com.huaxu.order.entity.WorkFlowDetail">
  49. <id column="id" property="id" jdbcType="INTEGER" />
  50. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  51. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  52. <result column="flow_detail" property="flowDetail" jdbcType="VARCHAR" />
  53. <result column="detail_create_by" property="createBy" jdbcType="VARCHAR" />
  54. <result column="detail_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  55. <result column="detail_update_by" property="updateBy" jdbcType="VARCHAR" />
  56. <result column="detail_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  57. </association>
  58. <collection property="workFlowLogList" ofType="com.huaxu.order.entity.WorkFlowLog" javaType="java.util.List" select="getWorkFlowLog" column="{flowId=id}">
  59. <id column="id" property="id" jdbcType="INTEGER" />
  60. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  61. <result column="log_process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  62. <result column="task_id" property="taskId" jdbcType="VARCHAR" />
  63. <result column="handle_user_id" property="handleUserId" jdbcType="VARCHAR" />
  64. <result column="handle_user_name" property="handleUserName" jdbcType="VARCHAR" />
  65. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  66. <result column="flow_result" property="flowResult" jdbcType="VARCHAR" />
  67. <result column="log_create_by" property="createBy" jdbcType="VARCHAR" />
  68. <result column="log_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  69. <result column="log_update_by" property="updateBy" jdbcType="VARCHAR" />
  70. <result column="log_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  71. </collection>
  72. </resultMap>
  73. <sql id="Base_Column_List" >
  74. id, plan_id, plan_name, plan_user_id, user_id, plan_date, plan_start_date, plan_end_date,
  75. task_content, task_area_shape, task_area_name, task_type, plan_status, tenant_id,
  76. process_instance_id, process_def_id, current_task_id, current_users, current_task_name,
  77. create_by, date_create, update_by, date_update, company_org_id, department_org_id,
  78. task_checked
  79. </sql>
  80. <select id="getWorkFlowLog" resultMap="workFlowLogResultMap" parameterType="map">
  81. select t3.process_instance_id log_process_instance_id,t3.task_id,t3.handle_user_id,t3.handle_user_name,t3.flow_result,t3.create_by log_create_by,
  82. t3.date_create log_date_create,t3.update_by log_update_by,t3.date_update log_date_update
  83. from sc_work_flow_log t3
  84. where t3.flow_id= #{flowId,jdbcType=INTEGER} and t3.flow_type=1
  85. </select>
  86. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  87. select
  88. <include refid="Base_Column_List" />
  89. from sc_plan_manage
  90. where id = #{id,jdbcType=INTEGER}
  91. </select>
  92. <select id="selectByPlanId" resultMap="BaseResultMap" parameterType="java.lang.String" >
  93. select
  94. <include refid="Base_Column_List" />
  95. from sc_plan_manage
  96. where plan_id = #{planId,jdbcType=VARCHAR}
  97. </select>
  98. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  99. delete from sc_plan_manage
  100. where id = #{id,jdbcType=INTEGER}
  101. </delete>
  102. <insert id="insertSelective" parameterType="com.huaxu.task.entity.PlanManage" >
  103. insert into sc_plan_manage
  104. <trim prefix="(" suffix=")" suffixOverrides="," >
  105. <if test="id != null" >
  106. id,
  107. </if>
  108. <if test="planId != null" >
  109. plan_id,
  110. </if>
  111. <if test="planName != null" >
  112. plan_name,
  113. </if>
  114. <if test="planUserId != null" >
  115. plan_user_id,
  116. </if>
  117. <if test="userId != null" >
  118. user_id,
  119. </if>
  120. <if test="planDate != null" >
  121. plan_date,
  122. </if>
  123. <if test="planStartDate != null" >
  124. plan_start_date,
  125. </if>
  126. <if test="planEndDate != null" >
  127. plan_end_date,
  128. </if>
  129. <if test="taskContent != null" >
  130. task_content,
  131. </if>
  132. <if test="taskAreaShape != null" >
  133. task_area_shape,
  134. </if>
  135. <if test="taskAreaName != null" >
  136. task_area_name,
  137. </if>
  138. <if test="taskType != null" >
  139. task_type,
  140. </if>
  141. <if test="planStatus != null" >
  142. plan_status,
  143. </if>
  144. <if test="tenantId != null" >
  145. tenant_id,
  146. </if>
  147. <if test="processInstanceId != null" >
  148. process_instance_id,
  149. </if>
  150. <if test="processDefId != null" >
  151. process_def_id,
  152. </if>
  153. <if test="currentTaskId != null" >
  154. current_task_id,
  155. </if>
  156. <if test="currentUsers != null" >
  157. current_users,
  158. </if>
  159. <if test="currentTaskName != null" >
  160. current_task_name,
  161. </if>
  162. <if test="createBy != null" >
  163. create_by,
  164. </if>
  165. <if test="dateCreate != null" >
  166. date_create,
  167. </if>
  168. <if test="updateBy != null" >
  169. update_by,
  170. </if>
  171. <if test="dateUpdate != null" >
  172. date_update,
  173. </if>
  174. <if test="companyOrgId != null" >
  175. company_org_id,
  176. </if>
  177. <if test="departmentOrgId != null" >
  178. department_org_id,
  179. </if>
  180. <if test="taskChecked != null" >
  181. task_checked,
  182. </if>
  183. </trim>
  184. <trim prefix="values (" suffix=")" suffixOverrides="," >
  185. <if test="id != null" >
  186. #{id,jdbcType=INTEGER},
  187. </if>
  188. <if test="planId != null" >
  189. #{planId,jdbcType=VARCHAR},
  190. </if>
  191. <if test="planName != null" >
  192. #{planName,jdbcType=VARCHAR},
  193. </if>
  194. <if test="planUserId != null" >
  195. #{planUserId,jdbcType=VARCHAR},
  196. </if>
  197. <if test="userId != null" >
  198. #{userId,jdbcType=VARCHAR},
  199. </if>
  200. <if test="planDate != null" >
  201. #{planDate,jdbcType=TIMESTAMP},
  202. </if>
  203. <if test="planStartDate != null" >
  204. #{planStartDate,jdbcType=DATE},
  205. </if>
  206. <if test="planEndDate != null" >
  207. #{planEndDate,jdbcType=DATE},
  208. </if>
  209. <if test="taskContent != null" >
  210. #{taskContent,jdbcType=VARCHAR},
  211. </if>
  212. <if test="taskAreaShape != null" >
  213. #{taskAreaShape,jdbcType=VARCHAR},
  214. </if>
  215. <if test="taskAreaName != null" >
  216. #{taskAreaName,jdbcType=VARCHAR},
  217. </if>
  218. <if test="taskType != null" >
  219. #{taskType,jdbcType=INTEGER},
  220. </if>
  221. <if test="planStatus != null" >
  222. #{planStatus,jdbcType=INTEGER},
  223. </if>
  224. <if test="tenantId != null" >
  225. #{tenantId,jdbcType=VARCHAR},
  226. </if>
  227. <if test="processInstanceId != null" >
  228. #{processInstanceId,jdbcType=VARCHAR},
  229. </if>
  230. <if test="processDefId != null" >
  231. #{processDefId,jdbcType=VARCHAR},
  232. </if>
  233. <if test="currentTaskId != null" >
  234. #{currentTaskId,jdbcType=VARCHAR},
  235. </if>
  236. <if test="currentUsers != null" >
  237. #{currentUsers,jdbcType=VARCHAR},
  238. </if>
  239. <if test="currentTaskName != null" >
  240. #{currentTaskName,jdbcType=VARCHAR},
  241. </if>
  242. <if test="createBy != null" >
  243. #{createBy,jdbcType=VARCHAR},
  244. </if>
  245. <if test="dateCreate != null" >
  246. #{dateCreate,jdbcType=TIMESTAMP},
  247. </if>
  248. <if test="updateBy != null" >
  249. #{updateBy,jdbcType=VARCHAR},
  250. </if>
  251. <if test="dateUpdate != null" >
  252. #{dateUpdate,jdbcType=TIMESTAMP},
  253. </if>
  254. <if test="companyOrgId != null" >
  255. #{companyOrgId,jdbcType=VARCHAR},
  256. </if>
  257. <if test="departmentOrgId != null" >
  258. #{departmentOrgId,jdbcType=VARCHAR},
  259. </if>
  260. <if test="taskChecked != null" >
  261. #{taskChecked,jdbcType=VARCHAR},
  262. </if>
  263. </trim>
  264. </insert>
  265. <update id="updateByPrimaryKeySelective" parameterType="com.huaxu.task.entity.PlanManage" >
  266. update sc_plan_manage
  267. <set >
  268. <if test="planId != null" >
  269. plan_id = #{planId,jdbcType=VARCHAR},
  270. </if>
  271. <if test="planName != null" >
  272. plan_name = #{planName,jdbcType=VARCHAR},
  273. </if>
  274. <if test="planUserId != null" >
  275. plan_user_id = #{planUserId,jdbcType=VARCHAR},
  276. </if>
  277. <if test="userId != null" >
  278. user_id = #{userId,jdbcType=VARCHAR},
  279. </if>
  280. <if test="planDate != null" >
  281. plan_date = #{planDate,jdbcType=TIMESTAMP},
  282. </if>
  283. <if test="planStartDate != null" >
  284. plan_start_date = #{planStartDate,jdbcType=TIMESTAMP},
  285. </if>
  286. <if test="planEndDate != null" >
  287. plan_end_date = #{planEndDate,jdbcType=TIMESTAMP},
  288. </if>
  289. <if test="taskContent != null" >
  290. task_content = #{taskContent,jdbcType=VARCHAR},
  291. </if>
  292. <if test="taskAreaShape != null" >
  293. task_area_shape = #{taskAreaShape,jdbcType=VARCHAR},
  294. </if>
  295. <if test="taskAreaName != null" >
  296. task_area_name = #{taskAreaName,jdbcType=VARCHAR},
  297. </if>
  298. <if test="taskType != null" >
  299. task_type = #{taskType,jdbcType=INTEGER},
  300. </if>
  301. <if test="planStatus != null" >
  302. plan_status = #{planStatus,jdbcType=INTEGER},
  303. </if>
  304. <if test="tenantId != null" >
  305. tenant_id = #{tenantId,jdbcType=VARCHAR},
  306. </if>
  307. <if test="processInstanceId != null" >
  308. process_instance_id = #{processInstanceId,jdbcType=VARCHAR},
  309. </if>
  310. <if test="processDefId != null" >
  311. process_def_id = #{processDefId,jdbcType=VARCHAR},
  312. </if>
  313. <if test="currentTaskId != null" >
  314. current_task_id = #{currentTaskId,jdbcType=VARCHAR},
  315. </if>
  316. <if test="currentUsers != null" >
  317. current_users = #{currentUsers,jdbcType=VARCHAR},
  318. </if>
  319. <if test="currentTaskName != null" >
  320. current_task_name = #{currentTaskName,jdbcType=VARCHAR},
  321. </if>
  322. <if test="createBy != null" >
  323. create_by = #{createBy,jdbcType=VARCHAR},
  324. </if>
  325. <if test="dateCreate != null" >
  326. date_create = #{dateCreate,jdbcType=TIMESTAMP},
  327. </if>
  328. <if test="updateBy != null" >
  329. update_by = #{updateBy,jdbcType=VARCHAR},
  330. </if>
  331. <if test="dateUpdate != null" >
  332. date_update = #{dateUpdate,jdbcType=TIMESTAMP},
  333. </if>
  334. <if test="companyOrgId != null" >
  335. company_org_id = #{companyOrgId,jdbcType=VARCHAR},
  336. </if>
  337. <if test="departmentOrgId != null" >
  338. department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
  339. </if>
  340. <if test="taskChecked != null" >
  341. task_checked = #{taskChecked,jdbcType=VARCHAR},
  342. </if>
  343. </set>
  344. where id = #{id,jdbcType=INTEGER}
  345. </update>
  346. <update id="updateByPrimaryKey" parameterType="com.huaxu.task.entity.PlanManage" >
  347. update sc_plan_manage
  348. set plan_id = #{planId,jdbcType=VARCHAR},
  349. plan_name = #{planName,jdbcType=VARCHAR},
  350. plan_user_id = #{planUserId,jdbcType=VARCHAR},
  351. user_id = #{userId,jdbcType=VARCHAR},
  352. plan_date = #{planDate,jdbcType=TIMESTAMP},
  353. plan_start_date = #{planStartDate,jdbcType=TIMESTAMP},
  354. plan_end_date = #{planEndDate,jdbcType=TIMESTAMP},
  355. task_content = #{taskContent,jdbcType=VARCHAR},
  356. task_area_shape = #{taskAreaShape,jdbcType=VARCHAR},
  357. task_area_name = #{taskAreaName,jdbcType=VARCHAR},
  358. task_type = #{taskType,jdbcType=INTEGER},
  359. plan_status = #{planStatus,jdbcType=INTEGER},
  360. tenant_id = #{tenantId,jdbcType=VARCHAR},
  361. process_instance_id = #{processInstanceId,jdbcType=VARCHAR},
  362. process_def_id = #{processDefId,jdbcType=VARCHAR},
  363. current_task_id = #{currentTaskId,jdbcType=VARCHAR},
  364. current_users = #{currentUsers,jdbcType=VARCHAR},
  365. current_task_name = #{currentTaskName,jdbcType=VARCHAR},
  366. create_by = #{createBy,jdbcType=VARCHAR},
  367. date_create = #{dateCreate,jdbcType=TIMESTAMP},
  368. update_by = #{updateBy,jdbcType=VARCHAR},
  369. date_update = #{dateUpdate,jdbcType=TIMESTAMP},
  370. company_org_id = #{companyOrgId,jdbcType=VARCHAR},
  371. department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
  372. task_checked = #{taskChecked,jdbcType=VARCHAR}
  373. where id = #{id,jdbcType=INTEGER}
  374. </update>
  375. <!--分页查询-->
  376. <select id="findPage" resultMap="TaskResultMap">
  377. select
  378. t1.id, t1.plan_id, plan_name, plan_user_id, user_id, plan_date, plan_start_date, plan_end_date,
  379. task_content, task_area_shape, task_area_name, task_type, plan_status, tenant_id,
  380. t1.process_instance_id, process_def_id, current_task_id, current_users, current_task_name,
  381. t1.create_by, t1.date_create, t1.update_by, t1.date_update, company_org_id, department_org_id,task_checked,
  382. t2.flow_detail,t2.create_by detail_create_by,t2.date_create detail_date_create,t2.update_by detail_update_by,t2.date_update detail_date_update
  383. from sc_plan_manage t1 left join sc_work_flow_detail t2
  384. on t1.id = t2.flow_id and t2.flow_type=1
  385. <where>
  386. <if test="plan.tenantId != null and plan.tenantId != ''">
  387. and t1.tenant_id = #{plan.tenantId}
  388. </if>
  389. <if test="plan.key != null and plan.key != ''">
  390. and (t1.plan_id like CONCAT('%',#{plan.key},'%') or t1.plan_name like CONCAT('%',#{plan.key},'%'))
  391. </if>
  392. <if test="plan.userType!=null and plan.userType!=-999 and plan.userType!=-9999 and plan.programItems != null and plan.programItems.size() > 0">
  393. <if test="plan.permissonType == 5 or plan.permissonType == 2">
  394. and ( t1.DEPT_ORG_ID in
  395. <foreach collection="plan.programItems" item="item" open="(" close=")" separator=",">
  396. #{item.orgId}
  397. </foreach>
  398. or
  399. t1.COMPANY_ORG_ID in
  400. <foreach collection="plan.programItems" item="item" open="(" close=")" separator=",">
  401. #{item.orgId}
  402. </foreach>
  403. )
  404. </if>
  405. <if test="plan.permissonType == 4 or plan.permissonType == 3">
  406. and t1.DEPT_ORG_ID in
  407. <foreach collection="plan.programItems" item="item" open="(" close=")" separator=",">
  408. #{item.orgId}
  409. </foreach>
  410. </if>
  411. <if test="plan.permissonType == 1">
  412. and t1.COMPANY_ORG_ID in
  413. <foreach collection="plan.programItems" item="item" open="(" close=")" separator=",">
  414. #{item.orgId}
  415. </foreach>
  416. and (t1.DEPT_ORG_ID is null or t1.DEPT_ORG_ID =0)
  417. </if>
  418. </if>
  419. <if test="plan.planStatus != null">
  420. and t1.plan_status = #{plan.planStatus,jdbcType=INTEGER}
  421. </if>
  422. <if test="plan.planStatus == null">
  423. and t1.plan_status != 0
  424. </if>
  425. <if test="plan.taskType != null">
  426. and t1.task_type = #{plan.taskType,jdbcType=INTEGER}
  427. </if>
  428. <if test="plan.currentUsers != null">
  429. and INSTR(t1.current_users,#{plan.currentUsers})
  430. </if>
  431. <if test="plan.startDate != null and plan.endDate != null">
  432. and t1.date_create &gt;= date_format(#{plan.startDate,jdbcType=VARCHAR},'%Y-%c-%d')
  433. and t1.date_create &lt;= DATE_ADD(date_format(#{plan.endDate,jdbcType=VARCHAR},'%Y-%c-%d'),INTERVAL 1 DAY)
  434. </if>
  435. </where>
  436. order by t1.date_create
  437. </select>
  438. <!--待处理权限-->
  439. <select id="selectPendingPower" resultType="java.lang.Integer" parameterType="map">
  440. select count(1) from sc_plan_manage
  441. where id = #{id,jdbcType=INTEGER} and INSTR(current_users,#{currentUsers,jdbcType=VARCHAR})
  442. </select>
  443. <!--查询流程节点-->
  444. <select id="selectTaskName" resultType="map" parameterType="map">
  445. select distinct current_task_name 任务节点,task_type 任务类型 from sc_plan_manage
  446. where INSTR(current_users,#{currentUsers,jdbcType=VARCHAR})
  447. <if test="taskType != null">
  448. and task_type = #{taskType,jdbcType=INTEGER}
  449. </if>
  450. order by task_type
  451. </select>
  452. <!--删除-->
  453. <delete id="batchDelete">
  454. delete from sc_plan_manage
  455. where plan_status = 0
  456. and id in
  457. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  458. #{item}
  459. </foreach>
  460. </delete>
  461. <select id="selectPlanDetail" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  462. select t1.*,t2.flow_detail
  463. from sc_plan_manage t1
  464. left join sc_work_flow_detail t2 on t1.id=t2.flow_id and t2.flow_type=1
  465. where t1.id = #{id,jdbcType=INTEGER}
  466. </select>
  467. </mapper>