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.

651 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}
  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. from SOIssueNotifyOrderMaterialList a
  336. left join SOIssueNotifyOrderList b on a.site = b.site and a.NotifyNo = b.NotifyNo and a.ItemNo = b.ItemNo
  337. left join SOBOM c on c.site = A.site and b.SOOrderNo = c.OrderNo and c.ItemNo = A.BOMItemNo and c.ComponentPartNo = a.ComponentPartNo
  338. left join part d on d.site = a.site and d.PartNo = a.ComponentPartNo
  339. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  340. where a.NotifyNo = #{notifyNo} and a.site = #{site}
  341. order by b.needDate, a.ItemNo
  342. </select>
  343. <select id="searchSumNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  344. select
  345. a.site,
  346. b.bu,
  347. A.NotifyNo,
  348. a.ComponentPartNo,
  349. sum(a.QtyToIssue) QtyToIssue,
  350. sum(a.actual_out_qty) as QtyToIssue_Original,
  351. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  352. a.issueType,
  353. a.warehouse_id,
  354. W.WareHouseName AS warehouseName
  355. from SOIssueNotifyHeader B
  356. INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
  357. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
  358. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  359. where a.NotifyNo = #{notifyNo} and a.site = #{site} and b.bu = #{bu}
  360. group by a.site, a.ComponentPartNo, a.issueType , b.BU ,a.warehouse_id ,wareHouseName, A.NotifyNo
  361. order by a.issueType
  362. </select>
  363. <select id="getPartList" resultType="PartEntity" >
  364. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  365. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  366. <where>
  367. and P.site = #{site} and P.bu_no = #{sourceBu} AND s.Site IS NULL
  368. <if test="partNo != null and partNo != ''">
  369. AND P.PartNo LIKE '%'+ #{partNo} + '%'
  370. </if>
  371. <if test = "partDesc != null and partDesc != ''">
  372. AND P.PartDescription LIKE '%'+ #{partDesc}+ '%'
  373. </if>
  374. <if test = "spec != null and spec != ''">
  375. AND P.spec LIKE '%'+ #{spec}+ '%'
  376. </if>
  377. </where>
  378. </select>
  379. <select id="getPartListByPaging" resultType="PartEntity" >
  380. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  381. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  382. <where>
  383. and P.site = #{query.site} and P.bu_no = #{query.sourceBu} AND s.Site IS NULL
  384. <if test="query.partNo != null and query.partNo != ''">
  385. AND P.PartNo LIKE '%'+ #{query.partNo} + '%'
  386. </if>
  387. <if test = "query.partDesc != null and query.partDesc != ''">
  388. AND P.PartDescription LIKE '%'+ #{query.partDesc}+ '%'
  389. </if>
  390. <if test = "query.spec != null and query.spec != ''">
  391. AND P.spec LIKE '%'+ #{query.spec}+ '%'
  392. </if>
  393. </where>
  394. </select>
  395. <select id="getNoControlPartList" resultType="PartEntity" >
  396. select top 1000 part_no, PartDescription as part_desc, umid, spec, sku, cinv_source_code
  397. from part
  398. <where>
  399. and site = #{site} and sourceBu = #{sourceBu} and control_mes='N'
  400. <if test="partNo != null and partNo != ''">
  401. AND part_no LIKE '%'+ #{partNo} + '%'
  402. </if>
  403. <if test = "partDesc != null and partDesc != ''">
  404. AND PartDescription LIKE '%'+ #{partDesc}+ '%'
  405. </if>
  406. <if test = "spec != null and spec != ''">
  407. AND spec LIKE '%'+ #{spec}+ '%'
  408. </if>
  409. </where>
  410. </select>
  411. <select id="checkPartStock" resultType="SOIssueNotifyOrderMaterialListData" >
  412. select g.ComponentPartNo,g.QtyToIssue ,g.partDesc,sum(h.qty_on_hand) qty_on_hand,sum(h.qty_available) qty_available
  413. from
  414. (
  415. select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original,
  416. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.site
  417. from SOIssueNotifyOrderMaterialList a
  418. where a.NotifyNo=#{notifyNo} and a.site=#{site}
  419. group by a.site,a.ComponentPartNo
  420. ) g left join view_custdev_currentstock h on g.site=h.site and g.ComponentPartNo=h.part_no
  421. group by g.ComponentPartNo,g.QtyToIssue ,g.partDesc
  422. </select>
  423. <select id="checkDeleteOrderList" resultType="SOIssueNotifyOrderMaterialListData" >
  424. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  425. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  426. and ItemNo=#{itemNo,jdbcType=DOUBLE}
  427. </select>
  428. <update id="updateNotifyStatus" >
  429. update SOIssueNotifyHeader set status=#{status}
  430. where Site=#{site} and NotifyNo=#{notifyNo}
  431. </update>
  432. <select id="checkDeleteMaterial" resultType="SOIssueNotifyOrderMaterialListData">
  433. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType
  434. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  435. and ItemNo=#{itemNo}
  436. </select>
  437. <select id="deleteNotifyMaterial">
  438. delete from SOIssueNotifyOrderMaterialList
  439. where Site = #{site} and NotifyNo = #{notifyNo}
  440. and ItemNo = #{itemNo}
  441. </select>
  442. <delete id="deleteNotifyMaterial2">
  443. delete from SOIssueNotifyOrderMaterialList
  444. where Site=#{site} and NotifyNo=#{notifyNo}
  445. and BOMItemNo=#{bOMItemNo}
  446. </delete>
  447. <insert id="saveIssueNotifyChangeLog">
  448. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  449. values (#{site},#{notifyNo},#{itemNo},#{sOOrderNo},#{seqNo},#{componentPartNo},#{qtyToIssue,jdbcType=DOUBLE},#{updateType},#{updateBy},#{updateDate},#{issueType})
  450. </insert>
  451. <insert id="batchSaveIssueNotifyChangeLog">
  452. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  453. values
  454. <foreach collection="list" separator="," item="item">
  455. (#{item.site},#{item.notifyNo},#{item.itemNo},#{item.sOOrderNo},#{item.seqNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DOUBLE},#{item.updateType},#{item.updateBy},#{item.updateDate},#{item.issueType})
  456. </foreach>
  457. </insert>
  458. <select id="getSOIssueNotifyOrderListData" resultType="com.gaotao.modules.orderIssure.vo.SOIssueNotifyOrderList">
  459. select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate,aps_resource_total,not_yet_started_resource_total
  460. from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo}
  461. and ItemNo=#{itemNo}
  462. </select>
  463. <select id="checkOtherPart" resultType="SOIssueNotifyOrderMaterialListData">
  464. select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  465. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  466. and ComponentPartNo=#{componentPartNo}
  467. </select>
  468. <select id="getNextBomItemNo" resultType="String">
  469. SELECT #{str}+
  470. CONVERT(VARCHAR(50),isnull( max(CONVERT(int,SUBSTRING(BOMItemNo, LEN(#{str})+1, LEN(BOMItemNo)))+1),1))
  471. FROM SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  472. and BOMItemNo like #{str}+'%'
  473. </select>
  474. <select id="searchIssueNotifyChangeLog" resultType="com.gaotao.modules.orderIssure.vo.IssueNotifyChangeLog">
  475. select Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType
  476. from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo}
  477. </select>
  478. <select id="insertNotifyLogClose" >
  479. insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark)
  480. values (#{site},#{notifyNo},'关闭',#{username},GetDate(),#{closeRemark})
  481. </select>
  482. <!-- 获取下一个BOMItemNo -->
  483. <select id="getNextBOMItemNoForMateria" resultType="String">
  484. SELECT
  485. CASE
  486. WHEN MAX(BOMItemNo) IS NULL THEN '10'
  487. ELSE
  488. CASE
  489. WHEN ISNUMERIC(MAX(BOMItemNo)) = 1 THEN
  490. CAST(CAST(MAX(BOMItemNo) AS DECIMAL(10,0)) + 10 AS VARCHAR)
  491. ELSE '10'
  492. END
  493. END
  494. FROM SOIssueNotifyOrderMaterialList
  495. WHERE Site = #{site}
  496. AND NotifyNo = #{notifyNo}
  497. AND ItemNo = #{itemNo}
  498. AND ISNUMERIC(BOMItemNo) = 1
  499. </select>
  500. <!-- 保存申请单材料明细 -->
  501. <insert id="saveSOIssueNotifyOrderMateria">
  502. INSERT INTO SOIssueNotifyOrderMaterialList
  503. (NotifyNo, Site, ItemNo, BOMItemNo, ComponentPartNo, QtyToIssue, QtyToIssue_Original, issueType, remark, warehouse_id, component_scrap, first_inspection_qty, standard_dosage)
  504. VALUES
  505. (#{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})
  506. </insert>
  507. <select id="searchNotifyLogClose" resultType="SOIssueNotifyLogData">
  508. select id,Site,NotifyNo,[Action],username,ActionTime,ActionRemark ,dbo.plm_get_user_display(Site,username) userDisplay
  509. from SOIssueNotifyLog where site=#{site} and NotifyNo=#{notifyNo}
  510. order by id
  511. </select>
  512. <!-- 获取用户 bu -->
  513. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  514. SELECT
  515. a.site,
  516. a.bu_no,
  517. b.bu_desc
  518. FROM AccessBu as a
  519. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  520. WHERE a.username = #{username} and a.site = #{site}
  521. </select>
  522. <!-- 修改编码信息 -->
  523. <select id="updateTransNo" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  524. EXEC UpdateTransNo #{site}, #{transTypeDB}
  525. </select>
  526. <!-- 获取编码信息 -->
  527. <select id="getTransNo" resultType="com.gaotao.modules.pms.data.TransNoData" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  528. SELECT
  529. #{site} as site,
  530. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  531. </select>
  532. <select id="getEamWorkShop" resultType="com.gaotao.modules.orderIssure.vo.EamWorkShop">
  533. select WorkCenterNo WorkShopId,WorkCenterDesc WorkShopName from WorkCenter
  534. </select>
  535. <!-- 获取用户 bu -->
  536. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  537. SELECT
  538. b.id,
  539. a.site,
  540. c.sitename,
  541. (a.site + '_' + a.bu_no) as buNo,
  542. b.bu_desc
  543. FROM AccessBu as a
  544. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  545. left join site as c on a.site = c.siteid
  546. WHERE a.username = #{username}
  547. </select>
  548. <update id="updateNotifyDetail">
  549. UPDATE SOIssueNotifyOrderMaterialList
  550. SET QtyToIssue = #{qtyToIssue,jdbcType=DOUBLE},
  551. component_scrap = #{componentScrap,jdbcType=DOUBLE},
  552. first_inspection_qty = #{firstInspectionQty,jdbcType=DOUBLE},
  553. standard_dosage = #{standardDosage,jdbcType=DOUBLE}
  554. WHERE Site = #{site} and NotifyNo = #{notifyNo} and ItemNo = #{itemNo} and BOMItemNo = #{bOMItemNo}
  555. </update>
  556. <!-- 根据站点和物料编码查询物料信息 -->
  557. <select id="getPartBySiteAndPartNo" resultType="com.gaotao.modules.orderIssure.entity.PartEntity">
  558. SELECT
  559. PartNo as partNo,
  560. PartDescription as partDesc,
  561. Site as site,
  562. issue_method as issueMethod,
  563. outbound_warehouse_id as outboundWarehouseId
  564. FROM part
  565. WHERE Site = #{site} AND PartNo = #{partNo}
  566. </select>
  567. <!-- 查询BOM替代料列表 -->
  568. <select id="getBomAlternativeParts" resultType="com.gaotao.modules.orderIssure.entity.BomAlternativePartsData">
  569. SELECT DISTINCT
  570. <!-- A.FGPartNo as partNo, &#45;&#45; 母件编码-->
  571. <!-- DBO.Get_PartDesc(A.SITE, A.FGPartNo) AS partDesc, &#45;&#45; 母件名称-->
  572. <!-- C.component_part AS componentPartNo, &#45;&#45; 子件编码-->
  573. <!-- DBO.Get_PartDesc(A.SITE, C.component_part) AS componentPartDesc, &#45;&#45; 子件名称-->
  574. C.alternative_part_no AS alternativePartNo, -- 替代料编码
  575. DBO.Get_PartDesc(A.SITE, C.alternative_part_no) AS alternativePartDesc, -- 替代料名称
  576. C.replacement_ratio AS replacementRatio, -- 替代比例
  577. C.priority AS priority -- 优先级
  578. FROM SOIssueNotifyOrderList A
  579. INNER JOIN ShopOrder B ON A.SITE = B.SITE AND A.SOOrderNo = B.OrderNo
  580. INNER JOIN BomAlternativeParts C ON B.SITE = C.SITE AND B.PartNo = C.part_no AND B.BOMRevNo = C.bom_version
  581. WHERE A.site = #{site}
  582. AND A.NotifyNo = #{notifyNo}
  583. AND A.SOOrderNo = #{orderNo}
  584. AND C.component_part = #{componentPart}
  585. AND C.active = 'Y'
  586. ORDER BY C.priority
  587. </select>
  588. <select id="getWorkCenterList" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  589. select
  590. site,
  591. bu_no,
  592. WorkCenterNo,
  593. WorkCenterDesc
  594. from WorkCenter
  595. where site = #{site} and bu_no = #{buNo}
  596. </select>
  597. </mapper>