MouldMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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.hssx.cloudmodel.mapper.MouldMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.Mould">
  6. <id column="id" property="id" />
  7. <result column="model_no" property="modelNo" />
  8. <result column="model_name" property="modelName" />
  9. <result column="water_gap" property="waterGap" />
  10. <result column="tonnage" property="tonnage" />
  11. <result column="oc_cycle" property="ocCycle" />
  12. <result column="daily_output" property="dailyOutput" />
  13. <result column="company_id" property="companyId" />
  14. <result column="current_version_id" property="currentVersionId" />
  15. <result column="state" property="state" />
  16. <result column="is_delete" property="isDelete" />
  17. <result column="creator_id" property="creatorId" />
  18. <result column="project_id" property="projectId" />
  19. <result column="rfid" property="rfid" />
  20. <result column="setting_life" property="settingLife" />
  21. <result column="area" property="area" />
  22. <result column="produce_company_name" property="produceCompanyName" />
  23. <result column="initial_modulus" property="initialModulus" />
  24. <result column="equipment_id" property="equipmentId" />
  25. <result column="belong_project_grade" property="belongProjectGrade" />
  26. <result column="produce_company_id" property="produceCompanyId" />
  27. <result column="run_times" property="runTimes" />
  28. <result column="is_maintain" property="isMaintain" />
  29. <result column="maintain_count" property="maintainCount" />
  30. <result column="holes" property="holes" />
  31. <result column="pre_update_id" property="preUpdateId" />
  32. <result column="history_run_times" property="historyRunTimes" />
  33. </resultMap>
  34. <!-- 通用查询结果列 -->
  35. <sql id="Base_Column_List">
  36. id, model_no, model_name, water_gap, tonnage, oc_cycle, daily_output, company_id, current_version_id, state, is_delete, creator_id, project_id, rfid, setting_life, area, produce_company_name, initial_modulus, equipment_id, belong_project_grade, produce_company_id, run_times, is_maintain, maintain_count, holes, pre_update_id, history_run_times
  37. </sql>
  38. <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.MouldVO">
  39. <id column="id" property="id"/>
  40. <result column="maintain_count" property="maintainCount" />
  41. <result column="model_no" property="modelNo"/>
  42. <result column="model_name" property="modelName"/>
  43. <result column="oc_cycle" property="ocCycle"/>
  44. <result column="daily_output" property="dailyOutput"/>
  45. <result column="company_id" property="companyId"/>
  46. <result column="current_version_id" property="currentVersionId"/>
  47. <result column="state" property="state"/>
  48. <result column="is_delete" property="isDelete"/>
  49. <result column="creator_id" property="creatorId"/>
  50. <result column="project_id" property="projectId"/>
  51. <result column="projectName" property="projectName"/>
  52. <result column="rfid" property="rfid"/>
  53. <result column="setting_life" property="settingLife"/>
  54. <result column="area" property="area"/>
  55. <result column="produce_company_name" property="produceCompanyName"/>
  56. <result column="initial_modulus" property="initialModulus"/>
  57. <result column="equipment_id" property="equipmentId"/>
  58. <result column="belong_project_grade" property="belongProjectGrade"/>
  59. <result column="produce_company_id" property="produceCompanyId"/>
  60. <result column="produceCompany" property="produceCompany"/>
  61. <result column="run_times" property="runTimes" />
  62. <result column="projectName" property="projectName"/>
  63. <result column="managerId" property="managerId" />
  64. <result column="mangerName" property="mangerName"/>
  65. <result column="equipmentNo" property="equipmentNo"/>
  66. <result column="stage" property="stage"/>
  67. <result column="endTime" property="endTime"/>
  68. <result column="lastopentime" property="lastOpenTime"/>
  69. <result column="hillNumber" property="hillNumber"/>
  70. <result column="temperature" property="temperature"/>
  71. <result column="ownerCompanyName" property="ownerCompanyName"/>
  72. <result column="companyName" property="companyName"/>
  73. <result column="is_maintain" property="isMaintain" />
  74. <result column="holes" property="holes" />
  75. <result column="lng" property="lng" />
  76. <result column="lat" property="lat" />
  77. <result column="equipmentName" property="equipmentName" />
  78. <result column="pre_update_id" property="preUpdateId" />
  79. </resultMap>
  80. <update id="updateMouldByProjectId">
  81. update tb_mould set project_id = null ,belong_project_grade = 0 where project_id = #{project.id}
  82. </update>
  83. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  84. select
  85. tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbm.creator_id creator_id,tbm.equipment_id equipment_id,tbm.is_maintain,tbm.holes,
  86. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,tbm.pre_update_id,
  87. tbp.manager mangerName,tbco.company_address area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,tbmp.equipment_name equipmentName,
  88. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  89. tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
  90. ,(SELECT battery FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  91. (SELECT temperature FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
  92. from
  93. tb_mould tbm
  94. left join
  95. tb_mould_equipment tbmp
  96. on
  97. tbm.equipment_id = tbmp.id
  98. left join
  99. tb_project tbp
  100. on tbp.id = tbm.project_id
  101. left join
  102. tb_company tbc
  103. on
  104. tbc.id = tbm.company_id
  105. left join
  106. tb_company tbco
  107. on
  108. tbco.id = tbm.produce_company_id
  109. <where>
  110. <if test="userVO.parentId != 0">
  111. tbm.company_id = #{userVO.companyId}
  112. </if>
  113. <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
  114. AND tbm.model_no like concat('%',#{userVO.keyName},'%')
  115. </if>
  116. <if test="userVO.searchType == 1 and userVO.keyName != '' and userVO.keyName != null">
  117. AND tbm.model_name like concat('%',#{userVO.keyName},'%')
  118. </if>
  119. <if test="userVO.projectId != -1">
  120. AND tbm.project_id = #{userVO.projectId}
  121. </if>
  122. <if test="userVO.type == 0">
  123. AND tbm.equipment_id is not null
  124. AND tbm.state != 4
  125. AND tbm.project_id is not null
  126. </if>
  127. <if test="userVO.mouleMap == -1">
  128. AND tbmp.lng IS NOT NULL and tbmp.lat IS NOT NULL
  129. </if>
  130. </where>
  131. </select>
  132. <select id="selectListByConditionByProject" resultMap="BaseResultMapVO">
  133. select
  134. tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbp.manager_id managerId,tbm.equipment_id equipment_id,is_maintain,
  135. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbm.holes,tbm.pre_update_id,tbco.company_name produceCompany,
  136. tbp.manager mangerName,tbco.company_address area,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,tbmp.equipment_name equipmentName,
  137. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  138. tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime,
  139. (SELECT battery FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  140. (SELECT temperature FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
  141. from
  142. tb_mould tbm
  143. left join
  144. tb_mould_equipment tbmp
  145. on
  146. tbm.equipment_id = tbmp.id
  147. left join
  148. tb_project tbp
  149. on
  150. tbp.id = tbm.project_id
  151. left join
  152. tb_company tbc
  153. on
  154. tbc.id = tbm.company_id
  155. left join
  156. tb_company tbco
  157. on
  158. tbco.id = tbm.produce_company_id
  159. <where>
  160. <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
  161. AND tbm.model_no like concat('%',#{userVO.keyName},'%')
  162. </if>
  163. <if test="userVO.searchType == 1 and userVO.keyName != '' and userVO.keyName != null">
  164. AND tbm.model_name like concat('%',#{userVO.keyName},'%')
  165. </if>
  166. <if test="userVO.mouleMap == -1">
  167. AND tbmp.lng IS NOT NULL and tbmp.lat IS NOT NULL
  168. </if>
  169. <if test="userVO.type == 0">
  170. AND tbm.equipment_id is not null
  171. AND tbm.state != 4
  172. AND tbm.project_id is not null
  173. </if>
  174. AND tbm.project_id in
  175. <foreach item="item" index="index" collection="list"
  176. open="(" separator="," close=")">
  177. #{item}
  178. </foreach>
  179. </where>
  180. </select>
  181. <select id="getDetailById" resultMap="BaseResultMapVO">
  182. select
  183. tbm.project_id project_id, tbm.setting_life setting_life,tbm.equipment_id equipment_id,tbm.maintain_count maintain_count,is_maintain,
  184. tbm.id id,tbm.model_no model_no, tbm.model_name,tbm.initial_modulus initial_modulus,tbp.manager_id managerId,tbm.produce_company_id produce_company_id,
  185. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbco.company_name produceCompany,tbm.creator_id creator_id,tbm.holes,
  186. tbp.manager mangerName,tbco.company_address area,tbm.rfid rfid,tbm.oc_cycle oc_cycle,tbc.company_name companyName,tbm.pre_update_id,tbmp.equipment_name equipmentName,
  187. tbmp.equipment_no equipmentNo,(SELECT battery FROM `mould_history` WHERE tbmp.equipment_no = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  188. (SELECT temperature FROM `mould_history` WHERE equipment_no = tbmp.equipment_no ORDER BY indate DESC LIMIT 1) temperature,tbm.setting_life setting_life,tbm.run_times run_times,tbmp.stage
  189. from
  190. tb_mould tbm
  191. left join
  192. tb_mould_equipment tbmp
  193. on
  194. tbm.equipment_id = tbmp.id
  195. left join
  196. tb_project tbp
  197. on tbp.id = tbm.project_id
  198. left join
  199. tb_company tbco
  200. on
  201. tbco.id = tbm.produce_company_id
  202. left join
  203. tb_company tbc
  204. on
  205. tbc.id = tbm.company_id
  206. where
  207. tbm.id = #{mouldVO.id}
  208. </select>
  209. <select id="selectListByCompanyId" resultMap="BaseResultMapVO">
  210. select
  211. tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbm.creator_id creator_id,tbm.equipment_id equipment_id,tbm.is_maintain,tbm.holes,
  212. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbm.pre_update_id,tbm.company_id,tbco.company_name produce_company_name,tbm.produce_company_id,
  213. tbp.manager mangerName,tbco.company_address area,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,
  214. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  215. tbmp.lng,tbmp.lat,tbmp.stage
  216. from
  217. tb_mould tbm
  218. left join
  219. tb_mould_equipment tbmp
  220. on
  221. tbm.equipment_id = tbmp.id
  222. left join
  223. tb_project tbp
  224. on tbp.id = tbm.project_id
  225. left join
  226. tb_company tbc
  227. on
  228. tbc.id = tbm.company_id
  229. left join
  230. tb_company tbco
  231. on
  232. tbco.id = tbm.produce_company_id
  233. where
  234. tbm.company_id = #{companyId}
  235. AND tbm.equipment_id is not null
  236. AND tbm.project_id is null
  237. <if test="projectId != null">
  238. OR tbm.project_id = #{projectId}
  239. </if>
  240. </select>
  241. <update id="updateModelProjectIdAndEquipmentIdToNullById">
  242. update
  243. tb_mould
  244. SET /*project_id = NULL , */equipment_id = NULL
  245. where id = #{model.id}
  246. </update>
  247. </mapper>