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.

734 lines
34 KiB

7 months ago
7 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
4 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
2 months ago
7 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, category)
  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}, #{category})
  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.category,
  220. r.crdname as categoryName,
  221. a.HaveIssueRecordFlag,
  222. a.CalcFlag,
  223. a.NeedApproveFlag,
  224. a.ApprovedFlag,
  225. a.Approver,
  226. a.ApproveDate,
  227. a.WarehouseID,
  228. a.RecordVersion,
  229. a.OutWorkOrderFlag,
  230. a.ProjectID,
  231. a.OrderType,
  232. a.AuthRuleID,
  233. (CASE WHEN a.confirm_status IS NULL THEN '未确认' ELSE a.confirm_status END) as confirm_status,
  234. dbo.plm_get_user_display(a.Site,a.UserName) userDisplay,
  235. a.confirm_user_id,
  236. a.confirm_username,
  237. a.confirm_user_display,
  238. a.confirm_date,
  239. a.bu,
  240. a.work_center_no,
  241. w.WorkCenterDesc as workCenterDesc
  242. from SOIssueNotifyHeader a
  243. left join workcenter w on a.site = w.site and a.bu = w.bu_no and a.work_center_no = w.WorkCenterNo
  244. left join Rdstyle r on a.category = r.crdcode and r.bRdFlag = '出'
  245. <where>
  246. a.site in (select site from AccessSite where userID = #{query.loginUserName})
  247. and bu in (select bu_no from AccessBu where username = #{query.loginUserName})
  248. <if test="query.notifyNo != null and query.notifyNo != ''">
  249. AND a.NotifyNo LIKE '%' + #{query.notifyNo} + '%'
  250. </if>
  251. <if test="query.status != null and query.status != ''">
  252. AND a.Status = #{query.status}
  253. </if>
  254. <if test="query.userName != null and query.userName != ''">
  255. AND a.UserName LIKE '%' + #{query.userName} + '%'
  256. </if>
  257. <if test="query.issueFlag != null and query.issueFlag != ''">
  258. AND a.issueFlag LIKE '%' + #{query.issueFlag} + '%'
  259. </if>
  260. <if test="query.issueResult != null and query.issueResult != ''">
  261. AND a.issueResult LIKE '%' + #{query.issueResult} + '%'
  262. </if>
  263. <if test="query.workCenterNoList != null and query.workCenterNoList.size() > 0">
  264. AND a.work_center_no IN
  265. <foreach collection="query.workCenterNoList" item="item" open="(" separator="," close=")">
  266. #{item}
  267. </foreach>
  268. </if>
  269. <if test="query.startDate != null">
  270. AND a.NotifyDate >= #{query.startDate}
  271. </if>
  272. <if test="query.endDate != null">
  273. AND DATEADD(DAY, 1, #{query.endDate}) >= a.NotifyDate
  274. </if>
  275. <if test="query.confirmStatus != null and query.confirmStatus != ''">
  276. <choose>
  277. <when test="query.confirmStatus == '未确认'">
  278. AND (a.confirm_status = #{query.confirmStatus} or a.confirm_status is null)
  279. </when>
  280. <otherwise>
  281. AND a.confirm_status = #{query.confirmStatus}
  282. </otherwise>
  283. </choose>
  284. </if>
  285. <if test="query.sql != null and query.sql != ''">
  286. ${query.sql}
  287. </if>
  288. </where>
  289. order by a.NotifyNo desc
  290. </select>
  291. <select id="searchNotifyOrderList" resultType="SOIssueNotifyOrderListData">
  292. select
  293. a.NotifyNo,
  294. a.Site,
  295. a.ItemNo,
  296. a.FGPartNo,
  297. a.SOOrderNo,
  298. a.OpsItemNo,
  299. a.SeqNo,
  300. a.IssureQty,
  301. a.OutWorkOrderFlag,
  302. b.OperationDesc itemDesc,
  303. a.locationNo,
  304. a.needDate,
  305. dbo.Get_PartDesc(a.site,a.FGPartNo) partDesc,
  306. a.resourceId,
  307. a.aps_resource_total,
  308. a.not_yet_started_resource_total,
  309. so.out_batchNo as outBatchNo
  310. from SOIssueNotifyOrderList a
  311. left join SORouting b on a.site=b.site and a.SOOrderNo=b.OrderNo and a.OpsItemNo=b.ItemNo
  312. left join ShopOrder so on a.site=so.site and a.SOOrderNo=so.OrderNo
  313. where a.site=#{site} and a.NotifyNo=#{notifyNo}
  314. order by a.ItemNo
  315. </select>
  316. <select id="searchNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  317. select
  318. a.NotifyNo,
  319. a.Site,
  320. a.ItemNo,
  321. a.ComponentPartNo,
  322. a.QtyToIssue,
  323. a.QtyToIssue_Original,
  324. b.FGPartNo,
  325. b.OpsItemNo,
  326. b.SOOrderNo orderNo,
  327. b.SeqNo,
  328. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  329. b.locationNo,
  330. a.issueType,
  331. b.needDate,
  332. a.remark,
  333. isnull(c.issue_method,d.issue_method) issue_method,
  334. a.warehouse_id,
  335. W.WareHouseName AS warehouseName,
  336. a.BOMItemNo as bOMItemNo,
  337. a.component_scrap,
  338. a.first_inspection_qty,
  339. a.standard_dosage,
  340. d.UMID as umId,
  341. um.UMName as umName
  342. from SOIssueNotifyOrderMaterialList a
  343. left join SOIssueNotifyOrderList b on a.site = b.site and a.NotifyNo = b.NotifyNo and a.ItemNo = b.ItemNo
  344. left join SOBOM c on c.site = A.site and b.SOOrderNo = c.OrderNo and c.ItemNo = A.BOMItemNo and c.ComponentPartNo = a.ComponentPartNo
  345. left join part d on d.site = a.site and d.PartNo = a.ComponentPartNo
  346. left join um as um on d.site = um.site and d.UMID = um.UMID
  347. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  348. where a.NotifyNo = #{notifyNo} and a.site = #{site}
  349. order by b.needDate, a.ItemNo
  350. </select>
  351. <select id="searchSumNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  352. select
  353. a.site,
  354. b.bu,
  355. A.NotifyNo,
  356. a.ComponentPartNo,
  357. sum(a.QtyToIssue) QtyToIssue,
  358. sum(a.actual_out_qty) as QtyToIssue_Original,
  359. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  360. a.issueType,
  361. a.warehouse_id,
  362. W.WareHouseName AS warehouseName
  363. from SOIssueNotifyHeader B
  364. INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
  365. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
  366. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  367. where a.NotifyNo = #{notifyNo} and a.site = #{site} and b.bu = #{bu}
  368. group by a.site, a.ComponentPartNo, a.issueType , b.BU ,a.warehouse_id ,wareHouseName, A.NotifyNo
  369. order by a.issueType
  370. </select>
  371. <select id="getPartList" resultType="PartEntity" >
  372. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  373. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  374. <where>
  375. and P.site = #{site} and P.bu_no = #{sourceBu} AND s.Site IS NULL
  376. <if test="partNo != null and partNo != ''">
  377. AND P.PartNo LIKE '%'+ #{partNo} + '%'
  378. </if>
  379. <if test = "partDesc != null and partDesc != ''">
  380. AND P.PartDescription LIKE '%'+ #{partDesc}+ '%'
  381. </if>
  382. <if test = "spec != null and spec != ''">
  383. AND P.spec LIKE '%'+ #{spec}+ '%'
  384. </if>
  385. </where>
  386. </select>
  387. <select id="getPartListByPaging" resultType="PartEntity" >
  388. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  389. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  390. <where>
  391. and P.site = #{query.site} and P.bu_no = #{query.sourceBu} AND s.Site IS NULL
  392. <if test="query.partNo != null and query.partNo != ''">
  393. AND P.PartNo LIKE '%'+ #{query.partNo} + '%'
  394. </if>
  395. <if test = "query.partDesc != null and query.partDesc != ''">
  396. AND P.PartDescription LIKE '%'+ #{query.partDesc}+ '%'
  397. </if>
  398. <if test = "query.spec != null and query.spec != ''">
  399. AND P.spec LIKE '%'+ #{query.spec}+ '%'
  400. </if>
  401. </where>
  402. </select>
  403. <select id="getNoControlPartList" resultType="PartEntity" >
  404. select top 1000 part_no, PartDescription as part_desc, umid, spec, sku, cinv_source_code
  405. from part
  406. <where>
  407. and site = #{site} and sourceBu = #{sourceBu} and control_mes='N'
  408. <if test="partNo != null and partNo != ''">
  409. AND part_no LIKE '%'+ #{partNo} + '%'
  410. </if>
  411. <if test = "partDesc != null and partDesc != ''">
  412. AND PartDescription LIKE '%'+ #{partDesc}+ '%'
  413. </if>
  414. <if test = "spec != null and spec != ''">
  415. AND spec LIKE '%'+ #{spec}+ '%'
  416. </if>
  417. </where>
  418. </select>
  419. <select id="checkPartStock" resultType="SOIssueNotifyOrderMaterialListData" >
  420. select g.ComponentPartNo,g.QtyToIssue ,g.partDesc,sum(h.qty_on_hand) qty_on_hand,sum(h.qty_available) qty_available
  421. from
  422. (
  423. select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original,
  424. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.site
  425. from SOIssueNotifyOrderMaterialList a
  426. where a.NotifyNo=#{notifyNo} and a.site=#{site}
  427. group by a.site,a.ComponentPartNo
  428. ) g left join view_custdev_currentstock h on g.site=h.site and g.ComponentPartNo=h.part_no
  429. group by g.ComponentPartNo,g.QtyToIssue ,g.partDesc
  430. </select>
  431. <select id="checkDeleteOrderList" resultType="SOIssueNotifyOrderMaterialListData" >
  432. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  433. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  434. and ItemNo=#{itemNo,jdbcType=DOUBLE}
  435. </select>
  436. <update id="updateNotifyStatus" >
  437. update SOIssueNotifyHeader set status = #{status}
  438. where Site = #{site} and NotifyNo = #{notifyNo}
  439. </update>
  440. <select id="checkDeleteMaterial" resultType="SOIssueNotifyOrderMaterialListData">
  441. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType
  442. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  443. and ItemNo=#{itemNo}
  444. </select>
  445. <select id="deleteNotifyMaterial">
  446. delete from SOIssueNotifyOrderMaterialList
  447. where Site = #{site} and NotifyNo = #{notifyNo}
  448. and ItemNo = #{itemNo}
  449. </select>
  450. <delete id="deleteNotifyMaterial2">
  451. delete from SOIssueNotifyOrderMaterialList
  452. where Site=#{site} and NotifyNo=#{notifyNo}
  453. and BOMItemNo=#{bOMItemNo}
  454. </delete>
  455. <insert id="saveIssueNotifyChangeLog">
  456. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  457. values (#{site},#{notifyNo},#{itemNo},#{sOOrderNo},#{seqNo},#{componentPartNo},#{qtyToIssue,jdbcType=DOUBLE},#{updateType},#{updateBy},#{updateDate},#{issueType})
  458. </insert>
  459. <insert id="batchSaveIssueNotifyChangeLog">
  460. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  461. values
  462. <foreach collection="list" separator="," item="item">
  463. (#{item.site},#{item.notifyNo},#{item.itemNo},#{item.sOOrderNo},#{item.seqNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DOUBLE},#{item.updateType},#{item.updateBy},#{item.updateDate},#{item.issueType})
  464. </foreach>
  465. </insert>
  466. <select id="getSOIssueNotifyOrderListData" resultType="com.gaotao.modules.orderIssure.vo.SOIssueNotifyOrderList">
  467. select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate,aps_resource_total,not_yet_started_resource_total
  468. from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo}
  469. and ItemNo=#{itemNo}
  470. </select>
  471. <select id="checkOtherPart" resultType="SOIssueNotifyOrderMaterialListData">
  472. select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  473. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  474. and ComponentPartNo=#{componentPartNo}
  475. </select>
  476. <select id="getNextBomItemNo" resultType="String">
  477. SELECT #{str}+
  478. CONVERT(VARCHAR(50),isnull( max(CONVERT(int,SUBSTRING(BOMItemNo, LEN(#{str})+1, LEN(BOMItemNo)))+1),1))
  479. FROM SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  480. and BOMItemNo like #{str}+'%'
  481. </select>
  482. <select id="searchIssueNotifyChangeLog" resultType="com.gaotao.modules.orderIssure.vo.IssueNotifyChangeLog">
  483. select Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType
  484. from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo}
  485. </select>
  486. <select id="insertNotifyLogClose" >
  487. insert into SOIssueNotifyLog (Site, NotifyNo, [Action], username, ActionTime, ActionRemark)
  488. values (#{site}, #{notifyNo}, '关闭', #{username}, GetDate(), #{closeRemark})
  489. </select>
  490. <!-- 获取下一个BOMItemNo -->
  491. <select id="getNextBOMItemNoForMateria" resultType="String">
  492. SELECT
  493. CASE
  494. WHEN MAX(BOMItemNo) IS NULL THEN '10'
  495. ELSE
  496. CASE
  497. WHEN ISNUMERIC(MAX(BOMItemNo)) = 1 THEN
  498. CAST(CAST(MAX(BOMItemNo) AS DECIMAL(10,0)) + 10 AS VARCHAR)
  499. ELSE '10'
  500. END
  501. END
  502. FROM SOIssueNotifyOrderMaterialList
  503. WHERE Site = #{site}
  504. AND NotifyNo = #{notifyNo}
  505. AND ItemNo = #{itemNo}
  506. AND ISNUMERIC(BOMItemNo) = 1
  507. </select>
  508. <!-- 保存申请单材料明细 -->
  509. <insert id="saveSOIssueNotifyOrderMateria">
  510. INSERT INTO SOIssueNotifyOrderMaterialList
  511. (NotifyNo, Site, ItemNo, BOMItemNo, ComponentPartNo, QtyToIssue, QtyToIssue_Original, issueType, remark, warehouse_id, component_scrap, first_inspection_qty, standard_dosage)
  512. VALUES
  513. (#{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})
  514. </insert>
  515. <select id="searchNotifyLogClose" resultType="SOIssueNotifyLogData">
  516. select id,Site,NotifyNo,[Action],username,ActionTime,ActionRemark ,dbo.plm_get_user_display(Site,username) userDisplay
  517. from SOIssueNotifyLog where site=#{site} and NotifyNo=#{notifyNo}
  518. order by id
  519. </select>
  520. <!-- 获取用户 bu -->
  521. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  522. SELECT
  523. a.site,
  524. a.bu_no,
  525. b.bu_desc
  526. FROM AccessBu as a
  527. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  528. WHERE a.username = #{username} and a.site = #{site}
  529. </select>
  530. <!-- 修改编码信息 -->
  531. <select id="updateTransNo" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  532. EXEC UpdateTransNo #{site}, #{transTypeDB}
  533. </select>
  534. <!-- 获取编码信息 -->
  535. <select id="getTransNo" resultType="com.gaotao.modules.pms.data.TransNoData" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  536. SELECT
  537. #{site} as site,
  538. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  539. </select>
  540. <select id="getEamWorkShop" resultType="com.gaotao.modules.orderIssure.vo.EamWorkShop">
  541. select WorkCenterNo WorkShopId,WorkCenterDesc WorkShopName from WorkCenter
  542. </select>
  543. <!-- 获取用户 bu -->
  544. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  545. SELECT
  546. b.id,
  547. a.site,
  548. c.sitename,
  549. (a.site + '_' + a.bu_no) as buNo,
  550. b.bu_desc
  551. FROM AccessBu as a
  552. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  553. left join site as c on a.site = c.siteid
  554. WHERE a.username = #{username}
  555. </select>
  556. <update id="updateNotifyDetail">
  557. UPDATE SOIssueNotifyOrderMaterialList
  558. SET QtyToIssue = #{qtyToIssue,jdbcType=DOUBLE},
  559. component_scrap = #{componentScrap,jdbcType=DOUBLE},
  560. first_inspection_qty = #{firstInspectionQty,jdbcType=DOUBLE},
  561. standard_dosage = #{standardDosage,jdbcType=DOUBLE},
  562. warehouse_id = #{warehouseId}
  563. WHERE Site = #{site} and NotifyNo = #{notifyNo} and ItemNo = #{itemNo} and BOMItemNo = #{bOMItemNo}
  564. </update>
  565. <!-- 根据站点和物料编码查询物料信息 -->
  566. <select id="getPartBySiteAndPartNo" resultType="com.gaotao.modules.orderIssure.entity.PartEntity">
  567. SELECT
  568. PartNo as partNo,
  569. PartDescription as partDesc,
  570. Site as site,
  571. issue_method as issueMethod,
  572. outbound_warehouse_id as outboundWarehouseId
  573. FROM part
  574. WHERE Site = #{site} AND PartNo = #{partNo}
  575. </select>
  576. <!-- 查询BOM替代料列表 -->
  577. <select id="getBomAlternativeParts" resultType="com.gaotao.modules.orderIssure.entity.BomAlternativePartsData">
  578. SELECT DISTINCT
  579. <!-- A.FGPartNo as partNo, &#45;&#45; 母件编码-->
  580. <!-- DBO.Get_PartDesc(A.SITE, A.FGPartNo) AS partDesc, &#45;&#45; 母件名称-->
  581. <!-- C.component_part AS componentPartNo, &#45;&#45; 子件编码-->
  582. <!-- DBO.Get_PartDesc(A.SITE, C.component_part) AS componentPartDesc, &#45;&#45; 子件名称-->
  583. C.alternative_part_no AS alternativePartNo, -- 替代料编码
  584. DBO.Get_PartDesc(A.SITE, C.alternative_part_no) AS alternativePartDesc, -- 替代料名称
  585. C.replacement_ratio AS replacementRatio, -- 替代比例
  586. C.priority AS priority -- 优先级
  587. FROM SOIssueNotifyOrderList A
  588. INNER JOIN ShopOrder B ON A.SITE = B.SITE AND A.SOOrderNo = B.OrderNo
  589. INNER JOIN BomAlternativeParts C ON B.SITE = C.SITE AND B.PartNo = C.part_no AND B.BOMRevNo = C.bom_version
  590. WHERE A.site = #{site}
  591. AND A.NotifyNo = #{notifyNo}
  592. AND A.SOOrderNo = #{orderNo}
  593. AND C.component_part = #{componentPart}
  594. AND C.active = 'Y'
  595. ORDER BY C.priority
  596. </select>
  597. <select id="getWorkCenterList" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  598. select
  599. site,
  600. bu_no,
  601. WorkCenterNo,
  602. WorkCenterDesc
  603. from WorkCenter
  604. where site in (select site from AccessSite where userID = #{username})
  605. and bu_no in (select bu_no from AccessBu where username = #{username})
  606. </select>
  607. <!-- 生产领料任务通知报表查询 -->
  608. <select id="searchIssueNotifyReport" parameterType="com.gaotao.modules.orderIssure.entity.IssueNotifyReportData" resultType="com.gaotao.modules.orderIssure.entity.IssueNotifyReportData">
  609. SELECT
  610. A.NotifyNo AS notifyNo,
  611. CONVERT(VARCHAR(10), A.NotifyDate, 23) AS notifyDate,
  612. A.Status AS status,
  613. B.SOOrderNo AS soOrderNo,
  614. C.BOMItemNo AS bomItemNo,
  615. C.ComponentPartNo AS componentPartNo,
  616. P.PartDescription AS partDescription,
  617. P.Spec AS spec,
  618. U.UMName AS umName,
  619. C.component_scrap AS componentScrap,
  620. C.first_inspection_qty AS firstInspectionQty,
  621. C.standard_dosage AS standardDosage,
  622. C.QtyToIssue AS qtyToIssue,
  623. ISNULL(C.actual_out_qty, 0) AS actualOutQty,
  624. A.work_center_no AS workCenterNo,
  625. so.out_batchNo AS outBatchNo,
  626. W.WareHouseName AS warehouseName,
  627. C.warehouse_id
  628. FROM SOIssueNotifyHeader A
  629. INNER JOIN SOIssueNotifyOrderList B ON A.Site = B.Site AND A.NotifyNo = B.NotifyNo
  630. LEFT JOIN ShopOrder so ON B.Site = so.Site AND B.SOOrderNo = so.OrderNo
  631. INNER JOIN SOIssueNotifyOrderMaterialList C ON B.Site = C.Site AND B.NotifyNo = C.NotifyNo AND B.ItemNo = C.ItemNo
  632. INNER JOIN Part P ON C.Site = P.Site AND C.ComponentPartNo = P.PartNo
  633. INNER JOIN UM U ON U.Site = P.Site AND U.UMID = P.UMID
  634. LEFT JOIN WareHouse W ON C.Site = W.Site AND C.warehouse_id = W.WareHouseID
  635. <where>
  636. A.site IN (SELECT site FROM AccessSite WHERE userID = #{query.userName})
  637. <if test="query.notifyNo != null and query.notifyNo != ''">
  638. AND A.NotifyNo LIKE '%' + #{query.notifyNo} + '%'
  639. </if>
  640. <if test="query.startDate != null and query.startDate != ''">
  641. AND A.NotifyDate >= #{query.startDate}
  642. </if>
  643. <if test="query.endDate != null and query.endDate != ''">
  644. AND A.NotifyDate &lt;= #{query.endDate} + ' 23:59:59'
  645. </if>
  646. <if test="query.status != null and query.status != ''">
  647. AND A.Status = #{query.status}
  648. </if>
  649. <if test="query.soOrderNo != null and query.soOrderNo != ''">
  650. AND B.SOOrderNo LIKE '%' + #{query.soOrderNo} + '%'
  651. </if>
  652. <if test="query.bomItemNo != null and query.bomItemNo != ''">
  653. AND C.BOMItemNo = #{query.bomItemNo}
  654. </if>
  655. <if test="query.componentPartNo != null and query.componentPartNo != ''">
  656. AND C.ComponentPartNo LIKE '%' + #{query.componentPartNo} + '%'
  657. </if>
  658. <if test="query.partDescription != null and query.partDescription != ''">
  659. AND P.PartDescription LIKE '%' + #{query.partDescription} + '%'
  660. </if>
  661. <if test="query.spec != null and query.spec != ''">
  662. AND P.Spec LIKE '%' + #{query.spec} + '%'
  663. </if>
  664. <if test="query.workCenterNoList != null and query.workCenterNoList.size() > 0">
  665. AND A.work_center_no IN
  666. <foreach collection="query.workCenterNoList" item="item" open="(" separator="," close=")">
  667. #{item}
  668. </foreach>
  669. </if>
  670. <if test="query.warehouseIdList != null and query.warehouseIdList.size() > 0">
  671. AND C.warehouse_id IN
  672. <foreach collection="query.warehouseIdList" item="item" open="(" separator="," close=")">
  673. #{item}
  674. </foreach>
  675. </if>
  676. </where>
  677. ORDER BY A.NotifyNo, B.SOOrderNo, C.BOMItemNo
  678. </select>
  679. </mapper>