@@ -41,12 +41,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
when t.status = 0 then
CONCAT(
IFNULL(
ROUND(
(SELECT count(1) FROM t_user_inspect ui,t_task_inspect ti WHERE ui.inspect_id = ti.id and ti.task_id = t.id and ti.status IN (2, 3))/
FLOOR(
(case t.type
when 1 then IF(ISNULL(t.task_type),(select count(1) from t_user u),(select count(1) from t_user u WHERE u.task_type = t.task_type))
when 3 then (select count(1) from t_industry)
else (select count(1) from t_business)
when 1 then
(SELECT
count(i.id)
FROM
t_task_inspect i,
(SELECT MAX(id) AS id FROM t_task_inspect WHERE `status` !=- 1 GROUP BY receive_id) d,
t_user u
WHERE
i.task_id = t.id
AND i.id = d.id
AND i.receive_id = u.id
AND u.task_type = t.task_type
AND i.`STATUS` != '-1') /
(SELECT COUNT(us.id) FROM t_user us WHERE us.task_type = t.task_type and us.village in (SELECT re.relation_id FROM t_task_relation_info re WHERE re.task_id = t.id and re.type = '1' ))
when 3 then
(SELECT
count(i.id)
FROM
t_task_inspect i,
(SELECT MAX(id) AS id FROM t_task_inspect WHERE `status` !=- 1 GROUP BY receive_id) d,
t_industry u
WHERE
i.task_id = t.id
AND i.id = d.id
AND i.receive_id = u.id
AND u.task_type = t.check_type
AND i.`STATUS` != '-1') /
(select count(1) from t_industry ind where ind.task_type = t.check_type)
else
(SELECT
count(i.id)
FROM
t_task_inspect i,
(SELECT MAX(id) AS id FROM t_task_inspect WHERE `status` !=- 1 GROUP BY receive_id) d,
t_business u
WHERE
i.task_id = t.id
AND i.id = d.id
AND i.receive_id = u.id
AND u.task_type = t.business_type
AND i.`STATUS` != '-1') /
(select count(1) from t_business ind where ind.task_type = t.business_type)
end) * 100
),
0),
...
...
@@ -206,22 +244,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(IF(!ISNULL(us.id) and p.status>=2 and p.member_id = #{params.memberId},1,0)) AS selfInspectNum,
</if>
<iftest="type != 1">
SUM(IF(p.status>=2 and p.member_id = #{params.memberId},1,0)) AS selfInspectNum,
</if>
<iftest="type == 1">
SUM(IF(ISNULL(us.id),0,1)) AS isjian,
</if>
<iftest="type != 1">
COUNT(p.id) AS isjian,
</if>
SUM(IF(!ISNULL(us.id) and p.status != -1 and p.member_id = #{params.memberId},1,0)) AS selfInspectNum,
SUM(IF(!ISNULL(us.id) and p.status != -1,1,0)) AS isjian,
CASE t.type
WHEN 1 THEN (SELECT COUNT(us.id) FROM t_user us WHERE us.task_type = t.task_type and us.village in (SELECT re.relation_id FROM t_task_relation_info re WHERE re.task_id = t.id and re.type = '1' ))
WHEN 2 THEN (SELECT COUNT(id) FROM t_business)
ELSE (SELECT COUNT(id) FROM t_industry)
WHEN 1 THEN (SELECT COUNT(us.id) FROM t_user us WHERE us.task_type = t.task_type and us.village in (SELECT re.relation_id FROM t_task_relation_info re WHERE re.task_id = t.id and re.type = '1' ))
WHEN 2 THEN (SELECT COUNT(id) FROM t_business bus where bus.task_type = t.business_type )
ELSE (SELECT COUNT(id) FROM t_industry ind where ind.task_type = t.check_type)
END AS allnum
FROM t_task t
LEFT JOIN (SELECT MAX(id) AS id,task_id FROM t_task_inspect WHERE `status` !=-1 GROUP BY task_id,receive_id ) mp ON mp.task_id = t.id
...
...
@@ -229,6 +257,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<iftest="type == 1">
LEFT JOIN t_user us ON us.id = p.receive_id AND t.task_type = us.task_type
</if>
<iftest="type == 2">
LEFT JOIN t_business us ON us.id = p.receive_id AND t.business_type = us.task_type
</if>
<iftest="type == 3">
LEFT JOIN t_industry us ON us.id = p.receive_id AND t.check_type = us.task_type