<?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.ruoyi.production.mapper.ProductOrderMapper">
|
|
|
<resultMap id="basicMap" type="com.ruoyi.production.pojo.ProductOrder">
|
<id property="id" column="id"/>
|
<result property="tenantId" column="tenant_id"/>
|
<result property="routeId" column="route_id"/>
|
<result property="npsNo" column="nps_no"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="planCompleteTime" column="plan_complete_time"/>
|
<result property="status" column="status"/>
|
</resultMap>
|
|
<resultMap id="ProductOrderSourceMap" type="com.ruoyi.production.dto.ProductOrderSourceDto">
|
<id property="applyNo" column="apply_no"/>
|
<result property="applyNo" column="apply_no"/>
|
<collection property="productPlans" ofType="com.ruoyi.productionPlan.dto.ProductionPlanDto" autoMapping="true">
|
<id property="id" column="plan_id"/>
|
<result property="materialCode" column="material_code"/>
|
<result property="productName" column="product_name"/>
|
<result property="model" column="model"/>
|
<result property="unit" column="unit"/>
|
<result property="totalAssignedQuantity" column="total_assigned_quantity"/>
|
</collection>
|
</resultMap>
|
|
<select id="pageProductOrder" resultType="com.ruoyi.production.dto.ProductOrderDto">
|
SELECT
|
po.id,
|
po.nps_no,
|
po.tenant_id,
|
po.create_time,
|
po.update_time,
|
po.route_id,
|
po.quantity,
|
po.complete_quantity,
|
po.start_time,
|
po.end_time,
|
po.plan_complete_time,
|
po.status,
|
pm.product_name,
|
po.strength AS strength,
|
pr.process_route_code AS processRouteCode,
|
pr.description,
|
pb.id AS bomId,
|
pb.bom_no AS bomNo,
|
ROUND(po.complete_quantity / po.quantity * 100, 2) AS completionStatus,
|
pms.model,
|
pms.material_code AS materialCode,
|
pms.id AS productId
|
FROM product_order po
|
LEFT JOIN process_route pr ON po.route_id = pr.id
|
LEFT JOIN product_bom pb ON pr.bom_id = pb.id
|
LEFT JOIN product_material_sku pms ON pms.id = po.product_material_sku_id
|
LEFT JOIN product_material pm ON pm.id = pms.product_id
|
<where>
|
<if test="c.npsNo != null and c.npsNo != ''">
|
AND po.nps_no LIKE CONCAT('%', #{c.npsNo}, '%')
|
</if>
|
<if test="c.startTime != null and c.endTime != null">
|
AND po.create_time BETWEEN #{c.startTime} AND #{c.endTime}
|
</if>
|
<if test="c.status != null">
|
AND po.status = #{c.status}
|
</if>
|
<if test="c.productName != null and c.productName != ''">
|
AND pm.product_name LIKE CONCAT('%', #{c.productName}, '%')
|
</if>
|
<if test="c.materialCode != null and c.materialCode != ''">
|
AND pms.material_code LIKE CONCAT('%', #{c.materialCode}, '%')
|
</if>
|
<if test="c.model != null and c.model != ''">
|
AND pms.model LIKE CONCAT('%', #{c.model}, '%')
|
</if>
|
<if test="c.strength != null and c.strength != ''">
|
AND po.strength = #{c.strength}
|
</if>
|
</where>
|
</select>
|
<select id="listProcessRoute" resultType="com.ruoyi.production.pojo.ProcessRoute">
|
select pr.*
|
from process_route pr
|
left join product_material_sku pms on pms.id = pr.product_model_id
|
where pms.id = #{productModelId}
|
</select>
|
<select id="listProcessBom" resultType="com.ruoyi.production.dto.ProductStructureDto">
|
select ps.id,
|
ps.product_model_id,
|
ps.process_id,
|
ps.unit_quantity,
|
ps.unit_quantity * po.quantity as demandedQuantity,
|
ps.unit,
|
p.product_name,
|
pp.name as process_name,
|
pm.product_id,
|
pm.model
|
from product_structure ps
|
left join product_model pm on ps.product_model_id = pm.id
|
left join product p on pm.product_id = p.id
|
left join product_process pp on ps.process_id = pp.id
|
left join product_process_route ppr on ps.bom_id = ppr.bom_id
|
left join product_order po on po.id = ppr.product_order_id
|
where ppr.product_order_id = #{orderId}
|
order by ps.id
|
</select>
|
|
|
<select id="countCreated" resultType="java.lang.Integer">
|
SELECT count(1)
|
FROM product_order
|
WHERE create_time >= #{startDate}
|
AND create_time <= #{endDate}
|
</select>
|
|
<select id="countCompleted" resultType="java.lang.Integer">
|
SELECT count(1)
|
FROM product_order
|
WHERE end_time >= #{startDate}
|
AND end_time <= #{endDate}
|
AND complete_quantity >= quantity
|
</select>
|
|
<select id="countPending" resultType="java.lang.Integer">
|
SELECT count(1)
|
FROM product_order
|
WHERE create_time >= #{startDate}
|
AND create_time <= #{endDate}
|
AND complete_quantity < quantity
|
</select>
|
|
<select id="productOrderSource" resultMap="ProductOrderSourceMap"
|
parameterType="java.lang.Long">
|
SELECT pp.id AS plan_id,
|
pp.apply_no,
|
pp.*,
|
pop.assigned_quantity AS total_assigned_quantity,
|
sku.material_code,
|
sku.model,
|
pm.product_name,
|
pm.unit
|
|
FROM product_order_plan pop
|
LEFT JOIN production_plan pp ON pop.production_plan_id = pp.id
|
LEFT JOIN product_material_sku sku ON pp.product_material_sku_id = sku.id
|
LEFT JOIN product_material pm ON sku.product_id = pm.id
|
|
WHERE pop.product_order_id = #{orderId}
|
ORDER BY pp.apply_no
|
|
</select>
|
<select id="finishedPage" resultType="com.ruoyi.quality.dto.FinishedPageDto">
|
select * from
|
(select po.id productOrderId,
|
po.status,
|
po.nps_no,
|
sku.material_code,
|
pm.product_name,
|
sku.model,
|
po.strength,
|
po.quantity needQuantity,
|
sum(ppo.quantity) qualifiedQuantity,
|
sum(ppo.scrap_qty) unqualifiedQuantity,
|
sum(ppo.quantity+ppo.scrap_qty) quantity
|
from product_order po
|
LEFT JOIN product_material_sku sku ON po.product_material_sku_id = sku.id
|
LEFT JOIN product_material pm ON sku.product_id = pm.id
|
LEFT JOIN production_product_main ppm ON ppm.product_order_id = po.id
|
LEFT JOIN production_product_output ppo ON ppo.product_main_id = ppm.id
|
group by po.id ,
|
po.status,
|
po.nps_no,
|
sku.material_code,
|
pm.product_name,
|
sku.model,
|
po.strength,
|
po.quantity
|
order by po.id desc )A
|
<where>
|
<if test="c.npsNo != null and c.npsNo != ''">
|
AND A.nps_no LIKE CONCAT('%', #{c.npsNo}, '%')
|
</if>
|
<if test="c.productName != null and c.productName != ''">
|
AND A.product_name LIKE CONCAT('%', #{c.productName}, '%')
|
</if>
|
<if test="c.materialCode != null and c.materialCode != ''">
|
AND A.material_code LIKE CONCAT('%', #{c.materialCode}, '%')
|
</if>
|
<if test="c.model != null and c.model != ''">
|
AND A.model LIKE CONCAT('%', #{c.model}, '%')
|
</if>
|
<if test="c.strength != null and c.strength != ''">
|
AND A.strength = #{c.strength}
|
</if>
|
</where>
|
</select>
|
<select id="finishedRatio" resultType="com.ruoyi.quality.dto.FinishedRatioDto">
|
select A.material_code,
|
product_name,
|
model,
|
unit,
|
actualInputQuantity,
|
actualOutputQuantity,
|
actualInputQuantity / actualOutputQuantity actualInputOutputRatio,
|
unit_quantity standardInputOutputRatio,
|
(actualInputQuantity / actualOutputQuantity - unit_quantity)/unit_quantity deviationRate
|
from (select
|
sku.material_code,
|
pm.product_name,
|
sku.model,
|
pprip.unit,
|
pos.unit_quantity,
|
sum(pprip.product_value) actualInputQuantity,
|
sum(ppo.quantity+ppo.scrap_qty) actualOutputQuantity
|
from production_product_route_item_param pprip
|
left join production_product_route_item ppri on ppri.id=pprip.production_product_route_item_id
|
left join production_product_main ppm on ppm.id=ppri.product_main_id
|
left join production_product_output ppo on ppm.id=ppo.product_main_id
|
left join product_material_sku sku ON pprip.product_id = sku.id
|
left join product_material pm ON sku.product_id = pm.id
|
left join production_order_structure pos ON pos.product_model_id = pprip.product_id
|
where ppm.product_order_id = #{productOrderId}
|
and pos.order_id = #{productOrderId}
|
and pprip.order_item_param_id is null
|
group by sku.material_code,
|
pm.product_name,
|
sku.model,
|
pos.unit_quantity,
|
pprip.unit)A
|
|
</select>
|
</mapper>
|