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
c465c0f9
Commit
c465c0f9
authored
Jun 01, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化霍煤响应速度;
parent
ca681a49
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
213 additions
and
172 deletions
+213
-172
IGradingItemService.java
.../cloud/service/lims/hmhj/service/IGradingItemService.java
+2
-0
IGradingProductService.java
...oud/service/lims/hmhj/service/IGradingProductService.java
+2
-0
IGradingStandardService.java
...ud/service/lims/hmhj/service/IGradingStandardService.java
+2
-0
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+98
-75
EntrustSampleServiceImpl.java
...vice/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
+9
-13
GradingItemServiceImpl.java
...ervice/lims/hmhj/service/impl/GradingItemServiceImpl.java
+11
-0
GradingProductServiceImpl.java
...ice/lims/hmhj/service/impl/GradingProductServiceImpl.java
+12
-0
GradingStandardServiceImpl.java
...ce/lims/hmhj/service/impl/GradingStandardServiceImpl.java
+39
-31
application.yml
src/main/resources/application.yml
+1
-1
EntrustSampleItemMapper.xml
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
+1
-0
EntrustSampleMapper.xml
src/main/resources/mapper/hmhj/EntrustSampleMapper.xml
+36
-52
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IGradingItemService.java
View file @
c465c0f9
...
...
@@ -17,4 +17,6 @@ public interface IGradingItemService extends IBaseService<GradingItem> {
Page
<
GradingItem
>
page
(
Page
<
GradingItem
>
page
,
GradingItem
gradingItem
);
boolean
removeByIds
(
List
<
Long
>
ids
);
List
<
GradingItem
>
listByProductIds
(
List
<
Long
>
productIds
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IGradingProductService.java
View file @
c465c0f9
...
...
@@ -17,4 +17,6 @@ public interface IGradingProductService extends IBaseService<GradingProduct> {
Page
<
GradingProduct
>
page
(
Page
<
GradingProduct
>
page
,
GradingProduct
gradingProduct
);
boolean
removeByIds
(
List
<
Long
>
ids
);
List
<
GradingProduct
>
listByStandardIds
(
List
<
Long
>
standardIds
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IGradingStandardService.java
View file @
c465c0f9
...
...
@@ -25,4 +25,6 @@ public interface IGradingStandardService extends IBaseService<GradingStandard> {
boolean
abolish
(
Long
[]
ids
,
String
reason
,
Account
account
);
boolean
editGradingStandard
(
GradingStandardDTO
dto
,
Account
account
);
List
<
GradingStandard
>
listByIds
(
List
<
Long
>
ids
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
c465c0f9
...
...
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.toolkit.IOUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.controller.Account
;
import
com.patzn.cloud.commons.controller.LoginHelper
;
...
...
@@ -64,6 +65,7 @@ import java.util.*;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
stream
.
Collectors
.
toSet
;
...
...
@@ -87,9 +89,6 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
private
IEntrustRecordService
entrustRecordService
;
@Autowired
private
IEntrustSampleItemService
entrustSampleItemService
;
@Autowired
private
IEntrustSampleItemIndexService
entrustSampleItemIndexService
;
@Autowired
...
...
@@ -187,7 +186,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
RestAssert
.
fail
(
entrustSampleItemList
.
stream
().
anyMatch
(
t
->
null
==
t
.
getId
()),
"要修改检测值的编号为空"
);
updateBatchById
(
entrustSampleItemList
);
EntrustSampleItem
sampleItem
=
entrustSampleItemList
.
get
(
0
);
entrustSampleItemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
eq
(
"entrust_sample_id"
,
sampleItem
.
getEntrustSampleId
()));
entrustSampleItemList
=
list
(
Condition
.
create
().
eq
(
"entrust_sample_id"
,
sampleItem
.
getEntrustSampleId
()));
//
EntrustSample
entrustSample
=
entrustSampleService
.
getById
(
sampleItem
.
getEntrustSampleId
());
if
(
null
!=
entrustSample
&&
null
!=
entrustSample
.
getContractSampleId
())
{
...
...
@@ -383,7 +382,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
if
(
entrustService
.
isCanIntoNextNode
(
entrust
))
{
entrustService
.
submitToNextNode
(
entrust
,
account
);
// 提交后执行组合判定
entrustSampleItemService
.
updateItemComposeJudgeByEntrustId
(
entrustId
);
updateItemComposeJudgeByEntrustId
(
entrustId
);
updateComposeJudgeByTestValue
(
entrustId
);
// 执行转PDF操作
executor1
.
execute
(()
->
changeExcelToPdf
(
ids
,
list
));
...
...
@@ -396,7 +395,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
entrustService
.
updateById
(
entrust
);
// 提交后执行组合判定
entrustSampleItemService
.
updateItemComposeJudgeByEntrustId
(
entrustId
);
updateItemComposeJudgeByEntrustId
(
entrustId
);
updateComposeJudgeByTestValue
(
entrustId
);
// 添加委托日志
...
...
@@ -1146,7 +1145,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
updateQualityJudge
(
Long
[]
ids
,
Account
account
)
{
long
time1
=
System
.
currentTimeMillis
();
logger
.
error
(
"======================质量判定开始========================"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"样品编号不能为空"
);
...
...
@@ -1163,13 +1162,61 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
sampleList
.
addAll
(
batchSampleList
);
}
// 是否外委数据
boolean
isOutEntrustData
=
contractSampleService
.
isOutEntrustData
(
sampleList
.
get
(
0
).
getContractSampleId
());
logger
.
error
(
"是否外委数据:"
+
isOutEntrustData
);
// 样品ids || 样品对应的标准ids
List
<
Long
>
sampleIds
=
new
ArrayList
<>(),
standardIds
=
new
ArrayList
<>();
sampleList
.
forEach
(
s
->
{
if
(!
sampleIds
.
contains
(
s
.
getId
()))
{
sampleIds
.
add
(
s
.
getId
());
}
if
(!
standardIds
.
contains
(
s
.
getProductStandardId
()))
{
standardIds
.
add
(
s
.
getProductStandardId
());
}
});
// === 查询检测项目指标信息
// 检测值【内部检测值实际为指标表中数据,外委检测值为检测项目数据】
List
<
EntrustSampleItemVO
>
allSampleItemList
;
// 若为外部检测
if
(
isOutEntrustData
)
{
allSampleItemList
=
getListBySampleIds
(
sampleIds
);
}
else
{
// 获取检测项目及指标数据
allSampleItemList
=
getSampleItemIndexList
(
sampleIds
);
}
// === 查询所有样品标准信息
List
<
GradingStandard
>
standardList
=
gradingStandardService
.
listByIds
(
standardIds
);
// key ==> value 直接获取
Map
<
Long
,
GradingStandard
>
standardMap
=
standardList
.
stream
().
collect
(
Collectors
.
toMap
(
GradingStandard:
:
getId
,
Function
.
identity
()));
// === 查询对应产品等级信息
List
<
GradingProduct
>
productList
=
gradingProductService
.
listByStandardIds
(
standardIds
);
// == 以key ===> value 形式处理
Map
<
Long
,
List
<
GradingProduct
>>
productMap
=
Maps
.
newHashMapWithExpectedSize
(
standardIds
.
size
());
Optional
.
ofNullable
(
productList
).
orElse
(
new
ArrayList
<>()).
forEach
(
p
->
{
MapMergeUtils
.
getorCreateMapArrayList
(
p
.
getGradingStandardId
(),
productMap
,
p
);
});
List
<
Long
>
productIds
=
Optional
.
ofNullable
(
productList
).
orElse
(
new
ArrayList
<>()).
stream
().
map
(
GradingProduct:
:
getId
).
collect
(
Collectors
.
toList
());
// === 查询产品等级下的检测项目
List
<
GradingItem
>
itemList
=
gradingItemService
.
listByProductIds
(
productIds
);
// == 以key ===> value 形式处理
Map
<
Long
,
List
<
GradingItem
>>
itemMap
=
Maps
.
newHashMapWithExpectedSize
(
productIds
.
size
());
Optional
.
ofNullable
(
itemList
).
orElse
(
new
ArrayList
<>()).
forEach
(
item
->
{
MapMergeUtils
.
getorCreateMapArrayList
(
item
.
getGradingProductId
(),
itemMap
,
item
);
});
long
time2
=
(
System
.
currentTimeMillis
()
-
time1
)
/
1000
;
System
.
out
.
println
(
"time2:::::::"
+
time2
);
//其他稀有元素
List
<
String
>
otherYsList
=
Arrays
.
asList
(
"Mn"
,
"V"
,
"Ni"
);
List
<
EntrustSample
>
updateSampleList
=
new
ArrayList
<>();
// 是否外委数据
boolean
isOutEntrustData
=
contractSampleService
.
isOutEntrustData
(
sampleList
.
get
(
0
).
getContractSampleId
());
logger
.
error
(
"是否外委数据:"
+
isOutEntrustData
);
// 样品标识:对于样品下存在特殊字符的检测值,整个样品不再做判级
sampleFlag:
...
...
@@ -1180,25 +1227,20 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
boolean
isSpecStandard
=
sampleVO
.
getProductCode
().
contains
(
"GB/T 1196 2017"
);
logger
.
error
(
"====是否GB/T 1196 2017标准:"
+
isSpecStandard
);
// 检测值【内部检测值实际为指标表中数据,外委检测值为检测项目数据】
List
<
EntrustSampleItemVO
>
sampleItemList
;
// 若为外部检测
if
(
isOutEntrustData
)
{
sampleItemList
=
entrustSampleItemService
.
getListBySampleId
(
sampleVO
.
getId
());
}
else
{
// 获取检测项目及指标数据
sampleItemList
=
getSampleItemIndexList
(
sampleVO
.
getId
());
}
// 从总集合中过滤出
List
<
EntrustSampleItemVO
>
sampleItemList
=
allSampleItemList
.
stream
()
.
filter
(
t
->
Objects
.
equals
(
t
.
getEntrustSampleId
(),
sample
.
getId
())).
collect
(
Collectors
.
toList
());
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
sampleItemList
),
"样品检测项目及内容不能为空"
);
StringBuffer
sb
=
new
StringBuffer
(
"====检测项目检测值:\r\n"
);
for
(
EntrustSampleItemVO
item
:
sampleItemList
)
{
sb
.
append
(
String
.
format
(
"itemName=%s,testValue=%s\r\n"
,
item
.
getName
(),
item
.
getTestValue
()));
}
logger
.
error
(
sb
.
toString
());
//
for (EntrustSampleItemVO item : sampleItemList) {
//
sb.append(String.format("itemName=%s,testValue=%s\r\n", item.getName(), item.getTestValue()));
//
}
//
logger.error(sb.toString());
// 获得产品标准信息 -- 实时最新不是根据样品中的是否组合判定进行判定
// 可能需要根据样品中的字段进行判断是否需要组合判定composeJudge
GradingStandard
standard
=
gradingStandardService
.
getById
(
sampleVO
.
getProductStandardId
());
GradingStandard
standard
=
standardMap
.
get
(
sample
.
getProductStandardId
());
RestAssert
.
fail
(
null
==
standard
,
"产品标准不能为空"
);
logger
.
error
(
"====检验标准,名称:{},编号:{},组合标识:{}"
,
standard
.
getName
(),
standard
.
getCode
(),
standard
.
getComposeJudge
());
// 是否组合判定
...
...
@@ -1234,24 +1276,6 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
}
// 计算合计-组合判定合计值
/*totalDecimal = sampleItemList.stream().map(t -> {
if (StringUtils.isBlank(t.getTestValue())) {
return BigDecimal.ZERO;
}
String testValue = t.getTestValue().trim();
int composeJudge = null == t.getComposeJudge() ? 0 : t.getComposeJudge().intValue();
// 符合此条件,需要判断是否此标准且为稀有元素且值小于0.01即可忽略为0
RestAssert.fail(!isNumber(testValue), String.format("样品编号【%s】存在错误检测值【%s】", sample.getCode(), testValue));
// 判定包含稀有元素
boolean incSpecElement = otherYsList.stream().anyMatch(x -> t.getName().contains(x));
if (1 == composeJudge || (isSpecStandard && incSpecElement && Double.parseDouble(testValue) >= 0.01)) {
return new BigDecimal(testValue);
}
return BigDecimal.ZERO;
}).reduce(BigDecimal.ZERO, BigDecimal::add);
*/
logger
.
error
(
"====杂质值:{}"
,
totalDecimal
);
// 杂质合计值修约
double
totalValue
=
totalDecimal
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_EVEN
).
doubleValue
();
...
...
@@ -1270,25 +1294,22 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
true
;
}).
collect
(
Collectors
.
toMap
(
EntrustSampleItemVO:
:
getName
,
t
->
Double
.
parseDouble
(
t
.
getTestValue
())));
sb
=
new
StringBuffer
(
"====实际比较的检测项目:\r\n"
);
for
(
Map
.
Entry
<
String
,
Double
>
entry
:
itemDataMap
.
entrySet
())
{
sb
.
append
(
String
.
format
(
"检测项目,name:%s,testValue:%f"
,
entry
.
getKey
(),
entry
.
getValue
())).
append
(
"\r\n"
);
}
logger
.
error
(
sb
.
toString
());
//
sb = new StringBuffer("====实际比较的检测项目:\r\n");
//
for (Map.Entry<String, Double> entry : itemDataMap.entrySet()) {
//
sb.append(String.format("检测项目,name:%s,testValue:%f", entry.getKey(), entry.getValue())).append("\r\n");
//
}
//
//
logger.error(sb.toString());
// 获得产品等级信息
List
<
GradingProduct
>
gradingProductList
=
gradingProductService
.
list
(
Condition
.
create
()
.
eq
(
"grading_standard_id"
,
standard
.
getId
())
// 依旧优先级来处理判定顺序
.
orderBy
(
"judge_priority"
,
true
));
List
<
GradingProduct
>
gradingProductList
=
productMap
.
get
(
standard
.
getId
());
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
gradingProductList
),
"产品标准不能为空"
);
sb
=
new
StringBuffer
(
"====产品标准:\r\n"
);
for
(
GradingProduct
gp
:
gradingProductList
)
{
sb
.
append
(
String
.
format
(
"grade:%s,sumVal:%f,symbol:%s"
,
gp
.
getProductGrade
(),
gp
.
getSumValue
(),
gp
.
getSumCompare
())).
append
(
"\r\n"
);
}
logger
.
error
(
sb
.
toString
());
//
sb = new StringBuffer("====产品标准:\r\n");
//
for (GradingProduct gp : gradingProductList) {
//
sb.append(String.format("grade:%s,sumVal:%f,symbol:%s", gp.getProductGrade(), gp.getSumValue(), gp.getSumCompare())).append("\r\n");
//
}
//
logger.error(sb.toString());
logger
.
error
(
"==== 循环产品等级 ==== "
);
// 循环产品标准依次判定级别
...
...
@@ -1301,7 +1322,9 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
logger
.
error
(
"==== GradingProduct, grade:{},sumVal:{},symbol:{}"
,
product
.
getProductGrade
(),
product
.
getSumValue
(),
product
.
getSumCompare
());
// 比较单个大小是否都符合
List
<
GradingItem
>
gradingItemList
=
gradingItemService
.
list
(
Condition
.
create
().
eq
(
"grading_product_id"
,
product
.
getId
()).
isNotNull
(
"limit_value"
));
List
<
GradingItem
>
gradingItemList
=
itemMap
.
get
(
product
.
getId
());
// gradingItemList.stream().filter(g -> Objects.equals(g.getGradingProductId(), product.getId())).collect(Collectors.toList());
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
gradingItemList
),
"产品等级【"
+
product
.
getProductGrade
()
+
"】下的检测项目为空"
);
sb
=
new
StringBuffer
(
"====过滤前产品下检测项目:\r\n"
);
...
...
@@ -1412,26 +1435,25 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
sampleBrandMap
=
updateSampleList
.
stream
().
collect
(
Collectors
.
toMap
(
EntrustSample:
:
getId
,
EntrustSample:
:
getSampleGrading
));
entrustSampleService
.
updateBatchById
(
updateSampleList
);
logger
.
error
(
"====更新样品判级:]\r\n"
);
for
(
EntrustSample
s
:
updateSampleList
)
{
logger
.
error
(
"====判定合格品级:sampleId:{},sampleName:{},sampleCode:{},grading:{}"
,
s
.
getId
(),
s
.
getName
(),
s
.
getCode
(),
s
.
getSampleGrading
());
}
//
for (EntrustSample s : updateSampleList) {
//
logger.error("====判定合格品级:sampleId:{},sampleName:{},sampleCode:{},grading:{}", s.getId(), s.getName(), s.getCode(), s.getSampleGrading());
//
}
}
Map
<
Long
,
String
>
finalSampleBrandMap
=
sampleBrandMap
;
executor1
.
execute
(()
->
{
// 处理正常的报告文件
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
false
);
// 处理一级编码的报告文件
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
true
);
});
executor1
.
execute
(()
->
{
// 针对铝成品和原铝进行发送ERP数据处理
logger
.
error
(
"{}开始执行发送ERP请求:---->ERP---"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
sendTestDataToErp
(
Arrays
.
asList
(
ids
),
finalSampleBrandMap
);
});
// executor1.execute(() -> {
// // 处理正常的报告文件
// handleSampleBrand(ids, finalSampleBrandMap, false);
// // 处理一级编码的报告文件
// handleSampleBrand(ids, finalSampleBrandMap, true);
// });
// executor1.execute(() -> {
// // 针对铝成品和原铝进行发送ERP数据处理
// logger.error("{}开始执行发送ERP请求:---->ERP---", DateUtils.toYearMonthDayTime(new Date()));
// sendTestDataToErp(Arrays.asList(ids), finalSampleBrandMap);
// });
logger
.
error
(
"======================质量判定结束========================"
);
return
true
;
}
...
...
@@ -2112,7 +2134,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
Map
<
String
,
String
>
sampleMap
=
null
;
// 根据是否一级编码确定使用得objectKey
if
(
finalIsOther
)
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getOtherObjectKey
().
equals
(
objectKey
))
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
Objects
.
equals
(
t
.
getOtherObjectKey
(),
objectKey
))
.
collect
(
Collectors
.
toMap
(
ReportSampleVO:
:
getFirstCode
,
ReportSampleVO:
:
getSampleGrading
));
}
else
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
Objects
.
equals
(
objectKey
,
t
.
getObjectKey
()))
...
...
@@ -2123,7 +2145,8 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
t
.
getSecondCode
();
}
return
t
.
getFirstCode
();
},
ReportSampleVO:
:
getSampleGrading
));
},
ReportSampleVO:
:
getSampleGrading
)
);
}
if
(
StringUtils
.
isBlank
(
objectKey
))
{
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
View file @
c465c0f9
...
...
@@ -16,6 +16,7 @@ import com.patzn.cloud.commons.exception.PatznException;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.commons.toolkit.DateUtils
;
import
com.patzn.cloud.commons.toolkit.FileUtils
;
import
com.patzn.cloud.commons.toolkit.MapMergeUtils
;
import
com.patzn.cloud.feign.base.client.SysFileTemplateClient
;
import
com.patzn.cloud.oss.starter.OssClient
;
import
com.patzn.cloud.service.hmhj.dto.*
;
...
...
@@ -215,21 +216,16 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if
(
CollectionUtils
.
isEmpty
(
indexList
))
{
return
page
.
setRecords
(
voList
);
}
Map
<
Long
,
List
<
EntrustSampleItemIndex
>>
sampleIndexMap
=
new
HashMap
<>();
for
(
EntrustSampleItemIndexVO
entrustSampleItemIndex
:
indexList
)
{
if
(
sampleIndexMap
.
containsKey
(
entrustSampleItemIndex
.
getSampleId
()))
{
List
<
EntrustSampleItemIndex
>
itemIndexList
=
sampleIndexMap
.
get
(
entrustSampleItemIndex
.
getSampleId
());
itemIndexList
.
add
(
entrustSampleItemIndex
);
sampleIndexMap
.
put
(
entrustSampleItemIndex
.
getSampleId
(),
itemIndexList
);
}
else
{
List
<
EntrustSampleItemIndex
>
itemIndexList
=
Lists
.
newArrayList
();
itemIndexList
.
add
(
entrustSampleItemIndex
);
sampleIndexMap
.
put
(
entrustSampleItemIndex
.
getSampleId
(),
itemIndexList
);
}
}
for
(
EntrustSampleVO
vo
:
voList
)
{
indexList
.
forEach
(
idx
->
{
MapMergeUtils
.
getorCreateMapArrayList
(
idx
.
getSampleId
(),
sampleIndexMap
,
idx
);
});
voList
.
forEach
(
vo
->
{
vo
.
setIndexList
(
sampleIndexMap
.
get
(
vo
.
getId
()));
}
});
// 数据排序,有结果的排在前面,无结果排后面
Collections
.
sort
(
voList
,
Comparator
.
comparingInt
(
t
->
CollectionUtils
.
isNotEmpty
(
t
.
getIndexList
())
?
1
:
0
));
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/GradingItemServiceImpl.java
View file @
c465c0f9
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
service
.
impl
;
import
com.baomidou.mybatisplus.mapper.Condition
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.service.hmhj.entity.GradingItem
;
import
com.patzn.cloud.service.lims.hmhj.mapper.GradingItemMapper
;
import
com.patzn.cloud.service.lims.hmhj.service.IGradingItemService
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -31,4 +34,12 @@ public class GradingItemServiceImpl extends BaseServiceImpl<GradingItemMapper, G
public
boolean
removeByIds
(
List
<
Long
>
ids
)
{
return
baseMapper
.
deleteBatchIds
(
ids
)
>
0
;
}
@Override
public
List
<
GradingItem
>
listByProductIds
(
List
<
Long
>
productIds
)
{
if
(
CollectionUtils
.
isEmpty
(
productIds
))
{
return
new
ArrayList
<>();
}
return
list
(
Condition
.
create
().
in
(
"grading_product_id"
,
productIds
).
isNotNull
(
"limit_value"
));
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/GradingProductServiceImpl.java
View file @
c465c0f9
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
service
.
impl
;
import
com.baomidou.mybatisplus.mapper.Condition
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.service.hmhj.entity.GradingProduct
;
import
com.patzn.cloud.service.lims.hmhj.mapper.GradingProductMapper
;
import
com.patzn.cloud.service.lims.hmhj.service.IGradingProductService
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -31,4 +34,13 @@ public class GradingProductServiceImpl extends BaseServiceImpl<GradingProductMap
public
boolean
removeByIds
(
List
<
Long
>
ids
)
{
return
baseMapper
.
deleteBatchIds
(
ids
)
>
0
;
}
@Override
public
List
<
GradingProduct
>
listByStandardIds
(
List
<
Long
>
standardIds
)
{
if
(
CollectionUtils
.
isEmpty
(
standardIds
))
{
return
new
ArrayList
<>();
}
// 依旧优先级来处理判定顺序
return
list
(
Condition
.
create
().
in
(
"grading_standard_id"
,
standardIds
).
orderBy
(
"judge_priority"
,
true
));
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/GradingStandardServiceImpl.java
View file @
c465c0f9
...
...
@@ -52,12 +52,12 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
@Override
public
Page
<
GradingStandard
>
page
(
Page
<
GradingStandard
>
page
,
GradingStandard
gradingStandard
)
{
Wrapper
wrapper
=
new
EntityWrapper
<>(
gradingStandard
);
if
(
StringUtils
.
isNotBlank
(
gradingStandard
.
getCode
())){
wrapper
.
like
(
"code"
,
gradingStandard
.
getCode
());
if
(
StringUtils
.
isNotBlank
(
gradingStandard
.
getCode
()))
{
wrapper
.
like
(
"code"
,
gradingStandard
.
getCode
());
gradingStandard
.
setCode
(
null
);
}
if
(
StringUtils
.
isNotBlank
(
gradingStandard
.
getName
())){
wrapper
.
like
(
"name"
,
gradingStandard
.
getName
());
if
(
StringUtils
.
isNotBlank
(
gradingStandard
.
getName
()))
{
wrapper
.
like
(
"name"
,
gradingStandard
.
getName
());
gradingStandard
.
setName
(
null
);
}
return
this
.
page
(
page
,
wrapper
);
...
...
@@ -71,8 +71,8 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
addGradingStandard
(
GradingStandardDTO
dto
,
Account
account
)
{
RestAssert
.
fail
(
StringUtils
.
isBlank
(
dto
.
getCode
()),
"产品标准不能为空!"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
dto
.
getName
()),
"产品标准名称不能为空!"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
dto
.
getCode
()),
"产品标准不能为空!"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
dto
.
getName
()),
"产品标准名称不能为空!"
);
GradingStandard
gradingStandard
=
dto
.
convert
(
GradingStandard
.
class
);
gradingStandard
.
setId
(
IdWorker
.
getId
());
...
...
@@ -81,14 +81,14 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
List
<
GradingItem
>
saveItemList
=
new
ArrayList
<>();
List
<
GradingProduct
>
saveGradingProductList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
gradingProductList
)){
if
(
CollectionUtils
.
isNotEmpty
(
gradingProductList
))
{
for
(
GradingProductDTO
productDTO
:
gradingProductList
)
{
List
<
GradingItem
>
itemList
=
productDTO
.
getGradingItemList
();
GradingProduct
product
=
productDTO
.
convert
(
GradingProduct
.
class
);
product
.
setGradingStandardId
(
gradingStandard
.
getId
());
product
.
setId
(
IdWorker
.
getId
());
saveGradingProductList
.
add
(
product
);
if
(
CollectionUtils
.
isNotEmpty
(
itemList
)){
if
(
CollectionUtils
.
isNotEmpty
(
itemList
))
{
for
(
GradingItem
item
:
itemList
)
{
item
.
setGradingProductId
(
product
.
getId
());
saveItemList
.
add
(
item
);
...
...
@@ -96,7 +96,7 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
}
}
}
if
(
save
(
gradingStandard
)){
if
(
save
(
gradingStandard
))
{
gradingProductService
.
saveBatch
(
saveGradingProductList
);
gradingItemService
.
saveBatch
(
saveItemList
);
}
...
...
@@ -117,12 +117,12 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
abolish
(
Long
[]
ids
,
String
reason
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择需要作废的判级标准"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
reason
),
"请填写,作废原因!"
);
List
<
GradingStandard
>
standards
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
).
eq
(
"effective"
,
1
));
if
(
CollectionUtils
.
isNotEmpty
(
standards
)){
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择需要作废的判级标准"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
reason
),
"请填写,作废原因!"
);
List
<
GradingStandard
>
standards
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
).
eq
(
"effective"
,
1
));
if
(
CollectionUtils
.
isNotEmpty
(
standards
))
{
for
(
GradingStandard
standard
:
standards
)
{
RestAssert
.
fail
(
"判级标准:"
+
standard
.
getCode
()+
"已经作废,请勿重复作废!"
);
RestAssert
.
fail
(
"判级标准:"
+
standard
.
getCode
()
+
"已经作废,请勿重复作废!"
);
}
}
GradingStandard
gradingStandard
=
new
GradingStandard
();
...
...
@@ -145,22 +145,22 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
saveRecord
.
add
(
record
);
}
gradingRecordService
.
saveBatch
(
saveRecord
);
return
super
.
update
(
gradingStandard
,
Condition
.
create
().
in
(
"id"
,
ids
));
return
super
.
update
(
gradingStandard
,
Condition
.
create
().
in
(
"id"
,
ids
));
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
editGradingStandard
(
GradingStandardDTO
dto
,
Account
account
)
{
if
(
null
==
dto
.
getId
()){
if
(
null
==
dto
.
getId
())
{
return
false
;
}
List
<
GradingProductDTO
>
sampleList
=
dto
.
getGradingProductList
();
if
(
CollectionUtils
.
isEmpty
(
sampleList
)){
if
(
CollectionUtils
.
isEmpty
(
sampleList
))
{
// PtAssert.fail("样品不能为空");
}
GradingStandard
standard
=
dto
.
convert
(
GradingStandard
.
class
);
if
(
updateById
(
standard
)){
GradingStandard
standard
=
dto
.
convert
(
GradingStandard
.
class
);
if
(
updateById
(
standard
))
{
List
<
Long
>
sampleIdsList
=
new
ArrayList
<>();
List
<
GradingProduct
>
updateSampleList
=
new
ArrayList
<>();
...
...
@@ -170,43 +170,43 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
List
<
GradingItem
>
saveItemList
=
new
ArrayList
<>();
List
<
GradingItem
>
updateItemList
=
new
ArrayList
<>();
for
(
GradingProductDTO
productDTO
:
sampleList
)
{
for
(
GradingProductDTO
productDTO
:
sampleList
)
{
GradingProduct
sample
=
productDTO
.
convert
(
GradingProduct
.
class
);
if
(
null
!=
sample
.
getId
()){
if
(
null
!=
sample
.
getId
())
{
updateSampleList
.
add
(
sample
);
sampleIdsList
.
add
(
sample
.
getId
());
}
else
{
}
else
{
sample
.
setGradingStandardId
(
standard
.
getId
());
sample
.
setId
(
IdWorker
.
getId
());
saveSampleList
.
add
(
sample
);
}
List
<
GradingItem
>
viewItemList
=
productDTO
.
getGradingItemList
();
if
(
CollectionUtils
.
isNotEmpty
(
viewItemList
)){
for
(
GradingItem
item
:
viewItemList
)
{
if
(
null
==
item
.
getId
()){
List
<
GradingItem
>
viewItemList
=
productDTO
.
getGradingItemList
();
if
(
CollectionUtils
.
isNotEmpty
(
viewItemList
))
{
for
(
GradingItem
item
:
viewItemList
)
{
if
(
null
==
item
.
getId
())
{
item
.
setId
(
IdWorker
.
getId
());
item
.
setGradingProductId
(
sample
.
getId
());
saveItemList
.
add
(
item
);
}
else
{
}
else
{
updateItemList
.
add
(
item
);
}
}
}
}
if
(
CollectionUtils
.
isNotEmpty
(
updateSampleList
)){
if
(
CollectionUtils
.
isNotEmpty
(
updateSampleList
))
{
gradingProductService
.
updateBatchById
(
updateSampleList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
saveSampleList
)){
if
(
CollectionUtils
.
isNotEmpty
(
saveSampleList
))
{
gradingProductService
.
saveBatch
(
saveSampleList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
saveItemList
)){
if
(
CollectionUtils
.
isNotEmpty
(
saveItemList
))
{
gradingItemService
.
saveBatch
(
saveItemList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
updateItemList
)){
if
(
CollectionUtils
.
isNotEmpty
(
updateItemList
))
{
gradingItemService
.
updateBatchById
(
updateItemList
);
}
...
...
@@ -222,4 +222,12 @@ public class GradingStandardServiceImpl extends BaseServiceImpl<GradingStandardM
gradingRecordService
.
save
(
record
);
return
true
;
}
@Override
public
List
<
GradingStandard
>
listByIds
(
List
<
Long
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
new
ArrayList
<>();
}
return
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
}
}
src/main/resources/application.yml
View file @
c465c0f9
...
...
@@ -10,7 +10,7 @@ server:
spring
:
# 环境 dev|test|pro
profiles
:
active
:
local
active
:
dev
application
:
name
:
hmhj
# 模板引擎配置
...
...
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
View file @
c465c0f9
...
...
@@ -682,6 +682,7 @@
<select
id=
"listIndexReplaceItemBySampleIds"
resultType=
"com.patzn.cloud.service.hmhj.vo.EntrustSampleItemVO"
>
select
i.name || '##'|| ii.name "name",
i.entrust_sample_id,
ii.*,
i.compose_judge,
s.code "sample_code",
...
...
src/main/resources/mapper/hmhj/EntrustSampleMapper.xml
View file @
c465c0f9
...
...
@@ -37,38 +37,14 @@
</select>
<select
id=
"selectVOList"
resultType=
"com.patzn.cloud.service.hmhj.vo.EntrustSampleVO"
>
with sample_item as (
select
i.company_id,
i.entrust_sample_id,
max(i.group_id) "group_id",
string_agg(distinct i.name,'、') "item_names"
<!-- ,case when count(1) != count(distinct i.name) then true else false end "item_report" -->
from entrust_sample_item i where i.deleted = 0
<if
test=
"null != vo.entrustId"
>
AND i.entrust_id = #{vo.entrustId}
</if>
<if
test=
"null != vo.itemStatus"
>
and i.status = #{vo.itemStatus}
</if>
<if
test=
"null != vo.itemStatusList"
>
and i.status IN
<foreach
collection=
"vo.itemStatusList"
index=
"index"
item=
"itemStatus"
open=
"("
separator=
","
close=
")"
>
#{itemStatus}
</foreach>
</if>
<if
test=
"null != vo.testerId "
>
and i.tester_id = #{vo.testerId}
</if>
group by i.company_id,i.entrust_sample_id
)
SELECT
s.*,
i.group_id
,
i.item_names
max(i.group_id) "group_id"
,
string_agg ( DISTINCT i.NAME, '、' ) "item_names"
FROM entrust_sample s
JOIN sample_item i on i.entrust_sample_id = s.id
WHERE deleted = 0
JOIN entrust_sample_item i on i.entrust_sample_id = s.id and i.deleted = 0
WHERE s.deleted = 0
<if
test=
"null != vo.entrustId"
>
AND s.entrust_id = #{vo.entrustId}
</if>
...
...
@@ -97,10 +73,19 @@
AND s.status != #{vo.notStatus}
</if>
<!--
<if test="null != vo.itemStatus or null != vo.itemStatusList or null != vo.testerId">
AND exists (
select 1 from entrust_sample_item i where i.deleted = 0 and i.entrust_sample_id = s.id
<if
test=
"null != vo.statusList"
>
and s.status IN
<foreach
collection=
"vo.statusList"
index=
"index"
item=
"status"
open=
"("
separator=
","
close=
")"
>
#{status}
</foreach>
</if>
<if
test=
"null != vo.ids"
>
AND s.id IN
<foreach
collection=
"vo.ids"
index=
"index"
item=
"sampleId"
open=
"("
separator=
","
close=
")"
>
#{sampleId}
</foreach>
</if>
<if
test=
"null != vo.itemStatus"
>
and i.status = #{vo.itemStatus}
...
...
@@ -116,25 +101,8 @@
<if
test=
"null != vo.testerId "
>
and i.tester_id = #{vo.testerId}
</if>
)
</if>
-->
<if
test=
"null != vo.statusList"
>
and s.status IN
<foreach
collection=
"vo.statusList"
index=
"index"
item=
"status"
open=
"("
separator=
","
close=
")"
>
#{status}
</foreach>
</if>
<if
test=
"null != vo.ids"
>
AND s.id IN
<foreach
collection=
"vo.ids"
index=
"index"
item=
"sampleId"
open=
"("
separator=
","
close=
")"
>
#{sampleId}
</foreach>
</if>
order by s.order_by asc, s.code ,s.ctime desc
GROUP BY s.ID
ORDER BY s.order_by asc, s.code ,s.ctime desc
</select>
<select
id=
"selectMinStatusByEntrustIds"
resultType=
"com.patzn.cloud.service.hmhj.vo.EntrustSampleVO"
>
...
...
@@ -211,6 +179,22 @@
<if
test=
"null != vo.slotNoE"
>
AND to_number(s.slot_no,'99999')
<
= #{vo.slotNoE}
</if>
<if
test=
"null != vo.shift"
>
<choose>
<!--零点 =》 00:00-8:00 -->
<when
test=
"0 == vo.shift"
>
and "time"('00:00:00')
<
= "time"(e.entrust_time) and "time"('08:00:00') > "time"(e.entrust_time)
</when>
<!--白班 =》 8:00-16:00 -->
<when
test=
"1 == vo.shift"
>
and "time"('08:00:00')
<
= "time"(e.entrust_time) and "time"('16:00:00') > "time"(e.entrust_time)
</when>
<!--中班 =》 16:00 —24:00 -->
<when
test=
"2 == vo.shift"
>
and "time"('16:00:00')
<
= "time"(e.entrust_time) and "time"('23:59:59') >= "time"(e.entrust_time)
</when>
</choose>
</if>
ORDER BY e.code,s.code
</select>
...
...
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