heli-mes/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/unqualifiednotification/UnqualifiedNotificationMapper.xml

217 lines
14 KiB
XML
Raw Normal View History

2025-01-09 18:29:48 +08:00
<?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.unqualifiednotification.UnqualifiedNotificationMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
2025-07-10 21:12:33 +08:00
<select id="QualityStatistics"
resultType="com.chanko.yunxi.mes.module.heli.controller.admin.unqualifiednotification.vo.QualityStatistics">
SELECT
t.*
FROM
(
SELECT
t.create_time as createTime,
t.project_name AS projectName,
c.NAME AS customerName,
t.project_sub_name AS projectSubName,
t.bom_name AS bomName,
0 AS type,
CASE
WHEN t.is_qua = 1 THEN
'是'
WHEN t.is_qua = 0 THEN
'否' ELSE '未知'
END AS isQua,
t.amount AS amount,
u1.nickname AS userName,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS testingTime,
pro.NAME AS procedureName,
u2.nickname AS auditorName,
DATE_FORMAT(t.audit_time, '%Y-%m-%d') AS auditTime,
t.audit_opinion AS auditOpinion,
p.CODE AS projectCode,
t.project_sub_number AS projectSubNumber
FROM
quality_pg_master_line t
LEFT JOIN project_sale_order p ON t.project_id = p.id
LEFT JOIN base_customer c ON p.customer_id = c.id
LEFT JOIN system_users u1 ON t.detil_user = u1.id
LEFT JOIN system_users u2 ON t.auditor = u2.id
LEFT JOIN base_procedure pro ON t.procedure_id = pro.id
WHERE
t.is_qua = 1
AND t.deleted = 0
UNION ALL
SELECT
t.create_time as createTime,
t.project_name AS projectName,
c.NAME AS customerName,
t.project_sub_name AS projectSubName,
'' AS bomName,
1 AS type,
CASE
WHEN t.is_qua = 1 THEN
'是'
WHEN t.is_qua = 0 THEN
'否' ELSE '未知'
END AS isQua,
t.amount AS amount,
u1.nickname AS userName,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS testingTime,
'' AS procedureName,
u2.nickname AS auditorName,
DATE_FORMAT(t.audit_time, '%Y-%m-%d') AS auditTime,
t.audit_opinion AS auditOpinion,
p.CODE AS projectCode,
t.project_sub_number AS projectSubNumber
FROM
quality_zj_pg_master_line t
LEFT JOIN project_sale_order p ON t.project_id = p.id
LEFT JOIN base_customer c ON p.customer_id = c.id
LEFT JOIN system_users u1 ON t.detil_user = u1.id
LEFT JOIN system_users u2 ON t.auditor = u2.id
WHERE
t.is_qua = 1
AND t.deleted = 0
) t
where 1=1
<if test="pageReqVO.projectCode!=null and pageReqVO.projectCode!=''">
and t.projectCode =#{pageReqVO.projectCode}
</if>
<if test="pageReqVO.projectName!=null and pageReqVO.projectName!=''">
and t.projectName =#{pageReqVO.projectName}
</if>
<if test="pageReqVO.projectSubCode!=null and pageReqVO.projectSubCode!=''">
and t.projectSubNumber =#{pageReqVO.projectSubCode}
</if>
<if test="pageReqVO.projectCode!=null and pageReqVO.projectCode!=''">
and t.projectCode =#{pageReqVO.projectCode}
</if>
<if test="pageReqVO.projectSubName!=null and pageReqVO.projectSubName!=''">
and t.projectSubName =#{pageReqVO.projectSubName}
</if>
<if test="pageReqVO.type!=null and pageReqVO.type!=''">
and t.type =#{pageReqVO.type}
</if>
<if test="pageReqVO.auditOpinion!=null and pageReqVO.auditOpinion!=''">
and t.auditOpinion =#{pageReqVO.auditOpinion}
</if>
order by t.createTime desc
</select>
2025-07-11 08:11:12 +08:00
<select id="selectCountPageWx" parameterType="java.lang.Integer" resultType="java.lang.Long">
2025-07-11 09:45:27 +08:00
SELECT count(*) FROM (
2025-07-11 08:11:12 +08:00
SELECT t.id as id, g.pg_number as code, g.project_sub_name as projectSubName,
t.amount as amount, g.amount as totalAmount, '过程检' as typeName,
t.ent_time as createTime,u.nickname as creatorName,g.project_sub_number as projectSubCode,
2025-07-11 09:45:27 +08:00
g.project_name as projectName ,u2.nickname as auditorName,t.audit_opinion as auditOpinion,
t.audit_time as auditTime,t.is_repre as isRepre,t.is_qua as isQua,t.notification_status as notificationStatus,
t.remark as remark, g.material_name as materialName,g.blueprint_no as blueprintNo, pr1.name as procedureName
2025-07-11 08:11:12 +08:00
FROM quality_bg_master_line t
LEFT JOIN quality_pg_master_line g ON t.zj_mx_id = g.id
LEFT JOIN base_procedure pr1 ON pr1.id = g.procedure_id
2025-07-11 09:45:27 +08:00
left join system_users u on u.id = t.bg_user left join system_users u2 on u2.id = t.auditor
2025-07-11 08:11:12 +08:00
WHERE t.deleted = 0 AND t.tenant_id = 2 AND g.deleted = 0 AND g.tenant_id = 2
AND pr1.deleted = 0 AND pr1.tenant_id = 2
AND t.notification_status = #{queryType}
UNION ALL
SELECT zj.id as id, g1.pg_number as code, g1.project_sub_name as projectSubName,
zj.amount as amount, g1.amount as totalAmount, '终检' as typeName,
zj.ent_time as createTime,u1.nickname as creatorName,g1.project_sub_number as projectSubCode,
2025-07-11 09:45:27 +08:00
g1.project_name as projectName , u3.nickname as auditorName,zj.audit_opinion as auditOpinion,
zj.audit_time as auditTime,zj.is_repre as isRepre,zj.is_qua as isQua,zj.notification_status as notificationStatus,
zj.remark as remark ,'' as materialName, '' as blueprintNo, '' as procedureName
2025-07-11 08:11:12 +08:00
FROM quality_zj_bg_master_line zj
LEFT JOIN quality_zj_pg_master_line g1 ON zj.zj_mx_id = g1.id
2025-07-11 09:45:27 +08:00
left join system_users u1 on u1.id = zj.bg_user left join system_users u3 on u3.id = zj.auditor
2025-07-11 08:11:12 +08:00
WHERE zj.deleted = 0 AND zj.tenant_id = 2 AND g1.deleted = 0 AND g1.tenant_id = 2
AND zj.notification_status = #{queryType}
) gh
</select>
2025-07-11 09:45:27 +08:00
<select id="selectWxById" parameterType="java.util.Map" resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.unqualifiednotification.UnqualifiedNotificationDO">
SELECT gh.id as id, gh.code as code, gh.projectSubName as projectSubName,
gh.amount as amount, gh.totalAmount as totalAmount, gh.typeName as typeName,
gh.createTime as createTime,gh.creatorName as creatorName,gh.projectSubCode as projectSubCode,
gh.projectName as projectName, gh.auditorName as auditorName,gh.auditOpinion as auditOpinion,
gh.auditTime as auditTime,gh.isRepre,gh.isQua,gh.notificationStatus as notificationStatus,
gh.remark as remark ,gh.materialName as materialName,gh.blueprintNo as blueprintNo, gh.procedureName as procedureName
FROM (
SELECT t.id as id, g.pg_number as code, g.project_sub_name as projectSubName,
t.amount as amount, g.amount as totalAmount, '过程检' as typeName,
t.ent_time as createTime,u.nickname as creatorName,g.project_sub_number as projectSubCode,
g.project_name as projectName ,u2.nickname as auditorName,t.audit_opinion as auditOpinion,
t.audit_time as auditTime,t.is_repre as isRepre,t.is_qua as isQua,t.notification_status as notificationStatus,
t.remark as remark, g.material_name as materialName,g.blueprint_no as blueprintNo, pr1.name as procedureName
FROM quality_bg_master_line t
LEFT JOIN quality_pg_master_line g ON t.zj_mx_id = g.id
LEFT JOIN base_procedure pr1 ON pr1.id = g.procedure_id
left join system_users u on u.id = t.bg_user left join system_users u2 on u2.id = t.auditor
WHERE t.deleted = 0 AND t.tenant_id = 2 AND g.deleted = 0 AND g.tenant_id = 2
AND pr1.deleted = 0 AND pr1.tenant_id = 2
UNION ALL
SELECT zj.id as id, g1.pg_number as code, g1.project_sub_name as projectSubName,
zj.amount as amount, g1.amount as totalAmount, '终检' as typeName,
zj.ent_time as createTime,u1.nickname as creatorName,g1.project_sub_number as projectSubCode,
g1.project_name as projectName , u3.nickname as auditorName,zj.audit_opinion as auditOpinion,
zj.audit_time as auditTime,zj.is_repre as isRepre,zj.is_qua as isQua,zj.notification_status as notificationStatus,
zj.remark as remark ,'' as materialName, '' as blueprintNo, '' as procedureName
FROM quality_zj_bg_master_line zj
LEFT JOIN quality_zj_pg_master_line g1 ON zj.zj_mx_id = g1.id
left join system_users u1 on u1.id = zj.bg_user left join system_users u3 on u3.id = zj.auditor
WHERE zj.deleted = 0 AND zj.tenant_id = 2 AND g1.deleted = 0 AND g1.tenant_id = 2
) gh
where gh.typeName = #{type} and gh.id = #{id}
</select>
2025-07-11 08:11:12 +08:00
<select id="selectPageWx" parameterType="java.lang.Integer" resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.unqualifiednotification.UnqualifiedNotificationDO">
SELECT gh.id as id, gh.code as code, gh.projectSubName as projectSubName,
gh.amount as amount, gh.totalAmount as totalAmount, gh.typeName as typeName,
gh.createTime as createTime,gh.creatorName as creatorName,gh.projectSubCode as projectSubCode,
2025-07-11 09:45:27 +08:00
gh.projectName as projectName, gh.auditorName as auditorName,gh.auditOpinion as auditOpinion,
gh.auditTime as auditTime,gh.isRepre,gh.isQua,gh.notificationStatus as notificationStatus,
gh.remark as remark ,gh.materialName as materialName,gh.blueprintNo as blueprintNo, gh.procedureName as procedureName
2025-07-11 08:11:12 +08:00
FROM (
SELECT t.id as id, g.pg_number as code, g.project_sub_name as projectSubName,
t.amount as amount, g.amount as totalAmount, '过程检' as typeName,
t.ent_time as createTime,u.nickname as creatorName,g.project_sub_number as projectSubCode,
2025-07-11 09:45:27 +08:00
g.project_name as projectName ,u2.nickname as auditorName,t.audit_opinion as auditOpinion,
t.audit_time as auditTime,t.is_repre as isRepre,t.is_qua as isQua,t.notification_status as notificationStatus,
t.remark as remark, g.material_name as materialName,g.blueprint_no as blueprintNo, pr1.name as procedureName
2025-07-11 08:11:12 +08:00
FROM quality_bg_master_line t
LEFT JOIN quality_pg_master_line g ON t.zj_mx_id = g.id
LEFT JOIN base_procedure pr1 ON pr1.id = g.procedure_id
2025-07-11 09:45:27 +08:00
left join system_users u on u.id = t.bg_user left join system_users u2 on u2.id = t.auditor
2025-07-11 08:11:12 +08:00
WHERE t.deleted = 0 AND t.tenant_id = 2 AND g.deleted = 0 AND g.tenant_id = 2
AND pr1.deleted = 0 AND pr1.tenant_id = 2
AND t.notification_status = #{queryType}
UNION ALL
SELECT zj.id as id, g1.pg_number as code, g1.project_sub_name as projectSubName,
zj.amount as amount, g1.amount as totalAmount, '终检' as typeName,
zj.ent_time as createTime,u1.nickname as creatorName,g1.project_sub_number as projectSubCode,
2025-07-11 09:45:27 +08:00
g1.project_name as projectName , u3.nickname as auditorName,zj.audit_opinion as auditOpinion,
zj.audit_time as auditTime,zj.is_repre as isRepre,zj.is_qua as isQua,zj.notification_status as notificationStatus,
zj.remark as remark ,'' as materialName, '' as blueprintNo, '' as procedureName
2025-07-11 08:11:12 +08:00
FROM quality_zj_bg_master_line zj
LEFT JOIN quality_zj_pg_master_line g1 ON zj.zj_mx_id = g1.id
2025-07-11 09:45:27 +08:00
left join system_users u1 on u1.id = zj.bg_user left join system_users u3 on u3.id = zj.auditor
2025-07-11 08:11:12 +08:00
WHERE zj.deleted = 0 AND zj.tenant_id = 2 AND g1.deleted = 0 AND g1.tenant_id = 2
AND zj.notification_status = #{queryType}
) gh
ORDER BY gh.createTime DESC LIMIT #{offset}, #{limit}
</select>
</mapper>