Commit 05d37edf by lijingjing

对有关原铝统计添加原铝重取的数据;

parent b2772b74
......@@ -185,6 +185,13 @@ public class StatisticsController extends ServiceController {
return success(statsService.getAlBrandsRate(queryDTO));
}
@ApiOperation("原铝低铁统计")
@Login(action = Action.Skip)
@PostMapping("/al_brands_low_fe")
public RestResult<Integer> selectAlBrandLowFeStats(QueryDTO queryDTO) {
return success(statsService.selectAlBrandLowFeStats(queryDTO));
}
@ApiOperation("昨日原铝质量统计")
@Login(action = Action.Skip)
@PostMapping("/prev_al_brands_rate")
......
......@@ -17,6 +17,8 @@ public interface IStatisticsService extends IBaseService<Statistics> {
*/
List<Statistics> getAlBrandsRate(QueryDTO queryDTO);
Integer selectAlBrandLowFeStats(QueryDTO queryDTO);
List<Statistics> getPrevAlBrandsRate(QueryDTO queryDTO);
List<Statistics> getEntrustedQuantity(QueryDTO queryDTO);
......
......@@ -93,6 +93,15 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public Integer selectAlBrandLowFeStats(QueryDTO queryDTO) {
RestAssert.fail(StringUtils.isBlank(queryDTO.getType()), "牌号不能为空!");
if (null == queryDTO.getQueryDate()) {
queryDTO.setQueryDate(new Date());
}
return baseMapper.selectAlBrandLowFeStats(queryDTO);
}
@Override
public List<Statistics> getPrevAlBrandsRate(QueryDTO queryDTO) {
return getAlBrandsRate(queryDTO);
}
......
......@@ -13,7 +13,7 @@ spring:
type: com.zaxxer.hikari.HikariDataSource
username: postgres
password: www.163.com
url: jdbc:postgresql://192.168.1.140:5432/dev_hmhj_pro
url: jdbc:postgresql://192.168.1.140:5432/dev_hmhj
driver-class-name: org.postgresql.Driver
dynamic:
enabled: false
......@@ -22,7 +22,7 @@ spring:
consul:
host: localhost
rabbitmq:
host: 192.168.1.140
host: localhost
port: 5672
username: mqbase
password: mqb123#@$5
......
......@@ -204,14 +204,15 @@
with ix as (
SELECT
s.id "sample_id",
case when s.sample_grading = 'Al99.85' then 1 else 0 end "al_85_num",
case when s.sample_grading = 'Al99.80' then 1 else 0 end "al_80_num",
case when s.sample_grading = 'Al99.70' then 1 else 0 end "al_70_num",
case when s.sample_grading = 'Al99.70DT' then 1 else 0 end "al_70_dt_num",
case when (s.sample_grading = 'Al99.85' or s.sample_grading = 'Al99.80' or s.sample_grading = 'Al99.70' or s.sample_grading = 'Al99.70DT') then 1 else 0 end "al_70_ge_num"
case when coalesce(s.sample_grading,rs.sample_grading) = 'Al99.85' then 1 else 0 end "al_85_num",
case when coalesce(s.sample_grading,rs.sample_grading) = 'Al99.80' then 1 else 0 end "al_80_num",
case when coalesce(s.sample_grading,rs.sample_grading) = 'Al99.70' then 1 else 0 end "al_70_num",
case when coalesce(s.sample_grading,rs.sample_grading) = 'Al99.70DT' then 1 else 0 end "al_70_dt_num",
case when coalesce(s.sample_grading,rs.sample_grading) in ('Al99.85' ,'Al99.80','Al99.70','Al99.70DT') then 1 else 0 end "al_70_ge_num"
FROM
entrust_sample s
JOIN electrolyzer e ON s.electrolyzer_id = e.ID
LEFT JOIN entrust_sample rs on rs.source_code = s.code and rs.name = '原铝重取' and rs.deleted = 0
WHERE
s.deleted = 0 and e.deleted = 0 AND s.type = 0
AND s.status = 70
......
......@@ -13,37 +13,49 @@
AND s.sample_grading IS NOT NULL
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}::TIMESTAMP, 'yyyy-MM-dd')
)
SELECT s.sample_grading "brand",
SELECT coalesce(rs.sample_grading,s.sample_grading) "brand",
total,
count(1) "brand_num",
round(count(1)::numeric / total, 4) "ratio"
FROM entrust_sample s,
total,
entrust e
WHERE s.entrust_id = e.id
and s.deleted = 0
and e.deleted = 0
count(1) "brand_num",
round(count(1)::numeric / total, 4) "ratio"
FROM entrust_sample s
join total t on 1 = 1
join entrust e on e.id = s.entrust_id and e.deleted = 0
LEFT JOIN entrust_sample rs on rs.source_code = s.code and rs.name = '原铝重取' and rs.deleted = 0
WHERE s.deleted = 0
AND s.TYPE = 0
and s.name = '原铝'
AND s.sample_grading IS NOT NULL
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}::TIMESTAMP, 'yyyy-MM-dd')
GROUP BY s.sample_grading, total
order by s.sample_grading DESC
GROUP BY "brand", total
order by "brand" DESC
</select>
<!--查询原铝某一牌号低铁-->
<!--添加重取数据-->
<select id="selectAlBrandLowFeStats" resultType="java.lang.Integer">
SELECT count(distinct (case when to_number(ii.test_value, '99.9999') &lt;= 0.1 then s.id else null end)) "num"
SELECT count(distinct (case when to_number(coalesce(cq.test_value,ii.test_value), '99.9999') &lt;= 0.1 then s.id else null end)) "num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
JOIN entrust_sample_item i on i.entrust_sample_id = s.id and i.deleted = 0
JOIN entrust_sample_item_index ii on ii.entrust_sample_item_id = i.id and ii.deleted = 0
LEFT JOIN (
SELECT
sc.source_code,cii.name "item_name",ci.test_time, cii.test_value
FROM
entrust_sample sc
join entrust_sample_item ci on ci.entrust_sample_id = sc.id and ci.deleted = 0
join entrust_sample_item_index cii on cii.entrust_sample_item_id = ci.id and cii.deleted = 0
WHERE
sc.deleted = 0 and sc.name ='原铝重取' and cii.name = '原铝Fe'
and sc.source_code is not null
and cii.test_value is not null
) cq on cq.source_code = s.code and cq.item_name = ii.name
WHERE s.deleted = 0
and s.name = '原铝'
and s.type = 0
and s.sample_grading = #{vo.type}
and ii.NAME = '原铝Fe'
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}, 'yyyy-MM-dd')
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}::timestamp, 'yyyy-MM-dd')
</select>
<!--外委完成量统计(获取外检完成量数据): 获取LIMS平台某段时间的外检数据总数量和已检测数量-->
......@@ -640,9 +652,9 @@
<!--原铝品位台账查询-->
<select id="selectAlGradeLedger" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
SELECT
s.slot_no "label",
i.test_time "day",
s.sample_grading "value"
s.slot_no "label",
i.test_time "day",
coalesce(rs.sample_grading,s.sample_grading) "value"
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id and e.deleted = 0
......@@ -657,6 +669,7 @@
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
left join entrust_sample rs on rs.source_code = s.code and rs.name = '原铝重取' and rs.deleted = 0
WHERE
s.deleted = 0
AND s.NAME = '原铝'
......@@ -668,7 +681,7 @@
<!-- 原铝品味台账统计 -->
<select id="selectAlGradeLedgerStats" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
SELECT
s.sample_grading "label",
coalesce(rs.sample_grading,s.sample_grading) "label",
i.test_time "day",
count(1) "value"
FROM
......@@ -685,26 +698,38 @@
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
LEFT JOIN entrust_sample rs on rs.source_code = s.code and rs.deleted = 0 and rs.name = '原铝重取'
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
<include refid="ledger_where"/>
GROUP BY s.sample_grading,i.test_time
ORDER BY s.sample_grading desc, i.test_time
GROUP BY "label",i.test_time
ORDER BY "label" desc, i.test_time
</select>
<!-- 原铝杂质含量台账 -->
<select id="selectAlImpurityLedger" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
SELECT
s.slot_no "label",
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "day",
SUM ( ii.test_value::NUMERIC ) "value"
to_char( MAX ( coalesce(cq.test_time,i.test_time)), 'yyyy-mm-dd' ) "day",
SUM ( coalesce(cq.test_value,ii.test_value)::NUMERIC ) "value"
FROM
entrust_sample s
JOIN entrust_sample_item i on i.entrust_sample_id = s.id and i.deleted = 0
JOIN entrust_sample_item_index ii on ii.entrust_sample_item_id = i.id and ii.deleted = 0
JOIN electrolyzer e ON e.ID = s.electrolyzer_id and e.deleted = 0
WHERE
left join (
SELECT
sc.source_code,cii.name "item_name",ci.test_time, cii.test_value
FROM
entrust_sample sc
join entrust_sample_item ci on ci.entrust_sample_id = sc.id and ci.deleted = 0
join entrust_sample_item_index cii on cii.entrust_sample_item_id = ci.id and cii.deleted = 0
WHERE
sc.deleted = 0 and sc.name ='原铝重取' and sc.source_code is not null and cii.test_value is not null
) cq on cq.source_code = s.code and cq.item_name = i.name
WHERE
s.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
......@@ -725,52 +750,43 @@
FROM
(
SELECT
I.test_time,
SUM ( i.fe_01 ) "fe_01",
SUM ( i.fe_0095 ) "fe_0095",
SUM ( i.fe_0090 ) "fe_0090",
SUM ( i.fe_0080 ) "fe_0080",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) THEN 1 ELSE 0 END )
"over_70",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) AND i.fe_01 > 0 THEN 1 ELSE
0 END ) "low_fe",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) AND i.fe_01 > 0 AND
i.ni_00042 > 0 THEN 1 ELSE 0 END ) "low_ni"
FROM
entrust_sample s
JOIN electrolyzer e ON e.ID = s.electrolyzer_id AND e.deleted = 0
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC ) &lt;= 0.1 THEN 1 ELSE 0 END ) "fe_01",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC ) &lt;= 0.095 THEN 1 ELSE 0 END )
"fe_0095",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC ) &lt;= 0.090 THEN 1 ELSE 0 END )
"fe_0090",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC ) &lt;= 0.080 THEN 1 ELSE 0 END )
"fe_0080",
SUM ( CASE WHEN ii.NAME = '原铝Ni' AND CAST ( ii.test_value AS NUMERIC ) &lt;= 0.0042 THEN 1 ELSE 0 END)
"ni_00042"
FROM
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID AND ii.deleted = 0
WHERE
i.deleted = 0
AND i.NAME IN ( '原铝Fe', '原铝Ni')
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND (TRIM(ii.test_value) ~ '^([0-9]+[.]?[0-9]*|[.][0-9]+)$')
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
<include refid="ledger_where"/>
GROUP BY
I.test_time
) T order by sn , day
s.test_time,
SUM ( s.fe_01 ) "fe_01",
SUM ( s.fe_0095 ) "fe_0095",
SUM ( s.fe_0090 ) "fe_0090",
SUM ( s.fe_0080 ) "fe_0080",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) THEN 1 ELSE 0 END ) "over_70",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) AND s.fe_01 > 0 THEN 1 ELSE 0 END ) "low_fe",
SUM ( CASE WHEN s.sample_grading IN ( 'Al99.85', 'Al99.70DT', 'Al99.80', 'Al99.70' ) AND s.fe_01 > 0 AND s.ni_00042 > 0 THEN 1 ELSE 0 END ) "low_ni"
FROM ( SELECT
s.id "sample_id",
coalesce(cq.sample_grading,s.sample_grading) "sample_grading",
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( coalesce(cq.test_value,ii.test_value) AS NUMERIC ) &lt;= 0.1 THEN 1 ELSE 0 END ) "fe_01",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( coalesce(cq.test_value,ii.test_value) AS NUMERIC ) &lt;= 0.095 THEN 1 ELSE 0 END ) "fe_0095",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( coalesce(cq.test_value,ii.test_value) AS NUMERIC ) &lt;= 0.090 THEN 1 ELSE 0 END ) "fe_0090",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( coalesce(cq.test_value,ii.test_value) AS NUMERIC ) &lt;= 0.080 THEN 1 ELSE 0 END ) "fe_0080",
SUM ( CASE WHEN ii.NAME = '原铝Ni' AND CAST ( coalesce(cq.test_value,ii.test_value) AS NUMERIC ) &lt;= 0.0042 THEN 1 ELSE 0 END) "ni_00042"
FROM
entrust_sample s
JOIN electrolyzer e ON e.ID = s.electrolyzer_id AND e.deleted = 0
JOIN entrust_sample_item i ON i.entrust_sample_id = s.id and i.deleted = 0
JOIN entrust_sample_item_index ii on ii.entrust_sample_item_id = i.id and ii.deleted = 0
LEFT JOIN (
SELECT sc.source_code,sc.sample_grading,cii.name "item_name",ci.test_time, cii.test_value
FROM entrust_sample sc
join entrust_sample_item ci on ci.entrust_sample_id = sc.id and ci.deleted = 0
join entrust_sample_item_index cii on cii.entrust_sample_item_id = ci.id and cii.deleted = 0
WHERE sc.deleted = 0 and sc.name ='原铝重取' and sc.source_code is not null and cii.test_value is not null and ci.NAME IN ( '原铝Fe', '原铝Ni')
) cq on cq.source_code = s.code and cq.item_name = ii.name
where s.deleted = 0 AND s.NAME = '原铝'
AND i.NAME IN ( '原铝Fe', '原铝Ni')
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND s.sample_grading IS NOT NULL
<include refid="ledger_where"/>
AND (TRIM(ii.test_value) ~ '^([0-9]+[.]?[0-9]*|[.][0-9]+)$')
group by s.id ,coalesce(cq.sample_grading,s.sample_grading)
) T order by sn, day
</select>
<!--原铝杂质含量台账统计 -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment