ProjectContentDataDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. a.contract_id AS "contractId",
  21. su.name AS "master.name"
  22. </sql>
  23. <sql id="projectContentDataJoins">
  24. LEFT JOIN sys_user su ON su.id = a.master
  25. </sql>
  26. <select id="get" resultType="ProjectContentData" >
  27. SELECT
  28. <include refid="projectContentDataColumns"/>
  29. FROM project_content_data a
  30. <include refid="projectContentDataJoins"/>
  31. WHERE a.id = #{id}
  32. </select>
  33. <select id="findList" resultType="ProjectContentData" >
  34. SELECT
  35. <include refid="projectContentDataColumns"/>
  36. FROM project_content_data a
  37. <include refid="projectContentDataJoins"/>
  38. <where>
  39. <if test="name !=null and name != ''">
  40. AND a.name LIKE concat('%',#{name},'%')
  41. </if>
  42. <if test="number !=null and number != ''">
  43. AND a.number = #{number}
  44. </if>
  45. <if test="master !=null and master.name != null and master.name !=''">
  46. AND su.name LIKE concat('%',#{master.name},'%')
  47. </if>
  48. <if test="project!=null and project.id!=null and project.id!=''">
  49. AND a.project_id = #{project.id}
  50. </if>
  51. <if test="type!=null and type!=''">
  52. AND a.type = #{type}
  53. </if>
  54. <if test="parentType != null">
  55. AND a.type LIKE concat(#{parentType},'%')
  56. </if>
  57. <if test="startDate != null">
  58. AND a.create_date >= #{startDate}
  59. </if>
  60. <if test="endDate != null">
  61. AND a.create_date &lt;= #{endDate}
  62. </if>
  63. <if test="extId !=null and extId!=''">
  64. AND a.id != #{extId}
  65. </if>
  66. AND a.del_flag = #{DEL_FLAG_NORMAL}
  67. </where>
  68. <choose>
  69. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  70. ORDER BY ${page.orderBy}
  71. </when>
  72. <otherwise>
  73. ORDER BY a.update_date DESC
  74. </otherwise>
  75. </choose>
  76. </select>
  77. <select id="findListOnRural" resultType="RuralProjectContentData" >
  78. SELECT
  79. <include refid="projectContentDataColumns"/>
  80. FROM project_content_data a
  81. <include refid="projectContentDataJoins"/>
  82. <where>
  83. <if test="name !=null and name != ''">
  84. AND a.name LIKE concat('%',#{name},'%')
  85. </if>
  86. <if test="number !=null and number != ''">
  87. AND a.number = #{number}
  88. </if>
  89. <if test="master !=null and master.name != null and master.name !=''">
  90. AND su.name LIKE concat('%',#{master.name},'%')
  91. </if>
  92. <if test="project!=null and project.id!=null and project.id!=''">
  93. AND a.project_id = #{project.id}
  94. </if>
  95. <if test="type!=null and type!=''">
  96. AND a.type = #{type}
  97. </if>
  98. <if test="parentType != null">
  99. AND a.type LIKE concat(#{parentType},'%')
  100. </if>
  101. <if test="startDate != null">
  102. AND a.create_date >= #{startDate}
  103. </if>
  104. <if test="endDate != null">
  105. AND a.create_date &lt;= #{endDate}
  106. </if>
  107. <if test="extId !=null and extId!=''">
  108. AND a.id != #{extId}
  109. </if>
  110. AND a.del_flag = #{DEL_FLAG_NORMAL}
  111. </where>
  112. <choose>
  113. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  114. ORDER BY ${page.orderBy}
  115. </when>
  116. <otherwise>
  117. ORDER BY a.update_date DESC
  118. </otherwise>
  119. </choose>
  120. </select>
  121. <select id="findReportContent" resultType="ProjectContentData" >
  122. SELECT
  123. <include refid="projectContentDataColumns"/>
  124. FROM project_content_data a
  125. <include refid="projectContentDataJoins"/>
  126. JOIN project_report_content rc ON rc.content_id = a.id
  127. WHERE rc.report_id = #{reportId}
  128. AND rc.type = #{type}
  129. AND a.del_flag = '0'
  130. ORDER BY a.update_date DESC
  131. </select>
  132. <select id="findAllList" resultType="ProjectContentData" >
  133. SELECT
  134. <include refid="projectContentDataColumns"/>
  135. FROM project_content_data a
  136. <include refid="projectContentDataJoins"/>
  137. <where>
  138. a.del_flag = #{DEL_FLAG_NORMAL}
  139. </where>
  140. <choose>
  141. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  142. ORDER BY ${page.orderBy}
  143. </when>
  144. <otherwise>
  145. ORDER BY a.update_date DESC
  146. </otherwise>
  147. </choose>
  148. </select>
  149. <select id="getNumber" resultType="ProjectContentData" >
  150. SELECT
  151. <include refid="projectContentDataColumns"/>
  152. FROM project_content_data a
  153. WHERE
  154. a.del_flag = #{DEL_FLAG_NORMAL}
  155. AND a.project_id = #{project.id}
  156. ORDER BY a.number DESC
  157. limit 1
  158. </select>
  159. <insert id="insert">
  160. INSERT INTO project_content_data(
  161. id,
  162. create_by,
  163. create_date,
  164. update_by,
  165. update_date,
  166. remarks,
  167. del_flag,
  168. company_id,
  169. office_id,
  170. project_id,
  171. name,
  172. number,
  173. type,
  174. master,
  175. content_details_id,
  176. contract_id
  177. ) VALUES (
  178. #{id},
  179. #{createBy.id},
  180. #{createDate},
  181. #{updateBy.id},
  182. #{updateDate},
  183. #{remarks},
  184. #{delFlag},
  185. #{companyId},
  186. #{officeId},
  187. #{project.id},
  188. #{name},
  189. #{number},
  190. #{type},
  191. #{master.id},
  192. #{contentDetailsId},
  193. #{contractId}
  194. )
  195. </insert>
  196. <insert id="saveReportContent">
  197. INSERT INTO project_report_content(
  198. report_id,
  199. content_id,
  200. type
  201. ) VALUES (
  202. #{reportId},
  203. #{contentId},
  204. #{type}
  205. )
  206. </insert>
  207. <update id="update">
  208. UPDATE project_content_data SET
  209. update_by = #{updateBy.id},
  210. update_date = #{updateDate},
  211. remarks = #{remarks},
  212. company_id = #{companyId},
  213. office_id = #{officeId},
  214. project_id = #{project.id},
  215. name = #{name},
  216. number = #{number},
  217. type = #{type},
  218. master = #{master.id},
  219. content_details_id = #{contentDetailsId}
  220. WHERE id = #{id}
  221. </update>
  222. <!--物理删除-->
  223. <update id="delete">
  224. UPDATE project_content_data SET
  225. del_flag = #{DEL_FLAG_DELETE}
  226. WHERE id = #{id}
  227. </update>
  228. <!--逻辑删除-->
  229. <update id="deleteByLogic">
  230. UPDATE project_content_data SET
  231. del_flag = #{DEL_FLAG_DELETE}
  232. WHERE id = #{id}
  233. </update>
  234. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  235. <select id="findUniqueByProperty" resultType="ProjectContentData" statementType="STATEMENT">
  236. select * FROM project_content_data where ${propertyName} = '${value}'
  237. </select>
  238. <select id="querySerialNum" resultType="int">
  239. SELECT MAX(cast(`number` as UNSIGNED INTEGER))
  240. from project_content_data pd LEFT JOIN work_content_type wt ON wt.type_id = pd.type
  241. WHERE pd.project_id = #{project.id} AND wt.parent_id = (SELECT parent_id from work_content_type where type_id = #{type})
  242. </select>
  243. <update id="deleteBasedByContentId">
  244. DELETE FROM project_content_based WHERE content_id = #{contentId}
  245. </update>
  246. <update id="deleteBasedData">
  247. DELETE FROM project_content_based WHERE content_id = #{contentId} and based_id = #{basedId}
  248. </update>
  249. <update id="deleteReportDataInfo">
  250. DELETE FROM project_report_content WHERE content_id = #{contentId} and report_id = #{reportId} AND type = #{type}
  251. </update>
  252. <update id="deleteReportDataMenu">
  253. DELETE FROM project_content_change WHERE info_id = #{reportId} and project_id = #{projectId} and link_id = #{linkId}
  254. </update>
  255. <insert id="batchInsertBaseData" parameterType="java.util.Map">
  256. INSERT INTO project_content_based
  257. (content_id ,based_id)
  258. VALUES
  259. <foreach collection="projectBasedDataList" item="projectBasedData" separator=",">
  260. ( #{contentId}, #{projectBasedData.id})
  261. </foreach>
  262. </insert>
  263. <select id="countByBaseId" resultType="int">
  264. SELECT count(*) FROM project_content_based WHERE based_id = #{basedId}
  265. </select>
  266. <select id="findByLinkId" resultType="java.lang.String">
  267. SELECT id FROM project_content_info WHERE info_id = #{contentId} and project_id = #{projectId}
  268. </select>
  269. <select id="getProjectContentDataList" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  270. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate",
  271. a.project_id as "pid", a.name as "projectName", "" as projectId,
  272. "0" as projectStatus,su.name as "projectRegistrant" ,
  273. pt.type_name as projectLeader,
  274. ppt.type_name as clientName,prd.status as status
  275. from project_content_data a
  276. left join sys_user su on su.id = a.create_by
  277. left join project_type pt on a.type = pt.type_id
  278. left join project_type ppt on pt.parent_id = ppt.id
  279. left join project_content_report pcr on pcr.content_id = a.id
  280. left join project_report_data prd on prd.id = pcr.report_id
  281. where a.project_id = #{projectId} and pt.parent_id =#{projectTypeParentId} and a.del_flag = 0 order by a.update_date desc
  282. </select>
  283. <select id="getProjectContentDataListOnImplement" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  284. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate",
  285. a.project_id as "pid", a.name as "projectName", "" as projectId,
  286. "0" as projectStatus,su.name as "projectRegistrant" ,
  287. pt.type_name as projectLeader,
  288. ppt.type_name as clientName,prd.status as status
  289. from project_content_data a
  290. left join sys_user su on su.id = a.create_by
  291. left join project_type pt on a.type = pt.type_id
  292. left join project_type ppt on pt.parent_id = ppt.id
  293. left join project_content_report pcr on pcr.content_id = a.id
  294. left join project_report_data prd on prd.id = pcr.report_id
  295. where a.project_id = #{projectId} and pt.parent_id =#{projectTypeParentId}
  296. and pt.type_id = #{typeId}
  297. <if test="contractId !=null and contractId!=''">
  298. and a.contract_id = #{contractId}
  299. </if>
  300. and a.del_flag = 0 order by a.update_date desc
  301. </select>
  302. <select id="getProjectContentReportDataList" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  303. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate", a.project_id as "pid",
  304. a.name as "projectName", "" as projectId, "0" as projectStatus,su.name as "projectRegistrant" ,
  305. pt.type_name as projectLeader, ppt.type_name as clientName,ifnull(prd.status,'10') as status,prd.id as reportId,ifnull(prd.name,'') as reportName
  306. from project_content_data a
  307. left join sys_user su on su.id = a.create_by
  308. left join project_type pt on a.type = pt.type_id
  309. left join project_type ppt on pt.parent_id = ppt.id
  310. left join project_content_report pcr on pcr.content_id = a.id
  311. left join project_report_data prd on prd.id = pcr.report_id
  312. where a.project_id = #{projectId} and pt.parent_id =#{projectTypeParentId} and a.del_flag = 0 order by prd.status, a.update_date desc, prd.update_date desc
  313. </select>
  314. <select id="getProjectContentReportDataListOnImplement" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  315. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate", a.project_id as "pid",
  316. a.name as "projectName", "" as projectId, "0" as projectStatus,su.name as "projectRegistrant" ,
  317. pt.type_name as projectLeader, ppt.type_name as clientName,ifnull(prd.status,'10') as status,prd.id as reportId,ifnull(prd.name,'') as reportName
  318. from project_content_data a
  319. left join sys_user su on su.id = a.create_by
  320. left join project_type pt on a.type = pt.type_id
  321. left join project_type ppt on pt.parent_id = ppt.id
  322. left join project_content_report pcr on pcr.content_id = a.id
  323. left join project_report_data prd on prd.id = pcr.report_id
  324. where a.project_id = #{projectId} and pt.parent_id =#{projectTypeParentId}
  325. and pt.type_id = #{typeId}
  326. and a.del_flag = 0 order by prd.status, a.update_date desc, prd.update_date desc
  327. </select>
  328. <select id="getProjectContentReportArchiveDataList" resultType="com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData">
  329. select a.id as "id", a.create_by as "createBy.id", a.create_date as "createDate", a.project_id as "pid",
  330. a.name as "projectName", "" as projectId, "0" as projectStatus,su.name as "projectRegistrant" ,
  331. pt.type_name as projectLeader, ppt.type_name as clientName,ifnull(prr.status,'10') as status,
  332. prd.id as reportId,ifnull(prr.id,'') as recordId,ifnull(prd.name,'') as reportName,
  333. ifnull(prr.record_num,'') as reportRecordName
  334. from project_content_data a
  335. left join sys_user su on su.id = a.create_by
  336. left join project_type pt on a.type = pt.type_id
  337. left join project_type ppt on pt.parent_id = ppt.id
  338. left join project_content_report pcr on pcr.content_id = a.id
  339. left join project_report_data prd on prd.id = pcr.report_id
  340. left join project_report_record prr on prd.id = prr.report_id
  341. where a.project_id = #{projectId} and pt.parent_id =#{projectTypeParentId}
  342. and a.del_flag = 0 and prd.status = 5 order by prr.update_date desc, a.update_date desc
  343. </select>
  344. <select id="getProjectContentData" resultType="ProjectContentData">
  345. select a.id,a.number,a.name,a.create_date as createDate,a.type ,su.name as masterName
  346. from project_content_data a
  347. left join sys_user su on su.id = a.master
  348. where a.id = #{id} and a.del_flag=0
  349. </select>
  350. <delete id="deleteProjectContentBased">
  351. delete from project_content_based
  352. where based_id = #{basedId}
  353. and content_id = #{contentId}
  354. </delete>
  355. </mapper>