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
81eda871
Commit
81eda871
authored
Jul 23, 2021
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
大屏统计相关查询;
parent
63990b29
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
433 additions
and
70 deletions
+433
-70
DateKit.java
...ain/java/com/patzn/cloud/service/lims/common/DateKit.java
+75
-0
EntrustSampleItemController.java
...ice/lims/hmhj/controller/EntrustSampleItemController.java
+6
-0
StatisticsController.java
...ud/service/lims/hmhj/controller/StatisticsController.java
+8
-7
EntrustSampleItemMapper.java
...oud/service/lims/hmhj/mapper/EntrustSampleItemMapper.java
+1
-1
StatisticsMapper.java
...atzn/cloud/service/lims/hmhj/mapper/StatisticsMapper.java
+15
-3
IEntrustSampleItemService.java
.../service/lims/hmhj/service/IEntrustSampleItemService.java
+9
-7
IStatisticsService.java
...n/cloud/service/lims/hmhj/service/IStatisticsService.java
+6
-14
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+51
-6
StandardSampleServiceImpl.java
...ice/lims/hmhj/service/impl/StandardSampleServiceImpl.java
+7
-3
StatisticsServiceImpl.java
...service/lims/hmhj/service/impl/StatisticsServiceImpl.java
+100
-23
EntrustSampleItemMapper.xml
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
+7
-1
StatisticsMapper.xml
src/main/resources/mapper/hmhj/StatisticsMapper.xml
+148
-5
No files found.
src/main/java/com/patzn/cloud/service/lims/common/DateKit.java
0 → 100644
View file @
81eda871
package
com
.
patzn
.
cloud
.
service
.
lims
.
common
;
import
java.time.LocalDate
;
import
java.time.Period
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
public
class
DateKit
{
public
static
LocalDate
date2Local
(
Date
date
)
{
if
(
null
==
date
)
{
return
null
;
}
return
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
}
public
static
Date
local2Date
(
LocalDate
localDate
)
{
if
(
null
==
localDate
)
{
return
null
;
}
ZonedDateTime
zonedDateTime
=
localDate
.
atStartOfDay
(
ZoneId
.
systemDefault
());
return
Date
.
from
(
zonedDateTime
.
toInstant
());
}
public
static
Integer
monthsBetweenTwoDates
(
Date
start
,
Date
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
return
monthsBetweenTwoDates
(
date2Local
(
start
),
date2Local
(
end
));
}
public
static
Integer
monthsBetweenTwoDates
(
LocalDate
start
,
LocalDate
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
return
Period
.
between
(
start
,
end
).
getMonths
();
}
public
static
Integer
daysBetweenTwoDates
(
Date
start
,
Date
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
return
daysBetweenTwoDates
(
start
,
end
);
}
public
static
Integer
daysBetweenTwoDates
(
LocalDate
start
,
LocalDate
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
return
Period
.
between
(
start
,
end
).
getDays
();
}
public
static
String
getYearMonth
(
LocalDate
date
)
{
if
(
null
==
date
)
{
return
null
;
}
return
date
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
));
}
public
static
List
<
String
>
monthStrBetweenTwoDates
(
LocalDate
start
,
LocalDate
end
)
{
if
(
null
==
start
||
null
==
end
)
{
return
null
;
}
List
<
String
>
monthList
=
new
ArrayList
<>();
Period
diff
=
Period
.
between
(
start
,
end
);
for
(
int
i
=
0
;
i
<
diff
.
getMonths
();
i
++)
{
monthList
.
add
(
getYearMonth
(
start
.
plusMonths
(
i
)));
}
return
monthList
;
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/EntrustSampleItemController.java
View file @
81eda871
...
...
@@ -293,6 +293,12 @@ public class EntrustSampleItemController extends ServiceController {
return
success
(
entrustSampleItemService
.
allotItem
(
ids
,
tester
,
testerId
,
getAccount
()));
}
@ApiOperation
(
"自动分配"
)
@PostMapping
(
"/auto_allot"
)
public
RestResult
<
Boolean
>
autoAllotItem
(
@RequestParam
(
"ids"
)
Long
[]
ids
)
{
return
success
(
entrustSampleItemService
.
autoAllotItem
(
ids
,
getAccount
()));
}
@ApiOperation
(
"偏离申请"
)
@PostMapping
(
"/deviate_apply"
)
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/StatisticsController.java
View file @
81eda871
...
...
@@ -3,7 +3,7 @@ package com.patzn.cloud.service.lims.hmhj.controller;
import
com.patzn.cloud.commons.api.RestResult
;
import
com.patzn.cloud.commons.controller.ServiceController
;
import
com.patzn.cloud.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Workload
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Range
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.entity.Statistics
;
import
com.patzn.cloud.service.lims.hmhj.service.IStatisticsService
;
import
io.swagger.annotations.Api
;
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
@Api
(
tags
=
"统计控制器"
)
@RestController
...
...
@@ -37,7 +38,7 @@ public class StatisticsController extends ServiceController {
@ApiOperation
(
"报告发放量统计"
)
@PostMapping
(
"/report_send_quantity"
)
public
RestResult
<
List
<
Statistics
>>
getReportSendQuantity
(
QueryDTO
queryDTO
)
{
public
RestResult
<
Map
<
String
,
Object
>>
getReportSendQuantity
(
RangeStats
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getReportSendQuantity
(
queryDTO
));
}
...
...
@@ -50,13 +51,13 @@ public class StatisticsController extends ServiceController {
@ApiOperation
(
"取样量统计"
)
@PostMapping
(
"/sampling_quantity"
)
public
RestResult
<
List
<
Statistics
>>
getSamplingQuantity
(
QueryDTO
queryDTO
)
{
public
RestResult
<
List
<
Statistics
>>
getSamplingQuantity
(
RangeStats
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getSamplingQuantity
(
queryDTO
));
}
@ApiOperation
(
"外检完成量统计"
)
@PostMapping
(
"/out_test_finish_quantity"
)
public
RestResult
<
List
<
Statistics
>
>
getOutTestFinishQuantity
(
QueryDTO
queryDTO
)
{
public
RestResult
<
Statistics
>
getOutTestFinishQuantity
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getOutTestFinishQuantity
(
queryDTO
));
}
...
...
@@ -68,18 +69,18 @@ public class StatisticsController extends ServiceController {
@ApiOperation
(
"工作量统计"
)
@PostMapping
(
"/workload_quantity"
)
public
RestResult
<
Statistics
>
getWorkloadQuantity
(
Workload
StatsQueryDTO
queryDTO
)
{
public
RestResult
<
Statistics
>
getWorkloadQuantity
(
Range
StatsQueryDTO
queryDTO
)
{
return
success
(
statsService
.
getWorkloadQuantity
(
queryDTO
));
}
@ApiOperation
(
"本周验收合格情况"
)
@PostMapping
(
"/cur_week_acceptance
qualified"
)
@PostMapping
(
"/cur_week_acceptance
_
qualified"
)
public
RestResult
<
List
<
Statistics
>>
getCurWeekAcceptanceQualified
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getCurWeekAcceptanceQualified
(
queryDTO
));
}
@ApiOperation
(
"本周自产炭块质量统计"
)
@PostMapping
(
"/cur_week_carbon
blocks"
)
@PostMapping
(
"/cur_week_carbon
_
blocks"
)
public
RestResult
<
List
<
Statistics
>>
getCurWeekCarbonBlocks
(
QueryDTO
queryDTO
)
{
return
success
(
statsService
.
getCurWeekCarbonBlocks
(
queryDTO
));
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/mapper/EntrustSampleItemMapper.java
View file @
81eda871
...
...
@@ -52,7 +52,7 @@ public interface EntrustSampleItemMapper extends BatchMapper<EntrustSampleItem>
List
<
EntrustSampleItemVO
>
selectByEntrustId
(
@Param
(
"entrustId"
)
Long
entrustId
);
int
selectUnallocatedCountByEntrustId
(
@Param
(
"entrustId"
)
Long
entrustId
);
int
selectUnallocatedCountByEntrustId
(
@Param
(
"entrustId"
)
Long
entrustId
,
@Param
(
"itemIds"
)
Long
[]
itemIds
);
List
<
TesterWorkloadStatsVO
>
selectTesterWorkloadStatus
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/mapper/StatisticsMapper.java
View file @
81eda871
...
...
@@ -2,7 +2,7 @@ package com.patzn.cloud.service.lims.hmhj.mapper;
import
com.patzn.cloud.commons.mapper.BatchMapper
;
import
com.patzn.cloud.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Workload
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Range
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.entity.Statistics
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -12,11 +12,23 @@ public interface StatisticsMapper extends BatchMapper<Statistics> {
List
<
Statistics
>
selectAlBrandsRateStats
(
@Param
(
"vo"
)
QueryDTO
dto
);
Statistics
selectOutTestFinish
Stats
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
Statistics
selectOutTestFinish
Quantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
List
<
Statistics
>
selectCurWeekCarbonBlocks
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
List
<
Statistics
>
selectCurWeekAcceptanceQualified
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
Statistics
selectWorkloadQuantity
(
@Param
(
"vo"
)
WorkloadStatsQueryDTO
workloadStatsQueryDTO
);
Statistics
selectWorkloadQuantity
(
@Param
(
"vo"
)
RangeStatsQueryDTO
workloadStatsQueryDTO
);
List
<
Statistics
>
selectOutTestItemQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
List
<
Statistics
>
selectSamplingQuantity
(
@Param
(
"vo"
)
RangeStatsQueryDTO
queryDTO
);
List
<
Statistics
>
selectItemQuantity
(
@Param
(
"vo"
)
QueryDTO
queryDTO
);
List
<
Statistics
>
selectReportSendQuantityMonth
(
@Param
(
"vo"
)
RangeStatsQueryDTO
queryDTO
);
Statistics
selectReportSendQuantity
(
@Param
(
"vo"
)
RangeStatsQueryDTO
queryDTO
);
List
<
Statistics
>
selectEntrustedQuantity
(
QueryDTO
queryDTO
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IEntrustSampleItemService.java
View file @
81eda871
...
...
@@ -19,7 +19,7 @@ import java.util.List;
import
java.util.Map
;
/**
*
服务类
* 服务类
*
* @author wwd
* @since 2021-02-01
...
...
@@ -55,10 +55,10 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
List
<
EntrustSampleItemVO
>
listBySampleIds
(
Long
[]
ids
);
List
<
EntrustSampleItemVO
>
listBySampleIdsAndIds
(
Long
[]
ids
,
Long
[]
itemIds
);
List
<
EntrustSampleItemVO
>
listBySampleIdsAndIds
(
Long
[]
ids
,
Long
[]
itemIds
);
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
,
String
entrustCode
);
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
,
String
entrustCode
);
boolean
deviateApply
(
Long
[]
ids
,
ItemDeviate
deviate
,
Account
account
);
...
...
@@ -70,7 +70,7 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
Page
<
EntrustSampleItemVO
>
pageItemDeviateCheckHis
(
Page
<
EntrustSampleItemVO
>
page
,
EntrustSampleItemVO
entrustSampleItem
);
List
<
EntrustSampleItemVO
>
getItemByOriginalRecordId
(
Long
originalRecordId
);
List
<
EntrustSampleItemVO
>
getItemByOriginalRecordId
(
Long
originalRecordId
);
List
<
EntrustSampleItemVO
>
listVOByIds
(
List
<
Long
>
expIdsList
);
...
...
@@ -80,13 +80,13 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
List
<
EntrustSampleItemVO
>
listMinStatusBySampleIds
(
List
<
Long
>
entrustIds
);
public
boolean
isAllocatedByEntrustId
(
Long
entrustId
);
public
boolean
isAllocatedByEntrustId
(
Long
entrustId
,
Long
[]
itemIds
);
Page
<
LmsUserRelGroupVO
>
pageGroupUser
(
Page
<
LmsUserRelGroupVO
>
page
,
LmsUserRelGroup
soilExperiment
);
List
<
TesterWorkloadStatsVO
>
getTesterWorkloadStatusQuery
(
QueryDTO
queryDTO
);
Page
<
LmsUserRelGroupVO
>
selectAllPersonWorkload
(
Page
<
LmsUserRelGroupVO
>
page
,
LmsUserRelGroup
rel
);
Page
<
LmsUserRelGroupVO
>
selectAllPersonWorkload
(
Page
<
LmsUserRelGroupVO
>
page
,
LmsUserRelGroup
rel
);
List
<
EntrustSampleCalcResultVO
>
getSampleCalcResult
(
QueryDTO
queryDTO
);
...
...
@@ -94,5 +94,7 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
boolean
updateItemComposeJudgeByEntrustId
(
Long
entrustId
);
Map
<
String
,
Object
>
getSampleItemStatsQuery
(
SampleItemDTO
sampleItemDTO
);
Map
<
String
,
Object
>
getSampleItemStatsQuery
(
SampleItemDTO
sampleItemDTO
);
boolean
autoAllotItem
(
Long
[]
ids
,
Account
account
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IStatisticsService.java
View file @
81eda871
...
...
@@ -2,41 +2,33 @@ package com.patzn.cloud.service.lims.hmhj.service;
import
com.patzn.cloud.commons.service.IBaseService
;
import
com.patzn.cloud.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Workload
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Range
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.entity.Statistics
;
import
java.util.List
;
import
java.util.Map
;
public
interface
IStatisticsService
extends
IBaseService
<
Statistics
>
{
/**
* 当日原铝质量统计
* @param queryDTO
* @return
*/
List
<
Statistics
>
getAlBrandsRate
(
QueryDTO
queryDTO
);
/**
* 外检完成量统计
* @param queryDTO
* @return
*/
Statistics
getOutTestFinishNumStatsQuery
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getEntrustedQuantity
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getAnodeInspectionQuantity
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getReportSendQuantity
(
QueryDTO
queryDTO
);
Map
<
String
,
Object
>
getReportSendQuantity
(
RangeStats
QueryDTO
queryDTO
);
List
<
Statistics
>
getItemQuantity
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getSamplingQuantity
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getSamplingQuantity
(
RangeStats
QueryDTO
queryDTO
);
List
<
Statistics
>
getOutTestFinishQuantity
(
QueryDTO
queryDTO
);
Statistics
getOutTestFinishQuantity
(
QueryDTO
queryDTO
);
List
<
Statistics
>
getOutTestItemQuantity
(
QueryDTO
queryDTO
);
Statistics
getWorkloadQuantity
(
Workload
StatsQueryDTO
queryDTO
);
Statistics
getWorkloadQuantity
(
Range
StatsQueryDTO
queryDTO
);
List
<
Statistics
>
getCurWeekAcceptanceQualified
(
QueryDTO
queryDTO
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
81eda871
...
...
@@ -31,7 +31,6 @@ import com.patzn.cloud.service.lims.base.entity.LmsUserRelGroup;
import
com.patzn.cloud.service.lims.base.vo.LmsUserRelGroupVO
;
import
com.patzn.cloud.service.lims.collection.entity.LmsOriginalRecordInfo
;
import
com.patzn.cloud.service.lims.common.CompareUtils
;
import
com.patzn.cloud.service.lims.hmhj.common.EntrustFlowUtils
;
import
com.patzn.cloud.service.lims.hmhj.common.HSSFWorkbookUtil
;
import
com.patzn.cloud.service.lims.hmhj.common.LabreOfficeUtil
;
import
com.patzn.cloud.service.lims.hmhj.mapper.EntrustSampleItemMapper
;
...
...
@@ -55,6 +54,7 @@ import java.math.BigDecimal;
import
java.util.*
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -117,7 +117,6 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Autowired
private
Executor
executor1
;
@Value
(
"${libreOffice.url}"
)
private
String
libreOfficeUrl
;
@Autowired
...
...
@@ -212,7 +211,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
// 判定是否委托下的检测项目都已分配
Entrust
entrust
=
getEntrustByItemId
(
ids
[
0
]);
if
(
null
!=
entrust
&&
isAllocatedByEntrustId
(
entrust
.
getId
()))
{
if
(
null
!=
entrust
&&
isAllocatedByEntrustId
(
entrust
.
getId
()
,
null
))
{
// 添加流程数据录入节点
if
(
entrustService
.
isCanIntoNextNode
(
entrust
))
{
entrustService
.
submitToNextNode
(
entrust
,
account
);
...
...
@@ -543,7 +542,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
for
(
EntrustSampleItemVO
itemVO
:
voList
)
{
sampleIdsList
.
add
(
itemVO
.
getEntrustSampleId
());
}
List
<
EntrustSample
>
sampleList
=
entrustSampleService
.
list
(
Condition
.
create
().
in
(
"id"
,
sampleIdsList
).
orderBy
(
"order_by"
,
true
));
List
<
EntrustSample
>
sampleList
=
entrustSampleService
.
list
(
Condition
.
create
().
in
(
"id"
,
sampleIdsList
).
orderBy
(
"order_by"
,
true
));
if
(
CollectionUtils
.
isNotEmpty
(
sampleList
))
{
mapReplace
.
put
(
"#{sampleFrom}"
,
sampleList
.
get
(
0
).
getSampleFrom
());
mapReplace
.
put
(
"#{sampleName}"
,
sampleList
.
get
(
0
).
getName
());
...
...
@@ -1045,11 +1044,11 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
@Override
public
boolean
isAllocatedByEntrustId
(
Long
entrustId
)
{
public
boolean
isAllocatedByEntrustId
(
Long
entrustId
,
Long
[]
notInItemIds
)
{
if
(
null
==
entrustId
)
{
return
false
;
}
return
baseMapper
.
selectUnallocatedCountByEntrustId
(
entrustId
)
==
0
;
return
baseMapper
.
selectUnallocatedCountByEntrustId
(
entrustId
,
notInItemIds
)
==
0
;
}
@Override
...
...
@@ -1128,6 +1127,52 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
result
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
autoAllotItem
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
null
==
ids
||
ids
.
length
==
0
,
"自动分配项目ID为空"
);
List
<
EntrustSampleItem
>
items
=
getBatchIds
(
Arrays
.
asList
(
ids
));
RestAssert
.
fail
(
null
==
items
||
items
.
size
()
==
0
,
"自动分配项目为空"
);
//
List
<
String
>
itemNameList
=
items
.
stream
().
map
(
EntrustSampleItem:
:
getName
).
distinct
().
collect
(
Collectors
.
toList
());
// 检测项目基础数据
List
<
Qualification
>
qualifications
=
qualificationService
.
list
(
Condition
.
create
().
in
(
"name"
,
itemNameList
));
items
.
forEach
(
t
->
{
AtomicReference
<
Qualification
>
qualificationAtomic
=
new
AtomicReference
<>();
if
(
qualifications
.
stream
().
anyMatch
(
q
->
{
if
(
q
.
getName
().
equals
(
t
.
getName
()))
{
qualificationAtomic
.
set
(
q
);
return
true
;
}
return
false
;
}))
{
Qualification
qua
=
qualificationAtomic
.
get
();
RestAssert
.
fail
(
null
==
qua
.
getMainTesterId
(),
String
.
format
(
"检测项目【%s】主检人为空"
,
t
.
getName
()));
t
.
setTester
(
qua
.
getMainTester
()).
setTesterId
(
qua
.
getMainTesterId
())
.
setStatus
(
EntrustSampleItemStatusEnum
.
TEST
).
setProgress
(
EntrustSampleItemStatusEnum
.
TEST
);
}
else
{
RestAssert
.
fail
(
String
.
format
(
"检测项目【%s】找不到对应的数据"
,
t
.
getName
()));
}
});
updateBatchById
(
items
);
// 判断是否都已经分配,若全部已经分配,那么更改样品和委托状态
entrustSampleItemRecordService
.
record
(
ids
,
EntrustSampleItemStatusEnum
.
ALLOT
.
getDisplay
(),
EntrustSampleItemStatusEnum
.
TEST
.
getDisplay
(),
0
,
"任务分配"
,
account
);
// 判定是否委托下的检测项目都已分配
Entrust
entrust
=
getEntrustByItemId
(
ids
[
0
]);
if
(
null
!=
entrust
&&
isAllocatedByEntrustId
(
entrust
.
getId
(),
ids
))
{
// 添加流程数据录入节点
if
(
entrustService
.
isCanIntoNextNode
(
entrust
))
{
entrustService
.
submitToNextNode
(
entrust
,
account
);
}
else
{
entrustRecordService
.
record
(
new
Long
[]{
entrust
.
getId
()},
"任务分配"
,
"数据录入"
,
0
,
account
,
"提交至数据录入"
);
}
}
return
true
;
}
/**
* 处理 原铝等标准为
*/
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/StandardSampleServiceImpl.java
View file @
81eda871
...
...
@@ -8,12 +8,13 @@ import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import
com.patzn.cloud.service.hmhj.entity.StandardSample
;
import
com.patzn.cloud.service.lims.hmhj.mapper.StandardSampleMapper
;
import
com.patzn.cloud.service.lims.hmhj.service.IStandardSampleService
;
import
jodd.util.StringUtil
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
*
服务实现类
* 服务实现类
*
* @author patzn
* @since 2021-07-22
...
...
@@ -23,8 +24,11 @@ public class StandardSampleServiceImpl extends BaseServiceImpl<StandardSampleMap
@Override
public
Page
<
StandardSample
>
page
(
Page
<
StandardSample
>
page
,
StandardSample
standardSample
)
{
Wrapper
wrapper
=
new
EntityWrapper
<>(
standardSample
);
String
name
=
standardSample
.
getName
();
Wrapper
wrapper
=
new
EntityWrapper
<>(
standardSample
.
setName
(
null
));
if
(
StringUtil
.
isNotBlank
(
name
))
{
wrapper
.
like
(
"name"
,
name
);
}
return
this
.
page
(
page
,
wrapper
);
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/StatisticsServiceImpl.java
View file @
81eda871
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.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Workload
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.
Range
StatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.entity.Statistics
;
import
com.patzn.cloud.service.lims.common.DateKit
;
import
com.patzn.cloud.service.lims.hmhj.mapper.StatisticsMapper
;
import
com.patzn.cloud.service.lims.hmhj.service.IStatisticsService
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
@Service
public
class
StatisticsServiceImpl
extends
BaseServiceImpl
<
StatisticsMapper
,
Statistics
>
implements
IStatisticsService
{
@Override
public
List
<
Statistics
>
getAlBrandsRate
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
selectAlBrandsRateStats
(
queryDTO
);
private
void
handleQueryTime
(
QueryDTO
queryDTO
)
{
RestAssert
.
fail
(
null
==
queryDTO
.
getTimeS
(),
"起始时间不为空"
);
// 截至时间若为空,默认当前时间
if
(
null
==
queryDTO
.
getTimeE
())
{
queryDTO
.
setTimeE
(
new
Date
());
}
}
private
void
handleQueryTimeRange
(
RangeStatsQueryDTO
queryDTO
)
{
handleQueryTime
(
queryDTO
);
queryDTO
.
setLastYearTimeS
(
DateUtils
.
addYears
(
queryDTO
.
getTimeS
(),
-
1
));
queryDTO
.
setLastYearTimeE
(
DateUtils
.
addYears
(
queryDTO
.
getTimeE
(),
-
1
));
Integer
days
=
DateKit
.
monthsBetweenTwoDates
(
queryDTO
.
getTimeS
(),
queryDTO
.
getTimeE
());
queryDTO
.
setPrevTimeS
(
DateUtils
.
addDays
(
queryDTO
.
getTimeS
(),
-
days
.
intValue
()));
queryDTO
.
setPrevTimeE
(
queryDTO
.
getTimeS
());
}
private
void
handleMonthData
(
QueryDTO
queryDTO
,
List
<
Statistics
>
statistics
)
{
List
<
String
>
months
=
DateKit
.
monthStrBetweenTwoDates
(
DateKit
.
date2Local
(
queryDTO
.
getTimeS
()),
DateKit
.
date2Local
(
queryDTO
.
getTimeE
()));
List
<
Statistics
>
statsList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isEmpty
(
statistics
))
{
statistics
=
months
.
stream
().
map
(
t
->
{
return
new
Statistics
().
setOccurDate
(
t
).
setDoneNum
(
0
);
}).
collect
(
Collectors
.
toList
());
}
else
{
List
<
Statistics
>
finalStatistics
=
statistics
;
months
.
stream
().
forEach
(
t
->
{
AtomicReference
<
Statistics
>
statsAtomic
=
new
AtomicReference
<>();
// 是否存在对应的月份数据
if
(
finalStatistics
.
stream
().
anyMatch
(
s
->
{
if
(
s
.
getOccurDate
().
equals
(
t
))
{
statsAtomic
.
set
(
s
);
return
true
;
}
return
false
;
}))
{
statsList
.
add
(
statsAtomic
.
get
());
}
else
{
statsList
.
add
(
new
Statistics
().
setOccurDate
(
t
).
setDoneNum
(
0
));
}
});
statistics
=
statsList
;
}
}
@Override
public
Statistics
getOutTestFinishNumStatsQuery
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
select
OutTestFinish
Stats
(
queryDTO
);
public
List
<
Statistics
>
getAlBrandsRate
(
QueryDTO
queryDTO
)
{
return
baseMapper
.
select
AlBrandsRate
Stats
(
queryDTO
);
}
@Override
public
List
<
Statistics
>
getEntrustedQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
handleQueryTime
(
queryDTO
);
List
<
String
>
sampleNameList
=
Arrays
.
asList
(
"电解质"
,
"硅铁"
,
"磷铁"
,
"锰铁"
,
"水"
,
"纯铝"
,
"铝合金"
,
"石灰石"
);
List
<
Statistics
>
statistics
=
baseMapper
.
selectEntrustedQuantity
(
queryDTO
);
if
(
CollectionUtils
.
isEmpty
(
statistics
))
{
return
sampleNameList
.
stream
().
map
(
t
->
{
return
new
Statistics
().
setBrand
(
t
).
setTotal
(
0
).
setDoneNum
(
0
);
}).
collect
(
Collectors
.
toList
());
}
List
<
Statistics
>
finalStatistics
=
statistics
;
List
<
Statistics
>
statsList
=
new
ArrayList
<>();
for
(
String
t
:
sampleNameList
)
{
AtomicReference
<
Statistics
>
statsAtomic
=
new
AtomicReference
<>();
// 是否存在对应的样品名称
if
(
finalStatistics
.
stream
().
anyMatch
(
s
->
{
if
(
s
.
getBrand
().
equals
(
t
))
{
statsAtomic
.
set
(
s
);
return
true
;
}
return
false
;
}))
{
statsList
.
add
(
statsAtomic
.
get
());
}
else
{
statsList
.
add
(
new
Statistics
().
setOccurDate
(
t
).
setTotal
(
0
).
setDoneNum
(
0
));
}
}
return
statsList
;
}
@Override
...
...
@@ -36,38 +105,46 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public
List
<
Statistics
>
getReportSendQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
public
Map
<
String
,
Object
>
getReportSendQuantity
(
RangeStatsQueryDTO
queryDTO
)
{
handleQueryTimeRange
(
queryDTO
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Statistics
>
monthList
=
baseMapper
.
selectReportSendQuantityMonth
(
queryDTO
);
handleMonthData
(
queryDTO
,
monthList
);
result
.
put
(
"monthList"
,
monthList
);
Statistics
statistics
=
baseMapper
.
selectReportSendQuantity
(
queryDTO
);
result
.
put
(
"statsData"
,
statistics
);
return
result
;
}
@Override
public
List
<
Statistics
>
getItemQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
handleQueryTime
(
queryDTO
);
return
baseMapper
.
selectItemQuantity
(
queryDTO
);
}
@Override
public
List
<
Statistics
>
getSamplingQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
public
List
<
Statistics
>
getSamplingQuantity
(
RangeStatsQueryDTO
queryDTO
)
{
handleQueryTimeRange
(
queryDTO
);
return
baseMapper
.
selectSamplingQuantity
(
queryDTO
);
}
@Override
public
List
<
Statistics
>
getOutTestFinishQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
public
Statistics
getOutTestFinishQuantity
(
QueryDTO
queryDTO
)
{
handleQueryTime
(
queryDTO
);
return
baseMapper
.
selectOutTestFinishQuantity
(
queryDTO
);
}
@Override
public
List
<
Statistics
>
getOutTestItemQuantity
(
QueryDTO
queryDTO
)
{
return
null
;
handleQueryTime
(
queryDTO
);
List
<
Statistics
>
list
=
baseMapper
.
selectOutTestItemQuantity
(
queryDTO
);
handleMonthData
(
queryDTO
,
list
);
return
list
;
}
@Override
public
Statistics
getWorkloadQuantity
(
WorkloadStatsQueryDTO
queryDTO
)
{
RestAssert
.
fail
(
null
==
queryDTO
.
getTimeS
()
||
null
==
queryDTO
.
getTimeE
(),
"起始和结束时间为空"
);
queryDTO
.
setLastYearTimeS
(
DateUtils
.
addYears
(
queryDTO
.
getTimeS
(),
-
1
));
queryDTO
.
setLastYearTimeE
(
DateUtils
.
addYears
(
queryDTO
.
getTimeE
(),
-
1
));
long
days
=
com
.
patzn
.
cloud
.
commons
.
toolkit
.
DateUtils
.
getDaysBetweenTwoDate
(
queryDTO
.
getTimeS
(),
queryDTO
.
getTimeE
());
queryDTO
.
setPrevTimeS
(
DateUtils
.
addDays
(
queryDTO
.
getTimeS
(),
-(
int
)
days
));
queryDTO
.
setPrevTimeE
(
queryDTO
.
getTimeS
());
public
Statistics
getWorkloadQuantity
(
RangeStatsQueryDTO
queryDTO
)
{
handleQueryTimeRange
(
queryDTO
);
return
baseMapper
.
selectWorkloadQuantity
(
queryDTO
);
}
...
...
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
View file @
81eda871
...
...
@@ -357,8 +357,14 @@
select count(1) from entrust_sample_item i
join entrust_sample s ON i.entrust_sample_id = s.ID
where i.deleted = 0 AND s.deleted = 0
and
i.status =
0
and
coalesce(i.status,0)
<
2
0
AND s.entrust_id = #{entrustId}
<if
test=
"null != itemIds"
>
and i.id not in
<foreach
collection=
"itemIds"
index=
"index"
item=
"itemId"
open=
"("
separator=
","
close=
")"
>
#{itemId}
</foreach>
</if>
</select>
<!-- 检测人员工作量统计查询 -->
<select
id=
"selectTesterWorkloadStatus"
resultType=
"com.patzn.cloud.service.hmhj.vo.TesterWorkloadStatsVO"
>
...
...
src/main/resources/mapper/hmhj/StatisticsMapper.xml
View file @
81eda871
...
...
@@ -25,7 +25,7 @@
</select>
<!--外委完成量统计-->
<select
id=
"selectOutTestFinish
Stats
"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
<select
id=
"selectOutTestFinish
Quantity
"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
count(1) "total",
sum(case when s.status = 70 and s.judge_status = 2 then 1 else 0 end) "done_num"
...
...
@@ -33,7 +33,7 @@
contract_sample c, entrust_sample s
WHERE
c.deleted = 0 and s.deleted = 0 and c.id = s.contract_sample_id
and c.type = 1
and c.type = 1
</select>
<!--本周自产炭块质量统计-->
...
...
@@ -108,7 +108,7 @@
WHERE
s.deleted = 0 and e.deleted = 0 and r.deleted = 0
AND s.status = 70 AND s.judge_status = 2
AND s.judge_time between #{
timeS} and #{
timeE}
AND s.judge_time between #{
vo.timeS} and #{vo.
timeE}
) a , (SELECT
count(r.id) "total"
FROM
...
...
@@ -118,7 +118,7 @@
WHERE
s.deleted = 0 and e.deleted = 0 and r.deleted = 0
AND s.status = 70 AND s.judge_status = 2
AND s.judge_time between #{
lastYearTimeS} and #{
lastYearTimeE}
AND s.judge_time between #{
vo.lastYearTimeS} and #{vo.
lastYearTimeE}
) b,
(SELECT
count(r.id) "total"
...
...
@@ -129,8 +129,151 @@
WHERE
s.deleted = 0 and e.deleted = 0 and r.deleted = 0
AND s.status = 70 AND s.judge_status = 2
AND s.judge_time between #{
prevTimeS} and #{
prevTimeE}
AND s.judge_time between #{
vo.prevTimeS} and #{vo.
prevTimeE}
) c
</select>
<!--外委检测数量统计-->
<select
id=
"selectOutTestItemQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
to_char(i.ctime,'yyyy-MM') "occur_date",
count(i.id) "done_num"
FROM
entrust_sample_item i
join entrust_sample s on s.id = i.entrust_sample_id
join contract_sample c on c.id = s.contract_sample_id
WHERE
i.deleted = 0 and s.deleted = 0 and c.deleted = 0 and c.type = 1
<if
test=
"null != vo.timeS and null != vo.timeE"
>
AND i.ctime between #{vo.timeS} and #{vo.timeE}
</if>
GROUP BY
to_char(i.ctime,'yyyy-MM')
ORDER BY
to_char(i.ctime,'yyyy-MM') ASC
</select>
<!--取样量统计-->
<select
id=
"selectSamplingQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
a.*,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",
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"
from (SELECT
count(s.id) "total"
FROM
entrust_sample s
join entrust e on e.id = s.entrust_id
WHERE
s.deleted = 0 and e.deleted = 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
WHERE s.deleted = 0 and e.deleted = 0
AND s.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
WHERE
s.deleted = 0 and e.deleted = 0
AND s.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--检测数量统计-->
<select
id=
"selectItemQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
to_char(i.ctime,'yyyy-MM') "occur_date",
count(i.id) "done_num"
FROM
entrust_sample_item i
join entrust_sample s on s.id = i.entrust_sample_id
WHERE
i.deleted = 0 and s.deleted = 0
<if
test=
"null != vo.timeS and null != vo.timeE"
>
AND i.ctime between #{vo.timeS} and #{vo.timeE}
</if>
GROUP BY
to_char(i.ctime,'yyyy-MM')
ORDER BY
to_char(i.ctime,'yyyy-MM') ASC
</select>
<!--报告发放量统计A-->
<select
id=
"selectReportSendQuantityMonth"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
to_char(r.report_check_time,'yyyy-MM') "occur_date",
count(r.id) "done_num"
FROM
entrust e
join entrust_report r on r.entrust_id = e.id
WHERE
e.deleted = 0 and r.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>
GROUP BY
to_char(r.report_check_time,'yyyy-MM')
ORDER BY
to_char(r.report_check_time,'yyyy-MM') ASC
</select>
<!--报告发放量统计B-->
<select
id=
"selectReportSendQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
SELECT
a.*,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",
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"
from (SELECT
count(r.id) "total"
FROM
entrust e
join entrust_report r on r.entrust_id = e.id
WHERE
e.deleted = 0 and r.deleted = 0
AND r.report_check_time between #{vo.timeS} and #{vo.timeE}
) a ,
(SELECT
count(r.id) "total"
FROM
entrust e
join entrust_report r on r.entrust_id = e.id
WHERE
e.deleted = 0 and r.deleted = 0
AND r.report_check_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT
count(r.id) "total"
FROM
entrust e
join entrust_report r on r.entrust_id = e.id
WHERE
e.deleted = 0 and r.deleted = 0
AND r.report_check_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--化验委托量统计-->
<select
id=
"selectEntrustedQuantity"
resultType=
"com.patzn.cloud.service.hmhj.entity.Statistics"
>
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
WHERE
E.deleted = 0
AND S.deleted = 0
AND S.NAME IN ( '电解质', '硅铁', '磷铁', '锰铁', '水', '纯铝', '铝合金', '石灰石' )
GROUP BY
s.NAME ORDER BY S.NAME
</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