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.

308 lines
12 KiB

10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 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.wms.dao.WmsPrintDao">
  4. <select id="getInboundQcResultData" resultType="InboundQcResultData">
  5. SELECT
  6. a.site,
  7. a.bu_no,
  8. A.order_no AS notifyNo,
  9. d.inspection_no AS order_no,
  10. a.order_status,
  11. d.part_no,
  12. d.part_desc,
  13. D.related_order_no AS po_orderNo,
  14. D.related_order_line_no AS po_itemNo,
  15. c.SupplierName,
  16. c.supplierID AS supplierId,
  17. b.inspector_date,
  18. b.submit_date,
  19. d.required_qty as order_qty,
  20. roll_qty,
  21. roll_count,
  22. inspection_result,
  23. disposal_measures,
  24. B.batch_qualified_qty,
  25. b.inspector_no
  26. from inbound_notification_head a
  27. inner join inbound_notification_detail D on a.site = D.site and a.bu_no = D.bu_no and a.order_no = D.order_no AND A.order_type ='采购入库'
  28. left join qc_iqc_record b on D.site = b.site and D.bu_no = b.bu_no and D.inspection_no = b.inspection_no
  29. inner join Supplier c on a.site = c.Site and a.Supplier_ID = c.supplierID
  30. <where>
  31. <if test="query.site != null and query.site != ''">
  32. and A.site=#{query.site,jdbcType=VARCHAR}
  33. </if>
  34. <if test="query.buNo != null and query.buNo != ''">
  35. and A.bu_no=#{query.buNo,jdbcType=CHAR}
  36. </if>
  37. <if test="query.orderNo != null and query.orderNo != ''">
  38. and d.inspection_no like '%'+ #{query.orderNo} +'%'
  39. </if>
  40. <if test="query.notifyNo != null and query.notifyNo != ''">
  41. and a.order_no like '%'+ #{query.notifyNo} +'%'
  42. </if>
  43. <if test="query.partNo != null and query.partNo != ''">
  44. and b.part_no like '%'+ #{query.partNo,jdbcType=CHAR} +'%'
  45. </if>
  46. <if test="query.partDesc != null and query.partDesc != ''">
  47. and b.part_desc like '%'+ #{query.partDesc,jdbcType=CHAR} +'%'
  48. </if>
  49. <if test="query.startDate != null">
  50. and b.inspector_date > #{query.startDate}
  51. </if>
  52. <if test="query.endDate != null">
  53. and #{query.endDate} > b.inspector_date
  54. </if>
  55. <if test="query.orderStatus != null and query.orderStatus != ''">
  56. and a.order_status = #{query.orderStatus,jdbcType=VARCHAR}
  57. </if>
  58. <if test="query.supplierName != null and query.supplierName != ''">
  59. and c.SupplierName like '%'+ #{query.supplierName} +'%'
  60. </if>
  61. <if test="query.poOrderNo != null and query.poOrderNo != ''">
  62. and d.related_order_no like '%'+ #{query.poOrderNo} +'%'
  63. </if>
  64. <if test="query.poItemNo != null and query.poItemNo != ''">
  65. and d.related_order_line_no = #{query.supplierName}
  66. </if>
  67. </where>
  68. </select>
  69. <select id="getPoOrderRollNoOutData" resultType="PoOrderRollNoOutData">
  70. SELECT
  71. ROW_NUMBER () OVER (ORDER BY a.created_date) orderId,
  72. a.site,
  73. a.bu_no,
  74. a.inspection_no,
  75. a.order_no,
  76. a.item_no,
  77. a.roll_no,
  78. a.roll_qty,
  79. a.part_no,
  80. a.part_desc,
  81. a.supplier_id,
  82. a.supplier_name,
  83. a.order_qty,
  84. a.created_by,
  85. a.created_date,
  86. a.update_by,
  87. a.updated_date,
  88. a.delflag,
  89. a.version,
  90. a.print_flag,
  91. a.citem_code,
  92. a.citem_class,
  93. a.sendto_address,
  94. a.hardtag_in_flag,
  95. a.batch_no,
  96. a.production_date,
  97. a.validity_period,
  98. a.chip_disk_no,
  99. a.expiration_warning_date,
  100. a.expiration_date
  101. from po_order_roll_no a
  102. where
  103. A.site = #{site} and A.bu_no = #{buNo}
  104. and A.inspection_no = #{inspectionNo,jdbcType=VARCHAR}
  105. </select>
  106. <select id="getInboundQcResultOtherData" resultType="PoOrderRollNoOutData">
  107. SELECT
  108. b.expiration_day,
  109. ISNULL(b.expiration_flag ,'N') AS expiration_flag,
  110. b.exceed_in_ratio,
  111. b.expiration_warning_day,
  112. ISNULL(a.batch_qualified_qty, 0) * (1 + ISNULL(b.exceed_in_ratio, 0) / 100.0)
  113. - ISNULL((
  114. SELECT SUM(roll_qty)
  115. FROM po_order_roll_no
  116. WHERE site = #{site}
  117. AND bu_no = #{buNo}
  118. AND inspection_no = #{orderNo}
  119. ), 0) AS remainingIssuableQty
  120. from qc_iqc_record a
  121. left join part b on a.site = b.site and a.bu_no = b.bu_No and a.part_no = b.PartNo
  122. where a.inspection_no = #{orderNo} and a.site = #{site} and a.bu_no = #{buNo}
  123. </select>
  124. <insert id="savePoOrderRollNo">
  125. insert into po_order_roll_no
  126. (site,bu_no,inspection_no,order_no,item_no,roll_no,roll_qty,part_no,part_desc,supplier_id,supplier_name,order_qty,
  127. created_by,created_date,delflag,version,print_flag,
  128. hardtag_in_flag,batch_no,production_date,expiration_warning_date,expiration_date
  129. ) values
  130. (#{site},#{buNo},#{inspectionNo},#{orderNo},#{itemNo},#{rollNo},#{rollQty},#{partNo},#{partDesc},#{supplierId},#{supplierName},#{orderQty},
  131. #{createdBy},GetDate(),#{delflag},#{version},#{printFlag},
  132. #{hardtagInFlag},#{batchNo},#{productionDate},#{expirationWarningDate},#{expirationDate})
  133. </insert>
  134. <delete id="deletePoPartLabelData">
  135. delete from po_order_roll_no where site=#{site} and bu_no=#{buNo} and roll_no=#{rollNo} and inspection_no=#{inspectionNo}
  136. </delete>
  137. <update id="updatePrintFlag">
  138. update po_order_roll_no set print_flag=isnull(print_flag,0)+1
  139. WHERE
  140. site = #{site} <!-- 先过滤 site -->
  141. and bu_no=#{buNo}
  142. AND roll_no IN
  143. <foreach item="item" collection="rollList" open="(" separator="," close=")">
  144. #{item.rollNo}
  145. </foreach>
  146. </update>
  147. <select id="getPoPartLabelData" resultType="PoOrderRollNoOutData">
  148. select site,bu_no,inspection_no,order_no,item_no,roll_no,roll_qty,part_no,part_desc,supplier_id,supplier_name,order_qty,
  149. created_by,created_date,delflag,version,print_flag,
  150. hardtag_in_flag,batch_no,production_date,expiration_warning_date,expiration_date
  151. from po_order_roll_no
  152. WHERE
  153. site = #{site} <!-- 先过滤 site -->
  154. and bu_no=#{buNo}
  155. AND roll_no IN
  156. <foreach item="item" collection="rollList" open="(" separator="," close=")">
  157. #{item.rollNo}
  158. </foreach>
  159. order by created_date
  160. </select>
  161. <select id="getKuCunLabelData" resultType="InventoryStockOutData">
  162. select
  163. a.site,
  164. a.bu_no,--事业部
  165. a.roll_no,--标签条码
  166. a.qty_on_hand,--标签数量
  167. a.status,--状态
  168. a.part_no,--物料编码
  169. b.PartDescription,--物料名称
  170. b.Spec,--规格型号
  171. b.UMID,
  172. UM.UMName,--单位名称
  173. a.label_type,--标签类型
  174. a.parent_roll_no, --上级标签号
  175. a.parent_roll_type,--上级标签类型
  176. a.warehouse_id,
  177. W.WareHouseName,--仓库名称
  178. a.location_id,
  179. L.LocationName,--货位名称
  180. a.first_in_date,--入库日期
  181. a.manufacture_date,--生产日期
  182. a.expired_date, --有效期
  183. a.orderref0,--来源单据类型
  184. a.orderref1,--来源单据号
  185. a.orderref2,--来源单据行号
  186. a.batch_no, --合约号码
  187. a.wdr, --批次号
  188. a.remark, --备注说明
  189. SUM(a.qty_on_hand) OVER() AS total_qty
  190. from inventory_stock a
  191. LEFT JOIN PART b ON a.site = b.Site AND a.part_no = b.PartNo
  192. LEFT JOIN UM ON b.Site = UM.Site AND b.UMID = UM.UMID
  193. LEFT JOIN WareHouse W ON a.site = W.Site AND a.warehouse_id = W.WareHouseID
  194. LEFT JOIN Location L ON a.site = L.Site AND a.location_id = L.LocationID
  195. <where>
  196. a.site in (select site from AccessSite where userID = #{query.userName})
  197. and a.status != '出库'
  198. <if test="query.warehouseIdList != null and query.warehouseIdList.size() > 0">
  199. and A.warehouse_id in
  200. <foreach collection="query.warehouseIdList" item="warehouseId" open="(" separator="," close=")">
  201. #{warehouseId}
  202. </foreach>
  203. </if>
  204. <if test="query.orderref0 != null and query.orderref0 != ''">
  205. and A.orderref0 like '%'+#{query.orderref0}+'%'
  206. </if>
  207. <if test="query.orderref1 != null and query.orderref1 != ''">
  208. and A.orderref1 like '%'+ #{query.orderref1}+'%'
  209. </if>
  210. <if test="query.remark != null and query.remark != ''">
  211. and A.remark like '%'+ #{query.remark}+'%'
  212. </if>
  213. <if test="query.locationId != null and query.locationId != ''">
  214. and A.location_id like '%'+ #{query.locationId}+'%'
  215. </if>
  216. <if test="query.rollNo != null and query.rollNo != ''">
  217. and A.roll_no like '%'+ #{query.rollNo}+'%'
  218. </if>
  219. <if test="query.parentRollNo != null and query.parentRollNo != ''">
  220. and A.parent_roll_no like '%'+ #{query.parentRollNo}+'%'
  221. </if>
  222. <if test="query.partNo != null and query.partNo != ''">
  223. and A.part_no like '%'+ #{query.partNo}+'%'
  224. </if>
  225. <if test="query.partDescription != null and query.partDescription != ''">
  226. and b.PartDescription like '%'+ #{query.partDescription}+'%'
  227. </if>
  228. <if test="query.statusList != null and query.statusList.size() > 0">
  229. and A.status in
  230. <foreach collection="query.statusList" item="status" open="(" separator="," close=")">
  231. #{status}
  232. </foreach>
  233. </if>
  234. <if test="query.labelType != null and query.labelType != ''">
  235. and a.label_type = #{query.labelType}
  236. </if>
  237. <if test="query.batchNo != null and query.batchNo != ''">
  238. and a.batch_no like '%'+ #{query.batchNo}+'%'
  239. </if>
  240. </where>
  241. </select>
  242. <!-- 查询物料有效期信息 -->
  243. <select id="getPartExpirationInfo" resultType="PoOrderRollNoOutData">
  244. SELECT
  245. expiration_flag as expirationFlag,
  246. expiration_day as expirationDay,
  247. expiration_warning_day as expirationWarningDay
  248. FROM part
  249. WHERE site = #{site}
  250. AND bu_no = #{buNo}
  251. AND PartNo = #{partNo}
  252. </select>
  253. <!-- 查询文件信息 -->
  254. <select id="queryFileId" resultType="java.util.HashMap">
  255. SELECT
  256. id,
  257. file_name as fileName
  258. FROM sys_oss
  259. WHERE order_ref1 = #{orderRef1}
  260. AND order_ref2 = #{orderRef2}
  261. </select>
  262. <!-- 检查标签条码是否已存在 -->
  263. <select id="checkRollNoExists" resultType="int">
  264. SELECT COUNT(1)
  265. FROM po_order_roll_no
  266. WHERE site = #{site}
  267. AND roll_no = #{rollNo}
  268. </select>
  269. <!-- 更新库存标签属性 -->
  270. <update id="updateInventoryStockAttribute">
  271. UPDATE inventory_stock
  272. SET
  273. batch_no = #{batchNo,jdbcType=VARCHAR},
  274. remark = #{remark,jdbcType=VARCHAR}
  275. WHERE site = #{site,jdbcType=VARCHAR}
  276. AND bu_no = #{buNo,jdbcType=VARCHAR}
  277. AND roll_no = #{rollNo,jdbcType=VARCHAR}
  278. </update>
  279. <update id="freezeStatusInventoryStock">
  280. update inventory_stock set status = '冻结',status_tb = 'F' where site = #{site} and bu_no = #{buNo} and roll_no = #{rollNo}
  281. </update>
  282. <!-- 获取仓库列表 -->
  283. <select id="getWarehouseList" resultType="InventoryStockOutData">
  284. SELECT DISTINCT
  285. WareHouseID as warehouseId,
  286. WareHouseName as warehouseName
  287. FROM WareHouse
  288. WHERE site in (select site from AccessSite where userID = #{userName})
  289. ORDER BY WareHouseID
  290. </select>
  291. </mapper>