Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
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
platform
hg-smart
Commits
8de5987c
Commit
8de5987c
authored
Sep 02, 2024
by
宋祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.优化:接口返回封装pager类
parent
85449e9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
42 deletions
+52
-42
DcOpenApi.java
.../com/baosight/hggp/core/extapp/decheng/api/DcOpenApi.java
+4
-5
DcApiUtils.java
...m/baosight/hggp/core/extapp/decheng/utils/DcApiUtils.java
+16
-7
ServiceHGSC101.java
.../java/com/baosight/hggp/hg/sc/service/ServiceHGSC101.java
+11
-9
ServiceHGXSOrg.java
.../java/com/baosight/hggp/hg/xs/service/ServiceHGXSOrg.java
+14
-14
ServiceHGXSUser.java
...java/com/baosight/hggp/hg/xs/service/ServiceHGXSUser.java
+7
-7
No files found.
src/main/java/com/baosight/hggp/core/extapp/decheng/api/DcOpenApi.java
View file @
8de5987c
...
...
@@ -16,7 +16,6 @@ import com.baosight.hggp.util.StringUtils;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
java.io.IOException
;
import
java.util.List
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -50,8 +49,8 @@ public class DcOpenApi {
*
* @param pageIndex 当前页
*/
public
static
Pager
<
DcUserList
>
userList
(
int
pageIndex
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
public
static
Pager
<
DcUserList
>
userList
(
int
pageIndex
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
JSONObject
paramJson
=
DcApiUtils
.
buildParamJson
(
pageIndex
);
String
result
=
HttpUtils
.
post
(
DeChengConst
.
USER_LIST
,
DcApiUtils
.
buildHeader
(),
JSON
.
toJSONString
(
paramJson
),
HttpUtils
.
JSON_MEDIA_TYPE
);
...
...
@@ -84,7 +83,7 @@ public class DcOpenApi {
* @param endTime 结束日期 20240820
* @param pageIndex 当前页
*/
public
static
List
<
DcChance
>
chanceList
(
String
startTime
,
String
endTime
,
int
pageIndex
)
throws
IOException
{
public
static
Pager
<
DcChance
>
chanceList
(
String
startTime
,
String
endTime
,
int
pageIndex
)
throws
IOException
{
JSONArray
dataJsons
=
new
JSONArray
();
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_0"
,
startTime
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_1"
,
endTime
));
...
...
@@ -103,7 +102,7 @@ public class DcOpenApi {
*
* @param pageIndex 当前页
*/
public
static
List
<
DcContractList
>
contactList
(
int
pageIndex
)
throws
IOException
{
public
static
Pager
<
DcContractList
>
contactList
(
int
pageIndex
)
throws
IOException
{
JSONArray
dataJsons
=
new
JSONArray
();
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"pageindex"
,
pageIndex
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"pagesize"
,
100
));
...
...
src/main/java/com/baosight/hggp/core/extapp/decheng/utils/DcApiUtils.java
View file @
8de5987c
...
...
@@ -191,12 +191,24 @@ public class DcApiUtils {
* @param result
* @return
*/
public
static
<
T
>
List
<
T
>
handleResult
(
String
result
,
Class
<
T
>
clazz
)
{
public
static
<
T
>
Pager
<
T
>
handleResult
(
String
result
,
Class
<
T
>
clazz
)
{
JSONObject
resultJson
=
JSONObject
.
parseObject
(
result
);
// 异常处理
handleMessage
(
resultJson
);
// 获取结果数据集
JSONObject
bodyJson
=
resultJson
.
getJSONObject
(
"body"
);
JSONObject
sourceJson
=
bodyJson
.
getJSONObject
(
"source"
);
JSONObject
tableJson
=
sourceJson
.
getJSONObject
(
"table"
);
// 构建结果数据集
return
buildTableData
(
resultJson
,
clazz
);
Pager
pager
=
new
Pager
<
T
>();
pager
.
setData
(
buildTableData
(
tableJson
,
clazz
));
// 分页数据
JSONObject
pageJson
=
tableJson
.
getJSONObject
(
"page"
);
pager
.
setPageIndex
(
pageJson
.
getInteger
(
"pageindex"
));
pager
.
setPageSize
(
pageJson
.
getInteger
(
"pagesize"
));
pager
.
setTotalRows
(
pageJson
.
getInteger
(
"recordcount"
));
pager
.
setTotalPages
(
pageJson
.
getInteger
(
"pagecount"
));
return
pager
;
}
/**
...
...
@@ -221,15 +233,12 @@ public class DcApiUtils {
/**
* 构建数据集
*
* @param
result
Json
* @param
table
Json
* @param clazz
* @param <T>
* @return
*/
public
static
<
T
>
List
<
T
>
buildTableData
(
JSONObject
resultJson
,
Class
<
T
>
clazz
)
{
JSONObject
bodyJson
=
resultJson
.
getJSONObject
(
"body"
);
JSONObject
sourceJson
=
bodyJson
.
getJSONObject
(
"source"
);
JSONObject
tableJson
=
sourceJson
.
getJSONObject
(
"table"
);
public
static
<
T
>
List
<
T
>
buildTableData
(
JSONObject
tableJson
,
Class
<
T
>
clazz
)
{
JSONArray
colJsons
=
tableJson
.
getJSONArray
(
"cols"
);
JSONArray
rowJsons
=
tableJson
.
getJSONArray
(
"rows"
);
return
rowJsons
.
stream
().
map
(
item
->
{
...
...
src/main/java/com/baosight/hggp/hg/sc/service/ServiceHGSC101.java
View file @
8de5987c
...
...
@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.sc.service;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.extapp.decheng.api.DcOpenApi
;
import
com.baosight.hggp.core.extapp.decheng.model.DcContractList
;
import
com.baosight.hggp.core.model.Pager
;
import
com.baosight.hggp.core.utils.ThreadUtils
;
import
com.baosight.hggp.hg.pz.domain.HGPZ009
;
import
com.baosight.hggp.hg.pz.tools.HGPZTools
;
...
...
@@ -125,12 +126,13 @@ public class ServiceHGSC101 extends ServiceEPBase {
if
(
pageIndex
>
1000
)
{
break
;
}
List
<
DcContractList
>
zbContracts
=
DcOpenApi
.
contactList
(
pageIndex
);
if
(
CollectionUtils
.
isEmpty
(
zbContracts
))
{
Pager
<
DcContractList
>
pager
=
DcOpenApi
.
contactList
(
pageIndex
);
List
<
DcContractList
>
dcContractLists
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
dcContractLists
)
||
pageIndex
>
pager
.
getTotalPages
())
{
break
;
}
// 写入合同数据
saveContractData
(
accountCode
,
zbContrac
ts
);
saveContractData
(
accountCode
,
dcContractLis
ts
);
pageIndex
++;
}
}
...
...
@@ -139,14 +141,14 @@ public class ServiceHGSC101 extends ServiceEPBase {
* 写入合同信息
*
* @param accountCode
* @param
zbContrac
ts
* @param
dcContractLis
ts
*/
private
void
saveContractData
(
String
accountCode
,
List
<
DcContractList
>
zbContrac
ts
)
{
private
void
saveContractData
(
String
accountCode
,
List
<
DcContractList
>
dcContractLis
ts
)
{
// 查询帐套信息
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
String
prefix
=
dbPz009
.
getLoginPrefix
();
for
(
DcContractList
zbContract
:
zbContrac
ts
)
{
String
projCode
=
prefix
+
zbContrac
t
.
getOrd
();
for
(
DcContractList
dcContractList
:
dcContractLis
ts
)
{
String
projCode
=
prefix
+
dcContractLis
t
.
getOrd
();
HGSC001
dbSc001
=
HGSCTools
.
Hgsc001
.
getByCode
(
projCode
);
if
(
dbSc001
==
null
)
{
dbSc001
=
new
HGSC001
();
...
...
@@ -154,12 +156,12 @@ public class ServiceHGSC101 extends ServiceEPBase {
dbSc001
.
setDepCode
(
accountCode
);
dbSc001
.
setDepName
(
dbPz009
.
getAccountName
());
dbSc001
.
setProjCode
(
projCode
);
dbSc001
.
setProjName
(
zbContrac
t
.
getTitle
());
dbSc001
.
setProjName
(
dcContractLis
t
.
getTitle
());
DaoUtils
.
insert
(
HGSC001
.
INSERT
,
dbSc001
);
}
else
{
Map
updateMap
=
new
HashMap
();
updateMap
.
put
(
HGSC001
.
FIELD_proj_code
,
projCode
);
updateMap
.
put
(
HGSC001
.
FIELD_proj_name
,
zbContrac
t
.
getTitle
());
updateMap
.
put
(
HGSC001
.
FIELD_proj_name
,
dcContractLis
t
.
getTitle
());
DaoUtils
.
insert
(
HgScSqlConstant
.
HgSc001
.
UPDATE_PROJ_NAME
,
dbSc001
);
}
}
...
...
src/main/java/com/baosight/hggp/hg/xs/service/ServiceHGXSOrg.java
View file @
8de5987c
...
...
@@ -150,34 +150,34 @@ public class ServiceHGXSOrg extends ServiceBase {
private
void
syncDcDeptData
(
String
accountCode
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
int
pageIndex
=
1
;
Pager
<
DcDeptList
>
pager
=
DcOpenApi
.
deptList
(
pageIndex
);
List
<
DcDeptList
>
zbDep
ts
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
zbDep
ts
))
{
List
<
DcDeptList
>
dcDeptLis
ts
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
dcDeptLis
ts
))
{
return
;
}
// 写入合同数据
syncDcDeptData
(
accountCode
,
zbDep
ts
);
syncDcDeptData
(
accountCode
,
dcDeptLis
ts
);
}
/**
* 写入部门信息
*
* @param accountCode
* @param
zbDep
ts
* @param
dcDeptLis
ts
*/
private
void
syncDcDeptData
(
String
accountCode
,
List
<
DcDeptList
>
zbDep
ts
)
{
private
void
syncDcDeptData
(
String
accountCode
,
List
<
DcDeptList
>
dcDeptLis
ts
)
{
// 查询帐套信息
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
for
(
DcDeptList
zbDept
:
zbDep
ts
)
{
String
orgId
=
dbPz009
.
getLoginPrefix
()
+
zbDep
t
.
getNodeId
();
for
(
DcDeptList
dcDeptList
:
dcDeptLis
ts
)
{
String
orgId
=
dbPz009
.
getLoginPrefix
()
+
dcDeptLis
t
.
getNodeId
();
Org
dbOrg
=
HGXSTools
.
XsOrg
.
get
(
orgId
);
if
(
dbOrg
==
null
)
{
dbOrg
=
new
Org
();
dbOrg
.
setOrgId
(
orgId
);
this
.
syncDcDeptAdd
(
accountCode
,
zbDep
t
,
dbOrg
,
dbPz009
);
this
.
syncDcDeptAdd
(
accountCode
,
dcDeptLis
t
,
dbOrg
,
dbPz009
);
}
else
{
Map
updateMap
=
new
HashMap
();
updateMap
.
put
(
Org
.
FIELD_ORG_ID
,
orgId
);
updateMap
.
put
(
Org
.
FIELD_ORG_CNAME
,
zbDep
t
.
getNodeText
());
updateMap
.
put
(
Org
.
FIELD_ORG_CNAME
,
dcDeptLis
t
.
getNodeText
());
updateMap
.
put
(
Org
.
FIELD_REC_REVISOR
,
"System"
);
updateMap
.
put
(
Org
.
FIELD_REC_REVISE_TIME
,
DateUtils
.
shortDateTime
());
updateMap
.
put
(
Org
.
FIELD_IS_DELETED
,
DeleteFlagEnum
.
UN_REMOVE
.
getCode
().
toString
());
...
...
@@ -194,16 +194,16 @@ public class ServiceHGXSOrg extends ServiceBase {
* @param dbOrg
* @param dbPz009
*/
private
void
syncDcDeptAdd
(
String
accountCode
,
DcDeptList
zbDep
t
,
Org
dbOrg
,
HGPZ009
dbPz009
)
{
private
void
syncDcDeptAdd
(
String
accountCode
,
DcDeptList
dcDeptLis
t
,
Org
dbOrg
,
HGPZ009
dbPz009
)
{
String
orgId
=
dbOrg
.
getOrgId
();
dbOrg
.
setAccountCode
(
accountCode
);
dbOrg
.
setOrgEname
(
orgId
);
dbOrg
.
setOrgCname
(
zbDep
t
.
getNodeText
());
dbOrg
.
setOrgCname
(
dcDeptLis
t
.
getNodeText
());
dbOrg
.
setOrgType
(
OrgTypeEnum
.
DEPT
.
getCode
());
dbOrg
.
setParentOrgId
(
"-1"
.
equals
(
zbDep
t
.
getParentId
())
?
accountCode
:
dbPz009
.
getLoginPrefix
()
+
zbDep
t
.
getParentId
());
dbOrg
.
setParentOrgId
(
"-1"
.
equals
(
dcDeptLis
t
.
getParentId
())
?
accountCode
:
dbPz009
.
getLoginPrefix
()
+
dcDeptLis
t
.
getParentId
());
dbOrg
.
setEstablishDate
(
"20240101"
);
dbOrg
.
setSortIndex
(
zbDep
t
.
getFullSort
());
dbOrg
.
setSortIndex
(
dcDeptLis
t
.
getFullSort
());
dbOrg
.
setCompanyCode
(
accountCode
);
dbOrg
.
setCompanyName
(
dbPz009
.
getAccountName
());
dbOrg
.
setRecCreator
(
"System"
);
...
...
src/main/java/com/baosight/hggp/hg/xs/service/ServiceHGXSUser.java
View file @
8de5987c
...
...
@@ -238,12 +238,12 @@ public class ServiceHGXSUser extends ServiceBase {
break
;
}
Pager
<
DcUserList
>
pager
=
DcOpenApi
.
userList
(
pageIndex
);
List
<
DcUserList
>
zbUser
s
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
zbUser
s
)
||
pageIndex
>
pager
.
getTotalPages
())
{
List
<
DcUserList
>
dcUserList
s
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
dcUserList
s
)
||
pageIndex
>
pager
.
getTotalPages
())
{
break
;
}
// 写入合同数据
syncDcUserData
(
accountCode
,
zbUser
s
);
syncDcUserData
(
accountCode
,
dcUserList
s
);
pageIndex
++;
}
}
...
...
@@ -252,14 +252,14 @@ public class ServiceHGXSUser extends ServiceBase {
* 写入用户信息
*
* @param accountCode
* @param
Zb
UserLists
* @param
dc
UserLists
*/
private
void
syncDcUserData
(
String
accountCode
,
List
<
DcUserList
>
Zb
UserLists
)
{
private
void
syncDcUserData
(
String
accountCode
,
List
<
DcUserList
>
dc
UserLists
)
{
// 查询帐套信息
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
for
(
DcUserList
zbUserList
:
Zb
UserLists
)
{
for
(
DcUserList
dcUserList
:
dc
UserLists
)
{
try
{
syncDcUserSingle
(
dbPz009
,
zb
UserList
.
getOrd
());
syncDcUserSingle
(
dbPz009
,
dc
UserList
.
getOrd
());
}
catch
(
Exception
e
)
{
log
.
error
(
"同步德诚用户失败:{}"
,
e
.
getMessage
(),
e
);
}
...
...
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