Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-hmhj
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangweidong
patzn-cloud-service-hmhj
Commits
eddc4c47
Commit
eddc4c47
authored
Jul 16, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
大屏接口添加;
parent
81133afa
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
535 additions
and
345 deletions
+535
-345
DateKit.java
...ain/java/com/patzn/cloud/service/lims/common/DateKit.java
+2
-4
NoticeAnnouncementController.java
...ce/lims/hmhj/controller/NoticeAnnouncementController.java
+5
-1
StatisticsController.java
...ud/service/lims/hmhj/controller/StatisticsController.java
+43
-0
NoticeAnnouncementMapper.java
...ud/service/lims/hmhj/mapper/NoticeAnnouncementMapper.java
+2
-0
StatisticsMapper.java
...atzn/cloud/service/lims/hmhj/mapper/StatisticsMapper.java
+16
-0
IStatisticsService.java
...n/cloud/service/lims/hmhj/service/IStatisticsService.java
+10
-0
StatisticsServiceImpl.java
...service/lims/hmhj/service/impl/StatisticsServiceImpl.java
+51
-22
StatisticsMapper.xml
src/main/resources/mapper/hmhj/StatisticsMapper.xml
+406
-318
No files found.
src/main/java/com/patzn/cloud/service/lims/common/DateKit.java
View file @
eddc4c47
...
...
@@ -40,10 +40,7 @@ public class DateKit {
}
public
static
Integer
daysBetweenTwoDates
(
Date
start
,
Date
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
return
daysBetweenTwoDates
(
start
,
end
);
return
daysBetweenTwoDates
(
date2Local
(
start
),
date2Local
(
end
));
}
public
static
Integer
daysBetweenTwoDates
(
LocalDate
start
,
LocalDate
end
)
{
...
...
@@ -93,6 +90,7 @@ public class DateKit {
/**
* 根据当前系统时间获取班次
*
* @return
*/
public
static
String
getShiftByNow
()
{
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/NoticeAnnouncementController.java
View file @
eddc4c47
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
controller
;
import
com.baomidou.kisso.annotation.Action
;
import
com.baomidou.kisso.annotation.Login
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.patzn.cloud.commons.api.RestConstants
;
import
com.patzn.cloud.commons.api.RestResult
;
...
...
@@ -82,12 +84,14 @@ public class NoticeAnnouncementController extends ServiceController {
@PostMapping
(
"/recent/"
)
public
RestResult
<
List
<
NoticeAnnouncement
>>
recent
(
@RequestParam
(
value
=
"count"
,
required
=
false
)
Integer
count
)
{
if
(
count
==
null
)
if
(
count
==
null
)
{
count
=
3
;
}
return
success
(
noticeAnnouncementService
.
recent
(
count
));
}
@ApiOperation
(
"显示最新 N 条通知公告"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/latest"
)
public
RestResult
<
List
<
NoticeAnnouncement
>>
latestNotices
(
Integer
limit
)
{
return
success
(
noticeAnnouncementService
.
latestNotices
(
limit
));
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/StatisticsController.java
View file @
eddc4c47
...
...
@@ -72,6 +72,7 @@ public class StatisticsController extends ServiceController {
@ApiOperation
(
"检测项目数量统计"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/item_quantity"
)
public
RestResult
<
List
<
Statistics
>>
getItemQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getItemQuantity
(
queryDTO
));
...
...
@@ -120,24 +121,28 @@ public class StatisticsController extends ServiceController {
}
@ApiOperation
(
"获取外检完成量数据"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/out_test_finish_quantity"
)
public
RestResult
<
Statistics
>
getOutTestFinishQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getOutTestFinishQuantity
(
queryDTO
));
}
@ApiOperation
(
"外检项目数量统计"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/out_test_item_quantity"
)
public
RestResult
<
List
<
Statistics
>>
getOutTestItemQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getOutTestItemQuantity
(
queryDTO
));
}
@ApiOperation
(
"工作量统计"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/workload_quantity"
)
public
RestResult
<
Statistics
>
getWorkloadQuantity
(
RangeStatsQueryDTO
queryDTO
)
{
return
success
(
statsService
.
getWorkloadQuantity
(
queryDTO
));
}
@ApiOperation
(
"本周验收合格情况"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/cur_week_acceptance_qualified"
)
public
RestResult
<
List
<
Statistics
>>
getCurWeekAcceptanceQualified
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getCurWeekAcceptanceQualified
(
queryDTO
));
...
...
@@ -158,12 +163,14 @@ public class StatisticsController extends ServiceController {
}
@ApiOperation
(
"本周自产炭块质量统计"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/cur_week_carbon_blocks"
)
public
RestResult
<
List
<
Statistics
>>
getCurWeekCarbonBlocks
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getCurWeekCarbonBlocks
(
queryDTO
));
}
@ApiOperation
(
"当日原铝质量统计"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/al_brands_rate"
)
public
RestResult
<
List
<
Statistics
>>
getAlBrandsRate
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getAlBrandsRate
(
queryDTO
));
...
...
@@ -220,4 +227,40 @@ public class StatisticsController extends ServiceController {
public
RestResult
<
Statistics
>
getTestItemQuantityStats
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getTestItemQuantityStats
(
queryDTO
));
}
@ApiOperation
(
"获取化验委托数量统计数据"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/assay_material_quantity"
)
public
RestResult
<
List
<
Map
<
String
,
Object
>>>
getAssayMaterialQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getAssayMaterialQuantity
(
queryDTO
));
}
@ApiOperation
(
"获取可检测项目统计数据"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/detectable_item_quantity"
)
public
RestResult
<
List
<
Map
<
String
,
Object
>>>
getDetectableItemQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getDetectableItemQuantity
(
queryDTO
));
}
@ApiOperation
(
"获取化验检测完毕任务数量统计数据"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/detected_tasks_quantity"
)
public
RestResult
<
List
<
Map
<
String
,
Object
>>>
getDetectedTasksQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getDetectedTasksQuantity
(
queryDTO
));
}
@ApiOperation
(
"获取日原辅料检测当前实时数据情况"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/cur_raw_material_quantity"
)
public
RestResult
<
Map
<
String
,
Object
>>
getRawMaterialStageQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getRawMaterialStageQuantity
(
queryDTO
));
}
@ApiOperation
(
"获取日过程样检测当前实时数据情况"
)
@Login
(
action
=
Action
.
Skip
)
@PostMapping
(
"/cur_process_sample_quantity"
)
public
RestResult
<
Map
<
String
,
Object
>>
getProcessSampleStageQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getProcessSampleStageQuantity
(
queryDTO
));
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/mapper/NoticeAnnouncementMapper.java
View file @
eddc4c47
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
mapper
;
import
com.baomidou.mybatisplus.annotations.SqlParser
;
import
com.patzn.cloud.commons.mapper.BatchMapper
;
import
com.patzn.cloud.service.hmhj.entity.NoticeAnnouncement
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -30,5 +31,6 @@ public interface NoticeAnnouncementMapper extends BatchMapper<NoticeAnnouncement
* @param limit the limit
* @return the list
*/
@SqlParser
(
filter
=
true
)
List
<
NoticeAnnouncement
>
selectLatestNotices
(
@Param
(
"limit"
)
Integer
limit
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/mapper/StatisticsMapper.java
View file @
eddc4c47
...
...
@@ -10,6 +10,7 @@ import com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
public
interface
StatisticsMapper
extends
BatchMapper
<
Statistics
>
{
...
...
@@ -93,4 +94,19 @@ public interface StatisticsMapper extends BatchMapper<Statistics> {
@SqlParser
(
filter
=
true
)
Statistics
selectAlProductInspectionQuantityRate
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
@SqlParser
(
filter
=
true
)
List
<
Map
<
String
,
Object
>>
selectAssayMaterialQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
@SqlParser
(
filter
=
true
)
List
<
Map
<
String
,
Object
>>
selectDetectableItemQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
@SqlParser
(
filter
=
true
)
List
<
Map
<
String
,
Object
>>
selectDetectedTasksQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
@SqlParser
(
filter
=
true
)
Map
<
String
,
Object
>
selectRawMaterialStageQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
@SqlParser
(
filter
=
true
)
Map
<
String
,
Object
>
selectProcessSampleStageQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IStatisticsService.java
View file @
eddc4c47
...
...
@@ -33,6 +33,12 @@ public interface IStatisticsService extends IBaseService<Statistics> {
List
<
Statistics
>
getSamplingQuantity
(
RangeStatsQueryDTO
queryDTO
);
List
<
Map
<
String
,
Object
>>
getDetectableItemQuantity
(
QueryDTO
queryDTO
);
List
<
Map
<
String
,
Object
>>
getDetectedTasksQuantity
(
QueryDTO
queryDTO
);
Map
<
String
,
Object
>
getRawMaterialStageQuantity
(
QueryDTO
queryDTO
);
Statistics
getItemSamesChainQuantity
(
RangeStatsQueryDTO
queryDTO
);
Statistics
getOutTestFinishQuantity
(
QueryDTO
queryDTO
);
...
...
@@ -70,4 +76,8 @@ public interface IStatisticsService extends IBaseService<Statistics> {
Integer
getAlProductInspectionQuantity
(
QueryDTO
queryDTO
);
Statistics
getAlProductInspectionQuantityRate
(
QueryDTO
queryDTO
);
List
<
Map
<
String
,
Object
>>
getAssayMaterialQuantity
(
QueryDTO
queryDTO
);
Map
<
String
,
Object
>
getProcessSampleStageQuantity
(
QueryDTO
queryDTO
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/StatisticsServiceImpl.java
View file @
eddc4c47
...
...
@@ -3,7 +3,6 @@ package com.patzn.cloud.service.lims.hmhj.service.impl;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.commons.toolkit.BigDecimalUtils
;
import
com.patzn.cloud.service.hmhj.dto.LedgerQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.RangeStatsQueryDTO
;
...
...
@@ -16,7 +15,6 @@ import org.apache.commons.lang.time.DateUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
...
...
@@ -89,24 +87,24 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
@Override
public
List
<
Statistics
>
getPrevAlBrandsRate
(
QueryDTO
queryDTO
)
{
List
<
Statistics
>
statistics
=
getAlBrandsRate
(
queryDTO
);
if
(
CollectionUtils
.
isEmpty
(
statistics
))
{
return
statistics
;
}
queryDTO
.
setType
(
"Al99.70"
);
Integer
total
=
statistics
.
get
(
0
).
getTotal
();
Integer
num
=
baseMapper
.
selectAlBrandLowFeStats
(
queryDTO
);
num
=
null
==
num
?
0
:
num
;
Statistics
lowFe
=
new
Statistics
();
lowFe
.
setBrand
(
queryDTO
.
getType
()
+
"低铁"
);
lowFe
.
setTotal
(
total
);
lowFe
.
setBrandNum
(
num
);
if
(
null
==
total
||
0
==
total
)
{
lowFe
.
setRatio
(
0.0000
);
}
else
{
double
def
=
1.0000
;
lowFe
.
setRatio
(
BigDecimalUtils
.
div
(
new
BigDecimal
(
def
*
num
),
new
BigDecimal
(
def
*
total
),
4
).
doubleValue
());
}
statistics
.
add
(
lowFe
);
//
if (CollectionUtils.isEmpty(statistics)) {
//
return statistics;
//
}
//
queryDTO.setType("Al99.70");
//
Integer total = statistics.get(0).getTotal();
//
Integer num = baseMapper.selectAlBrandLowFeStats(queryDTO);
//
num = null == num ? 0 : num;
//
Statistics lowFe = new Statistics();
//
lowFe.setBrand(queryDTO.getType() + "低铁");
//
lowFe.setTotal(total);
//
lowFe.setBrandNum(num);
//
if (null == total || 0 == total) {
//
lowFe.setRatio(0.0000);
//
} else {
//
double def = 1.0000;
//
lowFe.setRatio(BigDecimalUtils.div(new BigDecimal(def * num), new BigDecimal(def * total), 4).doubleValue());
//
}
//
statistics.add(lowFe);
return
statistics
;
}
...
...
@@ -143,7 +141,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public
Statistics
getAnodeInspectionDoneQuantity
(
QueryDTO
queryDTO
){
public
Statistics
getAnodeInspectionDoneQuantity
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
selectAnodeInspectionDoneQuantity
(
queryDTO
);
}
...
...
@@ -210,6 +208,37 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public
List
<
Map
<
String
,
Object
>>
getAssayMaterialQuantity
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
selectAssayMaterialQuantity
(
queryDTO
);
}
@Override
public
List
<
Map
<
String
,
Object
>>
getDetectableItemQuantity
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
selectDetectableItemQuantity
(
queryDTO
);
}
@Override
public
List
<
Map
<
String
,
Object
>>
getDetectedTasksQuantity
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
selectDetectedTasksQuantity
(
queryDTO
);
}
@Override
public
Map
<
String
,
Object
>
getRawMaterialStageQuantity
(
QueryDTO
queryDTO
)
{
if
(
null
==
queryDTO
.
getQueryDate
())
{
queryDTO
.
setQueryDate
(
new
Date
());
}
return
baseMapper
.
selectRawMaterialStageQuantity
(
queryDTO
);
}
@Override
public
Map
<
String
,
Object
>
getProcessSampleStageQuantity
(
QueryDTO
queryDTO
)
{
if
(
null
==
queryDTO
.
getQueryDate
())
{
queryDTO
.
setQueryDate
(
new
Date
());
}
return
baseMapper
.
selectProcessSampleStageQuantity
(
queryDTO
);
}
@Override
public
Statistics
getItemSamesChainQuantity
(
RangeStatsQueryDTO
queryDTO
)
{
handleSamesChainTimeRange
(
queryDTO
);
return
baseMapper
.
selectItemSamesChainQuantity
(
queryDTO
);
...
...
@@ -231,7 +260,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
private
void
handleTimeRange
(
RangeStatsQueryDTO
queryDTO
)
{
queryDTO
.
setLastYearTimeS
(
DateUtils
.
addYears
(
queryDTO
.
getTimeS
(),
-
1
));
queryDTO
.
setLastYearTimeE
(
DateUtils
.
addYears
(
queryDTO
.
getTimeE
(),
-
1
));
Integer
days
=
DateKit
.
monthsBetweenTwoDates
(
queryDTO
.
getTimeS
(),
queryDTO
.
getTimeE
())
;
Integer
days
=
DateKit
.
daysBetweenTwoDates
(
queryDTO
.
getTimeS
(),
queryDTO
.
getTimeE
())
+
2
;
queryDTO
.
setPrevTimeS
(
DateUtils
.
addDays
(
queryDTO
.
getTimeS
(),
-
days
));
queryDTO
.
setPrevTimeE
(
queryDTO
.
getTimeS
());
}
...
...
src/main/resources/mapper/hmhj/StatisticsMapper.xml
View file @
eddc4c47
...
...
@@ -4,28 +4,27 @@
<!--当日原铝质量统计-->
<select
id=
"selectAlBrandsRateStats"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
with total as (
SELECT
COUNT(1) "total"
FROM
entrust_sample s
JOIN entrust e ON s.entrust_id = e.ID AND e.deleted = 0
WHERE
s.deleted = 0
SELECT COUNT(1) "total"
FROM entrust_sample s
JOIN entrust e ON s.entrust_id = e.ID AND e.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')
)
SELECT
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
AND s.TYPE = 0 and s.name = '原铝'
SELECT 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
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
...
...
@@ -34,22 +33,23 @@
<!--查询原铝某一牌号低铁-->
<select
id=
"selectAlBrandLowFeStats"
resultType=
"java.lang.Integer"
>
SELECT
count(distinct(case when to_number(ii.test_value, '99.9999')
<
= 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
SELECT count(distinct (case when to_number(ii.test_value, '99.9999')
<
= 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
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')
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')
</select>
<!--外委完成量统计(获取外检完成量数据): 获取LIMS平台某段时间的外检数据总数量和已检测数量-->
<select
id=
"selectOutTestFinishQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT count(distinct c.id)
"total",
sum(case when s.status = 70 and s.judge_status = 2 then 1 else 0 end) "done_num"
SELECT count(distinct c.id) "total",
sum(case when s.status = 70 and s.judge_status = 2 then 1 else 0 end) "done_num"
FROM contract_sample c
JOIN entrust_sample s on c.id = s.contract_sample_id
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
...
...
@@ -65,13 +65,13 @@
<!--获取阳极检查量: 获取LIMS平台某段时间的阳极检查总数量-->
<select
id=
"selectAnodeInspectionQuantity"
resultType=
"java.lang.Integer"
>
select
count(1) "total"
count(1) "total"
from
entrust_sample s
entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
where
s.deleted = 0
and s.name = '自产阳极炭块'
s.deleted = 0
and s.name = '自产阳极炭块'
<if
test=
"null != vo.timeS"
>
AND e.entrust_time >= #{vo.timeS}
</if>
...
...
@@ -83,28 +83,28 @@
<!--获取阳极检查量合格率:获取LIMS平台某段时间的阳极检查合格数量以及不合格数量数据-->
<select
id=
"selectAnodeInspectionDoneQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if
test=
"null != vo.timeS"
>
AND e.entrust_time >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND e.entrust_time
<
= #{vo.timeE}
</if>
AND s.type = 0 and s.name = '自产阳极炭块'
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if
test=
"null != vo.timeS"
>
AND e.entrust_time >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND e.entrust_time
<
= #{vo.timeE}
</if>
</select>
<!--获取铝成品检查量合格率数据: 获取LIMS平台某段时间内的铝成品检查合格数量及不合格数量-->
<select
id=
"selectAlProductInspectionQuantityRate"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
...
...
@@ -131,14 +131,14 @@
(
SELECT COUNT(1) "total"
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
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.NAME = '自产阳极炭块'
AND EXTRACT(YEAR FROM s.judge_time) = EXTRACT(YEAR FROM NOW())
AND EXTRACT(WEEK FROM s.judge_time) = EXTRACT(WEEK FROM NOW())
) A
)
A
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
...
...
@@ -156,14 +156,14 @@
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
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
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
AND s.judge_time >= DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP) - interval '7 day'
AND s.judge_time
<
DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP)
AND s.judge_time >= DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP) - interval '7 day'
AND s.judge_time
<
DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP)
GROUP BY to_char(s.judge_time, 'yyyy-MM-dd')
ORDER BY to_char(s.judge_time, 'yyyy-MM-dd') ASC
</select>
...
...
@@ -171,30 +171,30 @@
<!--获取验收合格率数据: 获取LIMS平台某段时间的验收合格数量和验收不合格数量-->
<select
id=
"selectAcceptanceQualifiedByTimeFrame"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
sum(case when s.ok_judge = '合格' then 1 else 0 end)
"done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if
test=
"null != vo.timeS"
>
AND s.judge_time >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND s.judge_time
<
= #{vo.timeE}
</if>
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if
test=
"null != vo.timeS"
>
AND s.judge_time >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND s.judge_time
<
= #{vo.timeE}
</if>
</select>
<!--工作量统计-->
<select
id=
"selectWorkloadQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT a.*,
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "
chain
_ratio",
(case when 0 = b.total then 1 else b.total end), 2) "
sames
_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "
sames
_ratio"
(case when 0 = c.total then 1 else c.total end), 2) "
chain
_ratio"
from (SELECT count(r.id) "total",
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
count(1) - sum(case when s.ok_judge = '合格' then 1 else 0 end) "fail_num",
...
...
@@ -202,7 +202,7 @@
round((count(1) - sum(case when s.ok_judge = '合格' then 1 else 0 end)):: NUMERIC / count(1),
2) "fail_ratio"
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_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
AND s.status = 70
...
...
@@ -212,7 +212,7 @@
) a,
(SELECT count(r.id) "total"
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_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
AND s.status = 70
...
...
@@ -222,7 +222,7 @@
) b,
(SELECT count(r.id) "total"
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_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
AND s.status = 70
...
...
@@ -260,25 +260,28 @@
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "
chain
_ratio",
(case when 0 = b.total then 1 else b.total end), 2) "
sames
_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "
sames
_ratio"
(case when 0 = c.total then 1 else c.total end), 2) "
chain
_ratio"
from (SELECT count(s.id) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
...
...
@@ -286,7 +289,7 @@
<!--获取取样量统计数据: 获取LIMS平台某段时间的质检取样量总数量-->
<select
id=
"selectTotalSamplingQuantity"
resultType=
"java.lang.Integer"
>
SELECT
count(s.id) "total"
count(s.id) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
...
...
@@ -319,25 +322,27 @@
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "
chain
_ratio",
(case when 0 = b.total then 1 else b.total end), 2) "
sames
_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "
sames
_ratio"
(case when 0 = c.total then 1 else c.total end), 2) "
chain
_ratio"
from (SELECT count(s.id) "total"
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
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
...
...
@@ -348,29 +353,32 @@
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "
chain
_ratio",
(case when 0 = b.total then 1 else b.total end), 2) "
sames
_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "
sames
_ratio"
(case when 0 = c.total then 1 else c.total end), 2) "
chain
_ratio"
from (SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0
AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
...
...
@@ -396,24 +404,24 @@
<!--报告发放量统计A-->
<select
id=
"selectReportSendQuantityMonth"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
select
t.occur_date,
count(t.id) "done_num"
t.occur_date,
count(t.id) "done_num"
from
(select
to_char(r.report_check_time, 'yyyy-MM') "occur_date",
r.id
from
(select
to_char(r.report_check_time, 'yyyy-MM') "occur_date",
r.id
from
entrust e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
where e.deleted = 0 and r.status = 50
<if
test=
"null != vo.timeS and null != vo.timeE"
>
AND (r.report_check_time between #{vo.timeS} and #{vo.timeE})
</if>
) t
entrust e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
where e.deleted = 0 and r.status = 50
<if
test=
"null != vo.timeS and null != vo.timeE"
>
AND (r.report_check_time between #{vo.timeS} and #{vo.timeE})
</if>
) t
group by
t.occur_date
t.occur_date
order by
t.occur_date asc
t.occur_date asc
</select>
<!--报告发放量统计B-->
<select
id=
"selectReportSendQuantitySamesChain"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
...
...
@@ -421,34 +429,34 @@
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "
chain
_ratio",
(case when 0 = b.total then 1 else b.total end), 2) "
sames
_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "
sames
_ratio"
(case when 0 = c.total then 1 else c.total end), 2) "
chain
_ratio"
from (SELECT count(r.id) "total"
FROM entrust e
FROM entrust
e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
AND r.report_check_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(r.id) "total"
FROM entrust e
FROM entrust
e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
AND r.report_check_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(r.id) "total"
FROM entrust e
FROM entrust
e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
AND r.report_check_time between #{vo.prevTimeS} and #{vo.prevTimeE}
AND r.report_check_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--报告发放量统计C-->
<select
id=
"selectReportSendQuantityTotal"
resultType=
"java.lang.Integer"
>
<select
id=
"selectReportSendQuantityTotal"
resultType=
"java.lang.Integer"
>
select
count(r.id) "total"
count(r.id) "total"
from
entrust e
entrust e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
where e.deleted = 0 and r.status = 50
<if
test=
"null != vo.timeS and null != vo.timeE"
>
...
...
@@ -461,8 +469,8 @@
SELECT S.NAME "brand",
COUNT(DISTINCT e.ID) "total",
COUNT(DISTINCT (CASE WHEN s.status = 70 THEN e.ID ELSE NULL END)) "done_num"
FROM ENTRUST E
JOIN ENTRUST_SAMPLE S ON S.entrust_id = E.ID
FROM ENTRUST
E
JOIN ENTRUST_SAMPLE S ON S.entrust_id = E.ID
WHERE E.deleted = 0
AND S.deleted = 0
AND s.type = 0
...
...
@@ -472,19 +480,15 @@
</select>
<sql
id=
"query_date"
>
SELECT
to_char( tt.DAY, 'yyyy-mm-dd' ) AS DAY
FROM
(
SELECT
generate_series (
CAST ('${vo.yearMonth}-01' AS DATE ),
CAST ( CAST ('${vo.yearMonth}-01' AS TIMESTAMP ) + '1 MONTH' + '-1 d' AS DATE ),
'1 d'
) AS DAY
) AS tt
ORDER BY
DAY
SELECT to_char(tt.DAY, 'yyyy-mm-dd') AS DAY
FROM (
SELECT generate_series(
CAST('${vo.yearMonth}-01' AS DATE),
CAST(CAST('${vo.yearMonth}-01' AS TIMESTAMP) + '1 MONTH' + '-1 d' AS DATE),
'1 d'
) AS DAY
) AS tt
ORDER BY DAY
</sql>
<sql
id=
"ledger_where"
>
...
...
@@ -503,225 +507,309 @@
<!--原铝品位台账查询-->
<select
id=
"selectAlGradeLedger"
resultType=
"com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO"
>
SELECT
s.slot_no "label",
i.test_time "day",
s.sample_grading "value"
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"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
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 i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
ORDER BY
s.slot_no, i.test_time
SELECT
s.slot_no "label",
i.test_time "day",
s.sample_grading "value"
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"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
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 i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
ORDER BY
s.slot_no, i.test_time
</select>
<!-- 原铝品味台账统计 -->
<select
id=
"selectAlGradeLedgerStats"
resultType=
"com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO"
>
SELECT
s.sample_grading "label",
i.test_time "day",
count(1) "value"
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
s.sample_grading "label",
i.test_time "day",
count(1) "value"
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
GROUP BY s.sample_grading,i.test_time
ORDER BY
s.sample_grading desc, i.test_time
GROUP BY s.sample_grading,i.test_time
ORDER BY
s.sample_grading desc, i.test_time
</select>
<!-- 原铝杂质含量台账 -->
<select
id=
"selectAlImpurityLedger"
resultType=
"com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO"
>
SELECT
s.slot_no "label",
i.test_time "day",
i.value
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time",
sum(ii.zz_value) "value"
FROM
entrust_sample_item i
join (
select
ii.entrust_sample_item_id,
sum(cast(ii.test_value as numeric))
"zz_value"
from entrust_sample_item_index ii
where ii.deleted = 0 and is_numeric(ii.test_value)
<if
test=
"null != vo.impurity"
>
and ii.name like concat('%',#{vo.impurity},'%')
</if>
group by ii.entrust_sample_item_id
) ii on ii.entrust_sample_item_id = i.id
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
SELECT
s.slot_no "label",
i.test_time "day",
i.value
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time",
sum(ii.zz_value) "value"
FROM
entrust_sample_item i
join (
select
ii.entrust_sample_item_id,
sum(cast(ii.test_value as numeric))
"zz_value"
from entrust_sample_item_index ii
where ii.deleted = 0 and is_numeric(ii.test_value)
<if
test=
"null != vo.impurity"
>
and ii.name like concat('%',#{vo.impurity},'%')
</if>
group by ii.entrust_sample_item_id
) ii on ii.entrust_sample_item_id = i.id
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
ORDER BY
s.slot_no, i.test_time
<include
refid=
"ledger_where"
/>
ORDER BY
s.slot_no, i.test_time
</select>
<!--原铝含铁量台账统计 -->
<select
id=
"selectAlFeLedgerStats"
resultType=
"com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO"
>
SELECT
"unnest" ( Array[0,1,2,3,4,5,6] ) "sn",
"unnest" ( string_to_array( 'Fe≤0.100台次,Fe≤0.095台次,Fe≤0.090台次,Fe≤0.080台次,99.70以上槽台数,低铁铝台次,低镍铝台次', ',' ) ) "label",
T.test_time "day",
"unnest" (Array[t.fe_01,t.fe_0095,t.fe_0090,t.fe_0080,t.over_70,t.low_fe,t.low_ni]) "value"
"unnest" ( Array[0,1,2,3,4,5,6] ) "sn",
"unnest" ( string_to_array( 'Fe≤0.100台次,Fe≤0.095台次,Fe≤0.090台次,Fe≤0.080台次,99.70以上槽台数,低铁铝台次,低镍铝台次', ',' ) )
"label",
T.test_time "day",
"unnest" (Array[t.fe_01,t.fe_0095,t.fe_0090,t.fe_0080,t.over_70,t.low_fe,t.low_ni]) "value"
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"
(
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 )
<
= 0.1 THEN 1 ELSE 0 END ) "fe_01",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.095 THEN 1 ELSE 0 END )
"fe_0095",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.090 THEN 1 ELSE 0 END )
"fe_0090",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.080 THEN 1 ELSE 0 END )
"fe_0080",
SUM ( CASE WHEN ii.NAME = '原铝Ni' AND CAST ( ii.test_value AS NUMERIC )
<
= 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 (
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 )
<
= 0.1 THEN 1 ELSE 0 END ) "fe_01",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.095 THEN 1 ELSE 0 END ) "fe_0095",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.090 THEN 1 ELSE 0 END ) "fe_0090",
SUM ( CASE WHEN ii.NAME = '原铝Fe' AND CAST ( ii.test_value AS NUMERIC )
<
= 0.080 THEN 1 ELSE 0 END ) "fe_0080",
SUM ( CASE WHEN ii.NAME = '原铝Ni' AND CAST ( ii.test_value AS NUMERIC )
<
= 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-dd') LIKE '${vo.yearMonth}%'
AND ii.test_value is not null
AND is_numeric ( ii.test_value )
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID AND ii.deleted = 0
WHERE
s
.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
i
.deleted = 0
AND i.NAME IN ( '原铝Fe', '原铝Ni')
AND to_char(i.test_time,'yyyy-mm-dd') LIKE '${vo.yearMonth}%'
AND ii.test_value is not null
AND is_numeric ( ii.test_value )
GROUP BY
I.test_time
) T order by sn , day
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 i.test_time LIKE '${vo.yearMonth}%'
<include
refid=
"ledger_where"
/>
GROUP BY
I.test_time
) T order by sn , day
</select>
<!--原铝杂质含量台账统计 -->
<select
id=
"selectAlImpurityLedgerStats"
resultType=
"com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO"
>
SELECT
t.name,
"unnest"(Array[ 0,1,2,3 ]) "sn",
"unnest"(Array[ '平均值','最大值', '最小值', '差值'] ) "label",
t.test_time "day",
"unnest"(Array[t.avg_val,t.max_val,t.min_val,t.dif_val]) "value"
t.name,
"unnest"(Array[ 0,1,2,3 ]) "sn",
"unnest"(Array[ '平均值','最大值', '最小值', '差值'] ) "label",
t.test_time "day",
"unnest"(Array[t.avg_val,t.max_val,t.min_val,t.dif_val]) "value"
FROM
(
SELECT
i."name",
to_char( i.test_time, 'yyyy-mm-dd' ) "test_time",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) "max_val",
MIN ( CAST ( ii.test_value AS NUMERIC ) ) "min_val",
round( AVG ( CAST ( ii.test_value AS NUMERIC ) ), 5 ) "avg_val",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) - MIN ( CAST ( ii.test_value AS NUMERIC ) ) "dif_val"
FROM
(
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID
AND ii.NAME = i.NAME
WHERE
i.deleted = 0
AND ii.deleted = 0
AND i.NAME = ii.NAME
AND I.NAME LIKE'%原铝%'
AND to_char( i.test_time, 'yyyy-mm-dd' ) like '${vo.yearMonth}%'
AND is_numeric ( ii.test_value )
<if
test=
"null != vo.branch or null != vo.partition or null != vo.plant"
>
AND EXISTS (
SELECT
i."name",
to_char( i.test_time, 'yyyy-mm-dd' ) "test_time",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) "max_val",
MIN ( CAST ( ii.test_value AS NUMERIC ) ) "min_val",
round( AVG ( CAST ( ii.test_value AS NUMERIC ) ), 5 ) "avg_val",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) - MIN ( CAST ( ii.test_value AS NUMERIC ) ) "dif_val"
FROM
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID
AND ii.NAME = i.NAME
WHERE
i.deleted = 0
AND ii.deleted = 0
AND i.NAME = ii.NAME
AND I.NAME LIKE'%原铝%'
AND to_char( i.test_time, 'yyyy-mm-dd' ) like '${vo.yearMonth}%'
AND is_numeric ( ii.test_value )
<if
test=
"null != vo.branch or null != vo.partition or null != vo.plant"
>
AND EXISTS (
SELECT
1
FROM entrust_sample s
join electrolyzer e ON e.ID = s.electrolyzer_id
WHERE s.deleted = 0 and e.deleted = 0 and s.id = i.entrust_sample_id
<include
refid=
"ledger_where"
/>
)
</if>
GROUP BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
ORDER BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
) T order by t.name, sn, label, day
1
FROM entrust_sample s
join electrolyzer e ON e.ID = s.electrolyzer_id
WHERE s.deleted = 0 and e.deleted = 0 and s.id = i.entrust_sample_id
<include
refid=
"ledger_where"
/>
)
</if>
GROUP BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
ORDER BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
) T order by t.name, sn, label, day
</select>
<!--获取检测项目委托量统计数据: 获取LIMS平台某段时间的检测项目委托总数量-->
<select
id=
"selectTestItemQuantityStats"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
select
COUNT(i.ID) "total"
COUNT(i.ID) "total"
from
entrust_sample_item i
entrust_sample_item i
join entrust_sample s on
s.id = i.entrust_sample_id
and s.deleted = 0
s.id = i.entrust_sample_id
and s.deleted = 0
join entrust e on
e.ID = i.entrust_id
and e.deleted = 0
e.ID = i.entrust_id
and e.deleted = 0
where
i.deleted = 0 and s.type = 0
<if
test=
"null != vo.timeS"
>
AND e.ctime >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND e.ctime
<
= #{vo.timeE}
</if>
</select>
<!--获取化验委托数量统计数据: 获取LIMS平台某段时间内各类物料的化验委托数量数据-->
<select
id=
"selectAssayMaterialQuantity"
resultType=
"map"
>
select
s.name,
count(s.id) "data"
from
entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
where
i
.deleted = 0 and s.type = 0
s
.deleted = 0 and s.type = 0
<if
test=
"null != vo.timeS"
>
AND e.ctime >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND e.ctime
<
= #{vo.timeE}
</if>
group by
s.name
</select>
<!--获取可检测项目统计数据:获取LIMS平台可检测项目统计数据-->
<select
id=
"selectDetectableItemQuantity"
resultType=
"map"
>
select m.name,
count(mi.id) "data"
from material m
left join material_item mi on m.id = mi.material_id and mi.deleted = 0
where m.deleted = 0
group by m.name order by m.name
</select>
<!--获取化验检测完毕任务数量统计数据:获取LIMS平台某段时间内各类物料的化验检测完毕任务数量数据-->
<select
id=
"selectDetectedTasksQuantity"
resultType=
"map"
>
select
es.name,
count(distinct es.id) "data"
from entrust_sample es
join entrust e on es.entrust_id = e.id and e.deleted = 0
where es.deleted = 0 and es.type = 0 and es.status > 20
<if
test=
"null != vo.timeS"
>
AND e.ctime >= #{vo.timeS}
</if>
<if
test=
"null != vo.timeE"
>
AND e.ctime
<
= #{vo.timeE}
</if>
group by es.name
</select>
<!--获取日原辅料检测当前实时数据情况: 获取当天的截止查询时间内原辅料检测各个阶段的数量-->
<select
id=
"selectRawMaterialStageQuantity"
resultType=
"map"
>
select count(distinct cs.id) "inspectQuantity",
count(distinct e.id) "entrustQuantity",
count(distinct csl.id) "samplingQuantity",
count(distinct (case when cs.status = 180 then cs.id else null end)) "finishQuantity",
count(distinct r.id) "reportQuantity"
from contract_sample cs
left join contract_sampling csl on csl.contract_sample_id = cs.id and csl.deleted = 0
left join entrust_sample es on cs.id = es.contract_sample_id and es.deleted = 0
left join entrust e on e.id = es.entrust_id and e.deleted = 0
left join entrust_report r on e.id = r.entrust_id and r.deleted = 0
where cs.deleted = 0 and es.contract_sample_id is not null
and to_char(cs.ctime,'yy-MM-dd') = to_char(#{vo.queryDate}::timestamp,'yyyy-MM-dd')
</select>
<select
id=
"selectProcessSampleStageQuantity"
resultType=
"map"
>
select count(distinct e.id) "inspectQuantity",
count(distinct e.id) "entrustQuantity",
count(distinct s.id) "samplingQuantity",
count(distinct (case when s.status = 70 then e.id else null end)) "finishQuantity",
count(distinct r.id) "reportQuantity"
from entrust e
left join entrust_sample s on e.id = s.entrust_id and s.deleted = 0
left join entrust_report r on e.id = r.entrust_id and r.deleted = 0
where e.deleted = 0
and s.contract_sample_id is null and s.type = 0
and to_char(e.entrust_time,'yy-MM-dd') = to_char(#{vo.queryDate}::timestamp,'yyyy-MM-dd')
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment