ProjectContentDataDao.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.projectcontentinfo.dao.ProjectContentDataDao">
  4. <sql id="projectContentDataColumns">
  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.company_id AS "companyId",
  13. a.office_id AS "officeId",
  14. a.project_id AS "project.id",
  15. a.name AS "name",
  16. a.number AS "number",
  17. a.type AS "type",
  18. a.master AS "master.id",
  19. a.content_details_id AS "contentDetailsId",
  20. su.name AS "master.name"
  21. </sql>
  22. <sql id="projectContentDataJoins">
  23. LEFT JOIN sys_user su ON su.id = a.master
  24. </sql>
  25. <select id="get" resultType="ProjectContentData" >
  26. SELECT
  27. <include refid="projectContentDataColumns"/>
  28. FROM project_content_data a
  29. <include refid="projectContentDataJoins"/>
  30. WHERE a.id = #{id}
  31. </select>
  32. <select id="findList" resultType="ProjectContentData" >
  33. SELECT
  34. <include refid="projectContentDataColumns"/>
  35. FROM project_content_data a
  36. <include refid="projectContentDataJoins"/>
  37. <where>
  38. <if test="name !=null and name != ''">
  39. AND a.name LIKE concat('%',#{name},'%')
  40. </if>
  41. <if test="number !=null and number != ''">
  42. AND a.number = #{number}
  43. </if>
  44. <if test="master !=null and master.name != null and master.name !=''">
  45. AND su.name LIKE concat('%',#{master.name},'%')
  46. </if>
  47. <if test="project!=null and project.id!=null and project.id!=''">
  48. AND a.project_id = #{project.id}
  49. </if>
  50. <if test="type!=null and type!=''">
  51. AND a.type = #{type}
  52. </if>
  53. <if test="parentType != null">
  54. AND a.type LIKE concat(#{parentType},'%')
  55. </if>
  56. <if test="startDate != null">
  57. AND a.create_date >= #{startDate}
  58. </if>
  59. <if test="endDate != null">
  60. AND a.create_date &lt;= #{endDate}
  61. </if>
  62. <if test="extId !=null and extId!=''">
  63. AND a.id != #{extId}
  64. </if>
  65. AND a.del_flag = #{DEL_FLAG_NORMAL}
  66. </where>
  67. <choose>
  68. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  69. ORDER BY ${page.orderBy}
  70. </when>
  71. <otherwise>
  72. ORDER BY a.update_date DESC
  73. </otherwise>
  74. </choose>
  75. </select>
  76. <select id="findReportContent" resultType="ProjectContentData" >
  77. SELECT
  78. <include refid="projectContentDataColumns"/>
  79. FROM project_content_data a
  80. <include refid="projectContentDataJoins"/>
  81. JOIN project_report_content rc ON rc.content_id = a.id
  82. WHERE rc.report_id = #{reportId}
  83. AND rc.type = #{type}
  84. AND a.del_flag = '0'
  85. ORDER BY a.update_date DESC
  86. </select>
  87. <select id="findAllList" resultType="ProjectContentData" >
  88. SELECT
  89. <include refid="projectContentDataColumns"/>
  90. FROM project_content_data a
  91. <include refid="projectContentDataJoins"/>
  92. <where>
  93. a.del_flag = #{DEL_FLAG_NORMAL}
  94. </where>
  95. <choose>
  96. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  97. ORDER BY ${page.orderBy}
  98. </when>
  99. <otherwise>
  100. ORDER BY a.update_date DESC
  101. </otherwise>
  102. </choose>
  103. </select>
  104. <select id="getNumber" resultType="ProjectContentData" >
  105. SELECT
  106. <include refid="projectContentDataColumns"/>
  107. FROM project_content_data a
  108. WHERE
  109. a.del_flag = #{DEL_FLAG_NORMAL}
  110. AND a.project_id = #{project.id}
  111. ORDER BY a.number DESC
  112. limit 1
  113. </select>
  114. <insert id="insert">
  115. INSERT INTO project_content_data(
  116. id,
  117. create_by,
  118. create_date,
  119. update_by,
  120. update_date,
  121. remarks,
  122. del_flag,
  123. company_id,
  124. office_id,
  125. project_id,
  126. name,
  127. number,
  128. type,
  129. master,
  130. content_details_id
  131. ) VALUES (
  132. #{id},
  133. #{createBy.id},
  134. #{createDate},
  135. #{updateBy.id},
  136. #{updateDate},
  137. #{remarks},
  138. #{delFlag},
  139. #{companyId},
  140. #{officeId},
  141. #{project.id},
  142. #{name},
  143. #{number},
  144. #{type},
  145. #{master.id},
  146. #{contentDetailsId}
  147. )
  148. </insert>
  149. <insert id="saveReportContent">
  150. INSERT INTO project_report_content(
  151. report_id,
  152. content_id,
  153. type
  154. ) VALUES (
  155. #{reportId},
  156. #{contentId},
  157. #{type}
  158. )
  159. </insert>
  160. <update id="update">
  161. UPDATE project_content_data SET
  162. update_by = #{updateBy.id},
  163. update_date = #{updateDate},
  164. remarks = #{remarks},
  165. company_id = #{companyId},
  166. office_id = #{officeId},
  167. project_id = #{project.id},
  168. name = #{name},
  169. number = #{number},
  170. type = #{type},
  171. master = #{master.id},
  172. content_details_id = #{contentDetailsId}
  173. WHERE id = #{id}
  174. </update>
  175. <!--物理删除-->
  176. <update id="delete">
  177. UPDATE project_content_data SET
  178. del_flag = #{DEL_FLAG_DELETE}
  179. WHERE id = #{id}
  180. </update>
  181. <!--逻辑删除-->
  182. <update id="deleteByLogic">
  183. UPDATE project_content_data SET
  184. del_flag = #{DEL_FLAG_DELETE}
  185. WHERE id = #{id}
  186. </update>
  187. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  188. <select id="findUniqueByProperty" resultType="ProjectContentData" statementType="STATEMENT">
  189. select * FROM project_content_data where ${propertyName} = '${value}'
  190. </select>
  191. <select id="querySerialNum" resultType="int">
  192. SELECT MAX(cast(`number` as UNSIGNED INTEGER))
  193. from project_content_data pd LEFT JOIN work_content_type wt ON wt.type_id = pd.type
  194. WHERE pd.project_id = #{project.id} AND wt.parent_id = (SELECT parent_id from work_content_type where type_id = #{type})
  195. </select>
  196. <update id="deleteBasedByContentId">
  197. DELETE FROM project_content_based WHERE content_id = #{contentId}
  198. </update>
  199. <update id="deleteBasedData">
  200. DELETE FROM project_content_based WHERE content_id = #{contentId} and based_id = #{basedId}
  201. </update>
  202. <update id="deleteReportDataInfo">
  203. DELETE FROM project_report_content WHERE content_id = #{contentId} and report_id = #{reportId} AND type = #{type}
  204. </update>
  205. <update id="deleteReportDataMenu">
  206. DELETE FROM project_content_change WHERE info_id = #{reportId} and project_id = #{projectId} and link_id = #{linkId}
  207. </update>
  208. <insert id="batchInsertBaseData" parameterType="java.util.Map">
  209. INSERT INTO project_content_based
  210. (content_id ,based_id)
  211. VALUES
  212. <foreach collection="projectBasedDataList" item="projectBasedData" separator=",">
  213. ( #{contentId}, #{projectBasedData.id})
  214. </foreach>
  215. </insert>
  216. <select id="countByBaseId" resultType="int">
  217. SELECT count(*) FROM project_content_based WHERE based_id = #{basedId}
  218. </select>
  219. <select id="findByLinkId" resultType="java.lang.String">
  220. SELECT id FROM project_content_info WHERE info_id = #{contentId} and project_id = #{projectId}
  221. </select>
  222. </mapper>