生产模块
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?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.gear.mes.production.mapper.GearProductionTaskMaterialMapper">
|
||||
|
||||
<select id="selectByTaskId" resultType="com.gear.mes.production.domain.vo.GearProductionTaskMaterialVo">
|
||||
SELECT
|
||||
m.line_id AS lineId,
|
||||
m.task_id AS taskId,
|
||||
m.material_id AS materialId,
|
||||
m.material_role AS materialRole,
|
||||
m.plan_qty AS planQty,
|
||||
m.used_qty AS usedQty,
|
||||
m.unit AS unit,
|
||||
m.remark AS remark,
|
||||
mm.material_name AS materialName,
|
||||
mm.material_type AS materialType,
|
||||
mm.spec AS spec,
|
||||
mm.model AS model,
|
||||
mm.factory AS factory
|
||||
FROM gear_production_task_material m
|
||||
LEFT JOIN mat_material mm ON m.material_id = mm.material_id
|
||||
WHERE m.task_id = #{taskId}
|
||||
ORDER BY m.material_role, m.line_id
|
||||
</select>
|
||||
|
||||
<select id="selectRequirementByTaskId" resultType="com.gear.mes.production.domain.GearProductionTaskMaterial">
|
||||
SELECT
|
||||
r.material_id AS materialId,
|
||||
CASE WHEN mm.material_type = 2 THEN 'main' ELSE 'aux' END AS materialRole,
|
||||
SUM(
|
||||
(
|
||||
CASE
|
||||
WHEN p.finished_qty IS NOT NULL AND p.finished_qty > 0 THEN p.finished_qty
|
||||
ELSE IFNULL(p.plan_qty, 0)
|
||||
END
|
||||
) * IFNULL(r.material_num, 0)
|
||||
) AS planQty,
|
||||
mm.unit AS unit
|
||||
FROM gear_production_task_product p
|
||||
JOIN mat_product_material_relation r ON p.product_id = r.product_id AND r.del_flag = 0
|
||||
LEFT JOIN mat_material mm ON r.material_id = mm.material_id
|
||||
WHERE p.task_id = #{taskId}
|
||||
GROUP BY r.material_id, mm.material_type, mm.unit
|
||||
ORDER BY mm.material_type DESC, MIN(IFNULL(r.sort, 0)), r.material_id
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO gear_production_task_material (
|
||||
line_id,
|
||||
task_id,
|
||||
material_id,
|
||||
material_role,
|
||||
plan_qty,
|
||||
used_qty,
|
||||
unit,
|
||||
remark
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
(
|
||||
#{i.lineId},
|
||||
#{i.taskId},
|
||||
#{i.materialId},
|
||||
#{i.materialRole},
|
||||
#{i.planQty},
|
||||
#{i.usedQty},
|
||||
#{i.unit},
|
||||
#{i.remark}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByTaskId">
|
||||
DELETE FROM gear_production_task_material WHERE task_id = #{taskId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user