修复功能时间

back_recharge
wangyuan 2019-06-05 20:15:56 +08:00
parent 0e8b6eda1d
commit 7cbe91a672
2 changed files with 18 additions and 13 deletions

View File

@ -92,7 +92,7 @@ public class GlobalDataManaager {
}
Map<Integer, TimeControllerOfFunction> timeControllerOfFunctionMap = globalSystemControl.getTimeControllerOfFunctionMap();
List<Integer> reallyOpenList = new ArrayList<>();
List<Integer> reallyCloseList = new ArrayList<>();
// List<Integer> reallyCloseList = new ArrayList<>();
boolean needUpdate=false;
for(Integer id: openList){
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
@ -110,20 +110,20 @@ public class GlobalDataManaager {
}
for(Integer id: closeList){
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
/* TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
if(timeControllerOfFunction != null && timeControllerOfFunction.getStartTime()!=openTimeOfFuntionCache.get(id).getStartTime()){
needUpdate = true;
globalSystemControl.updateTimeControllerOfFunction(openTimeOfFuntionCache.get(id));
reallyCloseList.add(id);
}
}*/
openTimeOfFuntionCache.remove(id);
}
if(needUpdate){
MongoUtil.getInstence().getMyMongoTemplate().save(globalSystemControl);
openAction(reallyOpenList);
closeAction(reallyCloseList);
}
closeAction(closeList);
updateGetFunctionOfTimeResponse();
}
@ -182,27 +182,25 @@ public class GlobalDataManaager {
long systemEndLong = sGlobalSystemConfig.getSystemEndLong();
long seasonOpenLong = sGlobalSystemConfig.getSeasonOpenLong();
long seasonEndLong = sGlobalSystemConfig.getSeasonEndLong();
int seasonInterval = sGlobalSystemConfig.getSeasonInterval() * 3600;
long timeOpenOfThis =0;
long timeCloseOfThis =0;
int seasonInterval = sGlobalSystemConfig.getSeasonInterval() * 3600*1000;
long timeOpenOfThis =seasonOpenLong;
long timeCloseOfThis =seasonEndLong;
if(seasonInterval == 0){
timeOpenOfThis = systemOpenLong;
timeCloseOfThis = systemEndLong;
}else{
long diffTime = seasonEndLong - seasonOpenLong;
long passTims = now - seasonOpenLong;
if(passTims>0){
long mod = passTims % (diffTime + seasonInterval);
if(mod < diffTime ){//新的周期开启
//计算开启时间、关闭时间
long turns = passTims / ((diffTime + seasonInterval));
long addTim = turns * diffTime;
long addTim = turns * (diffTime + seasonInterval);
timeOpenOfThis =seasonOpenLong+addTim;
timeCloseOfThis =seasonEndLong+addTim;
}
}else{
timeOpenOfThis =seasonOpenLong;
timeCloseOfThis =seasonEndLong;
}
}

View File

@ -157,8 +157,15 @@ public class StringUtil {
public static String parseArrayToString(int[][] source) {
StringBuilder sb = new StringBuilder();
for(int[] item : source){
sb.append(item[0]).append("#").append(item[1]).append("|");
int length = source.length;
int last = length-1;
for(int i=0;i<length;i++){
int[] item = source[i];
if(i==last){
sb.append(item[0]).append("#").append(item[1]);
}else{
sb.append(item[0]).append("#").append(item[1]).append("|");
}
}
return sb.toString();
}