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;
...
@@ -16,7 +16,6 @@ import com.baosight.hggp.util.StringUtils;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -50,8 +49,8 @@ public class DcOpenApi {
...
@@ -50,8 +49,8 @@ public class DcOpenApi {
*
*
* @param pageIndex 当前页
* @param pageIndex 当前页
*/
*/
public
static
Pager
<
DcUserList
>
userList
(
int
pageIndex
)
public
static
Pager
<
DcUserList
>
userList
(
int
pageIndex
)
throws
IOException
,
InstantiationException
,
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
IllegalAccessException
{
JSONObject
paramJson
=
DcApiUtils
.
buildParamJson
(
pageIndex
);
JSONObject
paramJson
=
DcApiUtils
.
buildParamJson
(
pageIndex
);
String
result
=
HttpUtils
.
post
(
DeChengConst
.
USER_LIST
,
DcApiUtils
.
buildHeader
(),
JSON
.
toJSONString
(
paramJson
),
String
result
=
HttpUtils
.
post
(
DeChengConst
.
USER_LIST
,
DcApiUtils
.
buildHeader
(),
JSON
.
toJSONString
(
paramJson
),
HttpUtils
.
JSON_MEDIA_TYPE
);
HttpUtils
.
JSON_MEDIA_TYPE
);
...
@@ -84,7 +83,7 @@ public class DcOpenApi {
...
@@ -84,7 +83,7 @@ public class DcOpenApi {
* @param endTime 结束日期 20240820
* @param endTime 结束日期 20240820
* @param pageIndex 当前页
* @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
();
JSONArray
dataJsons
=
new
JSONArray
();
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_0"
,
startTime
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_0"
,
startTime
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_1"
,
endTime
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"a_date_1"
,
endTime
));
...
@@ -103,7 +102,7 @@ public class DcOpenApi {
...
@@ -103,7 +102,7 @@ public class DcOpenApi {
*
*
* @param pageIndex 当前页
* @param pageIndex 当前页
*/
*/
public
static
List
<
DcContractList
>
contactList
(
int
pageIndex
)
throws
IOException
{
public
static
Pager
<
DcContractList
>
contactList
(
int
pageIndex
)
throws
IOException
{
JSONArray
dataJsons
=
new
JSONArray
();
JSONArray
dataJsons
=
new
JSONArray
();
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"pageindex"
,
pageIndex
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"pageindex"
,
pageIndex
));
dataJsons
.
add
(
DcApiUtils
.
buildValueJson
(
"pagesize"
,
100
));
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 {
...
@@ -191,12 +191,24 @@ public class DcApiUtils {
* @param result
* @param result
* @return
* @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
);
JSONObject
resultJson
=
JSONObject
.
parseObject
(
result
);
// 异常处理
// 异常处理
handleMessage
(
resultJson
);
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 {
...
@@ -221,15 +233,12 @@ public class DcApiUtils {
/**
/**
* 构建数据集
* 构建数据集
*
*
* @param
result
Json
* @param
table
Json
* @param clazz
* @param clazz
* @param <T>
* @param <T>
* @return
* @return
*/
*/
public
static
<
T
>
List
<
T
>
buildTableData
(
JSONObject
resultJson
,
Class
<
T
>
clazz
)
{
public
static
<
T
>
List
<
T
>
buildTableData
(
JSONObject
tableJson
,
Class
<
T
>
clazz
)
{
JSONObject
bodyJson
=
resultJson
.
getJSONObject
(
"body"
);
JSONObject
sourceJson
=
bodyJson
.
getJSONObject
(
"source"
);
JSONObject
tableJson
=
sourceJson
.
getJSONObject
(
"table"
);
JSONArray
colJsons
=
tableJson
.
getJSONArray
(
"cols"
);
JSONArray
colJsons
=
tableJson
.
getJSONArray
(
"cols"
);
JSONArray
rowJsons
=
tableJson
.
getJSONArray
(
"rows"
);
JSONArray
rowJsons
=
tableJson
.
getJSONArray
(
"rows"
);
return
rowJsons
.
stream
().
map
(
item
->
{
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;
...
@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.sc.service;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.extapp.decheng.api.DcOpenApi
;
import
com.baosight.hggp.core.extapp.decheng.api.DcOpenApi
;
import
com.baosight.hggp.core.extapp.decheng.model.DcContractList
;
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.core.utils.ThreadUtils
;
import
com.baosight.hggp.hg.pz.domain.HGPZ009
;
import
com.baosight.hggp.hg.pz.domain.HGPZ009
;
import
com.baosight.hggp.hg.pz.tools.HGPZTools
;
import
com.baosight.hggp.hg.pz.tools.HGPZTools
;
...
@@ -125,12 +126,13 @@ public class ServiceHGSC101 extends ServiceEPBase {
...
@@ -125,12 +126,13 @@ public class ServiceHGSC101 extends ServiceEPBase {
if
(
pageIndex
>
1000
)
{
if
(
pageIndex
>
1000
)
{
break
;
break
;
}
}
List
<
DcContractList
>
zbContracts
=
DcOpenApi
.
contactList
(
pageIndex
);
Pager
<
DcContractList
>
pager
=
DcOpenApi
.
contactList
(
pageIndex
);
if
(
CollectionUtils
.
isEmpty
(
zbContracts
))
{
List
<
DcContractList
>
dcContractLists
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
dcContractLists
)
||
pageIndex
>
pager
.
getTotalPages
())
{
break
;
break
;
}
}
// 写入合同数据
// 写入合同数据
saveContractData
(
accountCode
,
zbContrac
ts
);
saveContractData
(
accountCode
,
dcContractLis
ts
);
pageIndex
++;
pageIndex
++;
}
}
}
}
...
@@ -139,14 +141,14 @@ public class ServiceHGSC101 extends ServiceEPBase {
...
@@ -139,14 +141,14 @@ public class ServiceHGSC101 extends ServiceEPBase {
* 写入合同信息
* 写入合同信息
*
*
* @param accountCode
* @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
);
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
String
prefix
=
dbPz009
.
getLoginPrefix
();
String
prefix
=
dbPz009
.
getLoginPrefix
();
for
(
DcContractList
zbContract
:
zbContrac
ts
)
{
for
(
DcContractList
dcContractList
:
dcContractLis
ts
)
{
String
projCode
=
prefix
+
zbContrac
t
.
getOrd
();
String
projCode
=
prefix
+
dcContractLis
t
.
getOrd
();
HGSC001
dbSc001
=
HGSCTools
.
Hgsc001
.
getByCode
(
projCode
);
HGSC001
dbSc001
=
HGSCTools
.
Hgsc001
.
getByCode
(
projCode
);
if
(
dbSc001
==
null
)
{
if
(
dbSc001
==
null
)
{
dbSc001
=
new
HGSC001
();
dbSc001
=
new
HGSC001
();
...
@@ -154,12 +156,12 @@ public class ServiceHGSC101 extends ServiceEPBase {
...
@@ -154,12 +156,12 @@ public class ServiceHGSC101 extends ServiceEPBase {
dbSc001
.
setDepCode
(
accountCode
);
dbSc001
.
setDepCode
(
accountCode
);
dbSc001
.
setDepName
(
dbPz009
.
getAccountName
());
dbSc001
.
setDepName
(
dbPz009
.
getAccountName
());
dbSc001
.
setProjCode
(
projCode
);
dbSc001
.
setProjCode
(
projCode
);
dbSc001
.
setProjName
(
zbContrac
t
.
getTitle
());
dbSc001
.
setProjName
(
dcContractLis
t
.
getTitle
());
DaoUtils
.
insert
(
HGSC001
.
INSERT
,
dbSc001
);
DaoUtils
.
insert
(
HGSC001
.
INSERT
,
dbSc001
);
}
else
{
}
else
{
Map
updateMap
=
new
HashMap
();
Map
updateMap
=
new
HashMap
();
updateMap
.
put
(
HGSC001
.
FIELD_proj_code
,
projCode
);
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
);
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 {
...
@@ -150,34 +150,34 @@ public class ServiceHGXSOrg extends ServiceBase {
private
void
syncDcDeptData
(
String
accountCode
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
private
void
syncDcDeptData
(
String
accountCode
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
int
pageIndex
=
1
;
int
pageIndex
=
1
;
Pager
<
DcDeptList
>
pager
=
DcOpenApi
.
deptList
(
pageIndex
);
Pager
<
DcDeptList
>
pager
=
DcOpenApi
.
deptList
(
pageIndex
);
List
<
DcDeptList
>
zbDep
ts
=
pager
.
getData
();
List
<
DcDeptList
>
dcDeptLis
ts
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
zbDep
ts
))
{
if
(
CollectionUtils
.
isEmpty
(
dcDeptLis
ts
))
{
return
;
return
;
}
}
// 写入合同数据
// 写入合同数据
syncDcDeptData
(
accountCode
,
zbDep
ts
);
syncDcDeptData
(
accountCode
,
dcDeptLis
ts
);
}
}
/**
/**
* 写入部门信息
* 写入部门信息
*
*
* @param accountCode
* @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
);
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
for
(
DcDeptList
zbDept
:
zbDep
ts
)
{
for
(
DcDeptList
dcDeptList
:
dcDeptLis
ts
)
{
String
orgId
=
dbPz009
.
getLoginPrefix
()
+
zbDep
t
.
getNodeId
();
String
orgId
=
dbPz009
.
getLoginPrefix
()
+
dcDeptLis
t
.
getNodeId
();
Org
dbOrg
=
HGXSTools
.
XsOrg
.
get
(
orgId
);
Org
dbOrg
=
HGXSTools
.
XsOrg
.
get
(
orgId
);
if
(
dbOrg
==
null
)
{
if
(
dbOrg
==
null
)
{
dbOrg
=
new
Org
();
dbOrg
=
new
Org
();
dbOrg
.
setOrgId
(
orgId
);
dbOrg
.
setOrgId
(
orgId
);
this
.
syncDcDeptAdd
(
accountCode
,
zbDep
t
,
dbOrg
,
dbPz009
);
this
.
syncDcDeptAdd
(
accountCode
,
dcDeptLis
t
,
dbOrg
,
dbPz009
);
}
else
{
}
else
{
Map
updateMap
=
new
HashMap
();
Map
updateMap
=
new
HashMap
();
updateMap
.
put
(
Org
.
FIELD_ORG_ID
,
orgId
);
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_REVISOR
,
"System"
);
updateMap
.
put
(
Org
.
FIELD_REC_REVISE_TIME
,
DateUtils
.
shortDateTime
());
updateMap
.
put
(
Org
.
FIELD_REC_REVISE_TIME
,
DateUtils
.
shortDateTime
());
updateMap
.
put
(
Org
.
FIELD_IS_DELETED
,
DeleteFlagEnum
.
UN_REMOVE
.
getCode
().
toString
());
updateMap
.
put
(
Org
.
FIELD_IS_DELETED
,
DeleteFlagEnum
.
UN_REMOVE
.
getCode
().
toString
());
...
@@ -194,16 +194,16 @@ public class ServiceHGXSOrg extends ServiceBase {
...
@@ -194,16 +194,16 @@ public class ServiceHGXSOrg extends ServiceBase {
* @param dbOrg
* @param dbOrg
* @param dbPz009
* @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
();
String
orgId
=
dbOrg
.
getOrgId
();
dbOrg
.
setAccountCode
(
accountCode
);
dbOrg
.
setAccountCode
(
accountCode
);
dbOrg
.
setOrgEname
(
orgId
);
dbOrg
.
setOrgEname
(
orgId
);
dbOrg
.
setOrgCname
(
zbDep
t
.
getNodeText
());
dbOrg
.
setOrgCname
(
dcDeptLis
t
.
getNodeText
());
dbOrg
.
setOrgType
(
OrgTypeEnum
.
DEPT
.
getCode
());
dbOrg
.
setOrgType
(
OrgTypeEnum
.
DEPT
.
getCode
());
dbOrg
.
setParentOrgId
(
"-1"
.
equals
(
zbDep
t
.
getParentId
())
dbOrg
.
setParentOrgId
(
"-1"
.
equals
(
dcDeptLis
t
.
getParentId
())
?
accountCode
:
dbPz009
.
getLoginPrefix
()
+
zbDep
t
.
getParentId
());
?
accountCode
:
dbPz009
.
getLoginPrefix
()
+
dcDeptLis
t
.
getParentId
());
dbOrg
.
setEstablishDate
(
"20240101"
);
dbOrg
.
setEstablishDate
(
"20240101"
);
dbOrg
.
setSortIndex
(
zbDep
t
.
getFullSort
());
dbOrg
.
setSortIndex
(
dcDeptLis
t
.
getFullSort
());
dbOrg
.
setCompanyCode
(
accountCode
);
dbOrg
.
setCompanyCode
(
accountCode
);
dbOrg
.
setCompanyName
(
dbPz009
.
getAccountName
());
dbOrg
.
setCompanyName
(
dbPz009
.
getAccountName
());
dbOrg
.
setRecCreator
(
"System"
);
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 {
...
@@ -238,12 +238,12 @@ public class ServiceHGXSUser extends ServiceBase {
break
;
break
;
}
}
Pager
<
DcUserList
>
pager
=
DcOpenApi
.
userList
(
pageIndex
);
Pager
<
DcUserList
>
pager
=
DcOpenApi
.
userList
(
pageIndex
);
List
<
DcUserList
>
zbUser
s
=
pager
.
getData
();
List
<
DcUserList
>
dcUserList
s
=
pager
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
zbUser
s
)
||
pageIndex
>
pager
.
getTotalPages
())
{
if
(
CollectionUtils
.
isEmpty
(
dcUserList
s
)
||
pageIndex
>
pager
.
getTotalPages
())
{
break
;
break
;
}
}
// 写入合同数据
// 写入合同数据
syncDcUserData
(
accountCode
,
zbUser
s
);
syncDcUserData
(
accountCode
,
dcUserList
s
);
pageIndex
++;
pageIndex
++;
}
}
}
}
...
@@ -252,14 +252,14 @@ public class ServiceHGXSUser extends ServiceBase {
...
@@ -252,14 +252,14 @@ public class ServiceHGXSUser extends ServiceBase {
* 写入用户信息
* 写入用户信息
*
*
* @param accountCode
* @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
);
HGPZ009
dbPz009
=
HGPZTools
.
HgPz009
.
getByCode
(
accountCode
);
for
(
DcUserList
zbUserList
:
Zb
UserLists
)
{
for
(
DcUserList
dcUserList
:
dc
UserLists
)
{
try
{
try
{
syncDcUserSingle
(
dbPz009
,
zb
UserList
.
getOrd
());
syncDcUserSingle
(
dbPz009
,
dc
UserList
.
getOrd
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"同步德诚用户失败:{}"
,
e
.
getMessage
(),
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