Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
H
Hgs
Project
Project
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
徐州
Hgs
Commits
4f512d78
Commit
4f512d78
authored
Mar 25, 2021
by
jay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口提交
parent
21fb13f1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
300 additions
and
0 deletions
+300
-0
applicationContext-dubbo.xml
...rces/development/application/applicationContext-dubbo.xml
+5
-0
applicationContext-dubbo.xml
...urces/production/application/applicationContext-dubbo.xml
+5
-0
applicationContext-dubbo.xml
...n/resources/test/application/applicationContext-dubbo.xml
+5
-0
IGetOnlineLog.java
...n/java/com/house365/ws/interfaces/rest/IGetOnlineLog.java
+9
-0
OnlineLogMapper.java
...main/java/com/house365/ws/dao/mapper/OnlineLogMapper.java
+5
-0
GetOnlineLogImpl.java
...ava/com/house365/ws/interfaces/rest/GetOnlineLogImpl.java
+190
-0
applicationContext-dubbo.xml
...rces/development/application/applicationContext-dubbo.xml
+5
-0
OnlineLogMapper.xml
...rc/main/resources/development/mybatis/OnlineLogMapper.xml
+22
-0
applicationContext-dubbo.xml
...urces/production/application/applicationContext-dubbo.xml
+5
-0
OnlineLogMapper.xml
...src/main/resources/production/mybatis/OnlineLogMapper.xml
+22
-0
applicationContext-dubbo.xml
...n/resources/test/application/applicationContext-dubbo.xml
+5
-0
OnlineLogMapper.xml
...gs-ws/src/main/resources/test/mybatis/OnlineLogMapper.xml
+22
-0
No files found.
house365-hgs-web/src/main/resources/development/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -393,6 +393,11 @@
...
@@ -393,6 +393,11 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-web/src/main/resources/production/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -390,5 +390,10 @@
...
@@ -390,5 +390,10 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-web/src/main/resources/test/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -390,5 +390,10 @@
...
@@ -390,5 +390,10 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws-interfaces/src/main/java/com/house365/ws/interfaces/rest/IGetOnlineLog.java
0 → 100644
View file @
4f512d78
package
com
.
house365
.
ws
.
interfaces
.
rest
;
import
com.house365.rest.context.IService
;
/**
* @author Created by 365 on 2021/3/24.
*/
public
interface
IGetOnlineLog
extends
IService
{
}
house365-hgs-ws/src/main/java/com/house365/ws/dao/mapper/OnlineLogMapper.java
View file @
4f512d78
...
@@ -3,6 +3,9 @@ package com.house365.ws.dao.mapper;
...
@@ -3,6 +3,9 @@ package com.house365.ws.dao.mapper;
import
com.house365.beans.entity.OnlineLogEntity
;
import
com.house365.beans.entity.OnlineLogEntity
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @author Created by 365 on 2020/12/31.
* @author Created by 365 on 2020/12/31.
*/
*/
...
@@ -10,4 +13,6 @@ import org.springframework.stereotype.Repository;
...
@@ -10,4 +13,6 @@ import org.springframework.stereotype.Repository;
public
interface
OnlineLogMapper
{
public
interface
OnlineLogMapper
{
void
save
(
OnlineLogEntity
entity
);
void
save
(
OnlineLogEntity
entity
);
List
<
OnlineLogEntity
>
queryByConditions
(
Map
<
String
,
Object
>
map
);
}
}
house365-hgs-ws/src/main/java/com/house365/ws/interfaces/rest/GetOnlineLogImpl.java
0 → 100644
View file @
4f512d78
package
com
.
house365
.
ws
.
interfaces
.
rest
;
import
com.google.common.base.Strings
;
import
com.house365.beans.entity.OnlineLogEntity
;
import
com.house365.beans.entity.UserEntity
;
import
com.house365.rest.context.Parameter
;
import
com.house365.rest.exception.ServiceRunException
;
import
com.house365.rest.parameter.House365RestObject
;
import
com.house365.rest.parameter.House365RestResponse
;
import
com.house365.web.util.DateTimeUtils
;
import
com.house365.ws.dao.mapper.OnlineLogMapper
;
import
com.house365.ws.dao.mapper.UserMapper
;
import
com.house365.ws.system.ReturnAppResult
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 查询人员上下线信息
*
* @author Created by 365 on 2021/3/24.
*/
@Service
(
"getOnlineLog"
)
public
class
GetOnlineLogImpl
implements
IGetOnlineLog
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GetNewUserInfoImpl
.
class
);
@Autowired
private
UserMapper
userMapper
;
@Autowired
private
OnlineLogMapper
logMapper
;
/**
* 分时间段返回用户上下线信息
*
* @param parameter 服务输入,不包含服务配置和控制信息
* @return
* @throws ServiceRunException
*/
@Override
public
Object
exectue
(
Parameter
parameter
)
throws
ServiceRunException
{
Map
<
String
,
Object
>
map
=
parameter
.
getArgs
();
House365RestResponse
<
Map
<
String
,
Object
>>
response
=
new
House365RestResponse
<>();
// 业务层统一处理
try
{
House365RestObject
<
Map
<
String
,
Object
>>
data
=
new
House365RestObject
<>();
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
String
time
=
getMapValueByKey
(
"time"
,
map
,
""
);
String
city
=
getMapValueByKey
(
"city"
,
map
,
""
);
if
(
StringUtils
.
isBlank
(
time
)
||
StringUtils
.
isBlank
(
city
))
{
response
.
setResult
(
ReturnAppResult
.
APP_FAIL
.
getResultCode
());
response
.
setMsg
(
"接口参数不全"
);
return
JSONObject
.
fromObject
(
response
).
toString
();
}
Map
<
String
,
Object
>
queryMap
=
new
HashMap
<>(
5
);
//测试临时新加部门,上线需要调整
// queryMap.put("deptId", 568);
queryMap
.
put
(
"deptId"
,
557
);
List
<
UserEntity
>
userList
=
userMapper
.
queryByConditions
(
queryMap
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
String
patten
=
DateTimeUtils
.
DEFAULT_DATE_FORMAT_PATTERN_FULL
;
userList
.
forEach
(
u
->
{
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>(
5
);
Map
<
String
,
Object
>
searchMap
=
new
HashMap
<>(
10
);
String
startTime
=
time
+
" 00:00:00"
;
String
endTime
=
time
+
" 23:59:59"
;
searchMap
.
put
(
"startTime"
,
startTime
);
searchMap
.
put
(
"endTime"
,
endTime
);
// searchMap.put("order", 1);
searchMap
.
put
(
"userId"
,
u
.
getId
());
List
<
OnlineLogEntity
>
logList
=
logMapper
.
queryByConditions
(
searchMap
);
if
(
CollectionUtils
.
isNotEmpty
(
logList
))
{
int
size
=
logList
.
size
();
int
size1
=
size
/
2
;
if
(
size1
>=
1
)
{
dataMap
.
put
(
"userId"
,
u
.
getId
());
StringBuilder
builder
=
new
StringBuilder
();
if
(
logList
.
get
(
0
).
getNewStatus
()
==
1
)
{
for
(
int
i
=
0
;
i
<=
size1
;
i
++)
{
if
(
2
*
(
i
+
1
)
<=
size
)
{
builder
.
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
).
getCreateTime
(),
patten
)).
append
(
"-"
).
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
+
1
).
getCreateTime
(),
patten
)).
append
(
","
);
}
else
{
if
(
2
*
i
!=
size
)
{
builder
.
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
).
getCreateTime
(),
patten
)).
append
(
"-"
).
append
(
endTime
);
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<=
size1
;
i
++)
{
if
(
2
*
(
i
+
1
)
<=
size
)
{
builder
.
append
(
startTime
).
append
(
"-"
).
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
).
getCreateTime
(),
patten
)).
append
(
","
);
}
else
{
String
timeEnd
;
if
(
2
*
i
==
size
)
{
timeEnd
=
endTime
;
}
else
{
timeEnd
=
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
).
getCreateTime
(),
patten
);
}
builder
.
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
2
*
i
-
1
).
getCreateTime
(),
patten
)).
append
(
"-"
).
append
(
timeEnd
);
}
}
}
dataMap
.
put
(
"time"
,
builder
.
toString
());
list
.
add
(
dataMap
);
}
else
{
dataMap
.
put
(
"userId"
,
u
.
getId
());
StringBuilder
builder
=
new
StringBuilder
();
if
(
logList
.
get
(
0
).
getNewStatus
()
==
1
)
{
builder
.
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
0
).
getCreateTime
(),
patten
)).
append
(
"-"
).
append
(
endTime
);
}
else
{
builder
.
append
(
startTime
).
append
(
"-"
).
append
(
DateTimeUtils
.
getDateString
(
logList
.
get
(
0
).
getCreateTime
(),
patten
));
}
dataMap
.
put
(
"time"
,
builder
.
toString
());
list
.
add
(
dataMap
);
}
}
else
{
//判断用户在线
if
(
u
.
getOnlineStatus
()
==
1
)
{
dataMap
.
put
(
"userId"
,
u
.
getId
());
String
timePeriod
=
startTime
+
"-"
+
endTime
;
dataMap
.
put
(
"time"
,
timePeriod
);
list
.
add
(
dataMap
);
}
else
{
//往前推一个月查询
}
}
});
}
data
.
setList
(
list
);
response
.
setResult
(
"200"
);
response
.
setMsg
(
"查询成功"
);
response
.
setData
(
data
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"查询用户上下线时间段失败"
,
e
);
response
.
setResult
(
ReturnAppResult
.
APP_FAIL
.
getResultCode
());
response
.
setMsg
((
ReturnAppResult
.
APP_FAIL
.
getResultMessage
()
+
":"
+
e
.
getMessage
()));
}
String
result
=
JSONObject
.
fromObject
(
response
).
toString
();
return
result
;
}
private
String
getMapValueByKey
(
String
key
,
Map
<
String
,
Object
>
map
,
String
defaultValue
)
{
String
value
=
""
;
if
(
map
.
containsKey
(
key
)
&&
map
.
get
(
key
)
!=
null
&&
!
Strings
.
isNullOrEmpty
(((
String
[])
map
.
get
(
key
))[
0
]))
{
value
=
((
String
[])
map
.
get
(
key
))[
0
];
}
if
(
Strings
.
isNullOrEmpty
(
value
))
{
value
=
defaultValue
;
}
return
value
;
}
@Override
public
boolean
isControlService
()
{
return
false
;
}
@Override
public
boolean
isLogService
()
{
return
false
;
}
@Override
public
boolean
isMonitorService
()
{
return
false
;
}
@Override
public
Object
rollback
()
{
return
null
;
}
@Override
public
void
commit
()
{
}
}
house365-hgs-ws/src/main/resources/development/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -388,4 +388,9 @@
...
@@ -388,4 +388,9 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws/src/main/resources/development/mybatis/OnlineLogMapper.xml
View file @
4f512d78
...
@@ -18,4 +18,25 @@
...
@@ -18,4 +18,25 @@
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
</insert>
</insert>
<select
id=
"queryByConditions"
resultMap=
"infoMap"
parameterType=
"map"
>
SELECT *
FROM online_log
where old_status != new_status
<if
test=
"userId != null and userId >= 0 "
>
AND user_id = #{userId}
</if>
<if
test=
"oldStatus != null and oldStatus >= 0 "
>
AND old_status = #{oldStatus}
</if>
<if
test=
"newStatus != null and newStatus >= 0 "
>
AND new_status = #{newStatus}
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if
test=
"order != null and order > 0 "
>
ORDER BY id desc
</if>
</select>
</mapper>
</mapper>
\ No newline at end of file
house365-hgs-ws/src/main/resources/production/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -381,4 +381,9 @@
...
@@ -381,4 +381,9 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws/src/main/resources/production/mybatis/OnlineLogMapper.xml
View file @
4f512d78
...
@@ -18,4 +18,25 @@
...
@@ -18,4 +18,25 @@
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
</insert>
</insert>
<select
id=
"queryByConditions"
resultMap=
"infoMap"
parameterType=
"map"
>
SELECT *
FROM online_log
where old_status != new_status
<if
test=
"userId != null and userId >= 0 "
>
AND user_id = #{userId}
</if>
<if
test=
"oldStatus != null and oldStatus >= 0 "
>
AND old_status = #{oldStatus}
</if>
<if
test=
"newStatus != null and newStatus >= 0 "
>
AND new_status = #{newStatus}
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if
test=
"order != null and order > 0 "
>
ORDER BY id desc
</if>
</select>
</mapper>
</mapper>
\ No newline at end of file
house365-hgs-ws/src/main/resources/test/application/applicationContext-dubbo.xml
View file @
4f512d78
...
@@ -390,4 +390,9 @@
...
@@ -390,4 +390,9 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--获取用户上下线时间段信息接口-->
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws/src/main/resources/test/mybatis/OnlineLogMapper.xml
View file @
4f512d78
...
@@ -18,4 +18,25 @@
...
@@ -18,4 +18,25 @@
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
( #{oldStatus},#{newStatus},#{userId},#{createTime} )
</insert>
</insert>
<select
id=
"queryByConditions"
resultMap=
"infoMap"
parameterType=
"map"
>
SELECT *
FROM online_log
where old_status != new_status
<if
test=
"userId != null and userId >= 0 "
>
AND user_id = #{userId}
</if>
<if
test=
"oldStatus != null and oldStatus >= 0 "
>
AND old_status = #{oldStatus}
</if>
<if
test=
"newStatus != null and newStatus >= 0 "
>
AND new_status = #{newStatus}
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if
test=
"order != null and order > 0 "
>
ORDER BY id desc
</if>
</select>
</mapper>
</mapper>
\ No newline at end of file
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