生产模块
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<?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.GearProductionTaskMapper">
|
||||
|
||||
<select id="selectTaskList" parameterType="com.gear.mes.production.domain.GearProductionTask" resultType="com.gear.mes.production.domain.vo.GearProductionTaskListVo">
|
||||
SELECT
|
||||
t.task_id AS taskId,
|
||||
t.task_code AS taskCode,
|
||||
t.task_name AS taskName,
|
||||
t.status AS status,
|
||||
t.plan_start_time AS planStartTime,
|
||||
t.plan_end_time AS planEndTime,
|
||||
t.remark AS remark,
|
||||
t.create_time AS createTime,
|
||||
t.update_time AS updateTime,
|
||||
IFNULL(SUM(p.plan_qty), 0) AS planQty,
|
||||
IFNULL(SUM(p.finished_qty), 0) AS finishedQty,
|
||||
IFNULL(SUM(p.bad_qty), 0) AS badQty,
|
||||
GREATEST(IFNULL(SUM(p.plan_qty), 0) - IFNULL(SUM(p.finished_qty), 0), 0) AS unfinishedQty
|
||||
FROM gear_production_task t
|
||||
LEFT JOIN gear_production_task_product p ON t.task_id = p.task_id
|
||||
<where>
|
||||
t.del_flag = '0'
|
||||
<if test="status != null and status != ''"> AND t.status = #{status}</if>
|
||||
<if test="taskCode != null and taskCode != ''"> AND t.task_code LIKE CONCAT('%', #{taskCode}, '%')</if>
|
||||
<if test="taskName != null and taskName != ''"> AND t.task_name LIKE CONCAT('%', #{taskName}, '%')</if>
|
||||
<if test="beginTime != null"> AND t.plan_start_time <![CDATA[>=]]> #{beginTime}</if>
|
||||
<if test="endTime != null"> AND t.plan_start_time <![CDATA[<=]]> #{endTime}</if>
|
||||
</where>
|
||||
GROUP BY t.task_id
|
||||
ORDER BY t.update_time DESC, t.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectTaskById" resultType="com.gear.mes.production.domain.GearProductionTask">
|
||||
SELECT
|
||||
task_id AS taskId,
|
||||
task_code AS taskCode,
|
||||
task_name AS taskName,
|
||||
status AS status,
|
||||
plan_start_time AS planStartTime,
|
||||
plan_end_time AS planEndTime,
|
||||
remark AS remark,
|
||||
create_by AS createBy,
|
||||
create_time AS createTime,
|
||||
update_by AS updateBy,
|
||||
update_time AS updateTime
|
||||
FROM gear_production_task
|
||||
WHERE task_id = #{taskId}
|
||||
AND del_flag = '0'
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertTask" parameterType="com.gear.mes.production.domain.GearProductionTask">
|
||||
INSERT INTO gear_production_task (
|
||||
task_id,
|
||||
task_code,
|
||||
task_name,
|
||||
status,
|
||||
plan_start_time,
|
||||
plan_end_time,
|
||||
remark,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
) VALUES (
|
||||
#{taskId},
|
||||
#{taskCode},
|
||||
#{taskName},
|
||||
#{status},
|
||||
#{planStartTime},
|
||||
#{planEndTime},
|
||||
#{remark},
|
||||
#{delFlag},
|
||||
#{createBy},
|
||||
#{createTime},
|
||||
#{updateBy},
|
||||
#{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateTask" parameterType="com.gear.mes.production.domain.GearProductionTask">
|
||||
UPDATE gear_production_task
|
||||
SET
|
||||
task_code = #{taskCode},
|
||||
task_name = #{taskName},
|
||||
status = #{status},
|
||||
plan_start_time = #{planStartTime},
|
||||
plan_end_time = #{planEndTime},
|
||||
remark = #{remark},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
WHERE task_id = #{taskId}
|
||||
AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="updateTaskStatus">
|
||||
UPDATE gear_production_task
|
||||
SET
|
||||
status = #{status},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
WHERE task_id = #{taskId}
|
||||
AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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.GearProductionTaskProductMapper">
|
||||
|
||||
<select id="selectByTaskId" resultType="com.gear.mes.production.domain.vo.GearProductionTaskProductVo">
|
||||
SELECT
|
||||
p.line_id AS lineId,
|
||||
p.task_id AS taskId,
|
||||
p.product_id AS productId,
|
||||
p.plan_qty AS planQty,
|
||||
p.finished_qty AS finishedQty,
|
||||
p.bad_qty AS badQty,
|
||||
p.unit AS unit,
|
||||
p.remark AS remark,
|
||||
COALESCE(gp.product_name, mp.product_name) AS productName,
|
||||
COALESCE(gp.product_code, CAST(mp.product_id AS CHAR)) AS productCode,
|
||||
COALESCE(gp.type, mp.product_type) AS productType,
|
||||
mp.spec AS spec,
|
||||
mp.model AS model
|
||||
FROM gear_production_task_product p
|
||||
LEFT JOIN gear_product gp ON p.product_id = gp.product_id
|
||||
LEFT JOIN mat_product mp ON p.product_id = mp.product_id
|
||||
WHERE p.task_id = #{taskId}
|
||||
ORDER BY p.line_id
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO gear_production_task_product (
|
||||
line_id,
|
||||
task_id,
|
||||
product_id,
|
||||
plan_qty,
|
||||
finished_qty,
|
||||
bad_qty,
|
||||
unit,
|
||||
remark
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
(
|
||||
#{i.lineId},
|
||||
#{i.taskId},
|
||||
#{i.productId},
|
||||
#{i.planQty},
|
||||
#{i.finishedQty},
|
||||
#{i.badQty},
|
||||
#{i.unit},
|
||||
#{i.remark}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByTaskId">
|
||||
DELETE FROM gear_production_task_product WHERE task_id = #{taskId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user