BdglRegularMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.supervision.bdglregular.mapper.BdglRegularMapper">
  6. <resultMap type="BdglRegular" id="BdglRegularResult">
  7. <result property="id" column="id" />
  8. <result property="inspectedUnitId" column="inspected_unit_id" />
  9. <result property="inspectedUnit" column="inspected_unit" />
  10. <result property="inspectionType" column="inspection_type" />
  11. <result property="unitCheckId" column="unit_check_id" />
  12. <result property="unitCheck" column="unit_check" />
  13. <result property="inspectionTime" column="inspection_time" />
  14. <result property="inspectionSite" column="inspection_site" />
  15. <result property="score" column="score" />
  16. <result property="rectificationTime" column="rectification_time" />
  17. <result property="currentState" column="current_state" />
  18. <result property="question" column="question" />
  19. <result property="createTime" column="create_time" />
  20. <result property="createUserId" column="create_user_id" />
  21. <result property="createUser" column="create_user" />
  22. <result property="updateTime" column="update_time" />
  23. <result property="chargePeopleId" column="charge_people_id" />
  24. <result property="chargePeople" column="charge_people" />
  25. <result property="correctiveAction" column="corrective_action" />
  26. <result property="pictureProof" column="picture_proof" />
  27. <result property="documentProof" column="document_proof" />
  28. <result property="caoZuoType" column="caozuo_type" />
  29. <result property="reasonReturn" column="reason_return" />
  30. <result property="parentId" column="parent_id" />
  31. <result property="paixuValue" column="paixu_value" />
  32. <result property="wenjianname" column="wenjianname" />
  33. </resultMap>
  34. <sql id="selectBdglRegularVo">
  35. select id, inspected_unit_id, inspected_unit, inspection_type, unit_check_id, unit_check, inspection_time, inspection_site, score, rectification_time, current_state, question, create_time, create_user_id, create_user, update_time, charge_people_id, charge_people, corrective_action, picture_proof, document_proof,caozuo_type,reason_return,parent_id,paixu_value,wenjianname from bdgl_regular
  36. </sql>
  37. <select id="selectBdglRegularList" parameterType="BdglRegular" resultMap="BdglRegularResult">
  38. <include refid="selectBdglRegularVo"/>
  39. <where>
  40. <if test="inspectedUnitId != null "> and inspected_unit_id = #{inspectedUnitId}</if>
  41. <if test="inspectedUnit != null and inspectedUnit != ''">and inspected_unit = #{inspectedUnit}</if>
  42. <if test="inspectionType != null and inspectionType != ''"> and inspection_type = #{inspectionType}</if>
  43. <if test="unitCheckId != null "> and unit_check_id = #{unitCheckId}</if>
  44. <if test="unitCheck != null and unitCheck != ''"> and unit_check = #{unitCheck}</if>
  45. <if test="inspectionTime != null and inspectionTime != ''"> and inspection_time = #{inspectionTime}</if>
  46. <if test="inspectionSite != null and inspectionSite != ''"> and inspection_site = #{inspectionSite}</if>
  47. <if test="score != null "> and score = #{score}</if>
  48. <if test="rectificationTime != null and rectificationTime != ''"> and rectification_time = #{rectificationTime}</if>
  49. <if test="currentState != null and currentState != ''"> and current_state = #{currentState}</if>
  50. <if test="question != null and question != ''"> and question = #{question}</if>
  51. <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
  52. <if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
  53. <if test="chargePeopleId != null "> and charge_people_id = #{chargePeopleId}</if>
  54. <if test="chargePeople != null and chargePeople != ''"> and charge_people = #{chargePeople}</if>
  55. <if test="correctiveAction != null and correctiveAction != ''"> and corrective_action = #{correctiveAction}</if>
  56. <if test="pictureProof != null and pictureProof != ''"> and picture_proof = #{pictureProof}</if>
  57. <if test="documentProof != null and documentProof != ''"> and document_proof = #{documentProof}</if>
  58. <if test="caoZuoType != null and caoZuoType != ''"> and caozuo_type = #{caoZuoType}</if>
  59. <if test="reasonReturn != null and reasonReturn != ''"> and reason_return = #{reasonReturn}</if>
  60. <if test="parentId != null "> and parent_id = #{parentId}</if>
  61. <if test="paixuValue != null and paixuValue != '' "> and paixu_value = #{paixuValue}</if>
  62. <if test="wenjianname != null and wenjianname != '' "> and wenjianname = #{wenjianname}</if>
  63. and YEAR(inspection_time) = YEAR(NOW())
  64. </where>
  65. order by paixu_value asc
  66. </select>
  67. <select id="selectBdglRegularLists" parameterType="BdglRegular" resultMap="BdglRegularResult">
  68. select id, inspected_unit_id, inspected_unit, inspection_type, unit_check_id, unit_check, inspection_time, inspection_site, r.score, rectification_time, current_state, question, r.create_time, create_user_id, create_user, r.update_time, charge_people_id, charge_people, corrective_action, picture_proof, document_proof,caozuo_type,reason_return,r.parent_id,paixu_value, wenjianname
  69. from bdgl_regular r left join sys_dept d
  70. on r.inspected_unit_id=d.dept_id
  71. <where>
  72. <if test="inspectedUnitId != null ">
  73. and (r.inspected_unit_id = #{inspectedUnitId} or d.ancestors like concat('%', #{inspectedUnitId}, '%'))
  74. </if>
  75. <if test="inspectedUnit != null and inspectedUnit != ''"> and r.zinspected_unit = #{inspectedUnit}</if>
  76. <if test="inspectionType != null and inspectionType != ''"> and r.inspection_type = #{inspectionType}</if>
  77. <if test="unitCheckId != null "> and r.unit_check_id = #{unitCheckId}</if>
  78. <if test="unitCheck != null and unitCheck != ''"> and r.unit_check = #{unitCheck}</if>
  79. <if test="inspectionTime != null and inspectionTime != ''"> and r.inspection_time = #{inspectionTime}</if>
  80. <if test="inspectionSite != null and inspectionSite != ''"> and r.inspection_site = #{inspectionSite}</if>
  81. <if test="score != null "> and r.score = #{score}</if>
  82. <if test="rectificationTime != null and rectificationTime != ''"> and r.rectification_time = #{rectificationTime}</if>
  83. <if test="currentState != null and currentState != ''"> and r.current_state = #{currentState}</if>
  84. <if test="question != null and question != ''"> and r.question = #{question}</if>
  85. <if test="createUserId != null "> and r.create_user_id = #{createUserId}</if>
  86. <if test="createUser != null and createUser != ''"> and r.create_user = #{createUser}</if>
  87. <if test="chargePeopleId != null "> and r.charge_people_id = #{chargePeopleId}</if>
  88. <if test="chargePeople != null and chargePeople != ''"> and r.charge_people = #{chargePeople}</if>
  89. <if test="correctiveAction != null and correctiveAction != ''"> and r.corrective_action = #{correctiveAction}</if>
  90. <if test="pictureProof != null and pictureProof != ''"> and r.picture_proof = #{pictureProof}</if>
  91. <if test="documentProof != null and documentProof != ''"> and r.document_proof = #{documentProof}</if>
  92. <if test="caoZuoType != null and caoZuoType != ''"> and r.caozuo_type = #{caoZuoType}</if>
  93. <if test="reasonReturn != null and reasonReturn != ''"> and r.reason_return = #{reasonReturn}</if>
  94. <if test="parentId != null "> and r.parent_id = #{parentId}</if>
  95. <if test="paixuValue != null and paixuValue != '' "> and r.paixu_value = #{paixuValue}</if>
  96. <if test="wenjianname != null and wenjianname != '' "> and r.wenjianname = #{wenjianname}</if>
  97. and YEAR(inspection_time) = YEAR(NOW())
  98. </where>
  99. ORDER BY paixu_value
  100. </select>
  101. <!-- 查询出 如果部门ID 相同的数据 -->
  102. <select id="selectBdglRegularListByDeptId" parameterType="BdglRegular" resultMap="BdglRegularResult">
  103. <include refid="selectBdglRegularVo"/>
  104. WHERE inspected_unit_id = #{inspectedUnitId} OR unit_check_id = #{unitCheckId}
  105. </select>
  106. <select id="selectBdglRegularById" parameterType="Long" resultMap="BdglRegularResult">
  107. <include refid="selectBdglRegularVo"/>
  108. where id = #{id}
  109. </select>
  110. <insert id="insertBdglRegular" parameterType="BdglRegular">
  111. insert into bdgl_regular
  112. <trim prefix="(" suffix=")" suffixOverrides=",">
  113. <if test="id != null">id,</if>
  114. <if test="inspectedUnitId != null">inspected_unit_id,</if>
  115. <if test="inspectedUnit != null">inspected_unit,</if>
  116. <if test="inspectionType != null">inspection_type,</if>
  117. <if test="unitCheckId != null">unit_check_id,</if>
  118. <if test="unitCheck != null">unit_check,</if>
  119. <if test="inspectionTime != null">inspection_time,</if>
  120. <if test="inspectionSite != null">inspection_site,</if>
  121. <if test="score != null">score,</if>
  122. <if test="rectificationTime != null">rectification_time,</if>
  123. <if test="currentState != null">current_state,</if>
  124. <if test="question != null">question,</if>
  125. <if test="createTime != null">create_time,</if>
  126. <if test="createUserId != null">create_user_id,</if>
  127. <if test="createUser != null">create_user,</if>
  128. <if test="updateTime != null">update_time,</if>
  129. <if test="chargePeopleId != null">charge_people_id,</if>
  130. <if test="chargePeople != null">charge_people,</if>
  131. <if test="correctiveAction != null">corrective_action,</if>
  132. <if test="pictureProof != null">picture_proof,</if>
  133. <if test="documentProof != null">document_proof,</if>
  134. <if test="caoZuoType != null "> caozuo_type ,</if>
  135. <if test="reasonReturn != null"> reason_return ,</if>
  136. <if test="parentId != null "> parent_id ,</if>
  137. <if test="paixuValue != null "> paixu_value ,</if>
  138. <if test="wenjianname != null "> wenjianname ,</if>
  139. </trim>
  140. <trim prefix="values (" suffix=")" suffixOverrides=",">
  141. <if test="id != null">#{id},</if>
  142. <if test="inspectedUnitId != null">#{inspectedUnitId},</if>
  143. <if test="inspectedUnit != null">#{inspectedUnit},</if>
  144. <if test="inspectionType != null">#{inspectionType},</if>
  145. <if test="unitCheckId != null">#{unitCheckId},</if>
  146. <if test="unitCheck != null">#{unitCheck},</if>
  147. <if test="inspectionTime != null">#{inspectionTime},</if>
  148. <if test="inspectionSite != null">#{inspectionSite},</if>
  149. <if test="score != null">#{score},</if>
  150. <if test="rectificationTime != null">#{rectificationTime},</if>
  151. <if test="currentState != null">#{currentState},</if>
  152. <if test="question != null">#{question},</if>
  153. <if test="createTime != null">#{createTime},</if>
  154. <if test="createUserId != null">#{createUserId},</if>
  155. <if test="createUser != null">#{createUser},</if>
  156. <if test="updateTime != null">#{updateTime},</if>
  157. <if test="chargePeopleId != null">#{chargePeopleId},</if>
  158. <if test="chargePeople != null">#{chargePeople},</if>
  159. <if test="correctiveAction != null">#{correctiveAction},</if>
  160. <if test="pictureProof != null">#{pictureProof},</if>
  161. <if test="documentProof != null">#{documentProof},</if>
  162. <if test="caoZuoType != null "> #{caoZuoType},</if>
  163. <if test="reasonReturn != null "> #{reasonReturn},</if>
  164. <if test="parentId != null "> #{parentId},</if>
  165. <if test="paixuValue != null"> #{paixuValue},</if>
  166. <if test="wenjianname != null ">#{wenjianname},</if>
  167. </trim>
  168. </insert>
  169. <update id="updateBdglRegular" parameterType="BdglRegular">
  170. update bdgl_regular
  171. <trim prefix="SET" suffixOverrides=",">
  172. <if test="inspectedUnitId != null">inspected_unit_id = #{inspectedUnitId},</if>
  173. <if test="inspectedUnit != null">inspected_unit = #{inspectedUnit},</if>
  174. <if test="inspectionType != null">inspection_type = #{inspectionType},</if>
  175. <if test="unitCheckId != null">unit_check_id = #{unitCheckId},</if>
  176. <if test="unitCheck != null">unit_check = #{unitCheck},</if>
  177. <if test="inspectionTime != null">inspection_time = #{inspectionTime},</if>
  178. <if test="inspectionSite != null">inspection_site = #{inspectionSite},</if>
  179. <if test="score != null">score = #{score},</if>
  180. <if test="rectificationTime != null">rectification_time = #{rectificationTime},</if>
  181. <if test="currentState != null">current_state = #{currentState},</if>
  182. <if test="question != null">question = #{question},</if>
  183. <if test="createTime != null">create_time = #{createTime},</if>
  184. <if test="createUserId != null">create_user_id = #{createUserId},</if>
  185. <if test="createUser != null">create_user = #{createUser},</if>
  186. <if test="updateTime != null">update_time = #{updateTime},</if>
  187. <if test="chargePeopleId != null">charge_people_id = #{chargePeopleId},</if>
  188. <if test="chargePeople != null">charge_people = #{chargePeople},</if>
  189. <if test="correctiveAction != null">corrective_action = #{correctiveAction},</if>
  190. <if test="pictureProof != null">picture_proof = #{pictureProof},</if>
  191. <if test="documentProof != null">document_proof = #{documentProof},</if>
  192. <if test="caoZuoType != null "> caozuo_type = #{caoZuoType},</if>
  193. <if test="reasonReturn != null ">reason_return = #{reasonReturn},</if>
  194. <if test="parentId != null "> parent_id = #{parentId},</if>
  195. <if test="paixuValue != null "> paixu_value = #{paixuValue},</if>
  196. <if test="wenjianname != null "> wenjianname = #{wenjianname},</if>
  197. </trim>
  198. where id = #{id}
  199. </update>
  200. <delete id="deleteBdglRegularById" parameterType="Long">
  201. delete from bdgl_regular where id = #{id}
  202. </delete>
  203. <!-- 查询当前部门以及部门下的数据 -->
  204. <select id="selectDeptById" parameterType="Long" resultMap="BdglRegularResult">
  205. <include refid="selectBdglRegularVo"/>
  206. WHERE id IN (SELECT id FROM bdgl_regular
  207. where inspected_unit_id = #{deptId} or parent_id = #{deptId}) and YEAR(inspection_time) = YEAR(NOW())
  208. </select>
  209. <!-- 查询当前部门以及部门下减分状态的数据 -->
  210. <select id="selectDeptByIdAndStates" resultMap="BdglRegularResult">
  211. <include refid="selectBdglRegularVo"/>
  212. where (inspected_unit_id = #{deptId} or parent_id = #{deptId}) and caozuo_type='0' and YEAR(inspection_time) = YEAR(NOW())
  213. </select>
  214. <delete id="deleteBdglRegularByIds" parameterType="String">
  215. delete from bdgl_regular where id in
  216. <foreach item="id" collection="array" open="(" separator="," close=")">
  217. #{id}
  218. </foreach>
  219. </delete>
  220. </mapper>