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
63381967
Commit
63381967
authored
Nov 04, 2024
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加同步鸿鹏日志接口
parent
c02459bb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
212 additions
and
10 deletions
+212
-10
SbOpenApi.java
.../com/baosight/hggp/core/extapp/decheng/api/SbOpenApi.java
+46
-0
SbTokenApi.java
...com/baosight/hggp/core/extapp/decheng/api/SbTokenApi.java
+126
-0
HGSB010.java
src/main/java/com/baosight/hggp/hg/sb/domain/HGSB010.java
+5
-5
ServiceHGSB010.java
.../java/com/baosight/hggp/hg/sb/service/ServiceHGSB010.java
+33
-0
HGSB010.xml
src/main/java/com/baosight/hggp/hg/sb/sql/HGSB010.xml
+2
-5
No files found.
src/main/java/com/baosight/hggp/core/extapp/decheng/api/SbOpenApi.java
0 → 100644
View file @
63381967
package
com
.
baosight
.
hggp
.
core
.
extapp
.
decheng
.
api
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baosight.hggp.util.HttpUtils
;
import
com.baosight.hggp.util.MapUtils
;
import
com.baosight.hggp.util.StringUtils
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author LiuYang
* @version 1.0 2024/11/3
* @description
*/
@Slf4j
public
class
SbOpenApi
{
/**
* 部门管理-列表
*
* @param eiInfo 当前页
*/
public
static
JSONArray
list
(
EiInfo
eiInfo
)
throws
IOException
,
InstantiationException
,
IllegalAccessException
{
Map
headerMap
=
new
HashMap
();
headerMap
.
put
(
"x-token"
,
SbTokenApi
.
getToken
());
String
url
=
PlatApplicationContext
.
getProperty
(
"hpjx.url"
);
String
result
=
HttpUtils
.
post
(
url
+
"/S_HP_SB_01"
,
headerMap
,
JSON
.
toJSONString
(
eiInfo
),
HttpUtils
.
JSON_MEDIA_TYPE
);
if
(
StringUtils
.
isBlank
(
result
))
{
throw
new
PlatException
(
"【鸿鹏】获取设备日志列表失败"
);
}
JSONObject
resultJson
=
JSONObject
.
parseObject
(
result
);
return
resultJson
.
getJSONArray
(
EiConstant
.
resultBlock
);
}
}
src/main/java/com/baosight/hggp/core/extapp/decheng/api/SbTokenApi.java
0 → 100644
View file @
63381967
package
com
.
baosight
.
hggp
.
core
.
extapp
.
decheng
.
api
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baosight.hggp.util.HttpUtils
;
import
com.baosight.hggp.util.StringUtils
;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author LiuYang
* @version 1.0 2024/11/3
* @description
*/
@Slf4j
public
class
SbTokenApi
{
/**
* 获取TOKEN
*
* @return
*/
public
static
String
getToken
()
{
String
token
=
SbTokenApi
.
SingletonHolder
.
getToken
();
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
PlatException
(
"hong pong token is null!"
);
}
return
token
;
}
/**
* 获取TOKEN(缓存)
*
* @return
*/
public
static
String
getTokenCache
()
{
String
token
=
SbTokenApi
.
SingletonHolder
.
TOKEN
;
if
(
StringUtils
.
isNotBlank
(
token
))
{
return
token
;
}
if
(
refreshToken
())
{
return
SbTokenApi
.
SingletonHolder
.
TOKEN
;
}
else
{
throw
new
PlatException
(
"hong pong token is null!"
);
}
}
/**
* 刷新TOKEN
*
* @return
*/
public
static
boolean
refreshToken
()
{
return
SbTokenApi
.
SingletonHolder
.
refresh
();
}
/**
* 静态内部类用于初始化
*
* @author:songx
* @date:2022/5/9,15:48
*/
private
static
class
SingletonHolder
{
/**
* TOKEN
*/
private
static
String
TOKEN
=
getToken
();
/**
* 刷新TOKEN
*
* @return
*/
public
static
boolean
refresh
()
{
String
token
=
getToken
();
if
(
StringUtils
.
isBlank
(
token
))
{
return
false
;
}
TOKEN
=
token
;
return
true
;
}
/**
* 获取TOKEN
*
* @return
*/
public
static
String
getToken
()
{
try
{
String
param
=
JSON
.
toJSONString
(
buildValueJson
(
"Q24022802"
,
"a123456"
));
String
url
=
PlatApplicationContext
.
getProperty
(
"hpjx.url"
);
String
result
=
HttpUtils
.
post
(
url
+
"/S_XS_105"
,
param
,
HttpUtils
.
JSON_MEDIA_TYPE
);
if
(
StringUtils
.
isBlank
(
result
))
{
log
.
error
(
"获取鸿鹏API的TOKEN失败,接口返回null"
);
return
null
;
}
JSONObject
headerJson
=
JSONObject
.
parseObject
(
result
);
Integer
status
=
headerJson
.
getJSONObject
(
"__sys__"
).
getInteger
(
"status"
);
if
(
status
==
null
||
status
<
0
)
{
log
.
error
(
"获取鸿鹏API的TOKEN失败,api msg:{}"
,
headerJson
.
getInteger
(
"msg"
));
return
null
;
}
return
headerJson
.
getString
(
"x-token"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取鸿鹏API的TOKEN失败:{}"
,
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* 组装值的json
*
* @param loginName 登录名
* @param password 密码
* @return
*/
private
static
JSONObject
buildValueJson
(
String
loginName
,
Object
password
)
{
JSONObject
valueJson
=
new
JSONObject
();
valueJson
.
put
(
"loginName"
,
loginName
);
valueJson
.
put
(
"password"
,
password
);
return
valueJson
;
}
}
}
src/main/java/com/baosight/hggp/hg/sb/domain/HGSB010.java
View file @
63381967
...
@@ -47,11 +47,11 @@ public class HGSB010 extends DaoEPBase {
...
@@ -47,11 +47,11 @@ public class HGSB010 extends DaoEPBase {
public
static
final
String
COL_UPDATED_TIME
=
"UPDATED_TIME"
;
/* 更新时间*/
public
static
final
String
COL_UPDATED_TIME
=
"UPDATED_TIME"
;
/* 更新时间*/
public
static
final
String
COL_DELETE_FLAG
=
"DELETE_FLAG"
;
/* 是否删除0.否1.是*/
public
static
final
String
COL_DELETE_FLAG
=
"DELETE_FLAG"
;
/* 是否删除0.否1.是*/
public
static
final
String
QUERY
=
"H
PSB002
.query"
;
public
static
final
String
QUERY
=
"H
GSB010
.query"
;
public
static
final
String
COUNT
=
"H
PSB002
.count"
;
public
static
final
String
COUNT
=
"H
GSB010
.count"
;
public
static
final
String
INSERT
=
"H
PSB002
.insert"
;
public
static
final
String
INSERT
=
"H
GSB010
.insert"
;
public
static
final
String
UPDATE
=
"H
PSB002
.update"
;
public
static
final
String
UPDATE
=
"H
GSB010
.update"
;
public
static
final
String
DELETE
=
"H
PSB002
.delete"
;
public
static
final
String
DELETE
=
"H
GSB010
.delete"
;
private
Long
id
=
new
Long
(
0
);
/* ID*/
private
Long
id
=
new
Long
(
0
);
/* ID*/
private
String
companyCode
=
" "
;
private
String
companyCode
=
" "
;
...
...
src/main/java/com/baosight/hggp/hg/sb/service/ServiceHGSB010.java
View file @
63381967
package
com
.
baosight
.
hggp
.
hg
.
sb
.
service
;
package
com
.
baosight
.
hggp
.
hg
.
sb
.
service
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baosight.hggp.aspect.annotation.OperationLogAnnotation
;
import
com.baosight.hggp.aspect.annotation.OperationLogAnnotation
;
import
com.baosight.hggp.core.dao.DaoBase
;
import
com.baosight.hggp.core.dao.DaoBase
;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.extapp.decheng.api.SbOpenApi
;
import
com.baosight.hggp.hg.sb.domain.HGSB010
;
import
com.baosight.hggp.hg.xs.domain.User
;
import
com.baosight.hggp.hg.xs.tools.HGXSTools
;
import
com.baosight.hggp.util.DateUtils
;
import
com.baosight.hggp.util.DateUtils
;
import
com.baosight.hggp.util.EiInfoUtils
;
import
com.baosight.hggp.util.EiInfoUtils
;
import
com.baosight.hggp.util.LogUtils
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.service.impl.ServiceEPBase
;
import
com.baosight.iplat4j.core.service.impl.ServiceEPBase
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -162,4 +171,28 @@ public class ServiceHGSB010 extends ServiceEPBase {
...
@@ -162,4 +171,28 @@ public class ServiceHGSB010 extends ServiceEPBase {
//inInfo.set("errerDate", listMap2);
//inInfo.set("errerDate", listMap2);
//inInfo.set("errerTime", result);
//inInfo.set("errerTime", result);
}
}
public
EiInfo
add
(
EiInfo
inInfo
){
try
{
JSONArray
jsonArray
=
SbOpenApi
.
list
(
inInfo
);
User
user
=
HGXSTools
.
XsUser
.
getByLogin
(
"HG0000"
);
List
<
Map
>
list
=
jsonArray
.
stream
().
map
(
o
->
(
Map
)
o
).
collect
(
Collectors
.
toList
());
for
(
Map
map:
list
)
{
HGSB010
hgsb010
=
new
HGSB010
();
hgsb010
.
fromMap
(
map
);
if
(
user
!=
null
){
hgsb010
.
setCompanyCode
(
user
.
getAccountCode
());
}
else
{
hgsb010
.
setCompanyCode
(
"Q24072514"
);
}
DaoUtils
.
insert
(
HGSB010
.
INSERT
,
hgsb010
);
}
inInfo
.
setStatus
(
EiConstant
.
STATUS_DEFAULT
);
inInfo
.
setMsg
(
"操作成功!本次对["
+
jsonArray
.
size
()
+
"]条数据新增成功!"
);
}
catch
(
Exception
e
)
{
LogUtils
.
setDetailMsg
(
inInfo
,
e
,
"设备数据同步失败"
);
}
return
inInfo
;
}
}
}
src/main/java/com/baosight/hggp/hg/sb/sql/HGSB010.xml
View file @
63381967
...
@@ -128,7 +128,7 @@
...
@@ -128,7 +128,7 @@
-->
-->
<insert
id=
"insert"
>
<insert
id=
"insert"
>
INSERT INTO ${hggpSchema}.HGSB010 (
ID,
<!-- ID -->
INSERT INTO ${hggpSchema}.HGSB010 (
ACCOUNT_CODE,
ACCOUNT_CODE,
FILE_NAME,
<!-- 文件名 -->
FILE_NAME,
<!-- 文件名 -->
EQUIPMENT_TYPE,
<!-- 设备状态 -->
EQUIPMENT_TYPE,
<!-- 设备状态 -->
...
@@ -138,12 +138,9 @@
...
@@ -138,12 +138,9 @@
CREATED_BY,
<!-- 创建人 -->
CREATED_BY,
<!-- 创建人 -->
CREATED_NAME,
<!-- 创建人名称 -->
CREATED_NAME,
<!-- 创建人名称 -->
CREATED_TIME,
<!-- 创建时间 -->
CREATED_TIME,
<!-- 创建时间 -->
UPDATED_BY,
<!-- 更新人 -->
UPDATED_NAME,
<!-- 更新人名称 -->
UPDATED_TIME,
<!-- 更新时间 -->
DELETE_FLAG
<!-- 是否删除0.否1.是 -->
DELETE_FLAG
<!-- 是否删除0.否1.是 -->
)
)
VALUES (#
id#, #accountCode#, #fileName#, #equipmentType#, #equipmentCode#, #logInivalue#, #logValue#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #upd
atedTime#, #deleteFlag#)
VALUES (#
companyCode#, #fileName#, #equipmentType#, #equipmentCode#, #logInivalue#, #logValue#, #createdBy#, #createdName#, #cre
atedTime#, #deleteFlag#)
</insert>
</insert>
<delete
id=
"delete"
>
<delete
id=
"delete"
>
...
...
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