CaseInfoDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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.jeeplus.modules.caseinfo.dao.CaseInfoDao">
  4. <sql id="caseInfoColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. a.create_date AS "createDate",
  8. a.update_by AS "updateBy.id",
  9. a.update_date AS "updateDate",
  10. a.remarks AS "remarks",
  11. a.del_flag AS "delFlag",
  12. a.class_id AS "caseCategory.id",
  13. a.name AS "name",
  14. a.source AS "source",
  15. a.companyName AS "companyName",
  16. a.start_date AS "startDate",
  17. a.end_date AS "endDate",
  18. a.area_id AS "area.id",
  19. area.name AS "area.name",
  20. a.price AS "price",
  21. project.project_name AS "project.projectName",
  22. a.project_id AS "project.id",
  23. a.feature AS "feature",
  24. a.record AS "record",
  25. a.ext AS "ext",
  26. a.contractName AS "contractName",
  27. a.peculiarity AS "peculiarity",
  28. a.unit AS "unit",
  29. a.status AS "status",
  30. a.userids AS "userids",
  31. a.share_status AS "shareStatus",
  32. a.company_id AS "companyId",
  33. a.process_instance_id AS "processInstanceId",
  34. a.office_id AS "officeId",
  35. u.name AS "createBy.name",
  36. u2.name AS "updateBy.name",
  37. o.name AS "officeName",
  38. c.name AS "caseCategory.name"
  39. </sql>
  40. <sql id="caseInfoJoins">
  41. LEFT JOIN case_category c ON c.id = a.class_id
  42. left join sys_user u on a.create_by = u.id
  43. left join sys_user u2 on a.update_by = u2.id
  44. LEFT JOIN sys_area area ON area.id = a.area_id
  45. LEFT JOIN project_records project ON project.id = a.project_id
  46. JOIN sys_office o ON o.id = a.office_id
  47. JOIN sys_office s ON s.id = a.company_id
  48. </sql>
  49. <select id="get" resultType="CaseInfo" >
  50. SELECT
  51. <include refid="caseInfoColumns"/>
  52. FROM case_info a
  53. <include refid="caseInfoJoins"/>
  54. WHERE a.id = #{id}
  55. </select>
  56. <select id="findListme" resultType="CaseInfo" >
  57. SELECT
  58. <include refid="caseInfoColumns"/>
  59. FROM case_info a
  60. <include refid="caseInfoJoins"/>
  61. <where>
  62. a.del_flag = #{DEL_FLAG_NORMAL}
  63. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  64. AND a.class_id = #{caseCategory.id}
  65. </if>
  66. <if test="name != null and name != ''">
  67. AND a.name LIKE
  68. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  69. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  70. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  71. </if>
  72. <if test="area != null and area.id != null and area.id != ''">
  73. AND a.area_id = #{area.id}
  74. </if>
  75. <if test="createBy != null and createBy.id != null and createBy.id != ''">
  76. AND a.create_by = #{createBy.id}
  77. </if>
  78. <if test="id != null and id != ''">
  79. AND a.id = #{id}
  80. </if>
  81. </where>
  82. <choose>
  83. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  84. ORDER BY ${page.orderBy}
  85. </when>
  86. <otherwise>
  87. ORDER BY a.update_date DESC
  88. </otherwise>
  89. </choose>
  90. </select>
  91. <select id="findListoffice" resultType="CaseInfo" >
  92. SELECT
  93. <include refid="caseInfoColumns"/>
  94. FROM case_info a
  95. <include refid="caseInfoJoins"/>
  96. <where>
  97. a.del_flag = #{DEL_FLAG_NORMAL} and a.status in('2','5')
  98. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  99. AND a.class_id = #{caseCategory.id}
  100. </if>
  101. <if test="name != null and name != ''">
  102. AND a.name LIKE
  103. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  104. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  105. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  106. </if>
  107. <if test="area != null and area.id != null and area.id != ''">
  108. AND a.area_id = #{area.id}
  109. </if>
  110. <if test="officeId != null and officeId != ''">
  111. AND a.office_id = #{officeId}
  112. </if>
  113. </where>
  114. <choose>
  115. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  116. ORDER BY ${page.orderBy}
  117. </when>
  118. <otherwise>
  119. ORDER BY a.update_date DESC
  120. </otherwise>
  121. </choose>
  122. </select>
  123. <select id="findListoffice2" resultType="CaseInfo" >
  124. SELECT
  125. <include refid="caseInfoColumns"/>
  126. FROM case_info a
  127. <include refid="caseInfoJoins"/>
  128. <where>
  129. a.del_flag = #{DEL_FLAG_NORMAL} and a.status =5
  130. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  131. AND a.class_id = #{caseCategory.id}
  132. </if>
  133. <if test="name != null and name != ''">
  134. AND a.name LIKE
  135. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  136. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  137. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  138. </if>
  139. <if test="area != null and area.id != null and area.id != ''">
  140. AND a.area_id = #{area.id}
  141. </if>
  142. <if test="officeId != null and officeId != ''">
  143. AND a.office_id = #{officeId}
  144. </if>
  145. </where>
  146. <choose>
  147. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  148. ORDER BY ${page.orderBy}
  149. </when>
  150. <otherwise>
  151. ORDER BY a.update_date DESC
  152. </otherwise>
  153. </choose>
  154. </select>
  155. <!--<select id="findList" resultType="CaseInfo" >
  156. SELECT
  157. <include refid="caseInfoColumns"/>
  158. FROM case_info a
  159. <include refid="caseInfoJoins"/>
  160. <where>
  161. (a.share_status = '1' and
  162. a.del_flag = #{DEL_FLAG_NORMAL}
  163. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  164. AND a.class_id = #{caseCategory.id}
  165. </if>
  166. <if test="name != null and name != ''">
  167. AND a.name LIKE
  168. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  169. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  170. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  171. </if>
  172. <if test="id != null and id != ''">
  173. AND a.id = #{id}
  174. </if>
  175. ) or
  176. (
  177. (a.del_flag = #{DEL_FLAG_NORMAL} AND a.status = '4'
  178. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  179. AND a.class_id = #{caseCategory.id}
  180. </if>
  181. <if test="name != null and name != ''">
  182. AND a.name LIKE
  183. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  184. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  185. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  186. </if>
  187. <if test="area != null and area.id != null and area.id != ''">
  188. AND a.area_id = #{area.id}
  189. </if>
  190. <if test="id != null and id != ''">
  191. AND a.id = #{id}
  192. </if>
  193. ${sqlMap.dsf})
  194. or(
  195. (a.status != '4'
  196. <if test="createBy != null and createBy.id != null and createBy.id != ''">
  197. AND a.create_by = #{createBy.id}
  198. </if>
  199. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  200. AND a.class_id = #{caseCategory.id}
  201. </if>
  202. <if test="name != null and name != ''">
  203. AND a.name LIKE
  204. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  205. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  206. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  207. </if>
  208. <if test="area != null and area.id != null and area.id != ''">
  209. AND a.area_id = #{area.id}
  210. </if>
  211. <if test="id != null and id != ''">
  212. AND a.id = #{id}
  213. </if>
  214. ) or (a.status in('2','3','4')
  215. <if test="createBy != null and createBy.id != null and createBy.id != ''">
  216. and find_in_set(#{createBy.id},a.userids)
  217. </if>
  218. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  219. AND a.class_id = #{caseCategory.id}
  220. </if>
  221. <if test="name != null and name != ''">
  222. AND a.name LIKE
  223. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  224. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  225. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  226. </if>
  227. <if test="area != null and area.id != null and area.id != ''">
  228. AND a.area_id = #{area.id}
  229. </if>
  230. <if test="id != null and id != ''">
  231. AND a.id = #{id}
  232. </if>
  233. )
  234. )
  235. )
  236. </where>
  237. <choose>
  238. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  239. ORDER BY ${page.orderBy}
  240. </when>
  241. <otherwise>
  242. ORDER BY a.update_date DESC
  243. </otherwise>
  244. </choose>
  245. </select>-->
  246. <select id="findByAllList" resultType="CaseInfo" >
  247. SELECT
  248. <include refid="caseInfoColumns"/>
  249. FROM case_info a
  250. <include refid="caseInfoJoins"/>
  251. <where>
  252. a.status = '5'
  253. AND
  254. a.del_flag = #{DEL_FLAG_NORMAL}
  255. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  256. AND a.class_id = #{caseCategory.id}
  257. </if>
  258. <if test="shareStatus != null and shareStatus != ''">
  259. AND a.share_status = #{shareStatus}
  260. </if>
  261. <if test="name != null and name != ''">
  262. AND a.name LIKE
  263. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  264. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  265. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  266. </if>
  267. <if test="area != null and area.id != null and area.id != ''">
  268. AND a.area_id = #{area.id}
  269. </if>
  270. </where>
  271. <choose>
  272. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  273. ORDER BY ${page.orderBy}
  274. </when>
  275. <otherwise>
  276. ORDER BY a.update_date DESC
  277. </otherwise>
  278. </choose>
  279. </select>
  280. <select id="findByAllLists" resultType="CaseInfo" >
  281. SELECT
  282. <include refid="caseInfoColumns"/>
  283. FROM case_info a
  284. <include refid="caseInfoJoins"/>
  285. <where>
  286. a.status = '5' and a.share_status is not null
  287. AND
  288. a.del_flag = #{DEL_FLAG_NORMAL}
  289. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  290. AND a.class_id = #{caseCategory.id}
  291. </if>
  292. <if test="shareStatus != null and shareStatus != ''">
  293. AND a.share_status = #{shareStatus}
  294. </if>
  295. <if test="name != null and name != ''">
  296. AND a.name LIKE
  297. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  298. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  299. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  300. </if>
  301. <if test="area != null and area.id != null and area.id != ''">
  302. AND a.area_id = #{area.id}
  303. </if>
  304. </where>
  305. <choose>
  306. <when test="dateOrder == 1">
  307. order by a.start_date desc
  308. </when>
  309. <when test="dateOrder == 2">
  310. order by a.start_date asc
  311. </when>
  312. <!--<when test="page !=null and page.orderBy != null and page.orderBy != ''">
  313. ORDER BY ${page.orderBy}
  314. </when>-->
  315. <otherwise>
  316. ORDER BY a.update_date DESC
  317. </otherwise>
  318. </choose>
  319. </select>
  320. <select id="findBuyCase" resultType="CaseInfo" >
  321. SELECT
  322. DISTINCT
  323. <include refid="caseInfoColumns"/>
  324. FROM case_info a
  325. <include refid="caseInfoJoins"/>
  326. LEFT join case_member cm on cm.case_id = a.id
  327. <where>
  328. a.status = '5' and a.share_status is not null
  329. AND
  330. a.del_flag = #{DEL_FLAG_NORMAL}
  331. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  332. AND a.class_id = #{caseCategory.id}
  333. </if>
  334. <if test="memberId != null and memberId != ''">
  335. AND cm.member_id = #{memberId}
  336. </if>
  337. <if test="name != null and name != ''">
  338. AND a.name LIKE
  339. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  340. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  341. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  342. </if>
  343. <if test="area != null and area.id != null and area.id != ''">
  344. AND a.area_id = #{area.id}
  345. </if>
  346. </where>
  347. <choose>
  348. <when test="dateOrder == 1">
  349. order by a.start_date desc
  350. </when>
  351. <when test="dateOrder == 2">
  352. order by a.start_date asc
  353. </when>
  354. <!--<when test="page !=null and page.orderBy != null and page.orderBy != ''">
  355. ORDER BY ${page.orderBy}
  356. </when>-->
  357. <otherwise>
  358. ORDER BY a.update_date DESC
  359. </otherwise>
  360. </choose>
  361. </select>
  362. <select id="findCompanyList" resultType="CaseInfo" >
  363. SELECT
  364. <include refid="caseInfoColumns"/>
  365. FROM case_info a
  366. <include refid="caseInfoJoins"/>
  367. <where>
  368. a.del_flag = #{DEL_FLAG_NORMAL} AND a.status = '5'
  369. <if test="caseCategory != null and caseCategory.id != null and caseCategory.id != ''">
  370. AND a.class_id = #{caseCategory.id}
  371. </if>
  372. <if test="name != null and name != ''">
  373. AND a.name LIKE
  374. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  375. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  376. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  377. </if>
  378. <if test="createBy != null and createBy != null and createBy.name != ''">
  379. AND u.name LIKE
  380. <if test="dbName == 'oracle'">'%'||#{createBy.name}||'%'</if>
  381. <if test="dbName == 'mssql'">'%'+#{createBy.name}+'%'</if>
  382. <if test="dbName == 'mysql'">concat('%',#{createBy.name},'%')</if>
  383. </if>
  384. <if test="area != null and area.id != null and area.id != ''">
  385. AND a.area_id = #{area.id}
  386. </if>
  387. <if test="startDate != null and startDate != ''">
  388. AND a.start_date = #{startDate}
  389. </if>
  390. <if test="shareStatus != null and shareStatus != ''">
  391. AND a.share_status = #{shareStatus}
  392. </if>
  393. <if test="officeId != null and officeId != ''">
  394. AND a.office_id = #{officeId}
  395. </if>
  396. <if test="companyId != null and companyId != ''">
  397. AND a.company_id = #{companyId}
  398. </if>
  399. <if test="companyId != null and companyId != ''">
  400. AND find_in_set(a.company_id,#{companyId})
  401. </if>
  402. </where>
  403. <choose>
  404. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  405. ORDER BY ${page.orderBy}
  406. </when>
  407. <otherwise>
  408. ORDER BY a.update_date DESC
  409. </otherwise>
  410. </choose>
  411. </select>
  412. <select id="findAllList" resultType="CaseInfo" >
  413. SELECT
  414. <include refid="caseInfoColumns"/>
  415. FROM case_info a
  416. <include refid="caseInfoJoins"/>
  417. <where>
  418. a.del_flag = #{DEL_FLAG_NORMAL}
  419. </where>
  420. <choose>
  421. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  422. ORDER BY ${page.orderBy}
  423. </when>
  424. <otherwise>
  425. ORDER BY a.update_date DESC
  426. </otherwise>
  427. </choose>
  428. </select>
  429. <insert id="insert">
  430. INSERT INTO case_info(
  431. id,
  432. create_by,
  433. create_date,
  434. update_by,
  435. update_date,
  436. remarks,
  437. del_flag,
  438. class_id,
  439. name,
  440. start_date,
  441. end_date,
  442. area_id,
  443. price,
  444. project_id,
  445. feature,
  446. source,
  447. companyName,
  448. ext,
  449. contractName,
  450. peculiarity,
  451. unit,
  452. status,
  453. userids,
  454. share_status,
  455. company_id,
  456. office_id,
  457. record
  458. ) VALUES (
  459. #{id},
  460. #{createBy.id},
  461. #{createDate},
  462. #{updateBy.id},
  463. #{updateDate},
  464. #{remarks},
  465. #{delFlag},
  466. #{caseCategory.id},
  467. #{name},
  468. #{startDate},
  469. #{endDate},
  470. #{area.id},
  471. #{price},
  472. #{project.id},
  473. #{feature},
  474. #{source},
  475. #{companyName},
  476. #{ext},
  477. #{contractName},
  478. #{peculiarity},
  479. #{unit},
  480. #{status},
  481. #{userids},
  482. #{shareStatus},
  483. #{companyId},
  484. #{officeId},
  485. #{record}
  486. )
  487. </insert>
  488. <update id="update">
  489. UPDATE case_info SET
  490. update_by = #{updateBy.id},
  491. update_date = #{updateDate},
  492. remarks = #{remarks},
  493. class_id = #{caseCategory.id},
  494. name = #{name},
  495. start_date = #{startDate},
  496. end_date = #{endDate},
  497. area_id = #{area.id},
  498. price = #{price},
  499. project_id = #{project.id},
  500. feature = #{feature},
  501. source = #{source},
  502. ext = #{ext},
  503. contractName = #{contractName},
  504. peculiarity = #{peculiarity},
  505. unit = #{unit},
  506. status = #{status},
  507. userids = #{userids},
  508. share_status = #{shareStatus},
  509. company_id = #{companyId},
  510. office_id = #{officeId},
  511. record = #{record}
  512. WHERE id = #{id}
  513. </update>
  514. <!--物理删除-->
  515. <update id="delete">
  516. DELETE FROM case_info
  517. WHERE id = #{id}
  518. </update>
  519. <!--逻辑删除-->
  520. <update id="deleteByLogic">
  521. UPDATE case_info SET
  522. del_flag = #{DEL_FLAG_DELETE}
  523. WHERE id = #{id}
  524. </update>
  525. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  526. <select id="findUniqueByProperty" resultType="CaseInfo" statementType="STATEMENT">
  527. select * FROM case_info where ${propertyName} = '${value}'
  528. </select>
  529. <select id="findListByproject" resultType="WorkProject">
  530. SELECT
  531. *
  532. FROM work_project a
  533. <where>
  534. a.del_flag = #{DEL_FLAG_NORMAL}
  535. <if test="id != null and id != ''">
  536. AND a.id LIKE
  537. <if test="dbName == 'oracle'">#{id}||'%'</if>
  538. <if test="dbName == 'mssql'">#{id}+'%'</if>
  539. <if test="dbName == 'mysql'">concat(#{id},'%')</if>
  540. </if>
  541. </where>
  542. <choose>
  543. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  544. ORDER BY ${page.orderBy}
  545. </when>
  546. <otherwise>
  547. ORDER BY a.update_date DESC
  548. </otherwise>
  549. </choose>
  550. </select>
  551. <update id="updateProcessInstanceId">
  552. UPDATE case_info SET
  553. process_instance_id = #{processInstanceId}
  554. WHERE id = #{id}
  555. </update>
  556. <select id="getByProcessInstanceId" resultType="CaseInfo">
  557. SELECT
  558. <include refid="caseInfoColumns"/>
  559. FROM case_info a
  560. <include refid="caseInfoJoins"/>
  561. WHERE a.process_instance_id = #{processInstanceId}
  562. </select>
  563. </mapper>