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.

654 lines
30 KiB

5 months ago
5 months ago
5 months ago
2 months ago
5 months ago
2 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
2 months ago
2 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months 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.gaotao.modules.orderIssure.mapper.IssureNotifyMapper">
  4. <select id="getUserNotifyNo" resultType="SOIssueNotifyHeaderData">
  5. select top 1 a.NotifyNo,a.Site,a.NotifyDate,a.UserName,a.EnteredDate,a.Receiver,a.DepartmentID,a.Remark,a.CreditFlag,a.IssueFlag,
  6. a.IssueResult,a.PlanIssueDate,a.RealIssueDate,a.Status,a.HaveIssueRecordFlag,a.CalcFlag,a.NeedApproveFlag,a.ApprovedFlag,
  7. a.Approver,a.ApproveDate,a.WarehouseID,a.RecordVersion,a.OutWorkOrderFlag,a.ProjectID,a.OrderType,a.AuthRuleID,a.bu
  8. from SOIssueNotifyHeader a
  9. where a.Site=#{site} and a.UserName=#{userName} and a.Status='已计划'
  10. order by a.EnteredDate desc
  11. </select>
  12. <insert id="createNotify">
  13. insert into SOIssueNotifyHeader (NotifyNo,Site,NotifyDate,UserName,EnteredDate,Receiver,DepartmentID,Remark,CreditFlag,IssueFlag,IssueResult,PlanIssueDate,
  14. RealIssueDate,Status,HaveIssueRecordFlag,CalcFlag,NeedApproveFlag,ApprovedFlag,Approver,ApproveDate,WarehouseID,
  15. RecordVersion,OutWorkOrderFlag,ProjectID,OrderType,AuthRuleID,bu, work_center_no)
  16. values(#{notifyNo},#{site},#{notifyDate},#{userName},#{enteredDate},#{receiver},#{departmentID},#{remark},#{creditFlag},#{issueFlag},#{issueResult},#{planIssueDate},
  17. #{realIssueDate},#{status},#{haveIssueRecordFlag},#{calcFlag},#{needApproveFlag},#{approvedFlag},#{approver},#{approveDate},#{warehouseID},
  18. #{recordVersion},#{outWorkOrderFlag},#{projectID},#{orderType},#{authRuleID},#{bu}, #{workCenterNo})
  19. </insert>
  20. <update id="updateNotifyBu">
  21. update SOIssueNotifyHeader set bu=#{bu} where site=#{site} and NotifyNo=#{notifyNo}
  22. </update>
  23. <select id="getNotifyNoDetail" resultType="SOIssueNotifyOrderListData">
  24. select
  25. a.NotifyNo,
  26. a.Site,
  27. a.ItemNo,
  28. a.FGPartNo,
  29. a.SOOrderNo,
  30. a.OpsItemNo,
  31. a.SeqNo,
  32. a.IssureQty,
  33. a.OutWorkOrderFlag,
  34. a.locationNo,
  35. a.needDate,
  36. b.OperationDesc itemDesc,
  37. a.aps_resource_total,
  38. a.not_yet_started_resource_total
  39. from SOIssueNotifyOrderList a
  40. left join sorouting b on a.site = b.site and a.SOOrderNo = b.OrderNo and b.ItemNo = a.OpsItemNo
  41. where a.site = #{site} and a.NotifyNo = #{notifyNo}
  42. </select>
  43. <select id="getSOScheduledRoutingListForIssure" resultType="SOScheduledRoutingEntity">
  44. select a.site,a.OrderNo orderno,a.ItemNo itemNo,b.OperationDesc itemDesc,a.seqno ,a.qtyrequired,a.qtyreported,a.remark,
  45. a.s_scheduleddate,a.S_ResourceID sResourceid,dbo.getResourceDesc(a.site,a.S_ResourceID) resourceDesc,a.S_ShiftNo sShiftno,
  46. dbo.getScheduleShiftDesc(a.site,a.s_shiftno) shiftDesc,a.s_workcenterno,s.PartNo partNo,
  47. c.WorkCenterDesc workCenterDesc,dbo.Get_PartDesc(a.site,s.PartNo) partDesc
  48. from SOScheduledRouting a
  49. left join ShopOrder s on a.site=s.site and a.OrderNo=s.OrderNo
  50. left join SORouting b on a.site=b.site and a.OrderNo=b.OrderNo and b.ItemNo=a.ItemNo
  51. left join workcenter c on a.site=c.site and a.S_WorkCenterNo=c.WorkCenterNo
  52. left join part d on a.site=d.site and d.PartNo=s.PartNo
  53. <where>
  54. and a.site=#{site}
  55. and d.bu_no=#{bu}
  56. and a.ClosedFlag='N'
  57. <if test="partNo != null and partNo != ''">
  58. and s.PartNo like '%' + #{partNo} + '%'
  59. </if>
  60. <if test="seqno != null and seqno != ''">
  61. and a.seqno like '%' + #{seqno} + '%'
  62. </if>
  63. <if test="orderno != null and orderno != ''">
  64. and a.OrderNo like '%' + #{orderno} + '%'
  65. </if>
  66. <if test="sShiftno != null and sShiftno != ''">
  67. and a.S_ShiftNo like '%' + #{sShiftno} + '%'
  68. </if>
  69. <if test="sResourceid != null and sResourceid != ''">
  70. and a.S_ResourceID like '%' + #{sResourceid} + '%'
  71. </if>
  72. <if test="sWorkcenterno != null and sWorkcenterno != ''">
  73. and a.s_workcenterno like '%' + #{sWorkcenterno} + '%'
  74. </if>
  75. <if test="startDate != null ">
  76. AND a.S_ScheduledDate >= #{startDate}
  77. </if>
  78. <if test="endDate != null ">
  79. AND #{endDate} >= a.S_ScheduledDate
  80. </if>
  81. </where>
  82. order by a.OrderNo
  83. </select>
  84. <select id="getSOScheduledRoutingListForIssureByPaging" parameterType="SOScheduledRoutingEntity" resultType="SOScheduledRoutingEntity">
  85. select a.site,a.OrderNo orderno,a.ItemNo itemNo,b.OperationDesc itemDesc,a.seqno ,a.qtyrequired,a.qtyreported,a.remark,
  86. a.s_scheduleddate,a.S_ResourceID sResourceid,dbo.getResourceDesc(a.site,a.S_ResourceID) resourceDesc,a.S_ShiftNo sShiftno,
  87. dbo.getScheduleShiftDesc(a.site,a.s_shiftno) shiftDesc,a.s_workcenterno,s.PartNo partNo,
  88. c.WorkCenterDesc workCenterDesc,dbo.Get_PartDesc(a.site,s.PartNo) partDesc,
  89. <!--(SELECT ROUND(SUM(issureQty),3) FROM SOIssueNotifyOrderList where Site = a.site and seqNo = a.seqno)--> 0 alreadyApplyTotal
  90. from SOScheduledRouting a
  91. left join ShopOrder s on a.site=s.site and a.OrderNo=s.OrderNo
  92. left join SORouting b on a.site=b.site and a.OrderNo=b.OrderNo and b.ItemNo=a.ItemNo
  93. left join workcenter c on a.site=c.site and a.S_WorkCenterNo=c.WorkCenterNo
  94. <where>
  95. and a.site=#{query.site}
  96. and s.bu_no=#{query.bu}
  97. and a.ClosedFlag='N'
  98. <if test="query.partNo != null and query.partNo != ''">
  99. and s.PartNo like '%' + #{query.partNo} + '%'
  100. </if>
  101. <if test="query.seqno != null and query.seqno != ''">
  102. and a.seqno like '%' + #{query.seqno} + '%'
  103. </if>
  104. <if test="query.orderno != null and query.orderno != ''">
  105. and a.OrderNo like '%' + #{query.orderno} + '%'
  106. </if>
  107. <if test="query.sShiftno != null and query.sShiftno != ''">
  108. and a.S_ShiftNo like '%' + #{query.sShiftno} + '%'
  109. </if>
  110. <if test="query.sResourceid != null and query.sResourceid != ''">
  111. and a.S_ResourceID like '%' + #{query.sResourceid} + '%'
  112. </if>
  113. <if test="query.sWorkcenterno != null and query.sWorkcenterno != ''">
  114. and a.s_workcenterno like '%' + #{query.sWorkcenterno} + '%'
  115. </if>
  116. <if test="query.startDate != null ">
  117. AND a.S_ScheduledDate >= #{query.startDate}
  118. </if>
  119. <if test="query.endDate != null ">
  120. AND #{query.endDate} >= a.S_ScheduledDate
  121. </if>
  122. </where>
  123. order by a.OrderNo
  124. </select>
  125. <select id="getSOSBOMForIssure" resultType="SOIssueNotifyOrderMaterialListData">
  126. select a.site,b.ItemNo,a.item_no_mat as BOMItemNo,a.component_partno as ComponentPartNo,
  127. round(a.qty_assembly*b.IssureQty,2) qty_required , round(a.qty_issue,2) qty_issue,c.QtyToIssue,#{notifyNo} as notifyNo
  128. ,dbo.Get_PartDesc(a.site,a.component_partno) partDesc,Round( dbo.get_MaterialOnUse(a.site,a.order_no,a.item_no,a.component_partno),3) qtyOnHand,
  129. round(sum(h.qty_on_hand),2) stockQty,c.remark
  130. from so_bom a
  131. left join SOIssueNotifyOrderList b on a.site=b.site and b.NotifyNo=#{notifyNo} and b.seqNo=#{seqno}
  132. left join SOIssueNotifyOrderMaterialList c on a.site=c.site and a.item_no_mat=c.BOMItemNo and c.NotifyNo=#{notifyNo} and c.itemNo=b.itemNo
  133. left join view_custdev_currentstock h on a.site=h.site and a.component_partno=h.part_no
  134. where a.site=#{site} and a.order_no=#{orderno} and a.item_no=#{itemno,jdbcType=DOUBLE} and a.control_mes='Y'
  135. group by a.site,b.ItemNo,a.item_no_mat,a.component_partno,a.qty_assembly,b.IssureQty,a.qty_issue,c.QtyToIssue,a.order_no,a.item_no,a.control_mes,c.remark
  136. </select>
  137. <select id="getSOSBOMInfo" resultType="SoBomData">
  138. select
  139. a.Site as site,
  140. a.ItemNo as itemNo,
  141. a.OrderNo as orderNo,
  142. a.ComponentPartNo as ComponentPartNo,
  143. round(a.QtyAssembly,3) as qtyAssembly,
  144. round(a.QtyRequired,3) as qtyRequired,
  145. round(a.QtyIssue,3) as qtyIssue,
  146. dbo.Get_PartDesc(a.Site,a.ComponentPartNo) as partDesc,
  147. a.Remark as remark,
  148. a.issue_method as issueMethod,
  149. a.outbound_warehouse_id as outboundWarehouseId
  150. from SOBOM a
  151. where a.Site = #{site} and a.OrderNo = #{orderno} and a.issue_method <![CDATA[<>]]> '入库倒冲'
  152. and a.ComponentPartNo is not null
  153. </select>
  154. <!-- and a.ItemNo=#{itemno,jdbcType=DOUBLE} -->
  155. <select id="searchOtherPart" resultType="SOIssueNotifyOrderMaterialListData">
  156. select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType
  157. ,dbo.Get_PartDesc(site,ComponentPartNo) partDesc,remark
  158. from SOIssueNotifyOrderMaterialList where NotifyNo=#{notifyNo} and site=#{site} and issueType=#{issueType}
  159. </select>
  160. <select id="getNextItemForSOIssueNotifyOrderList" resultType="Double">
  161. select isnull(max(ItemNo),0)+1 from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and 998>ItemNo
  162. </select>
  163. <insert id="saveSOIssueNotifyOrderList">
  164. insert into SOIssueNotifyOrderList(NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate, resourceId, aps_resource_total, not_yet_started_resource_total)
  165. values(#{notifyNo},#{site},#{itemNo},#{fGPartNo},#{sOOrderNo},#{opsItemNo},#{seqNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag}
  166. ,#{locationNo},#{needDate}, #{resourceId}, #{apsResourceTotal,jdbcType=INTEGER}, #{notYetStartedResourceTotal,jdbcType=INTEGER})
  167. </insert>
  168. <delete id="deleteSOIssueNotifyOrderMaterialListData">
  169. delete from SOIssueNotifyOrderMaterialList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo}
  170. </delete>
  171. <insert id="batchSaveSOIssueNotifyOrderMaterialListData">
  172. insert into SOIssueNotifyOrderMaterialList
  173. (NotifyNo, Site, ItemNo, BOMItemNo, ComponentPartNo, QtyToIssue, QtyToIssue_Original, issueType, remark, warehouse_id, standard_dosage)
  174. values
  175. <foreach collection="list" separator="," item="item">
  176. (#{item.notifyNo}, #{item.site}, #{item.itemNo}, #{item.bOMItemNo}, #{item.componentPartNo}, #{item.qtyToIssue}, 0, #{item.issueType}, #{item.remark}, #{item.warehouseId}, #{item.standardDosage,jdbcType=FLOAT})
  177. </foreach>
  178. </insert>
  179. <insert id="saveSOIssueNotifyOrderMaterialListData">
  180. insert into SOIssueNotifyOrderMaterialList
  181. (NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType,remark)
  182. values
  183. (#{notifyNo},#{site},#{itemNo},#{bOMItemNo},#{componentPartNo},#{qtyToIssue},0,#{issueType},#{remark})
  184. </insert>
  185. <delete id="deleteNotifySOS">
  186. delete from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo}
  187. </delete>
  188. <update id="xiadaNotifyHeader">
  189. update SOIssueNotifyHeader
  190. set PlanIssueDate = #{planIssueDate},
  191. status = '待出库'
  192. where site = #{site} and NotifyNo = #{notifyNo}
  193. </update>
  194. <update id="editNotifyMaterial">
  195. update SOIssueNotifyHeader
  196. set status = '编辑中'
  197. where site = #{site}
  198. and NotifyNo = #{notifyNo}
  199. </update>
  200. <delete id="deleteNotifyHeader">
  201. delete from SOIssueNotifyHeader where site=#{site} and NotifyNo=#{notifyNo}
  202. </delete>
  203. <select id="searchNotifyHeader" parameterType="SOIssueNotifyHeaderData" resultType="SOIssueNotifyHeaderData">
  204. select
  205. a.NotifyNo,
  206. a.Site,
  207. a.NotifyDate,
  208. a.UserName,
  209. a.EnteredDate,
  210. a.Receiver,
  211. a.DepartmentID,
  212. a.Remark,
  213. a.CreditFlag,
  214. a.IssueFlag,
  215. a.IssueResult,
  216. a.PlanIssueDate,
  217. a.RealIssueDate,
  218. a.Status,
  219. a.HaveIssueRecordFlag,
  220. a.CalcFlag,
  221. a.NeedApproveFlag,
  222. a.ApprovedFlag,
  223. a.Approver,
  224. a.ApproveDate,
  225. a.WarehouseID,
  226. a.RecordVersion,
  227. a.OutWorkOrderFlag,
  228. a.ProjectID,
  229. a.OrderType,
  230. a.AuthRuleID,
  231. (CASE WHEN a.confirm_status IS NULL THEN '未确认' ELSE a.confirm_status END) as confirm_status,
  232. dbo.plm_get_user_display(a.Site,a.UserName) userDisplay,
  233. a.confirm_user_id,
  234. a.confirm_username,
  235. a.confirm_user_display,
  236. a.confirm_date,
  237. a.bu,
  238. a.work_center_no,
  239. w.WorkCenterDesc as workCenterDesc
  240. from SOIssueNotifyHeader a
  241. left join workcenter w on a.site = w.site and a.bu = w.bu_no and a.work_center_no = w.WorkCenterNo
  242. <where>
  243. a.site in (select site from AccessSite where userID = #{query.loginUserName})
  244. and bu in (select bu_no from AccessBu where username = #{query.loginUserName})
  245. <if test="query.notifyNo != null and query.notifyNo != ''">
  246. AND a.NotifyNo = #{query.notifyNo}
  247. </if>
  248. <if test="query.status != null and query.status != ''">
  249. AND a.Status = #{query.status}
  250. </if>
  251. <if test="query.userName != null and query.userName != ''">
  252. AND a.UserName LIKE '%' + #{query.userName} + '%'
  253. </if>
  254. <if test="query.issueFlag != null and query.issueFlag != ''">
  255. AND a.issueFlag LIKE '%' + #{query.issueFlag} + '%'
  256. </if>
  257. <if test="query.issueResult != null and query.issueResult != ''">
  258. AND a.issueResult LIKE '%' + #{query.issueResult} + '%'
  259. </if>
  260. <if test="query.workCenterNoList != null and query.workCenterNoList.size() > 0">
  261. AND a.work_center_no IN
  262. <foreach collection="query.workCenterNoList" item="item" open="(" separator="," close=")">
  263. #{item}
  264. </foreach>
  265. </if>
  266. <if test="query.startDate != null">
  267. AND a.NotifyDate >= #{query.startDate}
  268. </if>
  269. <if test="query.endDate != null">
  270. AND DATEADD(DAY, 1, #{query.endDate}) >= a.NotifyDate
  271. </if>
  272. <if test="query.confirmStatus != null and query.confirmStatus != ''">
  273. <choose>
  274. <when test="query.confirmStatus == '未确认'">
  275. AND (a.confirm_status = #{query.confirmStatus} or a.confirm_status is null)
  276. </when>
  277. <otherwise>
  278. AND a.confirm_status = #{query.confirmStatus}
  279. </otherwise>
  280. </choose>
  281. </if>
  282. <if test="query.sql != null and query.sql != ''">
  283. ${query.sql}
  284. </if>
  285. </where>
  286. order by a.NotifyNo desc
  287. </select>
  288. <select id="searchNotifyOrderList" resultType="SOIssueNotifyOrderListData">
  289. select
  290. a.NotifyNo,
  291. a.Site,
  292. a.ItemNo,
  293. a.FGPartNo,
  294. a.SOOrderNo,
  295. a.OpsItemNo,
  296. a.SeqNo,
  297. a.IssureQty,
  298. a.OutWorkOrderFlag,
  299. b.OperationDesc itemDesc,
  300. a.locationNo,
  301. a.needDate,
  302. dbo.Get_PartDesc(a.site,a.FGPartNo) partDesc,
  303. a.resourceId,
  304. a.aps_resource_total,
  305. a.not_yet_started_resource_total
  306. from SOIssueNotifyOrderList a
  307. left join SORouting b on a.site=b.site and a.SOOrderNo=b.OrderNo and a.OpsItemNo=b.ItemNo
  308. where a.site=#{site} and a.NotifyNo=#{notifyNo}
  309. order by a.ItemNo
  310. </select>
  311. <select id="searchNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  312. select
  313. a.NotifyNo,
  314. a.Site,
  315. a.ItemNo,
  316. a.ComponentPartNo,
  317. a.QtyToIssue,
  318. a.QtyToIssue_Original,
  319. b.FGPartNo,
  320. b.OpsItemNo,
  321. b.SOOrderNo orderNo,
  322. b.SeqNo,
  323. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  324. b.locationNo,
  325. a.issueType,
  326. b.needDate,
  327. a.remark,
  328. isnull(c.issue_method,d.issue_method) issue_method,
  329. a.warehouse_id,
  330. W.WareHouseName AS warehouseName,
  331. a.BOMItemNo as bOMItemNo,
  332. a.component_scrap,
  333. a.first_inspection_qty,
  334. a.standard_dosage,
  335. d.UMID as umId,
  336. um.UMName as umName
  337. from SOIssueNotifyOrderMaterialList a
  338. left join SOIssueNotifyOrderList b on a.site = b.site and a.NotifyNo = b.NotifyNo and a.ItemNo = b.ItemNo
  339. left join SOBOM c on c.site = A.site and b.SOOrderNo = c.OrderNo and c.ItemNo = A.BOMItemNo and c.ComponentPartNo = a.ComponentPartNo
  340. left join part d on d.site = a.site and d.PartNo = a.ComponentPartNo
  341. left join um as um on d.site = um.site and d.UMID = um.UMID
  342. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  343. where a.NotifyNo = #{notifyNo} and a.site = #{site}
  344. order by b.needDate, a.ItemNo
  345. </select>
  346. <select id="searchSumNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  347. select
  348. a.site,
  349. b.bu,
  350. A.NotifyNo,
  351. a.ComponentPartNo,
  352. sum(a.QtyToIssue) QtyToIssue,
  353. sum(a.actual_out_qty) as QtyToIssue_Original,
  354. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  355. a.issueType,
  356. a.warehouse_id,
  357. W.WareHouseName AS warehouseName
  358. from SOIssueNotifyHeader B
  359. INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
  360. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
  361. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  362. where a.NotifyNo = #{notifyNo} and a.site = #{site} and b.bu = #{bu}
  363. group by a.site, a.ComponentPartNo, a.issueType , b.BU ,a.warehouse_id ,wareHouseName, A.NotifyNo
  364. order by a.issueType
  365. </select>
  366. <select id="getPartList" resultType="PartEntity" >
  367. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  368. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  369. <where>
  370. and P.site = #{site} and P.bu_no = #{sourceBu} AND s.Site IS NULL
  371. <if test="partNo != null and partNo != ''">
  372. AND P.PartNo LIKE '%'+ #{partNo} + '%'
  373. </if>
  374. <if test = "partDesc != null and partDesc != ''">
  375. AND P.PartDescription LIKE '%'+ #{partDesc}+ '%'
  376. </if>
  377. <if test = "spec != null and spec != ''">
  378. AND P.spec LIKE '%'+ #{spec}+ '%'
  379. </if>
  380. </where>
  381. </select>
  382. <select id="getPartListByPaging" resultType="PartEntity" >
  383. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  384. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  385. <where>
  386. and P.site = #{query.site} and P.bu_no = #{query.sourceBu} AND s.Site IS NULL
  387. <if test="query.partNo != null and query.partNo != ''">
  388. AND P.PartNo LIKE '%'+ #{query.partNo} + '%'
  389. </if>
  390. <if test = "query.partDesc != null and query.partDesc != ''">
  391. AND P.PartDescription LIKE '%'+ #{query.partDesc}+ '%'
  392. </if>
  393. <if test = "query.spec != null and query.spec != ''">
  394. AND P.spec LIKE '%'+ #{query.spec}+ '%'
  395. </if>
  396. </where>
  397. </select>
  398. <select id="getNoControlPartList" resultType="PartEntity" >
  399. select top 1000 part_no, PartDescription as part_desc, umid, spec, sku, cinv_source_code
  400. from part
  401. <where>
  402. and site = #{site} and sourceBu = #{sourceBu} and control_mes='N'
  403. <if test="partNo != null and partNo != ''">
  404. AND part_no LIKE '%'+ #{partNo} + '%'
  405. </if>
  406. <if test = "partDesc != null and partDesc != ''">
  407. AND PartDescription LIKE '%'+ #{partDesc}+ '%'
  408. </if>
  409. <if test = "spec != null and spec != ''">
  410. AND spec LIKE '%'+ #{spec}+ '%'
  411. </if>
  412. </where>
  413. </select>
  414. <select id="checkPartStock" resultType="SOIssueNotifyOrderMaterialListData" >
  415. select g.ComponentPartNo,g.QtyToIssue ,g.partDesc,sum(h.qty_on_hand) qty_on_hand,sum(h.qty_available) qty_available
  416. from
  417. (
  418. select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original,
  419. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.site
  420. from SOIssueNotifyOrderMaterialList a
  421. where a.NotifyNo=#{notifyNo} and a.site=#{site}
  422. group by a.site,a.ComponentPartNo
  423. ) g left join view_custdev_currentstock h on g.site=h.site and g.ComponentPartNo=h.part_no
  424. group by g.ComponentPartNo,g.QtyToIssue ,g.partDesc
  425. </select>
  426. <select id="checkDeleteOrderList" resultType="SOIssueNotifyOrderMaterialListData" >
  427. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  428. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  429. and ItemNo=#{itemNo,jdbcType=DOUBLE}
  430. </select>
  431. <update id="updateNotifyStatus" >
  432. update SOIssueNotifyHeader set status=#{status}
  433. where Site=#{site} and NotifyNo=#{notifyNo}
  434. </update>
  435. <select id="checkDeleteMaterial" resultType="SOIssueNotifyOrderMaterialListData">
  436. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType
  437. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  438. and ItemNo=#{itemNo}
  439. </select>
  440. <select id="deleteNotifyMaterial">
  441. delete from SOIssueNotifyOrderMaterialList
  442. where Site = #{site} and NotifyNo = #{notifyNo}
  443. and ItemNo = #{itemNo}
  444. </select>
  445. <delete id="deleteNotifyMaterial2">
  446. delete from SOIssueNotifyOrderMaterialList
  447. where Site=#{site} and NotifyNo=#{notifyNo}
  448. and BOMItemNo=#{bOMItemNo}
  449. </delete>
  450. <insert id="saveIssueNotifyChangeLog">
  451. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  452. values (#{site},#{notifyNo},#{itemNo},#{sOOrderNo},#{seqNo},#{componentPartNo},#{qtyToIssue,jdbcType=DOUBLE},#{updateType},#{updateBy},#{updateDate},#{issueType})
  453. </insert>
  454. <insert id="batchSaveIssueNotifyChangeLog">
  455. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  456. values
  457. <foreach collection="list" separator="," item="item">
  458. (#{item.site},#{item.notifyNo},#{item.itemNo},#{item.sOOrderNo},#{item.seqNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DOUBLE},#{item.updateType},#{item.updateBy},#{item.updateDate},#{item.issueType})
  459. </foreach>
  460. </insert>
  461. <select id="getSOIssueNotifyOrderListData" resultType="com.gaotao.modules.orderIssure.vo.SOIssueNotifyOrderList">
  462. select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate,aps_resource_total,not_yet_started_resource_total
  463. from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo}
  464. and ItemNo=#{itemNo}
  465. </select>
  466. <select id="checkOtherPart" resultType="SOIssueNotifyOrderMaterialListData">
  467. select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  468. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  469. and ComponentPartNo=#{componentPartNo}
  470. </select>
  471. <select id="getNextBomItemNo" resultType="String">
  472. SELECT #{str}+
  473. CONVERT(VARCHAR(50),isnull( max(CONVERT(int,SUBSTRING(BOMItemNo, LEN(#{str})+1, LEN(BOMItemNo)))+1),1))
  474. FROM SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  475. and BOMItemNo like #{str}+'%'
  476. </select>
  477. <select id="searchIssueNotifyChangeLog" resultType="com.gaotao.modules.orderIssure.vo.IssueNotifyChangeLog">
  478. select Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType
  479. from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo}
  480. </select>
  481. <select id="insertNotifyLogClose" >
  482. insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark)
  483. values (#{site},#{notifyNo},'关闭',#{username},GetDate(),#{closeRemark})
  484. </select>
  485. <!-- 获取下一个BOMItemNo -->
  486. <select id="getNextBOMItemNoForMateria" resultType="String">
  487. SELECT
  488. CASE
  489. WHEN MAX(BOMItemNo) IS NULL THEN '10'
  490. ELSE
  491. CASE
  492. WHEN ISNUMERIC(MAX(BOMItemNo)) = 1 THEN
  493. CAST(CAST(MAX(BOMItemNo) AS DECIMAL(10,0)) + 10 AS VARCHAR)
  494. ELSE '10'
  495. END
  496. END
  497. FROM SOIssueNotifyOrderMaterialList
  498. WHERE Site = #{site}
  499. AND NotifyNo = #{notifyNo}
  500. AND ItemNo = #{itemNo}
  501. AND ISNUMERIC(BOMItemNo) = 1
  502. </select>
  503. <!-- 保存申请单材料明细 -->
  504. <insert id="saveSOIssueNotifyOrderMateria">
  505. INSERT INTO SOIssueNotifyOrderMaterialList
  506. (NotifyNo, Site, ItemNo, BOMItemNo, ComponentPartNo, QtyToIssue, QtyToIssue_Original, issueType, remark, warehouse_id, component_scrap, first_inspection_qty, standard_dosage)
  507. VALUES
  508. (#{notifyNo}, #{site}, #{itemNo,jdbcType=FLOAT}, #{bOMItemNo}, #{componentPartNo}, #{qtyToIssue,jdbcType=FLOAT}, #{qtyToIssueOriginal,jdbcType=FLOAT}, #{issueType}, #{remark}, #{warehouseId}, #{componentScrap,jdbcType=FLOAT}, #{firstInspectionQty,jdbcType=FLOAT}, #{standardDosage,jdbcType=FLOAT})
  509. </insert>
  510. <select id="searchNotifyLogClose" resultType="SOIssueNotifyLogData">
  511. select id,Site,NotifyNo,[Action],username,ActionTime,ActionRemark ,dbo.plm_get_user_display(Site,username) userDisplay
  512. from SOIssueNotifyLog where site=#{site} and NotifyNo=#{notifyNo}
  513. order by id
  514. </select>
  515. <!-- 获取用户 bu -->
  516. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  517. SELECT
  518. a.site,
  519. a.bu_no,
  520. b.bu_desc
  521. FROM AccessBu as a
  522. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  523. WHERE a.username = #{username} and a.site = #{site}
  524. </select>
  525. <!-- 修改编码信息 -->
  526. <select id="updateTransNo" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  527. EXEC UpdateTransNo #{site}, #{transTypeDB}
  528. </select>
  529. <!-- 获取编码信息 -->
  530. <select id="getTransNo" resultType="com.gaotao.modules.pms.data.TransNoData" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  531. SELECT
  532. #{site} as site,
  533. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  534. </select>
  535. <select id="getEamWorkShop" resultType="com.gaotao.modules.orderIssure.vo.EamWorkShop">
  536. select WorkCenterNo WorkShopId,WorkCenterDesc WorkShopName from WorkCenter
  537. </select>
  538. <!-- 获取用户 bu -->
  539. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  540. SELECT
  541. b.id,
  542. a.site,
  543. c.sitename,
  544. (a.site + '_' + a.bu_no) as buNo,
  545. b.bu_desc
  546. FROM AccessBu as a
  547. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  548. left join site as c on a.site = c.siteid
  549. WHERE a.username = #{username}
  550. </select>
  551. <update id="updateNotifyDetail">
  552. UPDATE SOIssueNotifyOrderMaterialList
  553. SET QtyToIssue = #{qtyToIssue,jdbcType=DOUBLE},
  554. component_scrap = #{componentScrap,jdbcType=DOUBLE},
  555. first_inspection_qty = #{firstInspectionQty,jdbcType=DOUBLE},
  556. standard_dosage = #{standardDosage,jdbcType=DOUBLE}
  557. WHERE Site = #{site} and NotifyNo = #{notifyNo} and ItemNo = #{itemNo} and BOMItemNo = #{bOMItemNo}
  558. </update>
  559. <!-- 根据站点和物料编码查询物料信息 -->
  560. <select id="getPartBySiteAndPartNo" resultType="com.gaotao.modules.orderIssure.entity.PartEntity">
  561. SELECT
  562. PartNo as partNo,
  563. PartDescription as partDesc,
  564. Site as site,
  565. issue_method as issueMethod,
  566. outbound_warehouse_id as outboundWarehouseId
  567. FROM part
  568. WHERE Site = #{site} AND PartNo = #{partNo}
  569. </select>
  570. <!-- 查询BOM替代料列表 -->
  571. <select id="getBomAlternativeParts" resultType="com.gaotao.modules.orderIssure.entity.BomAlternativePartsData">
  572. SELECT DISTINCT
  573. <!-- A.FGPartNo as partNo, &#45;&#45; 母件编码-->
  574. <!-- DBO.Get_PartDesc(A.SITE, A.FGPartNo) AS partDesc, &#45;&#45; 母件名称-->
  575. <!-- C.component_part AS componentPartNo, &#45;&#45; 子件编码-->
  576. <!-- DBO.Get_PartDesc(A.SITE, C.component_part) AS componentPartDesc, &#45;&#45; 子件名称-->
  577. C.alternative_part_no AS alternativePartNo, -- 替代料编码
  578. DBO.Get_PartDesc(A.SITE, C.alternative_part_no) AS alternativePartDesc, -- 替代料名称
  579. C.replacement_ratio AS replacementRatio, -- 替代比例
  580. C.priority AS priority -- 优先级
  581. FROM SOIssueNotifyOrderList A
  582. INNER JOIN ShopOrder B ON A.SITE = B.SITE AND A.SOOrderNo = B.OrderNo
  583. INNER JOIN BomAlternativeParts C ON B.SITE = C.SITE AND B.PartNo = C.part_no AND B.BOMRevNo = C.bom_version
  584. WHERE A.site = #{site}
  585. AND A.NotifyNo = #{notifyNo}
  586. AND A.SOOrderNo = #{orderNo}
  587. AND C.component_part = #{componentPart}
  588. AND C.active = 'Y'
  589. ORDER BY C.priority
  590. </select>
  591. <select id="getWorkCenterList" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  592. select
  593. site,
  594. bu_no,
  595. WorkCenterNo,
  596. WorkCenterDesc
  597. from WorkCenter
  598. where site = #{site} and bu_no = #{buNo}
  599. </select>
  600. </mapper>