Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-platform
Commits
b507555b
Commit
b507555b
authored
Jun 21, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改批量提交逻辑
parent
2968563c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
14 deletions
+157
-14
bill-manager/src/main/java/com/mortals/xhx/common/utils/BatchSavePjTask.java
...in/java/com/mortals/xhx/common/utils/BatchSavePjTask.java
+40
-0
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/PjEvaluateService.java
.../com/mortals/xhx/module/pj/service/PjEvaluateService.java
+7
-0
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/impl/PjEvaluateServiceImpl.java
...als/xhx/module/pj/service/impl/PjEvaluateServiceImpl.java
+100
-7
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateController.java
...a/com/mortals/xhx/module/pj/web/PjEvaluateController.java
+10
-7
No files found.
bill-manager/src/main/java/com/mortals/xhx/common/utils/BatchSavePjTask.java
0 → 100644
View file @
b507555b
package
com.mortals.xhx.common.utils
;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.service.PjEvaluateService
;
import
com.mortals.xhx.utils.SpringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ObjectUtils
;
import
java.util.List
;
/**
* 发通知第三方
*
* @author: zxfei
* @date: 2022/4/28 10:56
* @description:
**/
@Slf4j
public
class
BatchSavePjTask
implements
Runnable
{
private
PjEvaluateService
pjEvaluateService
;
private
List
<
PjEvaluateEntity
>
list
;
public
BatchSavePjTask
(
List
<
PjEvaluateEntity
>
list
)
{
this
.
list
=
list
;
pjEvaluateService
=
SpringUtils
.
getBean
(
PjEvaluateService
.
class
);
}
@Override
public
void
run
()
{
for
(
PjEvaluateEntity
entity
:
list
)
{
pjEvaluateService
.
getSite
(
entity
);
}
pjEvaluateService
.
removeDuplicate
(
list
);
if
(
ObjectUtils
.
isEmpty
(
list
))
return
;
log
.
info
(
"批量保存评价数据:{}"
,
list
.
size
());
pjEvaluateService
.
save
(
list
);
}
}
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/PjEvaluateService.java
View file @
b507555b
...
...
@@ -2,6 +2,9 @@ package com.mortals.xhx.module.pj.service;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.dao.PjEvaluateDao
;
import
java.util.List
;
/**
* PjEvaluateService
*
...
...
@@ -13,4 +16,8 @@ import com.mortals.xhx.module.pj.dao.PjEvaluateDao;
public
interface
PjEvaluateService
extends
ICRUDService
<
PjEvaluateEntity
,
Long
>{
PjEvaluateDao
getDao
();
void
getSite
(
PjEvaluateEntity
entity
);
void
removeDuplicate
(
List
<
PjEvaluateEntity
>
list
);
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/impl/PjEvaluateServiceImpl.java
View file @
b507555b
package
com.mortals.xhx.module.pj.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.pj.model.PjEvaluateQuery
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.exception.AppException
;
...
...
@@ -7,15 +19,96 @@ import com.mortals.xhx.module.pj.dao.PjEvaluateDao;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.service.PjEvaluateService
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* PjEvaluateService
* 评价汇总 service实现
*
* @author zxfei
* @date 2024-05-27
*/
* PjEvaluateService
* 评价汇总 service实现
*
* @author zxfei
* @date 2024-05-27
*/
@Service
(
"pjEvaluateService"
)
@Slf4j
public
class
PjEvaluateServiceImpl
extends
AbstractCRUDServiceImpl
<
PjEvaluateDao
,
PjEvaluateEntity
,
Long
>
implements
PjEvaluateService
{
@Autowired
private
ISiteFeign
siteFeign
;
@Autowired
private
ICacheService
cacheService
;
@Override
public
void
getSite
(
PjEvaluateEntity
entity
)
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSiteId
()))
{
RedisTemplate
<
String
,
String
>
baseRedisTemplate
=
cacheService
.
selectDbRedisTemplate
(
1
);
//com:mortals:xhx:module:site:model:SiteEntity redis调用
String
siteStr
=
(
String
)
baseRedisTemplate
.
opsForHash
().
get
(
"com:mortals:xhx:module:site:model:SiteEntity"
,
String
.
valueOf
(
entity
.
getSiteId
()));
if
(!
ObjectUtils
.
isEmpty
(
siteStr
))
{
SitePdu
sitePdu
=
JSON
.
parseObject
(
siteStr
,
SitePdu
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
sitePdu
))
{
entity
.
setSiteCode
(
sitePdu
.
getSiteCode
());
entity
.
setSiteName
(
sitePdu
.
getSiteName
());
}
else
{
log
.
info
(
"站点信息不存在,siteId={}"
,
entity
.
getSiteId
());
}
}
//feign调用
/* Rest<SitePdu> sitePduRest = siteFeign.info(entity.getSiteId());
if (YesNoEnum.YES.getValue() == sitePduRest.getCode()) {
SitePdu sitePdu = sitePduRest.getData();
if (!ObjectUtils.isEmpty(sitePdu)) {
entity.setSiteCode(sitePdu.getSiteCode());
entity.setSiteName(sitePdu.getSiteName());
} else {
log.info("站点信息不存在,siteId={}", entity.getSiteId());
}
}*/
}
else
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSiteCode
()))
{
SitePdu
pdu
=
new
SitePdu
();
pdu
.
setSiteCode
(
entity
.
getSiteCode
());
Rest
<
RespData
<
List
<
SitePdu
>>>
sitePduRest
=
siteFeign
.
list
(
pdu
);
if
(
YesNoEnum
.
YES
.
getValue
()
==
sitePduRest
.
getCode
())
{
List
<
SitePdu
>
list
=
sitePduRest
.
getData
().
getData
();
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
entity
.
setSiteId
(
list
.
get
(
0
).
getId
());
entity
.
setSiteCode
(
list
.
get
(
0
).
getSiteCode
());
entity
.
setSiteName
(
list
.
get
(
0
).
getSiteName
());
}
else
{
log
.
info
(
"站点信息不存在,siteId={}"
,
entity
.
getSiteId
());
}
}
}
}
}
@Override
public
void
removeDuplicate
(
List
<
PjEvaluateEntity
>
list
)
{
//去重 关键exenum
List
<
String
>
extNumList
=
list
.
stream
().
map
(
m
->
m
.
getExtNum
()).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
PjEvaluateQuery
pjEvaluateQuery
=
new
PjEvaluateQuery
();
pjEvaluateQuery
.
setExtNumList
(
extNumList
);
List
<
PjEvaluateEntity
>
pjEvaluateEntities
=
this
.
find
(
pjEvaluateQuery
);
if
(!
ObjectUtils
.
isEmpty
(
pjEvaluateEntities
))
{
Set
<
String
>
existSet
=
pjEvaluateEntities
.
stream
().
map
(
item
->
item
.
getExtNum
()).
collect
(
Collectors
.
toSet
());
Iterator
<
PjEvaluateEntity
>
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
PjEvaluateEntity
next
=
iterator
.
next
();
if
(
existSet
.
contains
(
next
.
getExtNum
()))
{
log
.
info
(
"排号重复,extNum={}"
,
next
.
getExtNum
());
iterator
.
remove
();
}
}
}
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateController.java
View file @
b507555b
...
...
@@ -9,6 +9,7 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BatchSavePjTask
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.ph.model.PhQueueEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueQuery
;
...
...
@@ -59,8 +60,6 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
PjEvaluateService
pjEvaluateService
;
public
PjEvaluateController
()
{
...
...
@@ -86,7 +85,7 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
@UnAuth
public
String
save
(
@RequestBody
PjEvaluateEntity
entity
)
{
//获取站点信息
getSite
(
entity
);
this
.
service
.
getSite
(
entity
);
//todo 去重
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getExtNum
()))
{
...
...
@@ -108,10 +107,13 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
@UnAuth
public
String
batchSave
(
@RequestBody
List
<
PjEvaluateEntity
>
list
)
{
//线程保存
Runnable
runnable
=
new
Runnable
()
{
private
PjEvaluateService
pjEvaluateService
;
BatchSavePjTask
batchSavePjTask
=
new
BatchSavePjTask
(
list
);
ThreadPool
.
getInstance
().
execute
(
batchSavePjTask
);
/*
Runnable runnable = new Runnable() {
@Override
public void run() {
...
...
@@ -124,7 +126,7 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
}
};
ThreadPool
.
getInstance
().
execute
(
runnable
);
ThreadPool.getInstance().execute(runnable);
*/
return
JSON
.
toJSONString
(
Rest
.
ok
(
"接收成功"
));
// return super.batchSave(list);
...
...
@@ -191,6 +193,7 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
if
(
YesNoEnum
.
YES
.
getValue
()
==
sitePduRest
.
getCode
())
{
List
<
SitePdu
>
list
=
sitePduRest
.
getData
().
getData
();
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
entity
.
setSiteId
(
list
.
get
(
0
).
getId
());
entity
.
setSiteCode
(
list
.
get
(
0
).
getSiteCode
());
entity
.
setSiteName
(
list
.
get
(
0
).
getSiteName
());
}
else
{
...
...
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