ProjectContentDataDao.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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="findListOnRural" resultType="RuralProjectContentData" >
  77. SELECT
  78. <include refid="projectContentDataColumns"/>
  79. FROM project_content_data a
  80. <include refid="projectContentDataJoins"/>
  81. <where>
  82. <if test="name !=null and name != ''">
  83. AND a.name LIKE concat('%',#{name},'%')
  84. </if>
  85. <if test="number !=null and number != ''">
  86. AND a.number = #{number}
  87. </if>
  88. <if test="master !=null and master.name != null and master.name !=''">
  89. AND su.name LIKE concat('%',#{master.name},'%')
  90. </if>
  91. <if test="project!=null and project.id!=null and project.id!=''">
  92. AND a.project_id = #{project.id}
  93. </if>
  94. <if test="type!=null and type!=''">
  95. AND a.type = #{type}
  96. </if>
  97. <if test="parentType != null">
  98. AND a.type LIKE concat(#{parentType},'%')
  99. </if>
  100. <if test="startDate != null">
  101. AND a.create_date >= #{startDate}
  102. </if>
  103. <if test="endDate != null">
  104. AND a.create_date &lt;= #{endDate}
  105. </if>
  106. <if test="extId !=null and extId!=''">
  107. AND a.id != #{extId}
  108. </if>
  109. AND a.del_flag = #{DEL_FLAG_NORMAL}
  110. </where>
  111. <choose>
  112. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  113. ORDER BY ${page.orderBy}
  114. </when>
  115. <otherwise>
  116. ORDER BY a.update_date DESC
  117. </otherwise>
  118. </choose>
  119. </select>
  120. <select id="findReportContent" resultType="ProjectContentData" >
  121. SELECT
  122. <include refid="projectContentDataColumns"/>
  123. FROM project_content_data a
  124. <include refid="projectContentDataJoins"/>
  125. JOIN project_report_content rc ON rc.content_id = a.id
  126. WHERE rc.report_id = #{reportId}
  127. AND rc.type = #{type}
  128. AND a.del_flag = '0'
  129. ORDER BY a.update_date DESC
  130. </select>
  131. <select id="findAllList" resultType="ProjectContentData" >
  132. SELECT
  133. <include refid="projectContentDataColumns"/>
  134. FROM project_content_data a
  135. <include refid="projectContentDataJoins"/>
  136. <where>
  137. a.del_flag = #{DEL_FLAG_NORMAL}
  138. </where>
  139. <choose>
  140. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  141. ORDER BY ${page.orderBy}
  142. </when>
  143. <otherwise>
  144. ORDER BY a.update_date DESC
  145. </otherwise>
  146. </choose>
  147. </select>
  148. <select id="getNumber" resultType="ProjectContentData" >
  149. SELECT
  150. <include refid="projectContentDataColumns"/>
  151. FROM project_content_data a
  152. WHERE
  153. a.del_flag = #{DEL_FLAG_NORMAL}
  154. AND a.project_id = #{project.id}
  155. ORDER BY a.number DESC
  156. limit 1
  157. </select>
  158. <insert id="insert">
  159. INSERT INTO project_content_data(
  160. id,
  161. create_by,
  162. create_date,
  163. update_by,
  164. update_date,
  165. remarks,
  166. del_flag,
  167. company_id,
  168. office_id,
  169. project_id,
  170. name,
  171. number,
  172. type,
  173. master,
  174. content_details_id
  175. ) VALUES (
  176. #{id},
  177. #{createBy.id},
  178. #{createDate},
  179. #{updateBy.id},
  180. #{updateDate},
  181. #{remarks},
  182. #{delFlag},
  183. #{companyId},
  184. #{officeId},
  185. #{project.id},
  186. #{name},
  187. #{number},
  188. #{type},
  189. #{master.id},
  190. #{contentDetailsId}
  191. )
  192. </insert>
  193. <insert id="saveReportContent">
  194. INSERT INTO project_report_content(
  195. report_id,
  196. content_id,
  197. type
  198. ) VALUES (
  199. #{reportId},
  200. #{contentId},
  201. #{type}
  202. )
  203. </insert>
  204. <update id="update">
  205. UPDATE project_content_data SET
  206. update_by = #{updateBy.id},
  207. update_date = #{updateDate},
  208. remarks = #{remarks},
  209. company_id = #{companyId},
  210. office_id = #{officeId},
  211. project_id = #{project.id},
  212. name = #{name},
  213. number = #{number},
  214. type = #{type},
  215. master = #{master.id},
  216. content_details_id = #{contentDetailsId}
  217. WHERE id = #{id}
  218. </update>
  219. <!--物理删除-->
  220. <update id="delete">
  221. UPDATE project_content_data SET
  222. del_flag = #{DEL_FLAG_DELETE}
  223. WHERE id = #{id}
  224. </update>
  225. <!--逻辑删除-->
  226. <update id="deleteByLogic">
  227. UPDATE project_content_data SET
  228. del_flag = #{DEL_FLAG_DELETE}
  229. WHERE id = #{id}
  230. </update>
  231. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  232. <select id="findUniqueByProperty" resultType="ProjectContentData" statementType="STATEMENT">
  233. select * FROM project_content_data where ${propertyName} = '${value}'
  234. </select>
  235. <select id="querySerialNum" resultType="int">
  236. SELECT MAX(cast(`number` as UNSIGNED INTEGER))
  237. from project_content_data pd LEFT JOIN work_content_type wt ON wt.type_id = pd.type
  238. WHERE pd.project_id = #{project.id} AND wt.parent_id = (SELECT parent_id from work_content_type where type_id = #{type})
  239. </select>
  240. <update id="deleteBasedByContentId">
  241. DELETE FROM project_content_based WHERE content_id = #{contentId}
  242. </update>
  243. <update id="deleteBasedData">
  244. DELETE FROM project_content_based WHERE content_id = #{contentId} and based_id = #{basedId}
  245. </update>
  246. <update id="deleteReportDataInfo">
  247. DELETE FROM project_report_content WHERE content_id = #{contentId} and report_id = #{reportId} AND type = #{type}
  248. </update>
  249. <update id="deleteReportDataMenu">
  250. DELETE FROM project_content_change WHERE info_id = #{reportId} and project_id = #{projectId} and link_id = #{linkId}
  251. </update>
  252. <insert id="batchInsertBaseData" parameterType="java.util.Map">
  253. INSERT INTO project_content_based
  254. (content_id ,based_id)
  255. VALUES
  256. <foreach collection="projectBasedDataList" item="projectBasedData" separator=",">
  257. ( #{contentId}, #{projectBasedData.id})
  258. </foreach>
  259. </insert>
  260. <select id="countByBaseId" resultType="int">
  261. SELECT count(*) FROM project_content_based WHERE based_id = #{basedId}
  262. </select>
  263. <select id="findByLinkId" resultType="java.lang.String">
  264. SELECT id FROM project_content_info WHERE info_id = #{contentId} and project_id = #{projectId}
  265. </select>
  266. <select id="getProjectContentDataList" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  267. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate",
  268. a.project_id as "pid", a.name as "projectName", "" as projectId,
  269. "0" as projectStatus,su.name as "projectRegistrant" ,
  270. pt.type_name as projectLeader,
  271. ppt.type_name as clientName
  272. from project_content_data a
  273. left join sys_user su on su.id = a.create_by
  274. left join project_type pt on a.type = pt.id
  275. left join project_type ppt on pt.parent_id = ppt.id
  276. left join project_type ptd on a.type = ptd.type_id
  277. where a.project_id = #{projectId} and ptd.parent_id =#{projectTypeParentId} and a.del_flag = 0 order by a.update_date desc
  278. </select>
  279. </mapper>