Commit 05d37edf by lijingjing

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

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