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
82c4226f
Commit
82c4226f
authored
Sep 28, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整原铝、铝成品业务逻辑;
parent
f0a28110
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
188 additions
and
34 deletions
+188
-34
EntrustSampleItemIndexMapper.java
...ervice/lims/hmhj/mapper/EntrustSampleItemIndexMapper.java
+15
-3
IEntrustSampleItemIndexService.java
...ice/lims/hmhj/service/IEntrustSampleItemIndexService.java
+17
-1
IEntrustSampleService.java
...loud/service/lims/hmhj/service/IEntrustSampleService.java
+2
-0
IItemComparisonService.java
...oud/service/lims/hmhj/service/IItemComparisonService.java
+8
-0
EntrustSampleItemIndexServiceImpl.java
.../hmhj/service/impl/EntrustSampleItemIndexServiceImpl.java
+8
-0
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+56
-8
EntrustSampleServiceImpl.java
...vice/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
+8
-0
ItemComparisonServiceImpl.java
...ice/lims/hmhj/service/impl/ItemComparisonServiceImpl.java
+9
-0
EntrustMapper.xml
src/main/resources/mapper/hmhj/EntrustMapper.xml
+1
-3
EntrustSampleItemIndexMapper.xml
...in/resources/mapper/hmhj/EntrustSampleItemIndexMapper.xml
+41
-0
EntrustSampleMapper.xml
src/main/resources/mapper/hmhj/EntrustSampleMapper.xml
+6
-14
IDWorkTest.java
...st/java/com/patzn/cloud/service/lims/test/IDWorkTest.java
+17
-5
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/mapper/EntrustSampleItemIndexMapper.java
View file @
82c4226f
...
...
@@ -55,8 +55,9 @@ public interface EntrustSampleItemIndexMapper extends BatchMapper<EntrustSampleI
/**
* Gets in report item index.
* @param sampleIds
* @return
*
* @param sampleIds the sample ids
* @return in report item index by sample ids
*/
@SqlParser
(
filter
=
true
)
List
<
EntrustSampleItemIndexVO
>
getInReportItemIndexBySampleIds
(
@Param
(
"sampleIds"
)
List
<
Long
>
sampleIds
);
...
...
@@ -73,10 +74,21 @@ public interface EntrustSampleItemIndexMapper extends BatchMapper<EntrustSampleI
/**
* Select sample item index list.
*
* @param entrustIds the entrust ids
* @param sampleIds the sample ids
* @return the list
*/
List
<
Map
<
String
,
Object
>>
selectSampleItemIndex
(
@Param
(
"entrustIds"
)
List
<
Long
>
entrustIds
,
@Param
(
"sampleIds"
)
List
<
Long
>
sampleIds
);
List
<
Map
<
String
,
Object
>>
selectSampleItemIndex
(
@Param
(
"entrustIds"
)
List
<
Long
>
entrustIds
,
@Param
(
"sampleIds"
)
List
<
Long
>
sampleIds
);
/**
* 查询铝成品检测数据.
*
* @param entrustIds entrust ids
* @param sampleIds sample ids
* @return the list
*/
List
<
Map
<
String
,
Object
>>
selectCpSampleItemIndex
(
@Param
(
"entrustIds"
)
List
<
Long
>
entrustIds
,
@Param
(
"sampleIds"
)
List
<
Long
>
sampleIds
);
/**
* Physical delete by item ids integer.
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IEntrustSampleItemIndexService.java
View file @
82c4226f
...
...
@@ -39,7 +39,23 @@ public interface IEntrustSampleItemIndexService extends IBaseService<EntrustSamp
Page
<
EntrustSampleItemIndexVO
>
pageIndexWithItem
(
Page
<
EntrustSampleItemIndexVO
>
page
,
EntrustSampleItemIndexVO
entrustSampleItemIndexVO
);
List
<
Map
<
String
,
Object
>>
listSampleItemIndex
(
List
<
Long
>
entrustIds
,
List
<
Long
>
sampleIds
);
/**
* 原铝
*
* @param entrustIds
* @param sampleIds
* @return
*/
List
<
Map
<
String
,
Object
>>
listSampleItemIndex
(
List
<
Long
>
entrustIds
,
List
<
Long
>
sampleIds
);
/**
* 成品
*
* @param entrustIds
* @param sampleIds
* @return
*/
List
<
Map
<
String
,
Object
>>
listCpSampleItemIndex
(
List
<
Long
>
entrustIds
,
List
<
Long
>
sampleIds
);
boolean
physicalDeleteByItemIds
(
List
<
Long
>
itemIds
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IEntrustSampleService.java
View file @
82c4226f
...
...
@@ -145,4 +145,6 @@ public interface IEntrustSampleService extends IBaseService<EntrustSample> {
boolean
updateStatus
(
EntrustSampleStatusEnum
sampleStatus
,
List
<
Long
>
sampleIds
);
String
getCompatibleCode
(
EntrustSample
sample
);
Long
getEntrustIdBySampleCode
(
String
sampleCode
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IItemComparisonService.java
View file @
82c4226f
...
...
@@ -59,4 +59,12 @@ public interface IItemComparisonService extends IBaseService<ItemComparison> {
* @return the page
*/
Page
<
ItemComparisonVO
>
pageVO
(
Page
<
ItemComparisonVO
>
page
,
SlotQueryDTO
queryDTO
);
/**
* 是否存在对比数据
*
* @param sampleCodeList
* @return
*/
boolean
isExistCompareData
(
List
<
String
>
sampleCodeList
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemIndexServiceImpl.java
View file @
82c4226f
...
...
@@ -55,6 +55,14 @@ public class EntrustSampleItemIndexServiceImpl extends BaseServiceImpl<EntrustSa
}
@Override
public
List
<
Map
<
String
,
Object
>>
listCpSampleItemIndex
(
List
<
Long
>
entrustIds
,
List
<
Long
>
sampleIds
)
{
if
(
CollectionUtils
.
isEmpty
(
entrustIds
)
&&
CollectionUtils
.
isEmpty
(
sampleIds
))
{
return
new
ArrayList
<>();
}
return
baseMapper
.
selectCpSampleItemIndex
(
entrustIds
,
sampleIds
);
}
@Override
public
boolean
physicalDeleteByItemIds
(
List
<
Long
>
itemIds
)
{
if
(
CollectionUtils
.
isEmpty
(
itemIds
))
{
return
true
;
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
82c4226f
...
...
@@ -10,7 +10,6 @@ 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.MapMaker
;
import
com.google.common.collect.Maps
;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.controller.Account
;
...
...
@@ -23,9 +22,7 @@ import com.patzn.cloud.oss.starter.OssFileResult;
import
com.patzn.cloud.service.BaseEntity
;
import
com.patzn.cloud.service.hmhj.bean.KV
;
import
com.patzn.cloud.service.hmhj.dto.QueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.RangeStatsQueryDTO
;
import
com.patzn.cloud.service.hmhj.dto.SampleItemDTO
;
import
com.patzn.cloud.service.hmhj.dto.SlotQueryDTO
;
import
com.patzn.cloud.service.hmhj.entity.*
;
import
com.patzn.cloud.service.hmhj.enums.EntrustFlowEnum
;
import
com.patzn.cloud.service.hmhj.enums.EntrustSampleItemStatusEnum
;
...
...
@@ -64,7 +61,6 @@ import java.io.File;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
...
@@ -154,6 +150,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Autowired
private
ILmsOriginalRecordInfoService
originalRecordInfoService
;
@Autowired
private
IQualificationService
qualificationService
;
...
...
@@ -163,6 +160,9 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Autowired
private
IUserTestStatisticsService
userTestStatisticsService
;
@Autowired
private
IItemComparisonService
itemComparisonService
;
@Override
public
Page
<
EntrustSampleItem
>
page
(
Page
<
EntrustSampleItem
>
page
,
EntrustSampleItem
entrustSampleItem
)
{
String
name
=
entrustSampleItem
.
getName
();
...
...
@@ -1474,15 +1474,63 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
log
(
"数据为空,不发送!"
);
return
;
}
// 只针对原铝和铝成品
String
sampleName
=
sampleList
.
get
(
0
).
getName
();
//
EntrustSample
sample
=
sampleList
.
get
(
0
);
String
sampleName
=
sample
.
getName
();
log
(
"样品名称:"
+
sampleName
);
if
(!
Arrays
.
asList
(
"原铝"
,
"铝成品"
).
contains
(
sampleName
))
{
// 只针对原铝和铝成品,原铝重取只是对原铝的补充
final
String
ylname
=
"原铝"
,
cqname
=
"原铝重取"
,
cpname
=
"铝成品"
;
if
(!(
Objects
.
equals
(
ylname
,
sampleName
)
||
Objects
.
equals
(
cqname
,
sampleName
)
||
Objects
.
equals
(
cpname
,
sampleName
)))
{
log
(
"非原铝或铝成品,不予发送!"
);
return
;
}
// 获取检测项目指标数据
List
<
Map
<
String
,
Object
>>
dataList
=
entrustSampleItemIndexService
.
listSampleItemIndex
(
null
,
ids
);
List
<
Map
<
String
,
Object
>>
dataList
=
null
;
// 此处原铝的和铝成品的查询分开了,实际上只用原铝的即可,铝成品的重写是为了不再对比重取数据
if
(
Objects
.
equals
(
ylname
,
sampleName
))
{
// 当为原铝时,判断是否存在重取,如果存在重取,需要在重取时触发,也就是下个条件下触发,如果不存在重取,那么直接发
// == 若存在,那么需要在重取阶段处理(重取样品,报告发送再处理)
List
<
String
>
sampleCodeList
=
sampleList
.
stream
().
map
(
EntrustSample:
:
getCode
).
collect
(
Collectors
.
toList
());
if
(
itemComparisonService
.
isExistCompareData
(
sampleCodeList
))
{
log
(
"存在需要重取的样品,需要重取时再发送!"
);
return
;
}
dataList
=
entrustSampleItemIndexService
.
listSampleItemIndex
(
null
,
ids
);
}
else
if
(
Objects
.
equals
(
cqname
,
sampleName
))
{
// 此阶段为报告发放的重取数据,实际发送的数据还是原铝数据,只不过,需要将此样品下的数据替换到原铝的检测项目下
// 处理逻辑,业务逻辑可以根据重取的槽号对比原铝的槽号查询原铝数据,代码实现逻辑:根据处理后的样品编号进行查询
// 将重取编号转换成原铝编号,去查询对应的原铝委托ids
// 原铝重取的样品编号可能是下面的几种情况,正常智能是第一种
//Y2204262017C
//2110164032C12
//Y2201086159C1
//Y2112052110C2
//测试环境中,原铝重取可能并不是同一天生成的,"Y" + DateUtils.dateTransfer(sample.getCtime(), "yyMMdd") + "-" + sample.getSlotNo().trim();
String
sampleCode
=
sample
.
getCode
(),
prefix
=
"Y"
;
// == 只有旧数据会有这种情况,可以不去考虑
if
(
StringUtils
.
isBlank
(
sampleCode
))
{
sampleCode
=
"Y"
+
DateUtils
.
dateTransfer
(
sample
.
getCtime
(),
"yyMMdd"
)
+
"-"
+
sample
.
getSlotNo
().
trim
();
}
else
{
sampleCode
=
sampleCode
.
startsWith
(
prefix
)
?
sampleCode
:
(
prefix
+
sampleCode
);
sampleCode
=
sampleCode
.
substring
(
0
,
7
)
+
"-"
+
sample
.
getSlotNo
().
trim
();
}
//根据样品编号,查询出委托id
Long
entrustId
=
entrustSampleService
.
getEntrustIdBySampleCode
(
sampleCode
);
// 基本上不可能为空的
if
(
Objects
.
isNull
(
entrustId
))
{
log
(
"根据样品编号获取委托id失败"
);
return
;
}
// 根据委托去查询,也只能根据委托去查询
dataList
=
entrustSampleItemIndexService
.
listSampleItemIndex
(
Collections
.
singletonList
(
entrustId
),
null
);
}
else
{
dataList
=
entrustSampleItemIndexService
.
listCpSampleItemIndex
(
null
,
ids
);
}
// == search data loop
dataList
.
forEach
(
t
->
{
Long
sampleId
=
Long
.
valueOf
(
t
.
get
(
"id"
).
toString
());
t
.
put
(
"brand"
,
sampleBrandMap
.
get
(
sampleId
));
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
View file @
82c4226f
...
...
@@ -2368,6 +2368,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
return
sampleCode
;
}
@Override
public
Long
getEntrustIdBySampleCode
(
String
sampleCode
)
{
if
(
StringUtils
.
isBlank
(
sampleCode
))
{
return
null
;
}
return
(
Long
)
super
.
getObj
(
Condition
.
create
().
setSqlSelect
(
"entrust_id"
).
eq
(
"code"
,
sampleCode
.
trim
()));
}
private
List
<
EntrustSampleItemIndex
>
getIndexList
(
Long
sampleId
)
{
if
(
null
==
sampleId
)
{
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/ItemComparisonServiceImpl.java
View file @
82c4226f
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
service
.
impl
;
import
com.baomidou.mybatisplus.mapper.Condition
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.commons.controller.Account
;
...
...
@@ -185,4 +186,12 @@ public class ItemComparisonServiceImpl extends BaseServiceImpl<ItemComparisonMap
}
return
super
.
saveBatch
(
comparisonList
);
}
@Override
public
boolean
isExistCompareData
(
List
<
String
>
sampleCodeList
)
{
if
(
CollectionUtils
.
isEmpty
(
sampleCodeList
))
{
return
false
;
}
return
count
(
Condition
.
create
().
in
(
"sample_code"
,
sampleCodeList
))
>
0
;
}
}
src/main/resources/mapper/hmhj/EntrustMapper.xml
View file @
82c4226f
...
...
@@ -173,9 +173,7 @@
SELECT e.*,s.sample_from,r.report_send_time
FROM entrust e
JOIN sample s on s.entrust_id = e.id
left join (
select r.* from entrust_report r where r.deleted = 0
) r on r.entrust_id = e.id
LEFT JOIN entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
<include
refid=
"basicCondition"
/>
...
...
src/main/resources/mapper/hmhj/EntrustSampleItemIndexMapper.xml
View file @
82c4226f
...
...
@@ -167,6 +167,47 @@
si.brand
</select>
<!--查询铝成品要发送ERP数据-->
<select
id=
"selectCpSampleItemIndex"
resultType=
"java.util.Map"
>
SELECT
s.code "sample_code",
s.name "sample_name",
s.sample_from,
s.sample_grading "brand",
max(i.tester) "tester",
to_char(max(i.test_time), 'YYYY-MM-DD HH24:MI:SS') "test_time",
max(r.report_checker) "report_checker",
max(r.report_issuer) "report_issuer",
max(r.quality_inspector) "quality_inspector",
max(case when ii.name = '原铝Fe' then trim(ii.test_value) end) "fe",
max(case when ii.name = '原铝Si' then trim(ii.test_value) end) "si",
max(case when ii.name = '原铝Cu' then trim(ii.test_value) end) "cu",
max(case when ii.name = '原铝Ga' then trim(ii.test_value) end) "ga",
max(case when ii.name = '原铝Mg' then trim(ii.test_value) end) "mg",
max(case when ii.name = '原铝Zn' then trim(ii.test_value) end) "zn",
max(case when ii.name = '原铝Mn' then trim(ii.test_value) end) "mn",
max(case when ii.name = '原铝Ni' then trim(ii.test_value) end) "ni",
max(case when ii.name = '原铝V' then trim(ii.test_value) end) "v"
FROM entrust_sample_item_index ii
JOIN entrust_sample_item i on i.id = ii.entrust_sample_item_id and i.deleted = 0
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.ID = s.entrust_id AND e.deleted = 0
LEFT JOIN entrust_report r ON r.entrust_id = s.entrust_id AND r.deleted = 0
WHERE s.name = '铝成品'
<if
test=
"null != entrustIds"
>
<foreach
collection=
"entrustIds"
index=
"index"
item=
"entrustId"
open=
" and s.entrust_id in ("
separator=
","
close=
")"
>
#{entrustId}
</foreach>
</if>
<if
test=
"null != sampleIds"
>
<foreach
collection=
"sampleIds"
index=
"index"
item=
"sampleId"
open=
" and s.id in ("
separator=
","
close=
")"
>
#{sampleId}
</foreach>
</if>
group by
s.code,s.name,s.sample_from,s.sample_grading
</select>
<delete
id=
"physicalDeleteByItemIds"
>
delete from entrust_sample_item_index where entrust_sample_item_id in
<foreach
collection=
"itemIds"
index=
"index"
item=
"itemId"
open=
" ("
separator=
","
close=
")"
>
...
...
src/main/resources/mapper/hmhj/EntrustSampleMapper.xml
View file @
82c4226f
...
...
@@ -471,15 +471,11 @@
<!-- 查询样品指标 -->
<select
id=
"selectSampleIndex"
resultType=
"com.patzn.cloud.service.hmhj.vo.EntrustSampleIndexVO"
>
SELECT
s.id,
s.entrust_id,
s.code "sample_code",
s.NAME "sample_name",
s.sample_grading "brand",
i.*
FROM
(
SELECT
i.entrust_sample_id,
MAX ( CASE WHEN ii.NAME = '原铝Cu' THEN ii.test_value ELSE '' END ) "cu",
MAX ( CASE WHEN ii.NAME = '原铝Fe' THEN ii.test_value ELSE '' END ) "fe",
MAX ( CASE WHEN ii.NAME = '原铝Ga' THEN ii.test_value ELSE '' END ) "ga",
...
...
@@ -491,15 +487,10 @@
MAX ( CASE WHEN ii.NAME = '原铝Zn' THEN ii.test_value ELSE '' END ) "zn"
FROM
entrust_sample_item_index ii
JOIN entrust_sample_item i ON i.ID = ii.entrust_sample_item_id
WHERE
ii.deleted = 0 AND i.deleted = 0
GROUP BY
i.entrust_sample_id
) i
JOIN entrust_sample s ON s.ID = i.entrust_sample_id
JOIN entrust_sample_item i on i.ID = ii.entrust_sample_item_id and i.deleted = 0
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
WHERE
s.NAME = '铝成品' AND s.TYPE = 2
ii.deleted = 0 and
s.NAME = '铝成品' AND s.TYPE = 2
<if
test=
"null != vo.entrustId"
>
AND s.entrust_id = #{vo.entrustId}
</if>
...
...
@@ -509,7 +500,8 @@
<if
test=
"null != vo.sampleName"
>
AND s.name like concat('%',#{vo.sampleName},'%')
</if>
GROUP BY
s.id
</select>
<!---->
...
...
src/test/java/com/patzn/cloud/service/lims/test/IDWorkTest.java
View file @
82c4226f
package
com
.
patzn
.
cloud
.
service
.
lims
.
test
;
import
com.baomidou.mybatisplus.toolkit.IdWorker
;
import
org.junit.platform.commons.util.StringUtils
;
public
class
IDWorkTest
{
public
static
void
main
(
String
[]
args
)
{
int
i
=
0
;
while
(
i
<
54
)
{
System
.
out
.
println
(
IdWorker
.
getId
(
));
i
++
;
System
.
out
.
println
(
getCodeByCqCode
(
"Y2204262017C"
))
;
System
.
out
.
println
(
getCodeByCqCode
(
"2110164032C12"
));
System
.
out
.
println
(
getCodeByCqCode
(
"Y2201086159C1"
));
System
.
out
.
println
(
getCodeByCqCode
(
"Y2112052110C2"
))
;
}
private
static
String
getCodeByCqCode
(
String
code
)
{
//Y2204262017C
//2110164032C12
//Y2201086159C1
//Y2112052110C2
if
(
StringUtils
.
isBlank
(
code
))
{
return
code
;
}
code
=
code
.
startsWith
(
"Y"
)
?
code
:
"Y"
+
code
;
code
=
code
.
substring
(
0
,
7
)
+
"-"
+
code
.
substring
(
7
,
11
);
return
code
;
}
}
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