Group Timer
This commit is contained in:
@@ -48,6 +48,11 @@ public class Groups extends JpaBaseDomain implements Serializable {
|
||||
|
||||
@Column
|
||||
String orgIdsList;
|
||||
@Column
|
||||
String resumeTime;
|
||||
|
||||
@Column
|
||||
String suspendTime;
|
||||
|
||||
@Column
|
||||
int isdefault;
|
||||
@@ -181,6 +186,22 @@ public class Groups extends JpaBaseDomain implements Serializable {
|
||||
this.orgIdsList = orgIdsList;
|
||||
}
|
||||
|
||||
public String getResumeTime() {
|
||||
return resumeTime;
|
||||
}
|
||||
|
||||
public void setResumeTime(String resumeTime) {
|
||||
this.resumeTime = resumeTime;
|
||||
}
|
||||
|
||||
public String getSuspendTime() {
|
||||
return suspendTime;
|
||||
}
|
||||
|
||||
public void setSuspendTime(String suspendTime) {
|
||||
this.suspendTime = suspendTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -194,6 +215,10 @@ public class Groups extends JpaBaseDomain implements Serializable {
|
||||
builder.append(filters);
|
||||
builder.append(", orgIdsList=");
|
||||
builder.append(orgIdsList);
|
||||
builder.append(", resumeTime=");
|
||||
builder.append(resumeTime);
|
||||
builder.append(", suspendTime=");
|
||||
builder.append(suspendTime);
|
||||
builder.append(", isdefault=");
|
||||
builder.append(isdefault);
|
||||
builder.append(", description=");
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.maxkey.persistence.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
@@ -62,6 +64,25 @@ public class GroupsService extends JpaBaseService<Groups>{
|
||||
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getDynamic().equals("1")) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
boolean isBetweenEffectiveTime = false;
|
||||
if(dynamicGroup.getResumeTime()!=null&&dynamicGroup.getResumeTime().equals("")
|
||||
&&dynamicGroup.getSuspendTime()!=null&&dynamicGroup.getSuspendTime().equals("")) {
|
||||
LocalTime currentTime = LocalDateTime.now().toLocalTime();
|
||||
LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
|
||||
LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
|
||||
|
||||
_logger.info("currentTime: " + currentTime
|
||||
+ " , resumeTime : " + resumeTime
|
||||
+ " , suspendTime: " + suspendTime);
|
||||
isDynamicTimeSupport = true;
|
||||
|
||||
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
|
||||
isBetweenEffectiveTime = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(dynamicGroup.getOrgIdsList()!=null && !dynamicGroup.getOrgIdsList().equals("")) {
|
||||
dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
|
||||
}
|
||||
@@ -76,8 +97,17 @@ public class GroupsService extends JpaBaseService<Groups>{
|
||||
|
||||
dynamicGroup.setFilters(filters);
|
||||
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
if(isDynamicTimeSupport) {
|
||||
if(isBetweenEffectiveTime) {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}else {
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}else{
|
||||
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
|
||||
groupMemberService.addDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.jobs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.jobs;
|
||||
|
||||
public class DynamicRolesJob {
|
||||
|
||||
@@ -416,6 +416,8 @@ group.name=\u7528\u6237\u7ec4
|
||||
group.dynamic=\u52a8\u6001\u7ec4
|
||||
group.filters=\u8fc7\u6ee4\u5668
|
||||
group.orgidslist=\u673a\u6784\u5217\u8868
|
||||
group.resumeTime=\u52a8\u6001\u65f6\u95f4
|
||||
group.suspendTime=\u6302\u8d77\u65f6\u95f4
|
||||
|
||||
#role
|
||||
role.id=\u89d2\u8272\u7f16\u7801
|
||||
|
||||
@@ -415,6 +415,8 @@ group.name=name
|
||||
group.dynamic=dynamic
|
||||
group.filters=filters
|
||||
group.orgidslist=orgIdsList
|
||||
group.resumeTime=resumeTime
|
||||
group.suspendTime=suspendTime
|
||||
|
||||
#role
|
||||
role.id=id
|
||||
|
||||
@@ -417,6 +417,8 @@ group.name=\u7528\u6237\u7ec4
|
||||
group.dynamic=\u52a8\u6001\u7ec4
|
||||
group.filters=\u8fc7\u6ee4\u5668
|
||||
group.orgidslist=\u673a\u6784\u5217\u8868
|
||||
group.resumeTime=\u52a8\u6001\u65f6\u95f4
|
||||
group.suspendTime=\u6302\u8d77\u65f6\u95f4
|
||||
|
||||
#role
|
||||
role.id=\u89d2\u8272\u7f16\u7801
|
||||
|
||||
@@ -184,6 +184,18 @@ function showOrgsTree() {
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.resumeTime" />:</th>
|
||||
<td nowrap>
|
||||
<input type="text" id="resumeTime" name="resumeTime" class="form-control timepicker" title="" value="" required="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.suspendTime" />:</th>
|
||||
<td nowrap>
|
||||
<input type="text" id="suspendTime" name="suspendTime" class="form-control timepicker" title="" value="" required="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.orgidslist" />:</th>
|
||||
<td nowrap>
|
||||
@@ -194,13 +206,13 @@ function showOrgsTree() {
|
||||
<tr>
|
||||
<th><@locale code="group.filters" />:</th>
|
||||
<td nowrap>
|
||||
<textarea id="filters" name="filters" class="form-control" rows="7" cols="20"></textarea>
|
||||
<textarea id="filters" name="filters" class="form-control" rows="6" cols="20"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="common.text.description" />:</th>
|
||||
<td nowrap>
|
||||
<textarea id="description" name="description" class="form-control" rows="6" cols="20"></textarea>
|
||||
<textarea id="description" name="description" class="form-control" rows="4" cols="20"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -198,6 +198,18 @@ function showOrgsTree() {
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.resumeTime" />:</th>
|
||||
<td nowrap>
|
||||
<input type="text" id="resumeTime" name="resumeTime" class="form-control timepicker" title="" value="${model.resumeTime!}" required="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.suspendTime" />:</th>
|
||||
<td nowrap>
|
||||
<input type="text" id="suspendTime" name="suspendTime" class="form-control timepicker" title="" value="${model.suspendTime!}" required="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="group.orgidslist" />:</th>
|
||||
<td nowrap>
|
||||
@@ -208,13 +220,13 @@ function showOrgsTree() {
|
||||
<tr>
|
||||
<th><@locale code="group.filters" />:</th>
|
||||
<td nowrap>
|
||||
<textarea id="filters" name="filters" class="form-control" rows="7" cols="20">${model.filters!}</textarea>
|
||||
<textarea id="filters" name="filters" class="form-control" rows="6" cols="20">${model.filters!}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><@locale code="common.text.description" />:</th>
|
||||
<td nowrap>
|
||||
<textarea id="description" name="description" class="form-control" rows="6" cols="20">${model.description!}</textarea>
|
||||
<textarea id="description" name="description" class="form-control" rows="4" cols="20">${model.description!}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user