提交基础采购
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?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="com.klp.erp.mapper.ErpPurchaseOrderItemMapper">
|
||||
|
||||
<resultMap id="ErpPurchaseOrderItemResult" type="com.klp.erp.domain.ErpPurchaseOrderItem">
|
||||
<result property="itemId" column="item_id"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="materialTypeCode" column="material_type_code"/>
|
||||
<result property="specification" column="specification"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="unitPrice" column="unit_price"/>
|
||||
<result property="amount" column="amount"/>
|
||||
<result property="currentStock" column="current_stock"/>
|
||||
<result property="onTheWay" column="on_the_way"/>
|
||||
<result property="salesDemand" column="sales_demand"/>
|
||||
<result property="suggestPurchase" column="suggest_purchase"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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="com.klp.erp.mapper.ErpPurchaseReceiptMapper">
|
||||
|
||||
<resultMap id="ErpPurchaseReceiptResult" type="com.klp.erp.domain.ErpPurchaseReceipt">
|
||||
<result property="receiptId" column="receipt_id"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="itemId" column="item_id"/>
|
||||
<result property="receivedQty" column="received_qty"/>
|
||||
<result property="receiptTime" column="receipt_time"/>
|
||||
<result property="qualityResult" column="quality_result"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="sumQualifiedQtyByItem" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(received_qty), 0)
|
||||
FROM erp_purchase_receipt
|
||||
WHERE del_flag = 0
|
||||
AND item_id = #{itemId}
|
||||
AND (
|
||||
quality_result IS NULL
|
||||
OR UPPER(quality_result) IN ('QUALIFIED', '合格', 'PASS')
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?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="com.klp.erp.mapper.ErpPurchaseReportMapper">
|
||||
|
||||
<select id="sumTotalAmount" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(total_amount), 0)
|
||||
FROM erp_purchase_order
|
||||
WHERE del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="sumAmountBySupplier" resultType="java.util.HashMap">
|
||||
SELECT supplier_id AS supplierId,
|
||||
COALESCE(SUM(total_amount), 0) AS totalAmount,
|
||||
COUNT(*) AS orderCount
|
||||
FROM erp_purchase_order
|
||||
WHERE del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
GROUP BY supplier_id
|
||||
ORDER BY totalAmount DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPriceTrend" resultType="java.util.HashMap">
|
||||
SELECT DATE_FORMAT(po.order_date, '%Y-%m') AS period,
|
||||
poi.material_type_code AS materialCode,
|
||||
COALESCE(AVG(poi.unit_price), 0) AS avgPrice
|
||||
FROM erp_purchase_order po
|
||||
JOIN erp_purchase_order_item poi ON po.order_id = poi.order_id
|
||||
WHERE po.del_flag = 0
|
||||
AND poi.del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND po.order_date >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND po.order_date <= #{endTime}
|
||||
</if>
|
||||
GROUP BY period, poi.material_type_code
|
||||
ORDER BY period ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSupplierQuality" resultType="java.util.HashMap">
|
||||
SELECT po.supplier_id AS supplierId,
|
||||
COALESCE(SUM(pr.received_qty), 0) AS receivedQty,
|
||||
COALESCE(SUM(CASE WHEN r.status = 1 THEN ri.return_qty ELSE 0 END), 0) AS returnQty,
|
||||
COALESCE(SUM(CASE WHEN r.status = 1 THEN ri.return_qty ELSE 0 END), 0) /
|
||||
NULLIF(COALESCE(SUM(pr.received_qty), 0), 0) AS returnRate
|
||||
FROM erp_purchase_order po
|
||||
LEFT JOIN erp_purchase_receipt pr
|
||||
ON pr.order_id = po.order_id AND pr.del_flag = 0
|
||||
LEFT JOIN erp_purchase_return r
|
||||
ON r.order_id = po.order_id AND r.del_flag = 0
|
||||
LEFT JOIN erp_purchase_return_item ri
|
||||
ON ri.return_id = r.return_id AND ri.del_flag = 0
|
||||
WHERE po.del_flag = 0
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND po.create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND po.create_time <= #{endTime}
|
||||
</if>
|
||||
GROUP BY po.supplier_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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="com.klp.erp.mapper.ErpPurchaseReturnItemMapper">
|
||||
|
||||
<resultMap id="ErpPurchaseReturnItemResult" type="com.klp.erp.domain.ErpPurchaseReturnItem">
|
||||
<result property="returnItemId" column="return_item_id"/>
|
||||
<result property="returnId" column="return_id"/>
|
||||
<result property="itemId" column="item_id"/>
|
||||
<result property="returnQty" column="return_qty"/>
|
||||
<result property="photos" column="photos"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="sumAllReturnQtyByItem" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(return_qty), 0)
|
||||
FROM erp_purchase_return_item
|
||||
WHERE del_flag = 0
|
||||
AND item_id = #{itemId}
|
||||
</select>
|
||||
|
||||
<select id="sumCompletedReturnQtyByItem" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(ri.return_qty), 0)
|
||||
FROM erp_purchase_return_item ri
|
||||
JOIN erp_purchase_return r ON ri.return_id = r.return_id
|
||||
WHERE ri.del_flag = 0
|
||||
AND r.del_flag = 0
|
||||
AND r.status = 1
|
||||
AND ri.item_id = #{itemId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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="com.klp.erp.mapper.ErpPurchaseReturnMapper">
|
||||
|
||||
<resultMap id="ErpPurchaseReturnResult" type="com.klp.erp.domain.ErpPurchaseReturn">
|
||||
<result property="returnId" column="return_id"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="returnType" column="return_type"/>
|
||||
<result property="reason" column="reason"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
|
||||
25
klp-erp/src/main/resources/mapper/erp/ErpSupplierMapper.xml
Normal file
25
klp-erp/src/main/resources/mapper/erp/ErpSupplierMapper.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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="com.klp.erp.mapper.ErpSupplierMapper">
|
||||
|
||||
<resultMap id="ErpSupplierResult" type="com.klp.erp.domain.ErpSupplier">
|
||||
<result property="supplierId" column="supplier_id"/>
|
||||
<result property="supplierCode" column="supplier_code"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="creditRating" column="credit_rating"/>
|
||||
<result property="contactPerson" column="contact_person"/>
|
||||
<result property="contactPhone" column="contact_phone"/>
|
||||
<result property="address" column="address"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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="com.klp.erp.mapper.ErpSupplierPriceMapper">
|
||||
|
||||
<resultMap id="ErpSupplierPriceResult" type="com.klp.erp.domain.ErpSupplierPrice">
|
||||
<result property="priceId" column="price_id"/>
|
||||
<result property="supplierId" column="supplier_id"/>
|
||||
<result property="materialTypeCode" column="material_type_code"/>
|
||||
<result property="specification" column="specification"/>
|
||||
<result property="price" column="price"/>
|
||||
<result property="validFrom" column="valid_from"/>
|
||||
<result property="validTo" column="valid_to"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectMaterialTypeOptions" resultType="com.klp.erp.domain.vo.MaterialTypeOptionVo"
|
||||
parameterType="com.klp.erp.domain.bo.MaterialTypeQueryBo">
|
||||
SELECT DISTINCT
|
||||
esp.material_type_code AS materialTypeCode,
|
||||
esp.specification AS specification,
|
||||
esp.supplier_id AS supplierId,
|
||||
es.name AS supplierName,
|
||||
esp.price AS latestPrice
|
||||
FROM erp_supplier_price esp
|
||||
LEFT JOIN erp_supplier es ON esp.supplier_id = es.supplier_id
|
||||
<where>
|
||||
esp.del_flag = 0
|
||||
<if test="supplierId != null">
|
||||
AND esp.supplier_id = #{supplierId}
|
||||
</if>
|
||||
<if test="materialTypeCode != null and materialTypeCode != ''">
|
||||
AND esp.material_type_code LIKE CONCAT('%', #{materialTypeCode}, '%')
|
||||
</if>
|
||||
<if test="specification != null and specification != ''">
|
||||
AND esp.specification LIKE CONCAT('%', #{specification}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY esp.material_type_code, esp.specification
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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="com.klp.erp.mapper.PurchaseRequirementCalcMapper">
|
||||
|
||||
<resultMap id="ProductDemandMap" type="com.klp.erp.domain.dto.ProductDemandDTO">
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="demandQuantity" column="demand_quantity"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="ProductStockMap" type="com.klp.erp.domain.dto.ProductStockDTO">
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="coilCount" column="coil_count"/>
|
||||
<result property="totalWeight" column="total_weight"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RawStockMap" type="com.klp.erp.domain.dto.RawStockDTO">
|
||||
<result property="rawMaterialId" column="raw_material_id"/>
|
||||
<result property="coilCount" column="coil_count"/>
|
||||
<result property="totalWeight" column="total_weight"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RawTransitMap" type="com.klp.erp.domain.dto.RawTransitDTO">
|
||||
<result property="rawMaterialId" column="raw_material_id"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectProductDemand" resultMap="ProductDemandMap">
|
||||
SELECT
|
||||
od.product_id,
|
||||
COALESCE(SUM(od.quantity), 0) AS demand_quantity
|
||||
FROM wms_order_detail od
|
||||
JOIN wms_order o ON od.order_id = o.order_id
|
||||
WHERE o.del_flag = 0
|
||||
AND od.del_flag = 0
|
||||
AND o.order_status IN (0, 1)
|
||||
GROUP BY od.product_id
|
||||
</select>
|
||||
|
||||
<select id="selectProductStock" resultMap="ProductStockMap">
|
||||
SELECT
|
||||
item_id AS product_id,
|
||||
COUNT(*) AS coil_count,
|
||||
COALESCE(SUM(net_weight), 0) AS total_weight
|
||||
FROM wms_material_coil
|
||||
WHERE del_flag = 0
|
||||
AND status = 0
|
||||
AND data_type = 0
|
||||
AND item_type = 'product'
|
||||
AND (material_type IS NULL OR material_type <> '废品')
|
||||
GROUP BY item_id
|
||||
</select>
|
||||
|
||||
<select id="selectRawStock" resultMap="RawStockMap">
|
||||
SELECT
|
||||
item_id AS raw_material_id,
|
||||
COUNT(*) AS coil_count,
|
||||
COALESCE(SUM(net_weight), 0) AS total_weight
|
||||
FROM wms_material_coil
|
||||
WHERE del_flag = 0
|
||||
AND status = 0
|
||||
AND data_type = 0
|
||||
AND item_type = 'raw_material'
|
||||
AND (material_type IS NULL OR material_type <> '废品')
|
||||
GROUP BY item_id
|
||||
</select>
|
||||
|
||||
<sql id="PurchaseOrderJoin">
|
||||
FROM erp_purchase_order_item poi
|
||||
JOIN erp_purchase_order po ON poi.order_id = po.order_id
|
||||
LEFT JOIN wms_raw_material rm ON rm.raw_material_code = poi.material_type_code
|
||||
WHERE poi.del_flag = 0
|
||||
AND po.del_flag = 0
|
||||
AND rm.raw_material_id IS NOT NULL
|
||||
</sql>
|
||||
|
||||
<select id="selectRawInTransit" resultMap="RawTransitMap">
|
||||
SELECT
|
||||
rm.raw_material_id,
|
||||
COALESCE(SUM(poi.quantity), 0) AS quantity
|
||||
<include refid="PurchaseOrderJoin"/>
|
||||
AND po.order_status = 1
|
||||
GROUP BY rm.raw_material_id
|
||||
</select>
|
||||
|
||||
<select id="selectRawPending" resultMap="RawTransitMap">
|
||||
SELECT
|
||||
rm.raw_material_id,
|
||||
COALESCE(SUM(poi.quantity), 0) AS quantity
|
||||
<include refid="PurchaseOrderJoin"/>
|
||||
AND po.order_status = 0
|
||||
GROUP BY rm.raw_material_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user