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.

299 lines
13 KiB

3 months ago
​
​
​
​
2 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 weeks ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
2 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 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
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 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.autoWareHourceHaian.mapper.HaiAnNewIssureMapper">
  4. <!-- 查询海安已保存BOM明细用于编辑回显,避免覆盖已保存申请结果 - rqrq -->
  5. <select id="haiAnGetSOSBOMForIssureNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData">
  6. SELECT
  7. a.notify_no AS notifyNo,
  8. a.site,
  9. a.sub_site AS subSite,
  10. a.item_no AS itemNo,
  11. a.BOM_item_no AS BOMItemNo,
  12. a.component_part_no AS componentPartNo,
  13. a.qty_to_issue AS qtyToIssue,
  14. a.qty_to_issue_original AS qtyToIssueOriginal,
  15. a.remark,
  16. a.batch_no AS batchNo
  17. FROM haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK)
  18. INNER JOIN haian_SOIssueNotifyOrderList b WITH (NOLOCK)
  19. ON a.site = b.site
  20. AND a.notify_no = b.notify_no
  21. AND a.item_no = b.item_no
  22. WHERE a.notify_no = #{notifyNo}
  23. AND b.soorder_no = #{orderNo}
  24. AND b.release_no = #{releaseNo}
  25. AND b.sequence_no = #{sequenceNo}
  26. AND (a.site = #{site} OR a.sub_site = #{site})
  27. </select>
  28. <!-- 查询海安材料明细,按subsite可选过滤,保证子站点隔离 - rqrq -->
  29. <select id="haiAnSearchNotifyMaterialListNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData">
  30. SELECT
  31. a.notify_no AS notifyNo,
  32. a.site,
  33. a.sub_site AS subSite,
  34. a.item_no AS itemNo,
  35. a.BOM_item_no AS BOMItemNo,
  36. a.component_part_no AS componentPartNo,
  37. a.qty_to_issue AS qtyToIssue,
  38. a.qty_to_issue_original AS qtyToIssueOriginal,
  39. b.fgpart_no AS fgpartNo,
  40. b.ops_item_no AS opsItemNo,
  41. b.soorder_no AS soorderNo,
  42. b.seq_no AS seqNo,
  43. b.location_no AS locationNo,
  44. a.issue_type AS issueType,
  45. b.need_date AS needDate,
  46. a.remark,
  47. a.batch_no AS batchNo,
  48. ISNULL(pa.is_in_wh, '未维护') AS isInWh,
  49. b.push_wms_flag AS pushWmsFlag
  50. FROM haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK)
  51. LEFT JOIN haian_SOIssueNotifyOrderList b WITH (NOLOCK)
  52. ON a.site = b.site
  53. AND a.notify_no = b.notify_no
  54. AND a.item_no = b.item_no
  55. LEFT JOIN part_attribute pa WITH (NOLOCK)
  56. ON a.sub_site = pa.site
  57. AND a.component_part_no = pa.part_no
  58. WHERE a.notify_no = #{notifyNo}
  59. AND a.site = #{site}
  60. <if test="subSite != null and subSite != ''">
  61. AND a.sub_site = #{subSite}
  62. </if>
  63. ORDER BY b.need_date, a.item_no, a.BOM_item_no
  64. </select>
  65. <!-- 海安主单分页查询,查询维度与旧search页一致但改走haian主表 - rqrq -->
  66. <select id="haiAnSearchNotifyHeaderNew" parameterType="HaiAnSOIssueNotifyHeaderData" resultType="HaiAnSOIssueNotifyHeaderData">
  67. SELECT
  68. a.notify_no AS notifyNo,
  69. a.site,
  70. a.notify_date AS notifyDate,
  71. a.username,
  72. a.entered_date AS enteredDate,
  73. a.receiver,
  74. a.department_id AS departmentId,
  75. a.remark,
  76. a.credit_flag AS creditFlag,
  77. a.issue_flag AS issueFlag,
  78. a.issue_result AS issueResult,
  79. a.plan_issue_date AS planIssueDate,
  80. a.real_issue_date AS realIssueDate,
  81. a.status,
  82. a.have_issue_record_flag AS haveIssueRecordFlag,
  83. a.calc_flag AS calcFlag,
  84. a.need_approve_flag AS needApproveFlag,
  85. a.approved_flag AS approvedFlag,
  86. a.approver,
  87. a.approve_date AS approveDate,
  88. a.warehouse_id AS warehouseId,
  89. a.record_version AS recordVersion,
  90. a.out_work_order_flag AS outWorkOrderFlag,
  91. a.project_id AS projectId,
  92. a.order_type AS orderType,
  93. a.auth_rule_id AS authRuleId,
  94. a.confirm_status AS confirmStatus,
  95. a.confirm_user_id AS confirmUserId,
  96. a.confirm_username AS confirmUsername,
  97. a.confirm_user_display AS confirmUserDisplay,
  98. a.confirm_date AS confirmDate,
  99. a.handler_username AS handlerUsername,
  100. a.handler_display AS handlerDisplay,
  101. a.push_wcs_flag AS pushWcsFlag
  102. FROM haian_SOIssueNotifyHeader a WITH (NOLOCK)
  103. <where>
  104. <if test="query.notifyNo != null and query.notifyNo != ''">
  105. AND a.notify_no = #{query.notifyNo}
  106. </if>
  107. <if test="query.username != null and query.username != ''">
  108. AND a.username LIKE '%' + #{query.username} + '%'
  109. </if>
  110. <if test="query.orderType != null and query.orderType != ''">
  111. AND a.order_type = #{query.orderType}
  112. </if>
  113. <if test="query.status != null and query.status != ''">
  114. AND a.status = #{query.status}
  115. </if>
  116. <if test="query.orderNo != null and query.orderNo != ''">
  117. AND EXISTS (
  118. SELECT 1
  119. FROM haian_SOIssueNotifyOrderList b WITH (NOLOCK)
  120. WHERE b.site = a.site
  121. AND b.notify_no = a.notify_no
  122. AND b.soorder_no = #{query.orderNo}
  123. )
  124. </if>
  125. <if test="query.startDate != null">
  126. AND CONVERT(date, a.notify_date) &gt;= CONVERT(date, #{query.startDate})
  127. </if>
  128. <if test="query.endDate != null">
  129. AND CONVERT(date, a.notify_date) &lt; DATEADD(day, 1, CONVERT(date, #{query.endDate}))
  130. </if>
  131. <if test="query.site != null and query.site != ''">
  132. AND a.site = #{query.site}
  133. </if>
  134. <if test="query.pushWcsFlag != null and query.pushWcsFlag != ''">
  135. AND a.push_wcs_flag = #{query.pushWcsFlag}
  136. </if>
  137. AND a.status != 'UNISSUE'
  138. </where>
  139. ORDER BY a.notify_no DESC
  140. </select>
  141. <!-- 海安订单层明细查询,返回subsite与配送区域信息 - rqrq -->
  142. <select id="haiAnSearchNotifyOrderListNew" resultType="HaiAnSOIssueNotifyOrderListData">
  143. SELECT
  144. a.notify_no AS notifyNo,
  145. a.site,
  146. a.sub_site AS subSite,
  147. a.item_no AS itemNo,
  148. a.fgpart_no AS fgPartNo,
  149. a.soorder_no AS soorderNo,
  150. a.ops_item_no AS opsItemNo,
  151. a.seq_no AS seqNo,
  152. a.issure_qty AS issureQty,
  153. a.location_no AS locationNo,
  154. a.need_date AS needDate,
  155. a.out_work_order_flag AS outWorkOrderFlag,
  156. a.release_no AS releaseNo,
  157. a.sequence_no AS sequenceNo,
  158. a.push_wms_flag AS pushWmsFlag,
  159. a.transport_flag AS transportFlag,
  160. a.production_area AS productionArea,
  161. a.push_wcs_time AS pushWcsTime,
  162. b.area_desc AS areaDesc
  163. FROM haian_SOIssueNotifyOrderList a WITH (NOLOCK)
  164. <!-- 配送区域按通知单工厂及区域编码关联海安主数据;缺失时保留明细且名称为空,NOLOCK允许展示短暂脏读 - rqrq -->
  165. LEFT JOIN haian_area b WITH (NOLOCK)
  166. ON a.site = b.site
  167. AND a.production_area = b.area_id
  168. WHERE a.notify_no = #{notifyNo}
  169. AND a.site = #{site}
  170. ORDER BY a.item_no
  171. </select>
  172. <!-- 海安材料汇总查询,按subsite与物料聚合供汇总页签使用 - rqrq -->
  173. <select id="haiAnSearchSumNotifyMaterialListNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData">
  174. SELECT
  175. a.sub_site AS subSite,
  176. a.component_part_no AS componentPartNo,
  177. SUM(a.qty_to_issue) AS qtyToIssue,
  178. SUM(ISNULL(a.qty_to_issue_original, 0)) AS qtyToIssueOriginal,
  179. a.issue_type AS issueType,
  180. ISNULL(MAX(pa.is_in_wh), '未维护') AS isInWh
  181. FROM haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK)
  182. LEFT JOIN part_attribute pa WITH (NOLOCK)
  183. ON a.sub_site = pa.site
  184. AND a.component_part_no = pa.part_no
  185. WHERE a.notify_no = #{notifyNo}
  186. AND a.site = #{site}
  187. GROUP BY a.sub_site, a.component_part_no, a.issue_type
  188. ORDER BY a.issue_type
  189. </select>
  190. <!-- 海安申请单状态更新,保持关闭链路与原流程一致 - rqrq -->
  191. <update id="haiAnUpdateNotifyStatusNew">
  192. UPDATE haian_SOIssueNotifyHeader
  193. SET status = #{status},
  194. remark = #{closeRemark}
  195. WHERE site = #{site}
  196. AND notify_no = #{notifyNo}
  197. </update>
  198. <!-- 海安日志查询占位,先保证前端接口兼容后续再补日志表 - rqrq -->
  199. <select id="haiAnSearchNotifyLogNew" resultType="java.lang.Object">
  200. SELECT '暂无日志数据' AS message
  201. WHERE 1 = 2
  202. </select>
  203. <!-- 海安关闭日志查询占位,先保证前端接口兼容后续再补日志表 - rqrq -->
  204. <select id="haiAnSearchNotifyLogCloseNew" resultType="java.lang.Object">
  205. SELECT '暂无关闭日志数据' AS message
  206. WHERE 1 = 2
  207. </select>
  208. <!-- 查询海安标签明细清单,返回subsite与追踪字段用于对账 - rqrq -->
  209. <select id="haiAnSearchMaterialListDetail" resultType="HaiAnSOIssueNotifyOrderMaterialListDetailData">
  210. SELECT
  211. d.site,
  212. d.notify_no AS notifyNo,
  213. d.item_no AS itemNo,
  214. d.BOM_item_no AS bomItemNo,
  215. d.serialNo AS serialNo,
  216. d.task_ref AS taskRef,
  217. d.task_item AS taskItem,
  218. d.task_seq AS taskSeq,
  219. d.out_wcs_flag AS outWcsFlag,
  220. d.out_wcs_time AS outWcsTime,
  221. d.issure_flag AS issureFlag,
  222. d.order_type AS orderType,
  223. d.sub_site AS subSite,
  224. d.batch_no AS batchNo,
  225. d.alloc_seq AS allocSeq,
  226. d.pallet_id AS palletId,
  227. m.component_part_no AS componentPartNo
  228. FROM haian_SOIssueNotifyOrderMaterialList_detail d
  229. <!-- 按site、单号、订单行、BOM行和子site取预定明细对应的物料编码;物料行缺失时保留标签明细。NOLOCK仅供展示,可能短暂脏读 - rqrq -->
  230. LEFT JOIN haian_SOIssueNotifyOrderMaterialList m WITH (NOLOCK)
  231. ON m.site = d.site
  232. AND m.notify_no = d.notify_no
  233. AND m.item_no = d.item_no
  234. AND m.BOM_item_no = d.BOM_item_no
  235. AND ISNULL(m.sub_site, '') = ISNULL(d.sub_site, '')
  236. WHERE d.site = #{site}
  237. AND d.notify_no = #{notifyNo}
  238. <if test="subSite != null and subSite != ''">
  239. AND d.sub_site = #{subSite}
  240. </if>
  241. ORDER BY d.item_no, d.BOM_item_no, d.alloc_seq, d.task_seq
  242. </select>
  243. <!-- rqrq - 海安齐套候选:从物料层关联订单层筛选transport_flag='N'。禁止NOLOCK:本查询后会回写transport_flag,脏读未提交明细会导致提前齐套 -->
  244. <select id="haiAnGetPendingTransportOrders" resultType="com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderListData">
  245. SELECT DISTINCT
  246. o.site,
  247. o.notify_no AS notifyNo,
  248. o.item_no AS itemNo,
  249. o.transport_flag AS transportFlag
  250. FROM haian_SOIssueNotifyOrderMaterialList m
  251. INNER JOIN haian_SOIssueNotifyOrderList o
  252. ON m.site = o.site
  253. AND m.notify_no = o.notify_no
  254. AND m.item_no = o.item_no
  255. WHERE m.site = #{site}
  256. AND ISNULL(o.transport_flag, 'N') = 'N'
  257. ORDER BY o.notify_no, o.item_no
  258. </select>
  259. <!-- rqrq - 统计订单行detail总数:用于齐套判断分母,0时不回写transport_flag。禁止NOLOCK:与已取出计数必须同一已提交快照 -->
  260. <select id="haiAnCountMaterialDetailTotal" resultType="java.lang.Integer">
  261. SELECT COUNT(1)
  262. FROM haian_SOIssueNotifyOrderMaterialList_detail
  263. WHERE site = #{site}
  264. AND notify_no = #{notifyNo}
  265. AND item_no = #{itemNo}
  266. </select>
  267. <!-- rqrq - 统计订单行detail已取出数量:仅计out_wcs_flag='Y'。禁止NOLOCK:脏读会把未提交取出当成已齐套 -->
  268. <select id="haiAnCountMaterialDetailOut" resultType="java.lang.Integer">
  269. SELECT COUNT(1)
  270. FROM haian_SOIssueNotifyOrderMaterialList_detail
  271. WHERE site = #{site}
  272. AND notify_no = #{notifyNo}
  273. AND item_no = #{itemNo}
  274. AND out_wcs_flag = 'Y'
  275. </select>
  276. <!-- 齐套收口:仅把transport_flag从N回写为Y,不联动其他字段,满足“只改一个标记”要求 - rqrq -->
  277. <update id="haiAnUpdateTransportFlagToY">
  278. UPDATE haian_SOIssueNotifyOrderList
  279. SET transport_flag = 'Y'
  280. WHERE site = #{site}
  281. AND notify_no = #{notifyNo}
  282. AND item_no = #{itemNo}
  283. AND ISNULL(transport_flag, 'N') = 'N'
  284. </update>
  285. </mapper>