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
2ac19b73
Commit
2ac19b73
authored
Mar 04, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送ERP添加日志
parent
be0f3475
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
18 deletions
+36
-18
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+23
-4
EntrustSampleServiceImpl.java
...vice/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
+1
-1
EntrustServiceImpl.java
...ud/service/lims/hmhj/service/impl/EntrustServiceImpl.java
+12
-13
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
2ac19b73
...
...
@@ -1402,16 +1402,16 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
Map
<
Long
,
String
>
finalSampleBrandMap
=
sampleBrandMap
;
executor1
.
execute
(()
->
{
// 处理正常的报告文件
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
false
);
// 处理一级编码的报告文件
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
true
);
// 针对铝成品和原铝进行发送ERP数据处理
sendTestDataToErp
(
Arrays
.
asList
(
ids
));
});
// 针对铝成品和原铝进行发送ERP数据处理
logger
.
error
(
"{}开始执行发送ERP请求;"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
sendTestDataToErp
(
Arrays
.
asList
(
ids
));
logger
.
error
(
"======================质量判定结束========================"
);
return
true
;
}
...
...
@@ -1422,26 +1422,33 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
* @param sampleVOList
*/
private
void
sendTestDataToErp
(
List
<
Long
>
ids
)
{
logger
.
error
(
"====>ERP====:{}获取执行的样品IDS;【{}】"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()),
ids
.
toString
());
List
<
EntrustSample
>
sampleList
=
entrustSampleService
.
getBatchIds
(
ids
);
if
(
CollectionUtils
.
isEmpty
(
sampleList
))
{
logger
.
error
(
"====>ERP====:发送ERP样品数据为空!"
);
return
;
}
// 只针对原铝和铝成品
String
sampleName
=
sampleList
.
get
(
0
).
getName
();
logger
.
error
(
"====>ERP====:获取样品名称【{}】!"
,
sampleName
);
if
(!
Arrays
.
asList
(
"原铝"
,
"铝成品"
).
contains
(
sampleName
))
{
logger
.
error
(
"====>ERP====:不属于原铝和铝成品,不再发送!"
);
return
;
}
// 获取检测项目指标数据
List
<
SampleItemVO
>
dataList
=
entrustSampleItemIndexService
.
listSampleItemIndex
(
ids
);
logger
.
error
(
"====>ERP====:获取项目和指标数据:{}"
,
JSONArray
.
toJSON
(
dataList
));
String
suffix
=
sampleName
+
ids
.
get
(
0
)
+
dataList
.
size
();
// 通信
String
sampleConnectKey
=
"SAMPLE_CONNECT_COUNT_KEY"
+
suffix
;
try
{
logger
.
error
(
"{}=====>===:将要发送ERP数据;"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
doSendErpData
(
ids
,
dataList
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
"{}:发送ERP请求失败,请稍后重试!"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
try
{
logger
.
error
(
"{}====>ERP===:处理失败的数据"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
dealFailureRequest
(
ids
,
dataList
,
sampleConnectKey
);
}
catch
(
Exception
ex
)
{
logger
.
error
(
"{}:重试后失败,发送结束。错误内容:"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()),
ex
.
getMessage
());
...
...
@@ -1450,11 +1457,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
private
void
doSendErpData
(
List
<
Long
>
ids
,
List
<
SampleItemVO
>
dataList
)
{
logger
.
error
(
"{}====>ERP==== 开始发送中...."
);
String
result
=
OkHttpUtils
.
sendByPostJson
(
HttpConst
.
ERP_URL
,
HttpConst
.
ERP_TOKEN
,
JacksonUtils
.
toJSONString
(
dataList
));
logger
.
error
(
"======>ERP====>result:"
+
result
);
if
(
StringUtils
.
isNotBlank
(
result
))
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
logger
.
error
(
"======<ERP>===="
+
jsonObject
.
toJSONString
());
// 若成功 ,则更新标识
if
(
Objects
.
equals
(
jsonObject
.
getString
(
"code"
),
"1"
)
&&
Objects
.
equals
(
jsonObject
.
getBoolean
(
"success"
),
true
))
{
logger
.
error
(
"{}:====>ERP===>Result===>data,更新本地库是否发送标识!"
);
entrustSampleService
.
update
(
new
EntrustSample
().
setSendErp
(
1
),
Condition
.
create
().
in
(
"ids"
,
ids
));
}
else
{
logger
.
error
(
"{}:响应失败:{}"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()),
StringHandleUtils
.
parse
(
jsonObject
.
getString
(
"msg"
)));
...
...
@@ -1465,23 +1476,31 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
private
void
dealFailureRequest
(
List
<
Long
>
ids
,
List
<
SampleItemVO
>
dataList
,
String
sampleFlagKey
)
throws
InterruptedException
{
Integer
retryCount
=
0
;
//
logger
.
error
(
"====>ERP===:开始处理失败的数据!"
);
String
retryCountStr
=
RedisUtil
.
StringOps
.
get
(
sampleFlagKey
);
String
sampleFailureIdsKey
=
"SAMPLE_FAILURE_IDS_KEY"
;
logger
.
error
(
"====>ERP====:获取重试次数:"
+
retryCountStr
);
if
(
Objects
.
isNull
(
retryCountStr
)
||
(
retryCount
=
Integer
.
parseInt
(
retryCountStr
))
<
4
)
{
logger
.
error
(
"====>ERP===:满足重试机制限制数量!"
);
RedisUtil
.
StringOps
.
set
(
sampleFlagKey
,
retryCount
+
1
+
""
);
Thread
.
sleep
(
10000
);
executor1
.
execute
(()
->
{
logger
.
error
(
"{} =====>==== 另开线程:再次执行发送操作!"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
doSendErpData
(
ids
,
dataList
);
});
logger
.
error
(
"{}:处理之前发送失败的请求:{},嘀嘀嘀!"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()),
sampleFailureIdsKey
);
// 对于那些已经失败的请求,重试
if
(
RedisUtil
.
KeyOps
.
hasKey
(
sampleFailureIdsKey
))
{
List
<
String
>
idList
=
RedisUtil
.
ListOps
.
lWholeList
(
sampleFailureIdsKey
);
logger
.
error
(
"{}:处理之前发送失败的请求,获取IDS:{}"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()),
idList
.
toString
());
RedisUtil
.
KeyOps
.
delete
(
sampleFailureIdsKey
);
if
(
CollectionUtils
.
isNotEmpty
(
idList
))
{
logger
.
error
(
"失败的请求不为空,继续处理数据;"
);
List
<
Long
>
sampleIds
=
idList
.
stream
().
map
(
Long:
:
parseLong
).
collect
(
Collectors
.
toList
());
Thread
.
sleep
(
5000
);
executor1
.
execute
(()
->
{
logger
.
error
(
"{} =====>==== 另开线程:处理之前的数据进行发送操作!"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
doSendErpData
(
ids
,
dataList
);
});
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
View file @
2ac19b73
...
...
@@ -652,7 +652,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
new
ArrayList
<>();
}
return
list
.
stream
().
map
(
t
->
t
.
getId
()
).
collect
(
Collectors
.
toList
());
return
list
.
stream
().
map
(
EntrustSample:
:
getId
).
collect
(
Collectors
.
toList
());
}
@Override
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustServiceImpl.java
View file @
2ac19b73
...
...
@@ -460,18 +460,16 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
if
(
null
==
entrust
.
getMaterialId
())
{
entrust
.
setMaterialId
(
sampleDTOList
.
get
(
0
).
getMaterialId
());
}
if
(
saveEntrust
(
entrust
))
{
if
(
CollectionUtils
.
isNotEmpty
(
saveSampleList
))
{
entrustSampleService
.
saveBatch
(
saveSampleList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
saveEntrustSampleItemList
))
{
entrustSampleItemService
.
saveBatch
(
saveEntrustSampleItemList
);
}
// 更新备样entrust_id字段
entrustSampleBackupService
.
updateEntrustId
(
entrust
.
getId
(),
contractSampleIds
);
saveEntrust
(
entrust
);
if
(
CollectionUtils
.
isNotEmpty
(
saveSampleList
))
{
entrustSampleService
.
saveBatch
(
saveSampleList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
saveEntrustSampleItemList
))
{
entrustSampleItemService
.
saveBatch
(
saveEntrustSampleItemList
);
}
// 更新备样entrust_id字段
entrustSampleBackupService
.
updateEntrustId
(
entrust
.
getId
(),
contractSampleIds
);
}
return
true
;
}
...
...
@@ -1234,9 +1232,10 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
backFromReceive
(
Long
[]
ids
,
Account
account
,
String
reason
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要驳回的委托"
);
int
count
=
super
.
count
(
Condition
.
create
().
in
(
"id"
,
ids
).
eq
(
"status"
,
EntrustStatusEnum
.
TEST
));
RestAssert
.
fail
(
ids
.
length
!=
count
,
"请选择要退回至登记的委托"
);
//
int count = super.count(Condition.create().in("id", ids).eq("status", EntrustStatusEnum.TEST));
//
RestAssert.fail(ids.length != count, "请选择要退回至登记的委托");
List
<
Entrust
>
entrustList
=
getBatchIds
(
Arrays
.
asList
(
ids
));
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
entrustList
),
"请选择要驳回的委托"
);
List
<
Long
>
sendUidList
=
new
ArrayList
<>();
for
(
Entrust
e
:
entrustList
)
{
e
.
setStatus
(
EntrustStatusEnum
.
DRAFT
);
...
...
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