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.

381 lines
18 KiB

4 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 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.notify.mapper.NewIssureMapper">
  4. <insert id="saveSOIssueNotifyOrderListForExcel">
  5. insert into SOIssueNotifyOrderList(notify_no,site,item_no,fgpart_no,soorder_no,issure_qty,out_work_order_flag,need_date,release_no,sequence_no,order_type)
  6. values(#{notifyNo},#{site},#{itemNo},#{fgPartNo},#{soorderNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag}
  7. ,#{needDate},#{releaseNo},#{sequenceNo},#{orderType})
  8. </insert>
  9. <delete id="deleteSOIssueNotifyOrderMaterialListDataForExcel">
  10. delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo}
  11. </delete>
  12. <insert id="batchSaveSOIssueNotifyOrderMaterialListDataForExcel">
  13. insert into SOIssueNotifyOrderMaterialList (notify_no,site,item_no,BOM_item_no,component_part_no,qty_to_issue,qty_to_issue_original,issue_type,remark,order_type)
  14. values
  15. <foreach collection="data" separator="," item="item">
  16. (#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType})
  17. </foreach>
  18. </insert>
  19. <select id="getSOSBOMForIssureNew" resultType="SOIssueNotifyOrderMaterialListData">
  20. select a.notify_no,a.site,a.item_no,a.BOM_item_no as BOMItemNo,a.component_part_no as ComponentPartNo,
  21. a.qty_to_issue as QtyToIssue,a.qty_to_issue_original as QtyToIssueOriginal,a.remark
  22. from SOIssueNotifyOrderMaterialList a
  23. inner join SOIssueNotifyOrderList b on a.site=b.site and a.notify_no=b.notify_no and a.item_no=b.item_no
  24. where a.notify_no=#{notifyNo} and a.site=#{site} and b.soorder_no=#{orderNo}
  25. and b.release_no=#{releaseNo} and b.sequence_no=#{sequenceNo}
  26. </select>
  27. <!-- AI制作 - 查询申请单主表 -->
  28. <select id="searchNotifyHeaderNew" parameterType="SOIssueNotifyHeaderData" resultType="SOIssueNotifyHeaderData">
  29. select a.notify_no as notifyNo,a.site,a.notify_date as notifyDate,a.username,a.entered_date as enteredDate,a.receiver,a.department_id as departmentId,a.remark,a.credit_flag as creditFlag,a.issue_flag as issueFlag,
  30. a.issue_result as issueResult,a.plan_issue_date as planIssueDate,a.real_issue_date as realIssueDate,a.status,a.have_issue_record_flag as haveIssueRecordFlag,a.calc_flag as calcFlag,a.need_approve_flag as needApproveFlag,a.approved_flag as approvedFlag,
  31. a.approver,a.approve_date as approveDate,a.warehouse_id as warehouseId,a.record_version as recordVersion,a.out_work_order_flag as outWorkOrderFlag,a.project_id as projectId,a.order_type as orderType,a.auth_rule_id as authRuleId,
  32. a.confirm_status ,
  33. a.confirm_user_id as confirmUserId,a.confirm_username as confirmUsername,a.confirm_user_display as confirmUserDisplay,a.confirm_date as confirmDate,a.handler_username as handlerUsername,a.handler_display as handlerDisplay,a.push_wcs_flag as pushWcsFlag
  34. from SOIssueNotifyHeader a
  35. <where>
  36. <if test="query.notifyNo != null and query.notifyNo != ''">
  37. AND a.notify_no = #{query.notifyNo}
  38. </if>
  39. <if test="query.username != null and query.username != ''">
  40. AND a.username LIKE '%' + #{query.username} + '%'
  41. </if>
  42. <if test="query.orderType != null and query.orderType != ''">
  43. AND a.order_type = #{query.orderType}
  44. </if>
  45. <if test="query.status != null and query.status != ''">
  46. AND a.status = #{query.status}
  47. </if>
  48. <if test="query.orderNo != null and query.orderNo != ''">
  49. AND EXISTS (
  50. SELECT 1
  51. FROM SOIssueNotifyOrderList b
  52. WHERE b.site = a.site
  53. AND b.notify_no = a.notify_no
  54. AND b.soorder_no = #{query.orderNo}
  55. )
  56. </if>
  57. <if test="query.startDate != null">
  58. AND CONVERT(date, a.notify_date) >= CONVERT(date, #{query.startDate})
  59. </if>
  60. <if test="query.endDate != null">
  61. AND CONVERT(date, a.notify_date) &lt; DATEADD(day, 1, CONVERT(date, #{query.endDate}))
  62. </if>
  63. <if test="query.site != null and query.site != ''">
  64. AND a.site = #{query.site}
  65. </if>
  66. and a.status!='UNISSUE'
  67. </where>
  68. order by a.notify_no desc
  69. </select>
  70. <!-- rqrq - 查询申请单明细,关联area表获取配送区域描述 -->
  71. <select id="searchNotifyOrderListNew" resultType="SOIssueNotifyOrderListData">
  72. select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.fgpart_no as fgPartNo,a.soorder_no as soorderNo,a.ops_item_no as opsItemNo,a.seq_no as seqNo,
  73. a.issure_qty as issureQty,a.location_no as locationNo,a.need_date as needDate,a.out_work_order_flag as outWorkOrderFlag,a.release_no as releaseNo,a.sequence_no as sequenceNo,
  74. a.push_wms_flag as pushWmsFlag,a.transport_flag as transportFlag,a.production_area as productionArea,
  75. b.area_desc as areaDesc
  76. from SOIssueNotifyOrderList a
  77. left join area b on a.production_area = b.area_id
  78. where a.notify_no=#{notifyNo} and a.site=#{site}
  79. order by a.item_no
  80. </select>
  81. <!-- AI制作 - 查询材料明细 -->
  82. <!-- rqrq - 关联part_attribute表查询is_in_wh字段 -->
  83. <select id="searchNotifyMaterialListNew" resultType="SOIssueNotifyOrderMaterialListData">
  84. select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.BOM_item_no as bOMItemNo,a.component_part_no as componentPartNo,a.qty_to_issue as qtyToIssue,a.qty_to_issue_original as qtyToIssueOriginal,
  85. b.fgpart_no as fgpartNo,b.ops_item_no as opsItemNo,b.soorder_no as soorderNo,b.seq_no as seqNo,
  86. b.location_no as locationNo,a.issue_type as issueType,b.need_date as needDate,a.remark,
  87. ISNULL(pa.is_in_wh, '未维护') as isInWh
  88. from SOIssueNotifyOrderMaterialList a
  89. left join SOIssueNotifyOrderList b on a.site=b.site and a.notify_no=b.notify_no and a.item_no=b.item_no
  90. left join part_attribute pa on a.site=pa.site and a.component_part_no=pa.part_no
  91. where a.notify_no=#{notifyNo} and a.site=#{site}
  92. order by b.need_date,a.item_no
  93. </select>
  94. <!-- AI制作 - 查询材料汇总 -->
  95. <!-- rqrq - 关联part_attribute表查询is_in_wh字段 -->
  96. <select id="searchSumNotifyMaterialListNew" resultType="SOIssueNotifyOrderMaterialListData">
  97. select a.component_part_no as componentPartNo,sum(a.qty_to_issue) as qtyToIssue,sum(isnull(a.qty_to_issue_original,0)) as qtyToIssueOriginal,
  98. a.issue_type as issueType,
  99. ISNULL(MAX(pa.is_in_wh), '未维护') as isInWh
  100. from SOIssueNotifyOrderMaterialList a
  101. left join part_attribute pa on a.site=pa.site and a.component_part_no=pa.part_no
  102. where a.notify_no=#{notifyNo} and a.site=#{site}
  103. group by a.site,a.component_part_no,a.issue_type
  104. order by a.issue_type
  105. </select>
  106. <!-- AI制作 - 更新申请单状态为关闭 -->
  107. <update id="updateNotifyStatusNew">
  108. update SOIssueNotifyHeader
  109. set status=#{status}, remark=#{closeRemark}
  110. where site=#{site} and notify_no=#{notifyNo}
  111. </update>
  112. <!-- AI制作 - 查询申请单日志 -->
  113. <select id="searchNotifyLogNew" resultType="java.lang.Object">
  114. select '暂无日志数据' as message
  115. where 1=2
  116. </select>
  117. <!-- AI制作 - 查询申请单关闭日志 -->
  118. <select id="searchNotifyLogCloseNew" resultType="java.lang.Object">
  119. select '暂无关闭日志数据' as message
  120. where 1=2
  121. </select>
  122. <!-- AI制作 - 根据site和notify_no查询申请单明细 -->
  123. <select id="getOrderListForWcs" resultType="SOIssueNotifyOrderListData">
  124. select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.fgpart_no as fgPartNo,a.soorder_no as soorderNo,a.ops_item_no as opsItemNo,a.seq_no as seqNo,
  125. a.issure_qty as issureQty,a.location_no as locationNo,a.need_date as needDate,a.out_work_order_flag as outWorkOrderFlag,a.release_no as releaseNo,a.sequence_no as sequenceNo
  126. from SOIssueNotifyOrderList a
  127. where a.notify_no=#{notifyNo} and a.site=#{site}
  128. order by a.item_no
  129. </select>
  130. <!-- AI制作 - 根据site、notify_no和item_no查询材料明细 -->
  131. <select id="getMaterialListForWcs" resultType="SOIssueNotifyOrderMaterialListData">
  132. select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.BOM_item_no as bomItemNo,a.component_part_no as componentPartNo,a.qty_to_issue as qtyToIssue,a.qty_to_issue_original as qtyToIssueOriginal,
  133. a.issue_type as issueType,a.remark
  134. from SOIssueNotifyOrderMaterialList a
  135. where a.notify_no=#{notifyNo} and a.site=#{site} and a.item_no=#{itemNo}
  136. order by a.BOM_item_no
  137. </select>
  138. <!-- AI制作 - 根据site和part_no列表查询物料属性 -->
  139. <select id="getPartAttributeListForWcs" resultType="com.gaotao.modules.factory.entity.PartAttribute">
  140. select site, part_no as partNo, is_in_wh as isInWh, is_robot_pick as isRobotPick, weight, length, width, height, diameter
  141. from part_attribute
  142. where site = #{site}
  143. <if test="partNos != null and partNos.size() > 0">
  144. and part_no in
  145. <foreach collection="partNos" item="partNo" open="(" separator="," close=")">
  146. #{partNo}
  147. </foreach>
  148. </if>
  149. </select>
  150. <!-- AI制作 - 更新申请单推送WCS状态 -->
  151. <update id="updatePushWcsFlag">
  152. update SOIssueNotifyHeader
  153. set push_wcs_flag='已完成'
  154. where site=#{site} and notify_no=#{notifyNo}
  155. </update>
  156. <!-- ==================== 新增推送WCS相关SQL - rqrq ==================== -->
  157. <!-- rqrq - 根据条码列表查询handling_unit的reserve_flag -->
  158. <select id="checkReserveFlagBySerialNos" resultType="java.lang.String">
  159. SELECT reserve_flag
  160. FROM handling_unit
  161. WHERE site = #{site}
  162. AND unit_id IN
  163. <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")">
  164. #{serialNo}
  165. </foreach>
  166. AND (reserve_flag ='Y')
  167. </select>
  168. <!-- rqrq - 根据条码列表查询所有栈板ID -->
  169. <select id="getPalletIdsBySerialNos" resultType="java.lang.String">
  170. SELECT DISTINCT pd.pallet_id
  171. FROM pallet_detail pd
  172. WHERE pd.site = #{site}
  173. AND pd.serial_no IN
  174. <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")">
  175. #{serialNo}
  176. </foreach>
  177. </select>
  178. <!-- rqrq - 检查栈板的calling_flag -->
  179. <select id="checkCallingFlagByPalletIds" resultType="java.lang.String">
  180. SELECT pallet_id
  181. FROM pallet
  182. WHERE site = #{site}
  183. AND pallet_id IN
  184. <foreach collection="palletIds" item="palletId" open="(" separator="," close=")">
  185. #{palletId}
  186. </foreach>
  187. AND calling_flag ='Y'
  188. </select>
  189. <!-- rqrq - 根据notifyNo和productionOrderNo查询itemNo -->
  190. <select id="getItemNoByNotifyNoAndOrderNo" resultType="java.math.BigDecimal">
  191. SELECT top 1 item_no
  192. FROM SOIssueNotifyOrderList
  193. <where>
  194. and site = #{site}
  195. AND notify_no = #{notifyNo}
  196. <if test="productionOrderNo != null and productionOrderNo != ''">
  197. AND soorder_no = #{productionOrderNo}
  198. </if>
  199. </where>
  200. </select>
  201. <select id="getFgPartNoWithNotifyNo" resultType="String">
  202. SELECT top 1 fgpart_no
  203. FROM SOIssueNotifyOrderList
  204. <where>
  205. and site = #{site}
  206. AND notify_no = #{notifyNo}
  207. <if test="productionOrderNo != null and productionOrderNo != ''">
  208. AND soorder_no = #{productionOrderNo}
  209. </if>
  210. </where>
  211. </select>
  212. <select id="getFgPartNoWithNotifyNoItemNo" resultType="String">
  213. SELECT top 1 fgpart_no
  214. FROM SOIssueNotifyOrderList
  215. WHERE site = #{site}
  216. AND notify_no = #{notifyNo}
  217. AND item_no = #{itemNo,jdbcType=DECIMAL}
  218. </select>
  219. <!-- rqrq - 根据site+notifyNo+itemNo查询生产区域 -->
  220. <select id="getProductionAreaByNotifyNoAndItemNo" resultType="String">
  221. SELECT production_area
  222. FROM SOIssueNotifyOrderList WITH (NOLOCK)
  223. WHERE site = #{site}
  224. AND notify_no = #{notifyNo}
  225. AND item_no = #{itemNo,jdbcType=DECIMAL}
  226. </select>
  227. <!-- rqrq - 根据site+notifyNo+itemNo查询订单类型 -->
  228. <select id="getOrderTypeByNotifyNoAndItemNo" resultType="String">
  229. SELECT order_type
  230. FROM SOIssueNotifyOrderList WITH (NOLOCK)
  231. WHERE site = #{site}
  232. AND notify_no = #{notifyNo}
  233. AND item_no = #{itemNo,jdbcType=DECIMAL}
  234. </select>
  235. <!-- rqrq - 根据site+notifyNo+itemNo查询订单行完整信息(一次性获取所有需要的字段)-->
  236. <select id="getOrderListByNotifyNoAndItemNo" resultType="SOIssueNotifyOrderList">
  237. SELECT notify_no AS notifyNo,
  238. site,
  239. item_no AS itemNo,
  240. fgpart_no AS fgPartNo,
  241. soorder_no AS soorderNo,
  242. ops_item_no AS opsItemNo,
  243. seq_no AS seqNo,
  244. issure_qty AS issureQty,
  245. out_work_order_flag AS outWorkOrderFlag,
  246. need_date AS needDate,
  247. location_no AS locationNo,
  248. release_no AS releaseNo,
  249. sequence_no AS sequenceNo,
  250. push_wms_flag AS pushWmsFlag,
  251. production_area AS productionArea,
  252. transport_flag AS transportFlag,
  253. order_type AS orderType
  254. FROM SOIssueNotifyOrderList WITH (NOLOCK)
  255. WHERE site = #{site}
  256. AND notify_no = #{notifyNo}
  257. AND item_no = #{itemNo,jdbcType=DECIMAL}
  258. </select>
  259. <!-- rqrq - 更新handling_unit的reserve标志 -->
  260. <update id="updateHandlingUnitReserveFlag">
  261. UPDATE handling_unit
  262. SET reserve_flag = 'Y',
  263. reserve_order_ref1 = #{notifyNo},
  264. reserve_order_ref2 = CAST(#{itemNo} AS VARCHAR(50)),
  265. reserve_order_ref3 = #{productionOrderNo}
  266. WHERE site = #{site}
  267. AND unit_id IN
  268. <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")">
  269. #{serialNo}
  270. </foreach>
  271. </update>
  272. <!-- rqrq - 更新栈板的calling_flag -->
  273. <update id="updatePalletCallingFlag">
  274. UPDATE pallet
  275. SET calling_flag = 'Y',
  276. updated_by = 'WMS_SYSTEM',
  277. updated_time = GETDATE()
  278. WHERE site = #{site}
  279. AND pallet_id IN
  280. <foreach collection="palletIds" item="palletId" open="(" separator="," close=")">
  281. #{palletId}
  282. </foreach>
  283. </update>
  284. <!-- rqrq - 批量插入SOIssueNotifyOrderMaterialList_detail记录 -->
  285. <!-- rqrq - 批量插入SOIssueNotifyOrderMaterialList_detail,固定order_type为shoporder -->
  286. <insert id="batchInsertMaterialListDetail">
  287. INSERT INTO SOIssueNotifyOrderMaterialList_detail
  288. (site, notify_no, item_no, BOM_item_no, serialNo, task_ref, task_item, task_seq, out_wcs_flag, issure_flag, order_type)
  289. VALUES
  290. <foreach collection="list" item="item" separator=",">
  291. (#{item.site}, #{item.notifyNo}, #{item.itemNo}, #{item.bomItemNo}, #{item.serialNo},
  292. #{item.taskRef}, #{item.taskItem}, #{item.taskSeq}, #{item.outWcsFlag}, #{item.issureFlag}, #{item.orderType})
  293. </foreach>
  294. </insert>
  295. <!-- rqrq - 更新SOIssueNotifyOrderList的push_wms_flag -->
  296. <update id="updateOrderListPushWmsFlag">
  297. UPDATE SOIssueNotifyOrderList
  298. SET push_wms_flag = 'Y'
  299. WHERE site = #{site}
  300. AND notify_no = #{notifyNo}
  301. AND item_no = #{itemNo}
  302. </update>
  303. <!-- rqrq - 更新SOIssueNotifyHeader的push_wcs_flag -->
  304. <update id="updateNotifyHeaderPushWcsFlag">
  305. UPDATE SOIssueNotifyHeader
  306. SET push_wcs_flag = #{pushWcsFlag}
  307. WHERE site = #{site}
  308. AND notify_no = #{notifyNo}
  309. </update>
  310. <!-- rqrq - 根据栈板ID和序列号列表查询栈板明细信息 -->
  311. <select id="getPalletDetailsByPalletAndSerials" resultType="com.gaotao.modules.automatedWarehouse.entity.PalletDetail">
  312. SELECT position, layer, serial_no as serialNo
  313. FROM pallet_detail
  314. WHERE site = #{site}
  315. AND pallet_id = #{palletId}
  316. AND serial_no IN
  317. <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")">
  318. #{serialNo}
  319. </foreach>
  320. ORDER BY position, layer
  321. </select>
  322. <!-- rqrq - 查询序列号在handling_unit中的location_id(无锁查询)-->
  323. <select id="getSerialNoLocationId" resultType="java.lang.String">
  324. SELECT location_id
  325. FROM handling_unit WITH (NOLOCK)
  326. WHERE site = #{site}
  327. AND unit_id = #{serialNo}
  328. </select>
  329. <!-- rqrq - 查询预留标签清单(适用于所有订单类型:shoporder/shipment/noorder) -->
  330. <select id="searchMaterialListDetail" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail">
  331. SELECT
  332. site,
  333. notify_no AS notifyNo,
  334. item_no AS itemNo,
  335. BOM_item_no AS bomItemNo,
  336. serialNo,
  337. task_ref AS taskRef,
  338. task_item AS taskItem,
  339. task_seq AS taskSeq,
  340. out_wcs_flag AS outWcsFlag,
  341. issure_flag AS issureFlag,
  342. order_type AS orderType
  343. FROM SOIssueNotifyOrderMaterialList_detail WITH (NOLOCK)
  344. WHERE site = #{site}
  345. AND notify_no = #{notifyNo}
  346. ORDER BY item_no, BOM_item_no, task_seq
  347. </select>
  348. </mapper>