赫艾后端
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.

322 lines
13 KiB

4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  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.heai.modules.taskmanage.dao.TaskDetailDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.heai.modules.taskmanage.entity.TaskDetailEntity" id="taskListMap">
  6. <result property="id" column="id"/>
  7. <result property="department" column="department"/>
  8. <result property="status" column="status"/>
  9. <result property="createdDate" column="created_date"/>
  10. <result property="createdBy" column="created_by"/>
  11. <result property="updatedDate" column="updated_date"/>
  12. <result property="updatedBy" column="updated_by"/>
  13. </resultMap>
  14. <select id="taskDetailList" resultType="com.heai.modules.taskmanage.vo.TaskDetailVo">
  15. select td.id
  16. , tl.project
  17. , tl.customer
  18. , isnull(u2.username,tl.task_initiator) task_initiator
  19. , tl.task_description
  20. , td.department
  21. , tl.required_completion_date
  22. , td.status
  23. , td.final_status
  24. , tl.task_start_date
  25. , tl.created_date
  26. , tl.created_by
  27. , tl.updated_date
  28. , tl.updated_by
  29. , tl.task_header
  30. , u.username responsible_person
  31. ,( u.department + ' | ' + u.username) as dep_user_name
  32. , td.task_id
  33. , dbo.Get_chat_LastType(td.site,td.id,td.created_by) chatLastType
  34. ,tl.AllowCloseByHand,tl.OrderRef1,tl.OrderRef2,
  35. tl.OrderRef3,tl.OrderRefType,tl.OrderRef4
  36. from task_detail td
  37. left join task_list tl on td.task_id = tl.id AND td.site = tl.site
  38. left join users u on td.site = u.site and u.userId = td.responsible_person
  39. left join users u2 on td.site = u2.site and u2.userId = tl.task_initiator
  40. LEFT JOIN report_mapping_ipaddress rmi on rmi.department = u.department
  41. <where>
  42. td.site = #{site}
  43. and tl.created_date>DATEADD(dd, -60, GetDate())
  44. and (tl.created_by=td.responsible_person OR dbo.Get_chat_LastType(td.site,td.id,td.created_by)!='有新回复')
  45. <if test="ipAddress != null and ipAddress != ''">
  46. and rmi.ipaddress like #{ipAddress}
  47. </if>
  48. <if test="taskInitiator != null and taskInitiator != ''">
  49. and tl.created_by like #{taskInitiator}
  50. </if>
  51. <if test="department != null and department != ''">
  52. and u.department like #{department}
  53. </if>
  54. <if test="customer != null and customer != ''">
  55. and tl.customer like #{customer}
  56. </if>
  57. <if test="project != null and project != ''">
  58. and tl.project like #{project}
  59. </if>
  60. <if test="status != null and status != ''">
  61. and td.status = #{status}
  62. </if>
  63. <if test="finalStatus != null and finalStatus != ''">
  64. and td.final_status = #{finalStatus}
  65. </if>
  66. <if test="responsiblePerson != null and responsiblePerson != ''">
  67. and UPPER(td.responsible_person) like UPPER(#{responsiblePerson})
  68. </if>
  69. <if test="startDate !=null ">
  70. and tl.task_start_date <![CDATA[ >= ]]> #{startDate}
  71. </if>
  72. <if test="endDate !=null ">
  73. and tl.task_start_date <![CDATA[ <= ]]> #{endDate}
  74. </if>
  75. <if test="finishStartDate != null ">
  76. and tl.required_completion_date <![CDATA[ >= ]]> #{finishStartDate}
  77. </if>
  78. <if test="finishEndDate != null ">
  79. and tl.required_completion_date <![CDATA[ <= ]]> #{finishEndDate}
  80. </if>
  81. </where>
  82. </select>
  83. <select id="taskDetailListPC" resultType="com.heai.modules.taskmanage.vo.TaskDetailVo">
  84. select td.id
  85. , tl.project
  86. , tl.customer
  87. , isnull(u2.username,tl.task_initiator) task_initiator
  88. , tl.task_description
  89. , td.department
  90. , tl.required_completion_date
  91. , td.status
  92. , td.final_status
  93. , tl.task_start_date
  94. , tl.created_date
  95. , tl.created_by
  96. , tl.updated_date
  97. , tl.updated_by
  98. , tl.task_header
  99. , u.username responsible_person
  100. ,( u.department + ' | ' + u.username) as dep_user_name
  101. , td.task_id
  102. , dbo.Get_chat_LastType(td.site,td.id,td.created_by) chatLastType
  103. ,tl.AllowCloseByHand,tl.OrderRef1,tl.OrderRef2,
  104. tl.OrderRef3,tl.OrderRefType,tl.OrderRef4,tl.taskType,tl.oldSpec,tl.newSpec
  105. from task_detail td
  106. left join task_list tl on td.task_id = tl.id AND td.site = tl.site
  107. left join users u on td.site = u.site and u.userId = td.responsible_person
  108. left join users u2 on td.site = u2.site and u2.userId = tl.task_initiator
  109. LEFT JOIN report_mapping_ipaddress rmi on rmi.department = u.department
  110. <where>
  111. td.site = #{site}
  112. <if test="ipAddress != null and ipAddress != ''">
  113. and rmi.ipaddress like #{ipAddress}
  114. </if>
  115. <if test="taskInitiator != null and taskInitiator != ''">
  116. and tl.created_by like #{taskInitiator}
  117. </if>
  118. <if test="department != null and department != ''">
  119. and u.department like #{department}
  120. </if>
  121. <if test="customer != null and customer != ''">
  122. and tl.customer like #{customer}
  123. </if>
  124. <if test="taskType != null and taskType != ''">
  125. and tl.taskType like #{taskType}
  126. </if>
  127. <if test="oldSpec != null and oldSpec != ''">
  128. and tl.oldSpec like #{oldSpec}
  129. </if>
  130. <if test="newSpec != null and newSpec != ''">
  131. and tl.newSpec like #{newSpec}
  132. </if>
  133. <if test="project != null and project != ''">
  134. and tl.project like #{project}
  135. </if>
  136. <if test="status != null and status != ''">
  137. and td.status = #{status}
  138. </if>
  139. <if test="finalStatus != null and finalStatus != ''">
  140. and td.final_status = #{finalStatus}
  141. </if>
  142. <if test="responsiblePerson != null and responsiblePerson != ''">
  143. and UPPER(td.responsible_person) like UPPER(#{responsiblePerson})
  144. </if>
  145. <if test="startDate !=null ">
  146. and tl.task_start_date <![CDATA[ >= ]]> #{startDate}
  147. </if>
  148. <if test="endDate !=null ">
  149. and tl.task_start_date <![CDATA[ <= ]]> #{endDate}
  150. </if>
  151. <if test="finishStartDate != null ">
  152. and tl.required_completion_date <![CDATA[ >= ]]> #{finishStartDate}
  153. </if>
  154. <if test="finishEndDate != null ">
  155. and tl.required_completion_date <![CDATA[ <= ]]> #{finishEndDate}
  156. </if>
  157. </where>
  158. </select>
  159. <select id="taskDetailReportList" resultType="com.heai.modules.taskmanage.vo.TaskDetailVo">
  160. select td.id
  161. , tl.project
  162. , tl.customer
  163. , tl.task_initiator
  164. , tl.task_description
  165. , td.department
  166. , tl.required_completion_date
  167. , td.status
  168. , tl.final_status
  169. , tl.task_start_date
  170. , tl.created_date
  171. , tl.created_by
  172. , tl.updated_date
  173. , tl.updated_by
  174. , tl.task_header
  175. , u.username as responsible_person
  176. , td.task_id
  177. from task_detail td
  178. left join task_list tl on td.task_id = tl.id AND td.site = tl.site
  179. left join users u on td.site = u.site and u.userId = td.responsible_person
  180. <where>
  181. td.site = #{site}
  182. <if test="department != null and department != ''">
  183. and tl.department like #{department}
  184. </if>
  185. <if test="customer != null and customer != ''">
  186. and tl.customer like #{customer}
  187. </if>
  188. <if test="status != null and status != ''">
  189. and tl.status = #{status}
  190. </if>
  191. <if test="responsiblePerson != null and responsiblePerson != ''">
  192. and td.responsible_person like #{responsiblePerson}
  193. </if>
  194. <if test="startDate !=null ">
  195. and tl.task_start_date <![CDATA[ >= ]]> #{startDate}
  196. </if>
  197. <if test="endDate !=null ">
  198. and tl.task_start_date <![CDATA[ <= ]]> #{endDate}
  199. </if>
  200. <if test="finishStartDate != null ">
  201. and tl.required_completion_date <![CDATA[ >= ]]> #{finishStartDate}
  202. </if>
  203. <if test="finishEndDate != null ">
  204. and tl.required_completion_date <![CDATA[ <= ]]>#{finishEndDate}
  205. </if>
  206. </where>
  207. </select>
  208. <select id="queryPartInventory" resultType="com.heai.modules.board.entity.Inventory">
  209. Select T.Site,
  210. T.PartNo,
  211. P.PartDescription,
  212. P.Spec,
  213. <if test="summaryType != null and summaryType >= 1">
  214. T.WarehouseID,
  215. </if>
  216. P.UMID,
  217. <if test="summaryType != null and summaryType >= 2">
  218. T.LocationID,
  219. </if>
  220. <if test="summaryType != null and summaryType >= 3">
  221. T.BatchNo,
  222. </if>
  223. min(T.FirstInDate) as FirstInDate,
  224. max(T.LatestCountDate) as LatestCountDate,
  225. min(T.Freezeflag) as Freezeflag,
  226. P.PartType,
  227. P.FamilyID,
  228. dbo.Get_PartFamilyDesc(P.Site, P.FamilyID) as FamilyName,
  229. P.GroupID,
  230. dbo.Get_PartGroupDesc(T.Site, P.GroupID) as PartGroup,
  231. max(T.LatestOutDate) as LatestOutDate,
  232. max(T.LatestInDate) as LatestInDate,
  233. max(T.ActiveDate) as ActiveDate,
  234. max(T.PartnerID) as PartnerID,
  235. max(T.PartnerType) as PartnerType,
  236. min(T.ManufactureDate) as ManufactureDate,
  237. max(T.ExpiredDate) as ExpiredDate,
  238. sum(Round(T.QtyOnHand, 3)) as QtyOnHand,
  239. sum(Round(isnull(T.QtyReserved, 0), 3)) as QtyReserved,
  240. sum(Round(isnull(T.InStandardValue, 0), 4) - Round(isnull(T.OutStandardValue, 0), 4)) as StandartStockValue,
  241. sum(Round(isnull(T.InActualValue, 0), 4) - Round(isnull(T.OutActualValue, 0), 4)) as ActualStockValue,
  242. max(T.DemandPartnerType) as DemandPartnerType,
  243. max(T.DemandPartnerID) as DemandPartnerID,
  244. max(T.DemandPartnerName) as DemandPartnerName
  245. from InventoryStock as T,
  246. Part as P
  247. where T.Site = P.Site
  248. and T.PartNo = P.PartNo
  249. and T.Site in (Select Site from AccessSite where upper(UserID) = #{loginUser})
  250. <if test="partNo != null and partNo != ''">
  251. and T.PartNo like #{partNo}
  252. </if>
  253. <if test="partDescription != null and partDescription != ''">
  254. and P.PartDescription like #{partDescription}
  255. </if>
  256. <if test="spec != null and spec != ''">
  257. and P.Spec like #{spec}
  258. </if>
  259. <if test="site != null and site != ''">
  260. and T.Site = #{site}
  261. </if>
  262. <if test="partType != null and partType != ''">
  263. and P.PartType like #{partType}
  264. </if>
  265. <if test="warehouseId != null and warehouseId != ''">
  266. and T.WarehouseID = #{warehouseId}
  267. </if>
  268. <if test="locationId != null and locationId != '' and summaryType != null and summaryType >= 2">
  269. and T.LocationID = #{locationId}
  270. </if>
  271. <if test="batchNo != null and batchNo != '' and summaryType != null and summaryType >= 3">
  272. and T.BatchNo = #{batchNo}
  273. </if>
  274. <if test="familyId != null and familyId != ''">
  275. and P.FamilyID like #{familyId}
  276. </if>
  277. <if test="familyName != null and familyName != ''">
  278. and dbo.Get_PartFamilyDesc(P.Site, P.FamilyID) like #{familyName}
  279. </if>
  280. <if test="startFirstInDate != null">
  281. and T.FirstInDate >= #{startFirstInDate}
  282. </if>
  283. <if test="endFirstInDate != null">
  284. and #{endFirstInDate} >= T.FirstInDate
  285. </if>
  286. <if test="startExpiredDate != null">
  287. and T.ExpiredDate >= #{startExpiredDate}
  288. </if>
  289. <if test="endExpiredDate != null">
  290. and #{endExpiredDate} >= T.ExpiredDate
  291. </if>
  292. group by
  293. T.Site,
  294. T.PartNo,
  295. P.PartDescription,
  296. P.Spec,
  297. <if test="summaryType != null and summaryType >= 1">
  298. T.WarehouseID,
  299. </if>
  300. P.UMID,
  301. <if test="summaryType != null and summaryType >= 2">
  302. T.LocationID,
  303. </if>
  304. <if test="summaryType != null and summaryType >= 3">
  305. T.BatchNo,
  306. </if>
  307. P.Site,
  308. P.FamilyID,
  309. P.GroupID,
  310. P.PartType
  311. </select>
  312. </mapper>