heli-mes/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/taskdispatch/TaskDispatchDetailMapper.xml
2025-01-24 19:46:44 +08:00

106 lines
5.8 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.chanko.yunxi.mes.module.heli.dal.mysql.taskdispatch.TaskDispatchDetailMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<update id="updateOwnerAndPostIdById" parameterType="Long">
update pro_task_dispatch_detail set
<if test="type == 1">owner = null</if>
<if test="type == 2">post_id = null</if>
WHERE id =#{id}
</update>
<select id="planBbPage" resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.taskdispatch.TaskDispatchDetailDO">
SELECT d.code AS projectCode,
d.project_name AS projectName,
j.plan_no AS taskNo, 0 AS planType,
e.name AS projectSubName,
c.material_name AS materialName,
f.name AS procdureName,
t.work_time AS workTime,
t.owner,
b.dispatch_type as type,
t.amount AS amount,
COALESCE(SUM(CASE WHEN h.work_time IS NULL THEN 0 ELSE h.work_time END), 0) AS bgWorkTime,
COALESCE(SUM(CASE WHEN h.amount IS NULL THEN 0 ELSE h.amount END), 0) AS bgAmount,
t.procedure_status AS wgType, t.end_time AS endTime
FROM pro_task_dispatch_detail t
LEFT JOIN pro_task_dispatch b ON (b.id = t.dispatch_id AND b.tenant_id = 2 AND b.deleted = 0)
LEFT JOIN pro_task_report h ON (h.dispatch_detail_id = t.id AND h.tenant_id = 2 AND h.deleted = 0)
LEFT JOIN pro_process_bom_detail c ON (c.id = b.bom_detail_id AND c.tenant_id = 2 AND c.deleted = 0)
LEFT JOIN project_sale_order d ON (d.id = b.project_id AND d.tenant_id = 2 AND d.deleted = 0)
LEFT JOIN project_sale_order_sub e ON (e.id = b.project_sub_id AND e.tenant_id = 2 AND e.deleted = 0)
LEFT JOIN base_procedure f ON (f.id = t.procedure_id AND f.tenant_id = 2 AND f.deleted = 0)
LEFT JOIN project_plan_task g ON (g.id = b.task_id AND g.tenant_id = 2 AND g.deleted = 0)
LEFT JOIN project_plan j ON (j.id = b.plan_id AND j.tenant_id = 2 AND j.deleted = 0)
WHERE t.deleted = 0 AND t.tenant_id = 2
<if test="reqVO.projectCode != null and reqVO.projectCode != ''">
AND d.code = #{reqVO.projectCode}
</if>
<if test="reqVO.projectName != null and reqVO.projectName != ''">
AND d.project_name = #{reqVO.projectName}
</if>
<if test="reqVO.taskNo != null and reqVO.taskNo != ''">
AND j.plan_no = #{reqVO.taskNo}
</if>
<if test="reqVO.projectSubName != null and reqVO.projectSubName != ''">
AND e.name = #{reqVO.projectSubName}
</if>
<if test="reqVO.materialName != null and reqVO.materialName != ''">
AND c.material_name = #{reqVO.materialName}
</if>
<if test="reqVO.owner != null and reqVO.owner != ''">
AND t.owner = #{reqVO.owner}
</if>
GROUP BY t.id
limit #{reqVO.pageNo},#{reqVO.pageSize}
</select>
<select id="planBb" resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.taskdispatch.TaskDispatchDetailDO">
SELECT d.code AS projectCode,
d.project_name AS projectName,
j.plan_no AS taskNo, 0 AS planType,
e.name AS projectSubName,
c.material_name AS materialName,
f.name AS procdureName,
t.work_time AS workTime,
t.owner,
t.amount AS amount,
COALESCE(SUM(CASE WHEN h.work_time IS NULL THEN 0 ELSE h.work_time END), 0) AS bgWorkTime,
COALESCE(SUM(CASE WHEN h.amount IS NULL THEN 0 ELSE h.amount END), 0) AS bgAmount,
t.procedure_status AS wgType, t.end_time AS endTime
FROM pro_task_dispatch_detail t
LEFT JOIN pro_task_dispatch b ON (b.id = t.dispatch_id AND b.tenant_id = 2 AND b.deleted = 0)
LEFT JOIN pro_task_report h ON (h.dispatch_detail_id = t.id AND h.tenant_id = 2 AND h.deleted = 0)
LEFT JOIN pro_process_bom_detail c ON (c.id = b.bom_detail_id AND c.tenant_id = 2 AND c.deleted = 0)
LEFT JOIN project_sale_order d ON (d.id = b.project_id AND d.tenant_id = 2 AND d.deleted = 0)
LEFT JOIN project_sale_order_sub e ON (e.id = b.project_sub_id AND e.tenant_id = 2 AND e.deleted = 0)
LEFT JOIN base_procedure f ON (f.id = t.procedure_id AND f.tenant_id = 2 AND f.deleted = 0)
LEFT JOIN project_plan_task g ON (g.id = b.task_id AND g.tenant_id = 2 AND g.deleted = 0)
LEFT JOIN project_plan j ON (j.id = b.plan_id AND j.tenant_id = 2 AND j.deleted = 0)
WHERE t.deleted = 0 AND t.tenant_id = 2
<if test="reqVO.projectCode != null and reqVO.projectCode != ''">
AND d.code = #{reqVO.projectCode}
</if>
<if test="reqVO.projectName != null and reqVO.projectName != ''">
AND d.project_name = #{reqVO.projectName}
</if>
<if test="reqVO.taskNo != null and reqVO.taskNo != ''">
AND j.plan_no = #{reqVO.taskNo}
</if>
<if test="reqVO.projectSubName != null and reqVO.projectSubName != ''">
AND e.name = #{reqVO.projectSubName}
</if>
<if test="reqVO.materialName != null and reqVO.materialName != ''">
AND c.material_name = #{reqVO.materialName}
</if>
<if test="reqVO.owner != null and reqVO.owner != ''">
AND t.owner = #{reqVO.owner}
</if>
GROUP BY t.id
</select>
</mapper>