184 lines
6.1 KiB
XML
184 lines
6.1 KiB
XML
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.bonus.aqgqj.basis.dao.HomeDao">
|
|
<select id="getApprovalNum" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
|
select
|
|
sum(case when team_id is null then 1 else 0 end ) as dispatchWorkNum
|
|
,sum(case when team_id is not null and process_status is null then 1 else 0 end ) as testNum
|
|
,sum(case when process_status='1' AND ts.audti_status = 0 and is_er=1 then 1 else 0 end ) as reloadReviewNUm
|
|
,sum(case when process_status='1' and is_er is null and audti_status=0 then 1 else 0 end ) as reviewNUm
|
|
,sum(case when process_status='2' and audti_status=0 then 1 else 0 end ) as examineNum
|
|
,sum(case when process_status='3' and audti_status=0 then 1 else 0 end ) as approvalNum
|
|
,DATE_FORMAT(NOW(), '%Y-%m-%d') as updateDate
|
|
from (
|
|
select * from tb_sample where del_flag='0'
|
|
) ts
|
|
</select>
|
|
<select id="getATeamNumForEcharts" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
|
SELECT testData,COUNT(1) AS testNum from (
|
|
select tt.team_name as teamName,ts.id,DATE_FORMAT(ts.dispatch_time, '%Y-%m-%d') as testData from tb_sample ts
|
|
LEFT JOIN tb_team tt on ts.team_id=tt.id
|
|
where ts.del_flag='0' and tt.id=#{id}
|
|
) aa group by testData
|
|
</select>
|
|
<select id="getTeams" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
|
select id,team_name as teamname from tb_team where del_flag='0'
|
|
</select>
|
|
<select id="getATeamCostForEcharts" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
|
select
|
|
teamName,sum(amount) as testCost
|
|
from (
|
|
select tt.team_name as teamName,ts.id,te.amount
|
|
from tb_exper te
|
|
left join tb_sample ts on te.sample_id=ts.id
|
|
left join tb_team tt on ts.team_id=tt.id
|
|
where ts.del_flag='0'
|
|
) aa group by teamName
|
|
</select>
|
|
<select id="getCostRank" parameterType="com.bonus.aqgqj.basis.entity.vo.HomeVo" resultType="com.bonus.aqgqj.basis.entity.vo.HomeVo">
|
|
SELECT
|
|
*
|
|
FROM
|
|
(
|
|
SELECT
|
|
aa.id,
|
|
aa.custom_name AS userName,
|
|
aa.custom_user AS contacts,
|
|
aa.custom_phone AS contactPhone,
|
|
SUM( te.dev_num ) AS orderNum,
|
|
MAX( te.update_time ) AS cooperateDate,
|
|
SUM( te.dev_num * bb.amount ) + SUM(IFNULL( ted.amount, 0 )) AS totalCost
|
|
FROM
|
|
(
|
|
SELECT
|
|
ec.id,
|
|
ec.custom_name,
|
|
ec.custom_user,
|
|
ec.custom_phone
|
|
FROM
|
|
tb_custom ec
|
|
WHERE
|
|
ec.del_flag = 0
|
|
AND ec.dept_id = 0
|
|
) aa
|
|
LEFT JOIN tb_exper te ON te.submit_unit = aa.id
|
|
AND te.del_flag = 0
|
|
LEFT JOIN(
|
|
SELECT
|
|
exper_id,
|
|
SUM(amount) as amount
|
|
FROM
|
|
tb_exper_dev
|
|
GROUP BY exper_id
|
|
) ted ON ted.exper_id = te.id
|
|
LEFT JOIN ( SELECT exper_id, SUM( IFNULL( amount, 0 ) ) AS amount FROM tb_exper_items GROUP BY exper_id ) bb ON bb.exper_id = te.id
|
|
GROUP BY
|
|
te.submit_unit
|
|
) cc
|
|
WHERE
|
|
cc.cooperateDate IS NOT NULL
|
|
ORDER BY
|
|
cc.totalCost DESC
|
|
LIMIT 5
|
|
</select>
|
|
|
|
<select id="getExpireData" resultType="com.bonus.aqgqj.basis.entity.dto.SamplesManageDto">
|
|
SELECT
|
|
te.dev_type_name as name,
|
|
te.dev_module as devModule,
|
|
'试验样品' as type,
|
|
te.next_exper_time as nextExperTime,
|
|
DATEDIFF(te.next_exper_time, CURDATE()) AS days,
|
|
ted.dev_code as devCode,
|
|
tsd.customer_code as customerCode
|
|
FROM
|
|
tb_exper_dev ted
|
|
LEFT JOIN tb_exper te on te.id=ted.exper_id and te.del_flag=0
|
|
LEFT JOIN tb_sample_device tsd on tsd.id=ted.dev_id and tsd.del_falg=0
|
|
WHERE
|
|
1=1
|
|
and (
|
|
next_exper_time = CURDATE() + INTERVAL 60 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 30 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 15 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 0 DAY
|
|
OR
|
|
next_exper_time BETWEEN CURDATE()
|
|
AND CURDATE() + INTERVAL 7 DAY
|
|
)
|
|
|
|
UNION ALL
|
|
|
|
SELECT dev_name as name, dev_module as devModule, '试验设备' as type, contract_date as nextExperTime,
|
|
DATEDIFF(contract_date, CURDATE()) AS days,dev_code as devCode,'-' as customerCode
|
|
FROM tb_exper_device
|
|
WHERE contract_date = CURDATE() + INTERVAL 60 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 30 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 15 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 0 DAY
|
|
OR
|
|
contract_date BETWEEN CURDATE()
|
|
AND CURDATE() + INTERVAL 7 DAY
|
|
</select>
|
|
<select id="getExpireDataList" resultType="com.bonus.aqgqj.basis.entity.dto.SamplesManageDto">
|
|
select *
|
|
from (
|
|
SELECT
|
|
te.dev_type_name as name,
|
|
te.dev_module as devModule,
|
|
'试验样品' as type,
|
|
te.next_exper_time as nextExperTime,
|
|
DATEDIFF(te.next_exper_time, CURDATE()) AS days,
|
|
ted.dev_code as devCode,
|
|
tsd.customer_code as customerCode
|
|
FROM
|
|
tb_exper_dev ted
|
|
LEFT JOIN tb_exper te on te.id=ted.exper_id and te.del_flag=0
|
|
LEFT JOIN tb_sample_device tsd on tsd.id=ted.dev_id and tsd.del_falg=0
|
|
WHERE
|
|
1=1
|
|
and (
|
|
next_exper_time = CURDATE() + INTERVAL 60 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 30 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 15 DAY
|
|
OR
|
|
next_exper_time = CURDATE() + INTERVAL 0 DAY
|
|
OR
|
|
next_exper_time BETWEEN CURDATE()
|
|
AND CURDATE() + INTERVAL 7 DAY
|
|
)
|
|
|
|
UNION ALL
|
|
|
|
SELECT dev_name as name, dev_module as devModule, '试验设备' as type, contract_date as nextExperTime,
|
|
DATEDIFF(contract_date, CURDATE()) AS days,dev_code as devCode,'-' as customerCode
|
|
FROM tb_exper_device
|
|
WHERE contract_date = CURDATE() + INTERVAL 60 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 30 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 15 DAY
|
|
OR
|
|
contract_date = CURDATE() + INTERVAL 0 DAY
|
|
OR
|
|
contract_date BETWEEN CURDATE()
|
|
AND CURDATE() + INTERVAL 7 DAY) aa
|
|
where 1=1
|
|
<if test="name != null and name != ''">
|
|
and (
|
|
name like concat('%',#{name},'%') or
|
|
devModule like concat('%',#{name},'%') or
|
|
type like concat('%',#{name},'%')
|
|
)
|
|
</if>
|
|
order by days asc
|
|
</select>
|
|
</mapper> |