修复功能时间

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

View File

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