MouldMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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="ownerCompanyName" property="ownerCompanyName"/>
  71. <result column="companyName" property="companyName"/>
  72. <result column="is_maintain" property="isMaintain" />
  73. <result column="holes" property="holes" />
  74. <result column="lng" property="lng" />
  75. <result column="lat" property="lat" />
  76. <result column="equipmentName" property="equipmentName" />
  77. <result column="pre_update_id" property="preUpdateId" />
  78. </resultMap>
  79. <update id="updateMouldByProjectId">
  80. update tb_mould set project_id = null ,belong_project_grade = 0 where project_id = #{project.id}
  81. </update>
  82. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  83. select
  84. 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,
  85. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,tbm.pre_update_id,
  86. tbp.manager mangerName,tbco.company_address area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,tbmp.equipment_name equipmentName,
  87. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  88. tbmp.lng,tbmp.lat,tbmp.stage,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
  89. ,(SELECT battery FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  90. (SELECT temperature FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
  91. from
  92. tb_mould tbm
  93. left join
  94. tb_mould_equipment tbmp
  95. on
  96. tbm.equipment_id = tbmp.id
  97. left join
  98. tb_project tbp
  99. on tbp.id = tbm.project_id
  100. left join
  101. tb_company tbc
  102. on
  103. tbc.id = tbm.company_id
  104. left join
  105. tb_company tbco
  106. on
  107. tbco.id = tbm.produce_company_id
  108. <where>
  109. <if test="userVO.parentId != 0">
  110. tbm.company_id = #{userVO.companyId}
  111. </if>
  112. <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
  113. AND tbm.model_no like concat('%',#{userVO.keyName},'%')
  114. </if>
  115. <if test="userVO.searchType == 1 and userVO.keyName != '' and userVO.keyName != null">
  116. AND tbm.model_name like concat('%',#{userVO.keyName},'%')
  117. </if>
  118. <if test="userVO.projectId != -1">
  119. AND tbm.project_id = #{userVO.projectId}
  120. </if>
  121. <if test="userVO.type == 0">
  122. AND tbm.equipment_id is not null
  123. AND tbm.state != 4
  124. </if>
  125. <if test="userVO.mouleMap == -1">
  126. AND tbmp.lng IS NOT NULL and tbmp.lat IS NOT NULL
  127. </if>
  128. </where>
  129. </select>
  130. <select id="selectListByConditionByProject" resultMap="BaseResultMapVO">
  131. select
  132. 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,
  133. 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,
  134. tbp.manager mangerName,tbco.company_address area,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,tbmp.equipment_name equipmentName,
  135. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  136. tbmp.lng,tbmp.lat,tbmp.stage,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime,
  137. (SELECT battery FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  138. (SELECT temperature FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
  139. from
  140. tb_mould tbm
  141. left join
  142. tb_mould_equipment tbmp
  143. on
  144. tbm.equipment_id = tbmp.id
  145. left join
  146. tb_project tbp
  147. on
  148. tbp.id = tbm.project_id
  149. left join
  150. tb_company tbc
  151. on
  152. tbc.id = tbm.company_id
  153. left join
  154. tb_company tbco
  155. on
  156. tbco.id = tbm.produce_company_id
  157. <where>
  158. <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
  159. AND tbm.model_no like concat('%',#{userVO.keyName},'%')
  160. </if>
  161. <if test="userVO.searchType == 1 and userVO.keyName != '' and userVO.keyName != null">
  162. AND tbm.model_name like concat('%',#{userVO.keyName},'%')
  163. </if>
  164. <if test="userVO.mouleMap == -1">
  165. AND tbmp.lng IS NOT NULL and tbmp.lat IS NOT NULL
  166. </if>
  167. <if test="userVO.type == 0">
  168. AND tbm.equipment_id is not null
  169. AND tbm.state != 4
  170. </if>
  171. AND tbm.project_id in
  172. <foreach item="item" index="index" collection="list"
  173. open="(" separator="," close=")">
  174. #{item}
  175. </foreach>
  176. </where>
  177. </select>
  178. <select id="getDetailById" resultMap="BaseResultMapVO">
  179. select
  180. tbm.project_id project_id, tbm.setting_life setting_life,tbm.equipment_id equipment_id,tbm.maintain_count maintain_count,is_maintain,
  181. 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,
  182. tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbco.company_name produceCompany,tbm.creator_id creator_id,tbm.holes,
  183. 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,
  184. tbmp.equipment_no equipmentNo,(SELECT battery FROM `mould_history` WHERE tbmp.equipment_no = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
  185. (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
  186. from
  187. tb_mould tbm
  188. left join
  189. tb_mould_equipment tbmp
  190. on
  191. tbm.equipment_id = tbmp.id
  192. left join
  193. tb_project tbp
  194. on tbp.id = tbm.project_id
  195. left join
  196. tb_company tbco
  197. on
  198. tbco.id = tbm.produce_company_id
  199. left join
  200. tb_company tbc
  201. on
  202. tbc.id = tbm.company_id
  203. where
  204. tbm.id = #{mouldVO.id}
  205. </select>
  206. <select id="selectListByCompanyId" resultMap="BaseResultMapVO">
  207. select
  208. 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,
  209. 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,
  210. tbp.manager mangerName,tbco.company_address area,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,
  211. tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
  212. tbmp.lng,tbmp.lat,tbmp.stage
  213. from
  214. tb_mould tbm
  215. left join
  216. tb_mould_equipment tbmp
  217. on
  218. tbm.equipment_id = tbmp.id
  219. left join
  220. tb_project tbp
  221. on tbp.id = tbm.project_id
  222. left join
  223. tb_company tbc
  224. on
  225. tbc.id = tbm.company_id
  226. left join
  227. tb_company tbco
  228. on
  229. tbco.id = tbm.produce_company_id
  230. where
  231. tbm.company_id = #{companyId}
  232. AND tbm.equipment_id is not null
  233. AND tbm.project_id is null
  234. <if test="projectId != null">
  235. OR tbm.project_id = #{projectId}
  236. </if>
  237. </select>
  238. <update id="updateModelProjectIdAndEquipmentIdToNullById">
  239. update
  240. tb_mould
  241. SET /*project_id = NULL , */equipment_id = NULL
  242. where id = #{model.id}
  243. </update>
  244. </mapper>