Rev 5372 | Rev 5437 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="in.shop2020.warehouse.persistence.ScanMapper"><resultMap type="scan" id="scanResult"><id property="id" column="id"/></resultMap><insert id="insert" parameterType="scan" useGeneratedKeys="true" keyProperty="id">INSERT INTO scanNew(inventoryItemId, warehouseId, type, scannedAt, quantity, orderId)VALUES(#{inventoryItemId}, #{warehouseId}, #{type}, NOW(), #{quantity}, #{orderId})</insert><select id="get" parameterType="map" resultType="scan">SELECT *FROM scanNewWHERE inventoryItemId = #{inventoryItemId}<if test="scanType != null">AND type = #{scanType}</if>ORDER BY scannedAt</select><select id="getScansFromOrderId" parameterType="java.lang.Long" resultType="scan">SELECT *FROM scanNewWHERE orderId = #{orderId}ORDER BY scannedAt</select><select id="getPurchaseScans" parameterType="map" resultType="detailedPurchaseScan">SELECT p.purchaseOrder_id AS purchaseOrderId, 1000 * UNIX_TIMESTAMP(po.createdAt) AS poCreatedAt, s.name AS supplierName,GROUP_CONCAT(DISTINCT(invoiceNumber)) AS invoiceNumbers, i.itemId,CONCAT_WS(" ", brand, modelName, modelNumber, color) AS itemName, unitPrice, COUNT(*) AS quantityFROM purchase pJOIN purchaseorder poON (po.id = p.purchaseOrder_id)JOIN inventoryItem iON (p.id = i.purchaseId)JOIN lineitem lON (l.itemId = i.itemId AND l.purchaseOrder_id = po.id)JOIN supplier sON (s.id = po.supplierId)WHERE po.createdAt BETWEEN #{startDate} AND #{endDate}GROUP BY p.purchaseOrder_id, i.itemIdORDER BY p.purchaseOrder_id, i.itemId</select></mapper>