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.

742 lines
35 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. d.spec,
  342. um.UMName as umName,
  343. a.show_flag
  344. from SOIssueNotifyOrderMaterialList a
  345. left join SOIssueNotifyOrderList b on a.site = b.site and a.NotifyNo = b.NotifyNo and a.ItemNo = b.ItemNo
  346. left join SOBOM c on c.site = A.site and b.SOOrderNo = c.OrderNo and c.ItemNo = A.BOMItemNo and c.ComponentPartNo = a.ComponentPartNo
  347. left join part d on d.site = a.site and d.PartNo = a.ComponentPartNo
  348. left join um as um on d.site = um.site and d.UMID = um.UMID
  349. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  350. where a.NotifyNo = #{notifyNo} and a.site = #{site}
  351. order by b.needDate, a.ItemNo
  352. </select>
  353. <select id="searchSumNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData">
  354. select
  355. a.site,
  356. b.bu,
  357. A.NotifyNo,
  358. a.ComponentPartNo,
  359. sum(a.QtyToIssue) QtyToIssue,
  360. sum(a.actual_out_qty) as QtyToIssue_Original,
  361. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,
  362. a.issueType,
  363. a.warehouse_id,
  364. W.WareHouseName AS warehouseName
  365. from SOIssueNotifyHeader B
  366. INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
  367. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
  368. left join WareHouse w on a.site = w.site and a.warehouse_id = w.WareHouseID
  369. where a.NotifyNo = #{notifyNo} and a.site = #{site} and b.bu = #{bu}
  370. group by a.site, a.ComponentPartNo, a.issueType , b.BU ,a.warehouse_id ,wareHouseName, A.NotifyNo
  371. order by a.issueType
  372. </select>
  373. <select id="getPartList" resultType="PartEntity" >
  374. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  375. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  376. <where>
  377. and P.site = #{site} and P.bu_no = #{sourceBu} AND s.Site IS NULL
  378. <if test="partNo != null and partNo != ''">
  379. AND P.PartNo LIKE '%'+ #{partNo} + '%'
  380. </if>
  381. <if test = "partDesc != null and partDesc != ''">
  382. AND P.PartDescription LIKE '%'+ #{partDesc}+ '%'
  383. </if>
  384. <if test = "spec != null and spec != ''">
  385. AND P.spec LIKE '%'+ #{spec}+ '%'
  386. </if>
  387. </where>
  388. </select>
  389. <select id="getPartListByPaging" resultType="PartEntity" >
  390. select P.PartNo partNo,P.PartDescription partDesc,P.umid,P.spec,P.sku from part P
  391. LEFT JOIN SOBOM s on P.site = s.site and P.PartNo = s.ComponentPartNo
  392. <where>
  393. and P.site = #{query.site} and P.bu_no = #{query.sourceBu} AND s.Site IS NULL
  394. <if test="query.partNo != null and query.partNo != ''">
  395. AND P.PartNo LIKE '%'+ #{query.partNo} + '%'
  396. </if>
  397. <if test = "query.partDesc != null and query.partDesc != ''">
  398. AND P.PartDescription LIKE '%'+ #{query.partDesc}+ '%'
  399. </if>
  400. <if test = "query.spec != null and query.spec != ''">
  401. AND P.spec LIKE '%'+ #{query.spec}+ '%'
  402. </if>
  403. </where>
  404. </select>
  405. <select id="getNoControlPartList" resultType="PartEntity" >
  406. select top 1000 part_no, PartDescription as part_desc, umid, spec, sku, cinv_source_code
  407. from part
  408. <where>
  409. and site = #{site} and sourceBu = #{sourceBu} and control_mes='N'
  410. <if test="partNo != null and partNo != ''">
  411. AND part_no LIKE '%'+ #{partNo} + '%'
  412. </if>
  413. <if test = "partDesc != null and partDesc != ''">
  414. AND PartDescription LIKE '%'+ #{partDesc}+ '%'
  415. </if>
  416. <if test = "spec != null and spec != ''">
  417. AND spec LIKE '%'+ #{spec}+ '%'
  418. </if>
  419. </where>
  420. </select>
  421. <select id="checkPartStock" resultType="SOIssueNotifyOrderMaterialListData" >
  422. select g.ComponentPartNo,g.QtyToIssue ,g.partDesc,sum(h.qty_on_hand) qty_on_hand,sum(h.qty_available) qty_available
  423. from
  424. (
  425. select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original,
  426. dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.site
  427. from SOIssueNotifyOrderMaterialList a
  428. where a.NotifyNo=#{notifyNo} and a.site=#{site}
  429. group by a.site,a.ComponentPartNo
  430. ) g left join view_custdev_currentstock h on g.site=h.site and g.ComponentPartNo=h.part_no
  431. group by g.ComponentPartNo,g.QtyToIssue ,g.partDesc
  432. </select>
  433. <select id="checkDeleteOrderList" resultType="SOIssueNotifyOrderMaterialListData" >
  434. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  435. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  436. and ItemNo=#{itemNo,jdbcType=DOUBLE}
  437. </select>
  438. <update id="updateNotifyStatus" >
  439. update SOIssueNotifyHeader set status = #{status}
  440. where Site = #{site} and NotifyNo = #{notifyNo}
  441. </update>
  442. <select id="checkDeleteMaterial" resultType="SOIssueNotifyOrderMaterialListData">
  443. select NotifyNo,Site,ItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType
  444. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  445. and ItemNo=#{itemNo}
  446. </select>
  447. <select id="deleteNotifyMaterial">
  448. delete from SOIssueNotifyOrderMaterialList
  449. where Site = #{site} and NotifyNo = #{notifyNo}
  450. and ItemNo = #{itemNo}
  451. </select>
  452. <delete id="deleteNotifyMaterial2">
  453. delete from SOIssueNotifyOrderMaterialList
  454. where Site=#{site} and NotifyNo=#{notifyNo}
  455. and BOMItemNo=#{bOMItemNo}
  456. </delete>
  457. <update id="updateMaterialShowFlag">
  458. UPDATE SOIssueNotifyOrderMaterialList
  459. SET show_flag = #{showFlag}
  460. WHERE Site = #{site} AND NotifyNo = #{notifyNo} AND BOMItemNo = #{bOMItemNo}
  461. </update>
  462. <insert id="saveIssueNotifyChangeLog">
  463. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  464. values (#{site},#{notifyNo},#{itemNo},#{sOOrderNo},#{seqNo},#{componentPartNo},#{qtyToIssue,jdbcType=DOUBLE},#{updateType},#{updateBy},#{updateDate},#{issueType})
  465. </insert>
  466. <insert id="batchSaveIssueNotifyChangeLog">
  467. insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType)
  468. values
  469. <foreach collection="list" separator="," item="item">
  470. (#{item.site},#{item.notifyNo},#{item.itemNo},#{item.sOOrderNo},#{item.seqNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DOUBLE},#{item.updateType},#{item.updateBy},#{item.updateDate},#{item.issueType})
  471. </foreach>
  472. </insert>
  473. <select id="getSOIssueNotifyOrderListData" resultType="com.gaotao.modules.orderIssure.vo.SOIssueNotifyOrderList">
  474. select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate,aps_resource_total,not_yet_started_resource_total
  475. from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo}
  476. and ItemNo=#{itemNo}
  477. </select>
  478. <select id="checkOtherPart" resultType="SOIssueNotifyOrderMaterialListData">
  479. select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
  480. from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  481. and ComponentPartNo=#{componentPartNo}
  482. </select>
  483. <select id="getNextBomItemNo" resultType="String">
  484. SELECT #{str}+
  485. CONVERT(VARCHAR(50),isnull( max(CONVERT(int,SUBSTRING(BOMItemNo, LEN(#{str})+1, LEN(BOMItemNo)))+1),1))
  486. FROM SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
  487. and BOMItemNo like #{str}+'%'
  488. </select>
  489. <select id="searchIssueNotifyChangeLog" resultType="com.gaotao.modules.orderIssure.vo.IssueNotifyChangeLog">
  490. select Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType
  491. from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo}
  492. </select>
  493. <select id="insertNotifyLogClose" >
  494. insert into SOIssueNotifyLog (Site, NotifyNo, [Action], username, ActionTime, ActionRemark)
  495. values (#{site}, #{notifyNo}, '关闭', #{username}, GetDate(), #{closeRemark})
  496. </select>
  497. <!-- 获取下一个BOMItemNo -->
  498. <select id="getNextBOMItemNoForMateria" resultType="String">
  499. SELECT
  500. CASE
  501. WHEN MAX(BOMItemNo) IS NULL THEN '10'
  502. ELSE
  503. CASE
  504. WHEN ISNUMERIC(MAX(BOMItemNo)) = 1 THEN
  505. CAST(CAST(MAX(BOMItemNo) AS DECIMAL(10,0)) + 10 AS VARCHAR)
  506. ELSE '10'
  507. END
  508. END
  509. FROM SOIssueNotifyOrderMaterialList
  510. WHERE Site = #{site}
  511. AND NotifyNo = #{notifyNo}
  512. AND ItemNo = #{itemNo}
  513. AND ISNUMERIC(BOMItemNo) = 1
  514. </select>
  515. <!-- 保存申请单材料明细 -->
  516. <insert id="saveSOIssueNotifyOrderMateria">
  517. INSERT INTO SOIssueNotifyOrderMaterialList
  518. (NotifyNo, Site, ItemNo, BOMItemNo, ComponentPartNo, QtyToIssue, QtyToIssue_Original, issueType, remark, warehouse_id, component_scrap, first_inspection_qty, standard_dosage)
  519. VALUES
  520. (#{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})
  521. </insert>
  522. <select id="searchNotifyLogClose" resultType="SOIssueNotifyLogData">
  523. select id,Site,NotifyNo,[Action],username,ActionTime,ActionRemark ,dbo.plm_get_user_display(Site,username) userDisplay
  524. from SOIssueNotifyLog where site=#{site} and NotifyNo=#{notifyNo}
  525. order by id
  526. </select>
  527. <!-- 获取用户 bu -->
  528. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  529. SELECT
  530. a.site,
  531. a.bu_no,
  532. b.bu_desc
  533. FROM AccessBu as a
  534. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  535. WHERE a.username = #{username} and a.site = #{site}
  536. </select>
  537. <!-- 修改编码信息 -->
  538. <select id="updateTransNo" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  539. EXEC UpdateTransNo #{site}, #{transTypeDB}
  540. </select>
  541. <!-- 获取编码信息 -->
  542. <select id="getTransNo" resultType="com.gaotao.modules.pms.data.TransNoData" parameterType="com.gaotao.modules.orderIssure.entity.PartSpareData">
  543. SELECT
  544. #{site} as site,
  545. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  546. </select>
  547. <select id="getEamWorkShop" resultType="com.gaotao.modules.orderIssure.vo.EamWorkShop">
  548. select WorkCenterNo WorkShopId,WorkCenterDesc WorkShopName from WorkCenter
  549. </select>
  550. <!-- 获取用户 bu -->
  551. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  552. SELECT
  553. b.id,
  554. a.site,
  555. c.sitename,
  556. (a.site + '_' + a.bu_no) as buNo,
  557. b.bu_desc
  558. FROM AccessBu as a
  559. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  560. left join site as c on a.site = c.siteid
  561. WHERE a.username = #{username}
  562. </select>
  563. <update id="updateNotifyDetail">
  564. UPDATE SOIssueNotifyOrderMaterialList
  565. SET QtyToIssue = #{qtyToIssue,jdbcType=DOUBLE},
  566. component_scrap = #{componentScrap,jdbcType=DOUBLE},
  567. first_inspection_qty = #{firstInspectionQty,jdbcType=DOUBLE},
  568. standard_dosage = #{standardDosage,jdbcType=DOUBLE},
  569. warehouse_id = #{warehouseId}
  570. WHERE Site = #{site} and NotifyNo = #{notifyNo} and ItemNo = #{itemNo} and BOMItemNo = #{bOMItemNo}
  571. </update>
  572. <!-- 根据站点和物料编码查询物料信息 -->
  573. <select id="getPartBySiteAndPartNo" resultType="com.gaotao.modules.orderIssure.entity.PartEntity">
  574. SELECT
  575. PartNo as partNo,
  576. PartDescription as partDesc,
  577. Site as site,
  578. issue_method as issueMethod,
  579. outbound_warehouse_id as outboundWarehouseId
  580. FROM part
  581. WHERE Site = #{site} AND PartNo = #{partNo}
  582. </select>
  583. <!-- 查询BOM替代料列表 -->
  584. <select id="getBomAlternativeParts" resultType="com.gaotao.modules.orderIssure.entity.BomAlternativePartsData">
  585. SELECT DISTINCT
  586. <!-- A.FGPartNo as partNo, &#45;&#45; 母件编码-->
  587. <!-- DBO.Get_PartDesc(A.SITE, A.FGPartNo) AS partDesc, &#45;&#45; 母件名称-->
  588. <!-- C.component_part AS componentPartNo, &#45;&#45; 子件编码-->
  589. <!-- DBO.Get_PartDesc(A.SITE, C.component_part) AS componentPartDesc, &#45;&#45; 子件名称-->
  590. C.alternative_part_no AS alternativePartNo, -- 替代料编码
  591. DBO.Get_PartDesc(A.SITE, C.alternative_part_no) AS alternativePartDesc, -- 替代料名称
  592. C.replacement_ratio AS replacementRatio, -- 替代比例
  593. C.priority AS priority -- 优先级
  594. FROM SOIssueNotifyOrderList A
  595. INNER JOIN ShopOrder B ON A.SITE = B.SITE AND A.SOOrderNo = B.OrderNo
  596. INNER JOIN BomAlternativeParts C ON B.SITE = C.SITE AND B.PartNo = C.part_no AND B.BOMRevNo = C.bom_version
  597. WHERE A.site = #{site}
  598. AND A.NotifyNo = #{notifyNo}
  599. AND A.SOOrderNo = #{orderNo}
  600. AND C.component_part = #{componentPart}
  601. AND C.active = 'Y'
  602. ORDER BY C.priority
  603. </select>
  604. <select id="getWorkCenterList" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  605. select
  606. site,
  607. bu_no,
  608. WorkCenterNo,
  609. WorkCenterDesc
  610. from WorkCenter
  611. where site in (select site from AccessSite where userID = #{username})
  612. and bu_no in (select bu_no from AccessBu where username = #{username})
  613. </select>
  614. <!-- 生产领料任务通知报表查询 -->
  615. <select id="searchIssueNotifyReport" parameterType="com.gaotao.modules.orderIssure.entity.IssueNotifyReportData" resultType="com.gaotao.modules.orderIssure.entity.IssueNotifyReportData">
  616. SELECT
  617. A.NotifyNo AS notifyNo,
  618. CONVERT(VARCHAR(10), A.NotifyDate, 23) AS notifyDate,
  619. A.Status AS status,
  620. B.SOOrderNo AS soOrderNo,
  621. C.BOMItemNo AS bomItemNo,
  622. C.ComponentPartNo AS componentPartNo,
  623. P.PartDescription AS partDescription,
  624. P.Spec AS spec,
  625. U.UMName AS umName,
  626. C.component_scrap AS componentScrap,
  627. C.first_inspection_qty AS firstInspectionQty,
  628. C.standard_dosage AS standardDosage,
  629. C.QtyToIssue AS qtyToIssue,
  630. ISNULL(C.actual_out_qty, 0) AS actualOutQty,
  631. A.work_center_no AS workCenterNo,
  632. so.out_batchNo AS outBatchNo,
  633. W.WareHouseName AS warehouseName,
  634. C.warehouse_id
  635. FROM SOIssueNotifyHeader A
  636. INNER JOIN SOIssueNotifyOrderList B ON A.Site = B.Site AND A.NotifyNo = B.NotifyNo
  637. LEFT JOIN ShopOrder so ON B.Site = so.Site AND B.SOOrderNo = so.OrderNo
  638. INNER JOIN SOIssueNotifyOrderMaterialList C ON B.Site = C.Site AND B.NotifyNo = C.NotifyNo AND B.ItemNo = C.ItemNo
  639. INNER JOIN Part P ON C.Site = P.Site AND C.ComponentPartNo = P.PartNo
  640. INNER JOIN UM U ON U.Site = P.Site AND U.UMID = P.UMID
  641. LEFT JOIN WareHouse W ON C.Site = W.Site AND C.warehouse_id = W.WareHouseID
  642. <where>
  643. A.site IN (SELECT site FROM AccessSite WHERE userID = #{query.userName})
  644. <if test="query.notifyNo != null and query.notifyNo != ''">
  645. AND A.NotifyNo LIKE '%' + #{query.notifyNo} + '%'
  646. </if>
  647. <if test="query.startDate != null and query.startDate != ''">
  648. AND A.NotifyDate >= #{query.startDate}
  649. </if>
  650. <if test="query.endDate != null and query.endDate != ''">
  651. AND A.NotifyDate &lt;= #{query.endDate} + ' 23:59:59'
  652. </if>
  653. <if test="query.status != null and query.status != ''">
  654. AND A.Status = #{query.status}
  655. </if>
  656. <if test="query.soOrderNo != null and query.soOrderNo != ''">
  657. AND B.SOOrderNo LIKE '%' + #{query.soOrderNo} + '%'
  658. </if>
  659. <if test="query.bomItemNo != null and query.bomItemNo != ''">
  660. AND C.BOMItemNo = #{query.bomItemNo}
  661. </if>
  662. <if test="query.componentPartNo != null and query.componentPartNo != ''">
  663. AND C.ComponentPartNo LIKE '%' + #{query.componentPartNo} + '%'
  664. </if>
  665. <if test="query.partDescription != null and query.partDescription != ''">
  666. AND P.PartDescription LIKE '%' + #{query.partDescription} + '%'
  667. </if>
  668. <if test="query.spec != null and query.spec != ''">
  669. AND P.Spec LIKE '%' + #{query.spec} + '%'
  670. </if>
  671. <if test="query.workCenterNoList != null and query.workCenterNoList.size() > 0">
  672. AND A.work_center_no IN
  673. <foreach collection="query.workCenterNoList" item="item" open="(" separator="," close=")">
  674. #{item}
  675. </foreach>
  676. </if>
  677. <if test="query.warehouseIdList != null and query.warehouseIdList.size() > 0">
  678. AND C.warehouse_id IN
  679. <foreach collection="query.warehouseIdList" item="item" open="(" separator="," close=")">
  680. #{item}
  681. </foreach>
  682. </if>
  683. </where>
  684. ORDER BY A.NotifyNo, B.SOOrderNo, C.BOMItemNo
  685. </select>
  686. </mapper>