You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
6.6 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.xujie.sys.modules.machine.mapper.TpmMachineProjectMapper">
  5. <select id="queryMachinePage" resultType="com.xujie.sys.modules.machine.entity.TpmMachineProject">
  6. select a.id,
  7. a.site,
  8. a.bu_no,
  9. a.project_no,
  10. a.project_name,
  11. a.project_income,
  12. a.project_budget,
  13. a.project_actual_expenses,
  14. a.responsible_no,
  15. a.responsible_person,
  16. a.start_date,
  17. a.end_date,
  18. a.sstatus,
  19. a.create_by,
  20. a.create_date,
  21. a.update_by,
  22. a.update_date,
  23. a.remark,
  24. a.bu_id,
  25. a.object_id,
  26. a.object_desc,
  27. b.bu_desc
  28. from tpm_machine_project a
  29. left join BU b on a.bu_no = b.bu_no and b.site = a.site
  30. <where>
  31. a.site in (select site from eam_access_site where username = #{projectVo.createBy})
  32. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{projectVo.createBy}))
  33. <if test="projectVo.buNo != null and projectVo.buNo != ''">
  34. and a.bu_no = #{projectVo.buNo}
  35. </if>
  36. <if test="projectVo.projectNo != null and projectVo.projectNo != ''">
  37. and a.project_no like concat('%',#{projectVo.projectNo},'%')
  38. </if>
  39. <if test="projectVo.projectName != null and projectVo.projectName != ''">
  40. and a.project_name like concat('%',#{projectVo.projectName},'%')
  41. </if>
  42. <if test="projectVo.sstatus != null and projectVo.sstatus != ''">
  43. and a.sstatus = #{projectVo.sstatus}
  44. </if>
  45. <if test="projectVo.startDate != null">
  46. and a.start_date &gt;= #{projectVo.startDate}
  47. </if>
  48. <if test="projectVo.endDate != null">
  49. and a.start_date &lt;= concat(#{projectVo.endDate},' 23:59:59')
  50. </if>
  51. </where>
  52. order by a.id desc
  53. </select>
  54. <select id="queryBuSiteById" resultType="com.xujie.sys.modules.base.entity.Bu">
  55. select id, site, bu_no, bu_desc, remark, active
  56. from BU
  57. where id = #{buId}
  58. </select>
  59. <select id="queryProjectNo" resultType="java.lang.String">
  60. SELECT
  61. Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(project_no, 4, 10))), 0) + 1), 8)
  62. FROM tpm_machine_project
  63. WHERE site = #{site}
  64. </select>
  65. <select id="searchUserAuthMachineProjectApplicationInfo"
  66. resultType="com.xujie.sys.modules.machine.entity.TpmMachineProject">
  67. SELECT
  68. b.*,
  69. b.site + '_' + b.bu_no AS bu,
  70. dbo.get_bu_desc ( b.site, b.bu_no ) AS bu_desc,
  71. dbo.plm_get_customer_desc ( b.site, b.responsible_person ) AS customer_desc,
  72. dbo.plm_get_user_display ( b.site, b.project_name ) AS quoterName,
  73. dbo.plm_get_user_display ( b.site, b.responsible_no ) AS purchaseName,
  74. a.id AS auth_hist_id,
  75. a.auth_user_id,
  76. dbo.plm_get_user_display ( a.site, a.auth_user_id ) AS user_display,
  77. a.auth_group_id,
  78. a.step_id,
  79. c.group_desc,
  80. a.remark AS auth_hist_remark,
  81. a.can_auth_flag,
  82. a.last_step_flag,
  83. a.record_type_db,
  84. a.order_ref1,
  85. a.is_simultaneous
  86. FROM
  87. view_all_auth_info_with_email a
  88. LEFT JOIN tpm_machine_project b ON a.site = b.site
  89. AND a.order_ref2 = b.bu_no
  90. AND a.order_ref1 = b.project_no
  91. LEFT JOIN auth_group c ON c.site = a.site
  92. AND c.bu_no = a.order_ref2
  93. AND c.group_no = a.auth_group_id
  94. where
  95. a.user_id = #{projectVo.userId}
  96. AND a.site = #{projectVo.site}
  97. AND a.order_ref1 LIKE concat(#{projectVo.orderRef1} ,'%')
  98. <choose>
  99. <when test="projectVo.sstatus != null and projectVo.sstatus != ''">
  100. AND b.sstatus = #{projectVo.sstatus}
  101. </when>
  102. <otherwise>
  103. AND a.can_auth_flag = 'Y'
  104. </otherwise>
  105. </choose>
  106. <if test="projectVo.buNo != null and projectVo.buNo != ''">
  107. AND b.bu_no = #{projectVo.buNo}
  108. </if>
  109. <if test="projectVo.projectNo != null and projectVo.projectNo != ''">
  110. AND b.project_no like concat('%',#{projectVo.projectNo},'%')
  111. </if>
  112. <if test="projectVo.projectName != null and projectVo.projectName != ''">
  113. AND b.project_name like concat('%',#{projectVo.projectName},'%')
  114. </if>
  115. <if test="projectVo.sstatus != null and projectVo.sstatus != ''">
  116. AND b.sstatus = #{projectVo.sstatus}
  117. </if>
  118. <if test="projectVo.startDate != null">
  119. AND b.start_date &gt;= #{projectVo.startDate}
  120. </if>
  121. <if test="projectVo.endDate != null">
  122. AND b.start_date &lt;= concat(#{projectVo.endDate},' 23:59:59')
  123. </if>
  124. order by b.id desc,a.id desc
  125. </select>
  126. <select id="searchMachineProjectAuthRecords"
  127. resultType="com.xujie.sys.modules.machine.entity.vo.MachineProjectAuthVo">
  128. SELECT
  129. b.project_no,
  130. b.project_name,
  131. b.site + '_' + b.bu_no AS bu,
  132. dbo.get_bu_desc ( b.site, b.bu_no ) AS bu_desc,
  133. dbo.plm_get_customer_desc ( b.site, b.responsible_person ) AS customer_desc,
  134. dbo.plm_get_user_display ( b.site, b.project_name ) AS quoterName,
  135. dbo.plm_get_user_display ( b.site, b.responsible_no ) AS purchaseName,
  136. a.id AS auth_hist_id,
  137. a.auth_user_id,
  138. dbo.plm_get_user_display ( a.site, a.auth_user_id ) AS user_display,
  139. a.auth_group_id,
  140. c.group_desc,
  141. a.act_authorize_date,
  142. a.approve_result,
  143. a.approve_result_comments,
  144. a.remark AS auth_hist_remark,
  145. a.record_type_db,
  146. a.order_ref1
  147. FROM
  148. view_all_auth_info_with_email a
  149. LEFT JOIN tpm_machine_project b ON a.site = b.site
  150. AND a.order_ref2 = b.bu_no
  151. AND a.order_ref1 = b.project_no
  152. LEFT JOIN auth_group c ON c.site = a.site
  153. AND c.bu_no = a.order_ref2
  154. AND c.group_no = a.auth_group_id
  155. where
  156. a.site = #{site}
  157. AND a.order_ref1 = #{projectNo}
  158. </select>
  159. </mapper>