From 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 06 十二月 2023 08:41:32 +0800
Subject: [PATCH] bug
---
server/src/main/resources/mappers/PlansExtMapper.xml | 47 +++++++++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/server/src/main/resources/mappers/PlansExtMapper.xml b/server/src/main/resources/mappers/PlansExtMapper.xml
index df7ce24..ee7c019 100644
--- a/server/src/main/resources/mappers/PlansExtMapper.xml
+++ b/server/src/main/resources/mappers/PlansExtMapper.xml
@@ -123,7 +123,7 @@
<select id="selectByModel" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultMap="PlansExtListVO">
SELECT
`a`.*
- ,ifnull(( SELECT sum( b.PLAN_NUM ) FROM workorder b WHERE b.deleted = 0 AND b.PLAN_ID = a.id and b.status = 4 ),0) AS workorderDistributNum
+ , ifnull(( SELECT sum( b.UNQUALIFIED_NUM + QUALIFIED_NUM ) FROM workorder b WHERE b.deleted = 0 AND b.PLAN_ID = a.id and b.status = 4 ),0) AS workorderDistributNum
from plans a
<where>
<if test="id != null">
@@ -288,7 +288,7 @@
</where>
</select>
<select id="selectProcedureProcessList" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultType="doumeemes.dao.business.dto.statistics.ProcedureProcessModel">
- select a.PROCEDURE_ID as procedureId,
+ <!-- select a.PROCEDURE_ID as procedureId,
b.name as procedureName,
sum(a.num) as num,
count(DISTINCT(a.id)) as planCount,
@@ -298,19 +298,34 @@
left join procedures b on a.PROCEDURE_ID =b.ID
where ( a.`STATUS` in (1,4) or a.`STATUS`=6 and EXISTS(select e.id from workorder_record e where e.PLAN_ID = a.id and TO_DAYS(now())=TO_DAYS(e.CREATE_TIME)))
and a.ROOT_DEPART_ID=#{rootDepartId} and a.DEPART_ID=#{departId}
- and b.DELETED=0 and a.ROOT_DEPART_ID=132
+ and b.DELETED=0
GROUP BY a.PROCEDURE_ID
- order by b.SORTNUM
+ order by b.SORTNUM-->
+
+ select t.PROCEDURE_ID as procedureId,count(t.id) as planCount, t.SORTNUM,t.procedureName,sum(t.num) as num ,sum(t.qualifiedNum) as qualifiedNum,sum(t.unqualifiedNum) as unqualifiedNum
+ from (select a.id,a.PROCEDURE_ID ,
+ b.name as procedureName,
+ a.num as num,
+ b.SORTNUM,
+ (select sum(d.QUALIFIED_NUM) from workorder_record d where d.DELETED=0 and d.PLAN_ID=a.id and d.TYPE=1 ) as qualifiedNum ,
+ (select sum(d.UNQUALIFIED_NUM) from workorder_record d where d.DELETED=0 and d.PLAN_ID=a.id and d.TYPE=1 ) as unqualifiedNum
+ from plans a
+ left join procedures b on a.PROCEDURE_ID =b.ID
+ where ( a.`STATUS` in (1,4) or (a.`STATUS`=6 and EXISTS(select e.id from workorder_record e where e.PLAN_ID = a.id and TO_DAYS(now())=TO_DAYS(e.CREATE_TIME)))) and b.DELETED=0
+ and a.ROOT_DEPART_ID=#{rootDepartId} and a.DEPART_ID=#{departId}
+ ) t
+ GROUP BY t.PROCEDURE_ID
+ order by t.SORTNUM
</select>
<select id="selectStatisticsList" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultType="doumeemes.dao.business.dto.statistics.ProcedurePlansPageModel">
- select a.status,a.NUM,m.name as categoryName,m.code as materialCode
+ select a.status,a.NUM,m.name as categoryName,m.code as materialCode,m.name as materialName
,(select sum(b.UNQUALIFIED_NUM) from workorder_record b where b.type=1 and b.DELETED=0 and b.PLAN_ID=a.id) as unqualifiedNum
,(select sum(b.QUALIFIED_NUM) from workorder_record b where b.type=1 and b.DELETED=0 and b.PLAN_ID=a.id) as qualifiedNum
FROM `plans` `a`
LEFT JOIN `material_distribute` c ON a.MATERIAL_ID=c.ID
LEFT JOIN `material` m ON c.MATERIAL_ID=m.ID
- where (a.status in (1,4) or (a.status=6 and EXISTS(select b.id from workorder_record b where b.type=1 and b.DELETED=0 and b.PLAN_ID=a.id) ))
- and a.deleted=0 and a.ROOT_DEPART_ID=#{rootDepartId} and a.DEPART_ID=#{departId}
+ where (a.status in (1,4) or (a.status=6 and EXISTS(select b.id from workorder_record b where b.type=1 and b.DELETED=0 and b.PLAN_ID=a.id and to_days(b.create_time)=to_days(now())) ))
+ and a.deleted=0 and a.ROOT_DEPART_ID=#{rootDepartId} and a.DEPART_ID=#{departId} and a.PROCEDURE_ID=#{procedureId}
order by a.CREATE_TIME
</select>
<select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultMap="PlansExtListVO">
@@ -389,13 +404,13 @@
`usermodel`.`SYSTEMID` AS USERMODEL_SYSTEMID,
`usermodel`.`INVALID_TIME` AS USERMODEL_INVALID_TIME,
`usermodel`.`TYPE` AS USERMODEL_TYPE
- , ifnull(( SELECT sum( b.PLAN_NUM ) FROM workorder b WHERE b.deleted = 0 AND b.PLAN_ID = a.id and b.status !=6),0) AS workorderDistributNum ,
+ , ifnull(( SELECT sum( b.UNQUALIFIED_NUM + QUALIFIED_NUM ) FROM workorder b WHERE b.deleted = 0 AND b.PLAN_ID = a.id and b.status = 4 ),0) AS workorderDistributNum ,
`mmodel`.name as materialName , `mmodel`.code as materialCode ,`fmodel`.name as factoryName , `pmodel`.name as produceName ,
concat(`usermodel`.realname,' ',`usermodel`.mobile) as planUserName , `umodel`.name as unitName ,
w.PLAN_CODE as workPlanCode , w.SALESORDER as salesOrder ,
w.START_DATE as workPlanStartDate , w.PLAN_DATE as workPlanEndDate,
w.`PLAN_DATE` as workPlanPlanDate,
- ifnull((select sum(worder.PLAN_NUM) from workorder worder where worder.PLAN_ID = a.id and worder.STATUS not in (7,8) ),0) as produceNum
+ ifnull((select sum(worder.UNQUALIFIED_NUM + worder.QUALIFIED_NUM ) from workorder worder where worder.PLAN_ID = a.id and worder.STATUS = 4 ),0) as produceNum
FROM `plans` `a`
LEFT JOIN `department` `dmodel` ON a.DEPART_ID=dmodel.ID
LEFT JOIN `material_distribute` `mdmodel` ON a.MATERIAL_ID=mdmodel.ID
@@ -1239,12 +1254,12 @@
<if test="usermodelInvalidTime != null">
AND `usermodel`.`INVALID_TIME` = #{usermodelInvalidTime}
</if>
- <if test="startDate != null">
+ <!--<if test="startDate != null">
AND `a`.`PLAN_DATE` >= #{startDate}
</if>
<if test="endDate != null">
AND #{endDate} >= `a`.`PLAN_DATE`
- </if>
+ </if>-->
<if test="mixParam != null and mixParam!=''">
AND (mmodel.name like concat('%',#{mixParam},'%') or mmodel.code like concat('%',#{mixParam},'%') or pmodel.name like concat('%',#{mixParam},'%'))
</if>
@@ -1356,11 +1371,11 @@
</insert>
<select id="getPlansStaticticsData" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultType="doumeemes.dao.business.dto.statistics.StatisticsPlanDataModel">
SELECT count(a.id) as ingNum,
- (select count(b.id) FROM `plans` b where b.DELETED = 0 and b.PROCEDURE_ID=#{procedureId} AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND (b.`STATUS` in (1,4) and now() > b.plan_Date )) as delayNum,
- (select count(distinct(b.CREATE_USER)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status in (0,1,2,3,4,7)) as prouserNum,
- (select count(distinct(b.PRO_DEVICE_ID)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status in (0,1,2,3,4,7)) as deviceNum,
- (select sum(ifnull(b.UNQUALIFIED_NUM,0)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status=4) as unqualifiedNum,
- (select sum(ifnull(b.NUM,0)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status=4) as doneNum
+ (select count(b.id) FROM `plans` b where b.DELETED = 0 and b.PROCEDURE_ID=#{procedureId} AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND (b.`STATUS` in (1,4) and to_days(now()) > to_days(b.plan_Date) )) as delayNum,
+ (select count(distinct(b.CREATE_USER)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status in (0,1,2,3,4,7) AND to_days(b.create_time)=to_days(now())) as prouserNum,
+ (select count(distinct(b.PRO_GROUP_ID)) FROM workorder b where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND b.status in (0,1,2,3,4,7) AND to_days(b.create_time)=to_days(now())) as deviceNum,
+ (select sum(ifnull(b.UNQUALIFIED_NUM,0)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status=4 AND to_days(b.create_time)=to_days(now())) as unqualifiedNum,
+ (select sum(ifnull(b.NUM,0)) FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where b.PROCEDURE_ID=#{procedureId} AND b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId} AND c.status=4 AND to_days(b.create_time)=to_days(now())) as doneNum
FROM `plans` `a`
where
a.DELETED = 0 AND a.ROOT_DEPART_ID = #{rootDepartId} AND a.DEPART_ID = #{departId} and a.PROCEDURE_ID=#{procedureId} AND a.`STATUS` in (1,4)
--
Gitblit v1.9.3