Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
data-center
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
廖鑫
data-center
Commits
9dd93fa1
Commit
9dd93fa1
authored
Dec 06, 2021
by
shenxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加办件重新推送接口
parent
eac698ce
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
99 deletions
+120
-99
dataCenter-manager/src/main/java/com/mortals/xhx/modules/supplement/listener/InformationDataConversionListener.java
...upplement/listener/InformationDataConversionListener.java
+50
-39
dataCenter-manager/src/main/java/com/mortals/xhx/modules/supplement/service/impl/SupplementServiceImpl.java
...odules/supplement/service/impl/SupplementServiceImpl.java
+60
-50
dataCenter-manager/src/main/resources/sqlmap/module/supplement/supplement.xml
...rc/main/resources/sqlmap/module/supplement/supplement.xml
+10
-10
No files found.
dataCenter-manager/src/main/java/com/mortals/xhx/modules/supplement/listener/InformationDataConversionListener.java
View file @
9dd93fa1
...
...
@@ -50,14 +50,17 @@ public class InformationDataConversionListener extends AnalysisEventListener<Sup
//当前系统编码
private
String
SYS_CODE
=
""
;
private
String
AREA_CODE
=
""
;
private
String
TYPE
=
""
;
public
void
currentSystemCode
(
String
sysCode
,
String
areaCode
,
String
type
)
{
public
void
currentSystemCode
(
String
sysCode
,
String
type
)
{
this
.
SYS_CODE
=
sysCode
;
this
.
AREA_CODE
=
areaCode
;
this
.
TYPE
=
type
;
}
// public void currentSystemCode(String sysCode, String areaCode, String type) {
// this.SYS_CODE = sysCode;
// this.AREA_CODE = areaCode;
// this.TYPE = type;
// }
//当前系统剩余多少条办件量(可推送的办件量)=固定阈值-已推送办件
private
int
FIXED_AMOUNT
=
0
;
...
...
@@ -89,30 +92,37 @@ public class InformationDataConversionListener extends AnalysisEventListener<Sup
supplementEntity
.
setPushType
(
TYPE
);
entityList
.
add
(
supplementEntity
);
eventCodeList
.
add
(
supplementEntity
.
getImplCode
());
if
(
PushTypeEnum
.
SYTH
.
getStyle
().
equals
(
TYPE
)){
if
(
entityList
.
size
()
>
FIXED_AMOUNT
)
{
throw
new
RuntimeException
(
"数据上传失败,失败原因: 今日推送量已超过5000,请明天再试"
);
}
else
{
//达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
if
(
entityList
.
size
()
>=
BATCH_COUNT
)
{
//判断当前上传的excel表格中那些是非本区域的办件
Map
<
String
,
Object
>
stringObjectMap
=
judgeTheProcessingArea
(
eventCodeList
,
AREA_CODE
);
//判断当前是否还有数据,如果有数据,则表明当前map存在非本区域办件,则抛出异常
boolean
easyToUseValue
=
stringObjectMap
.
get
(
"boolean"
)
!=
null
?
false
:
true
;
if
(
easyToUseValue
)
{
supplementDao
.
insertBatch
(
entityList
);
//存储完成清理list
entityList
.
clear
();
}
else
{
throw
new
RuntimeException
(
"当前excel数据存在非本区域办件:"
+
stringObjectMap
);
}
}
}
}
else
if
(
PushTypeEnum
.
RYB
.
getStyle
().
equals
(
TYPE
)){
if
(
entityList
.
size
()
>=
BATCH_COUNT
)
{
supplementDao
.
insertBatch
(
entityList
);
}
}
// if(PushTypeEnum.SYTH.getStyle().equals(TYPE)){
// if (entityList.size() > FIXED_AMOUNT) {
// throw new RuntimeException("数据上传失败,失败原因: 今日推送量已超过5000,请明天再试");
// } else {
// //达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
// if (entityList.size() >= BATCH_COUNT) {
// //判断当前上传的excel表格中那些是非本区域的办件
// Map<String, Object> stringObjectMap = judgeTheProcessingArea(eventCodeList, AREA_CODE);
// //判断当前是否还有数据,如果有数据,则表明当前map存在非本区域办件,则抛出异常
// boolean easyToUseValue = stringObjectMap.get("boolean") != null ? false : true;
// if (easyToUseValue) {
// supplementDao.insertBatch(entityList);
// //存储完成清理list
// entityList.clear();
// } else {
// throw new RuntimeException("当前excel数据存在非本区域办件:" + stringObjectMap);
// }
// }
// }
// }else if(PushTypeEnum.RYB.getStyle().equals(TYPE)){
// if (entityList.size() >= BATCH_COUNT) {
// supplementDao.insertBatch(entityList);
// //存储完成清理list
// entityList.clear();
// }
// }
}
private
Map
<
String
,
Object
>
judgeTheProcessingArea
(
List
<
String
>
eventCodeList
,
String
areaCode
)
{
...
...
@@ -148,19 +158,20 @@ public class InformationDataConversionListener extends AnalysisEventListener<Sup
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
if
(
PushTypeEnum
.
SYTH
.
getStyle
().
equals
(
TYPE
)){
//判断当前上传的excel表格中那些是非本区域的办件
Map
<
String
,
Object
>
stringObjectMap
=
judgeTheProcessingArea
(
eventCodeList
,
AREA_CODE
);
//判断当前是否还有数据,如果有数据,则表明当前map存在非本区域办件,则抛出异常
boolean
easyToUseValue
=
stringObjectMap
.
get
(
"boolean"
)
!=
null
?
false
:
true
;
if
(
easyToUseValue
)
{
supplementDao
.
insertBatch
(
entityList
);
}
else
{
throw
new
RuntimeException
(
"当前excel数据存在非本区域办件:"
+
JSONObject
.
toJSONString
(
stringObjectMap
));
}
}
else
if
(
PushTypeEnum
.
RYB
.
getStyle
().
equals
(
TYPE
)){
// if(PushTypeEnum.SYTH.getStyle().equals(TYPE)){
// //判断当前上传的excel表格中那些是非本区域的办件
// Map<String, Object> stringObjectMap = judgeTheProcessingArea(eventCodeList, AREA_CODE);
// //判断当前是否还有数据,如果有数据,则表明当前map存在非本区域办件,则抛出异常
// boolean easyToUseValue = stringObjectMap.get("boolean") != null ? false : true;
// if (easyToUseValue) {
// supplementDao.insertBatch(entityList);
// } else {
// throw new RuntimeException("当前excel数据存在非本区域办件:" + JSONObject.toJSONString(stringObjectMap));
// }
// }else if(PushTypeEnum.RYB.getStyle().equals(TYPE)){
// supplementDao.insertBatch(entityList);
// }
supplementDao
.
insertBatch
(
entityList
);
}
log
.
info
(
"=======办件数据导入成功==========="
);
}
...
...
dataCenter-manager/src/main/java/com/mortals/xhx/modules/supplement/service/impl/SupplementServiceImpl.java
View file @
9dd93fa1
...
...
@@ -67,7 +67,7 @@ public class SupplementServiceImpl extends AbstractCRUDServiceImpl<SupplementDao
ApiRespPdu
<
Object
>
objectApiRespPdu
=
new
ApiRespPdu
<>();
try
{
InformationDataConversionListener
informationDataConversionListener
=
new
InformationDataConversionListener
(
supplementDao
,
implementlistService
);
informationDataConversionListener
.
currentSystemCode
(
null
,
null
,
type
);
informationDataConversionListener
.
currentSystemCode
(
null
,
type
);
EasyExcel
.
read
(
file
,
SupplementEntity
.
class
,
informationDataConversionListener
)
.
sheet
(
0
)
.
headRowNumber
(
3
)
...
...
@@ -82,41 +82,10 @@ public class SupplementServiceImpl extends AbstractCRUDServiceImpl<SupplementDao
}
}
private
ApiRespPdu
sythImport
(
BufferedInputStream
file
,
String
sysCode
,
String
type
){
//1.导入之前,查询当前系统编码的阈值,以及多少办件量,并判断今天能否再次推送
ArameterEntity
arameterEntity
=
new
ArameterEntity
();
arameterEntity
.
setSysCode
(
sysCode
);
List
<
ArameterEntity
>
arameterEntities
=
arameterService
.
find
(
arameterEntity
,
null
);
//地区编码
String
areaCode
=
arameterEntities
.
get
(
0
).
getAreaCode
();
// String areaCode = "513237000000";
//当前系统每天的固定办件量
// Integer limitTheNumberOfDocuments = Integer.valueOf(arameterEntities.get(0).getThresholdValue());
Integer
limitTheNumberOfDocuments
=
Integer
.
valueOf
(
"5000000"
);
InformationQuery
informationQuery
=
new
InformationQuery
();
//设置查询条件,查询当天的办件量
informationQuery
.
setSystemCode
(
sysCode
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//当前时间毫秒数
long
current
=
System
.
currentTimeMillis
();
//今天零点零分零秒的毫秒数
long
zero
=
current
/(
1000
*
3600
*
24
)*(
1000
*
3600
*
24
)-
TimeZone
.
getDefault
().
getRawOffset
();
//今天23点59分59秒的毫秒数
long
twelve
=
zero
+
24
*
60
*
60
*
1000
-
1
;
informationQuery
.
setQueryBeginTime
(
simpleDateFormat
.
format
(
new
Date
(
zero
)));
informationQuery
.
setQueryEndTime
(
simpleDateFormat
.
format
(
new
Date
(
twelve
)));
//当前系统(当天)已推送的办件量
int
count
=
informationDao
.
getCount
(
informationQuery
);
private
ApiRespPdu
sythImport
(
BufferedInputStream
file
,
String
sysCode
,
String
type
)
{
ApiRespPdu
<
Object
>
objectApiRespPdu
=
new
ApiRespPdu
<>();
if
(
count
>
limitTheNumberOfDocuments
)
{
objectApiRespPdu
.
setCode
(
500
);
objectApiRespPdu
.
setMsg
(
"数据上传失败,失败原因: 今日推送量已超过: "
+
limitTheNumberOfDocuments
+
" ,请明天再试"
);
return
objectApiRespPdu
;
}
else
{
try
{
InformationDataConversionListener
informationDataConversionListener
=
new
InformationDataConversionListener
(
supplementDao
,
implementlistService
);
informationDataConversionListener
.
theAmountOfDeliverablesThatCanBePushed
(
limitTheNumberOfDocuments
,
count
);
informationDataConversionListener
.
currentSystemCode
(
sysCode
,
areaCode
,
type
);
InformationDataConversionListener
informationDataConversionListener
=
new
InformationDataConversionListener
(
supplementDao
,
implementlistService
);
informationDataConversionListener
.
currentSystemCode
(
sysCode
,
type
);
EasyExcel
.
read
(
file
,
SupplementEntity
.
class
,
informationDataConversionListener
)
.
sheet
(
0
)
.
headRowNumber
(
3
)
...
...
@@ -124,13 +93,54 @@ public class SupplementServiceImpl extends AbstractCRUDServiceImpl<SupplementDao
objectApiRespPdu
.
setCode
(
200
);
objectApiRespPdu
.
setMsg
(
"数据上传成功"
);
return
objectApiRespPdu
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
objectApiRespPdu
.
setCode
(
500
);
objectApiRespPdu
.
setMsg
(
"数据上传失败,失败原因:"
+
e
.
getMessage
()+
"目前剩余容量:"
+
String
.
valueOf
(
limitTheNumberOfDocuments
-
count
));
return
objectApiRespPdu
;
}
// //1.导入之前,查询当前系统编码的阈值,以及多少办件量,并判断今天能否再次推送
// ArameterEntity arameterEntity = new ArameterEntity();
// arameterEntity.setSysCode(sysCode);
// List<ArameterEntity> arameterEntities = arameterService.find(arameterEntity, null);
// //地区编码
// String areaCode = arameterEntities.get(0).getAreaCode();
//// String areaCode = "513237000000";
// //当前系统每天的固定办件量
//// Integer limitTheNumberOfDocuments = Integer.valueOf(arameterEntities.get(0).getThresholdValue());
// Integer limitTheNumberOfDocuments = Integer.valueOf("5000000");
// InformationQuery informationQuery = new InformationQuery();
// //设置查询条件,查询当天的办件量
// informationQuery.setSystemCode(sysCode);
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// //当前时间毫秒数
// long current=System.currentTimeMillis();
// //今天零点零分零秒的毫秒数
// long zero=current/(1000*3600*24)*(1000*3600*24)- TimeZone.getDefault().getRawOffset();
// //今天23点59分59秒的毫秒数
// long twelve=zero+24*60*60*1000-1;
// informationQuery.setQueryBeginTime(simpleDateFormat.format(new Date(zero)));
// informationQuery.setQueryEndTime(simpleDateFormat.format(new Date(twelve)));
// //当前系统(当天)已推送的办件量
// int count = informationDao.getCount(informationQuery);
// ApiRespPdu<Object> objectApiRespPdu = new ApiRespPdu<>();
// if (count > limitTheNumberOfDocuments) {
// objectApiRespPdu.setCode(500);
// objectApiRespPdu.setMsg("数据上传失败,失败原因: 今日推送量已超过: "+limitTheNumberOfDocuments+" ,请明天再试");
// return objectApiRespPdu;
// } else {
// try {
// InformationDataConversionListener informationDataConversionListener = new InformationDataConversionListener(supplementDao,implementlistService);
// informationDataConversionListener.theAmountOfDeliverablesThatCanBePushed(limitTheNumberOfDocuments,count);
// informationDataConversionListener.currentSystemCode(sysCode,areaCode,type);
// EasyExcel.read(file, SupplementEntity.class, informationDataConversionListener)
// .sheet(0)
// .headRowNumber(3)
// .doRead();
// objectApiRespPdu.setCode(200);
// objectApiRespPdu.setMsg("数据上传成功");
// return objectApiRespPdu;
// } catch (Exception e) {
// e.printStackTrace();
// objectApiRespPdu.setCode(500);
// objectApiRespPdu.setMsg("数据上传失败,失败原因:" + e.getMessage()+"目前剩余容量:"+String.valueOf(limitTheNumberOfDocuments-count));
// return objectApiRespPdu;
// }
// }
// }
}
}
}
\ No newline at end of file
dataCenter-manager/src/main/resources/sqlmap/module/supplement/supplement.xml
View file @
9dd93fa1
...
...
@@ -146,7 +146,7 @@
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert
id=
"insert"
parameterType=
"SupplementEntity"
>
insert into
supplement
insert into
${tableName}
(id,impl_name,impl_code,application_type,application_card_type,application_name,application_id,application_phone,mechanism_name,mechanism_address,mechanism_type,mechanism_id_type,mechanism_id,legal_person,apply_time,accept_name,accept_id,accept_phone,sys_code,is_execute,is_success,fail_reason,push_type,createDate,updateDate)
VALUES
(#{id},#{implName},#{implCode},#{applicationType},#{applicationCardType},#{applicationName},#{applicationId},#{applicationPhone},#{mechanismName},#{mechanismAddress},#{mechanismType},#{mechanismIdType},#{mechanismId},#{legalPerson},#{applyTime},#{acceptName},#{acceptId},#{acceptPhone},#{sysCode},#{isExecute},#{isSuccess},#{failReason},#{pushType},#{createDate},#{updateDate})
...
...
@@ -154,7 +154,7 @@
<!-- 批量新增 -->
<insert
id=
"insertBatch"
parameterType=
"paramDto"
>
insert into
supplement
insert into
${tableName}
(id,impl_name,impl_code,application_type,application_card_type,application_name,application_id,application_phone,mechanism_name,mechanism_address,mechanism_type,mechanism_id_type,mechanism_id,legal_person,apply_time,accept_name,accept_id,accept_phone,sys_code,is_execute,is_success,fail_reason,push_type,createDate,updateDate)
VALUES
<foreach
collection=
"data.dataList"
item=
"item"
index=
"index"
separator=
","
>
...
...
@@ -165,7 +165,7 @@
<!-- 根据ParamDto更新 -->
<update
id=
"update"
parameterType=
"paramDto"
>
update
supplement
as a
update
${tableName}
as a
set
<trim
suffixOverrides=
","
suffix=
""
>
<if
test=
"(colPickMode==0 and data.containsKey('implName')) or (colPickMode==1 and !data.containsKey('implName'))"
>
...
...
@@ -250,7 +250,7 @@
</update>
<!-- 批量更新 -->
<update
id=
"updateBatch"
parameterType=
"paramDto"
>
update
supplement
as a
update
${tableName}
as a
<trim
prefix=
"set"
suffixOverrides=
","
>
<trim
prefix=
"impl_name=(case"
suffix=
"ELSE impl_name end),"
>
<foreach
collection=
"data.dataList"
item=
"item"
index=
"index"
separator=
""
>
...
...
@@ -429,23 +429,23 @@
<!-- 根据主健查询 -->
<select
id=
"getByKey"
parameterType=
"paramDto"
resultMap=
"SupplementEntity-Map"
>
select
<include
refid=
"_columns"
/>
from
supplement
as a
from
${tableName}
as a
where a.id=#{condition.id}
</select>
<!-- 根据主健删除 -->
<delete
id=
"deleteByKey"
parameterType=
"paramDto"
>
delete a.* from
supplement
as a where a.id=#{condition.id}
delete a.* from
${tableName}
as a where a.id=#{condition.id}
</delete>
<!-- 根据主健删除一批,针对单一主健有效 -->
<delete
id=
"deleteByKeys"
>
delete from
supplement
where id in
delete from
${tableName}
where id in
<foreach
collection=
"array"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</delete>
<!-- 根据paramDto删除一批 -->
<delete
id=
"deleteByMap"
parameterType=
"paramDto"
>
delete a.* from
supplement
as a
delete a.* from
${tableName}
as a
<trim
suffixOverrides=
"where"
suffix=
""
>
where
<trim
prefixOverrides=
"and"
prefix=
""
>
...
...
@@ -456,7 +456,7 @@
<!-- 获取列表 -->
<select
id=
"getList"
parameterType=
"paramDto"
resultMap=
"SupplementEntity-Map"
>
select
<include
refid=
"_columns"
/>
from
supplement
as a
from
${tableName}
as a
<trim
suffixOverrides=
"where"
suffix=
""
>
where
<trim
prefixOverrides=
"and"
prefix=
""
>
...
...
@@ -469,7 +469,7 @@
<!-- 获取 -->
<select
id=
"getListCount"
parameterType=
"paramDto"
resultType=
"int"
>
select count(1)
from
supplement
as a
from
${tableName}
as a
<trim
suffixOverrides=
"where"
suffix=
""
>
where
<trim
prefixOverrides=
"and"
prefix=
""
>
...
...
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