修改bug
This commit is contained in:
parent
5105dd13e7
commit
cd76249853
|
@ -28,7 +28,7 @@ public class WeatherResourceServiceImpl extends ServiceImpl<WeatherResourceMappe
|
|||
|
||||
@Override
|
||||
public Long count(WeatherResource ebe) {
|
||||
return this.baseMapper.count(ebe);
|
||||
return this.list(new QueryWrapper<WeatherResource>().eq("scenario_id",ebe.getScenarioId())).stream().count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -143,40 +143,63 @@ public class BattleRootTask extends AbtParentTask {
|
|||
medicalConsume = intervalDuringTime * MEDICAL_SPREED* RoomManager.getMag(roomId);
|
||||
|
||||
|
||||
if(scenarioInfoOnTime.getAmmunition().getCurrent() >0) {
|
||||
if(scenarioInfoOnTime.getAmmunition().getCurrent() - Double.valueOf(ammunition - ammunitionConsume)>0) {
|
||||
scenarioInfoOnTime.getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
||||
}else{
|
||||
scenarioInfoOnTime.getAmmunition().setCurrent(0D);
|
||||
}
|
||||
if(scenarioInfoOnTime.getFood().getCurrent() > 0) {
|
||||
if(scenarioInfoOnTime.getFood().getCurrent() -Double.valueOf(food - foodConsume)> 0) {
|
||||
scenarioInfoOnTime.getFood().setCurrent(Double.valueOf(food - foodConsume));
|
||||
}else{
|
||||
scenarioInfoOnTime.getFood().setCurrent(0D);
|
||||
}
|
||||
if(scenarioInfoOnTime.getMedical().getCurrent() > 0) {
|
||||
if(scenarioInfoOnTime.getMedical().getCurrent() -Double.valueOf(medical - medicalConsume)> 0) {
|
||||
scenarioInfoOnTime.getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
||||
}else{
|
||||
scenarioInfoOnTime.getMedical().setCurrent(0D);
|
||||
}
|
||||
if(scenarioInfoOnTime.getWater().getCurrent() > 0) {
|
||||
if(scenarioInfoOnTime.getWater().getCurrent() - Double.valueOf(water - waterConsume)> 0) {
|
||||
scenarioInfoOnTime.getWater().setCurrent(Double.valueOf(water - waterConsume));
|
||||
}else{
|
||||
scenarioInfoOnTime.getWater().setCurrent(0D);
|
||||
}
|
||||
scenarioInfoOnTime.getPerson().setDeath(Long.valueOf(death + deathConsume).intValue());
|
||||
scenarioInfoOnTime.getPerson().setInjured(Long.valueOf(injured + injuredConsume).intValue());
|
||||
scenarioInfoOnTime.getPerson().setCurrent(scenarioInfoOnTime.getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue());
|
||||
|
||||
if(scenarioInfoOnTime.getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue() <0){
|
||||
scenarioInfoOnTime.getPerson().setCurrent(0);
|
||||
}else {
|
||||
scenarioInfoOnTime.getPerson().setCurrent(scenarioInfoOnTime.getPerson().getCurrent() - Long.valueOf(deathConsume).intValue() - Long.valueOf(injuredConsume).intValue());
|
||||
}
|
||||
String updJsonStr = (String) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "updScenarioInfo");
|
||||
EditScenarioInfo updScenarioInfo = JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
||||
if(updScenarioInfo.getJbxx().getAmmunition().getCurrent() >0) {
|
||||
if(updScenarioInfo.getJbxx().getAmmunition().getCurrent() - Double.valueOf(ammunition - ammunitionConsume)>0) {
|
||||
updScenarioInfo.getJbxx().getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
||||
}else{
|
||||
updScenarioInfo.getJbxx().getAmmunition().setCurrent(0D);
|
||||
}
|
||||
if(updScenarioInfo.getJbxx().getFood().getCurrent() > 0) {
|
||||
if(updScenarioInfo.getJbxx().getFood().getCurrent() - Double.valueOf(food - foodConsume) > 0) {
|
||||
updScenarioInfo.getJbxx().getFood().setCurrent(Double.valueOf(food - foodConsume));
|
||||
}else{
|
||||
updScenarioInfo.getJbxx().getFood().setCurrent(0D);
|
||||
}
|
||||
// updScenarioInfo.getJbxx().getFuel().setCurrent(Double.valueOf(fuel - fuelConsume));
|
||||
if(updScenarioInfo.getJbxx().getMedical().getCurrent() > 0) {
|
||||
if(updScenarioInfo.getJbxx().getMedical().getCurrent() - Double.valueOf(medical - medicalConsume)> 0) {
|
||||
updScenarioInfo.getJbxx().getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
||||
}else{
|
||||
updScenarioInfo.getJbxx().getMedical().setCurrent(0D);
|
||||
}
|
||||
if(updScenarioInfo.getJbxx().getWater().getCurrent() > 0) {
|
||||
if(updScenarioInfo.getJbxx().getWater().getCurrent() -Double.valueOf(water - waterConsume)> 0) {
|
||||
updScenarioInfo.getJbxx().getWater().setCurrent(Double.valueOf(water - waterConsume));
|
||||
}else{
|
||||
updScenarioInfo.getJbxx().getWater().setCurrent(0D);
|
||||
}
|
||||
updScenarioInfo.getJbxx().getPerson().setDeath(Long.valueOf(death + deathConsume).intValue());
|
||||
updScenarioInfo.getJbxx().getPerson().setInjured(Long.valueOf(injured + injuredConsume).intValue());
|
||||
updScenarioInfo.getJbxx().getPerson().setCurrent(updScenarioInfo.getJbxx().getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue());
|
||||
if(updScenarioInfo.getJbxx().getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue() <0){
|
||||
updScenarioInfo.getJbxx().getPerson().setCurrent(0);
|
||||
}else {
|
||||
updScenarioInfo.getJbxx().getPerson().setCurrent(updScenarioInfo.getJbxx().getPerson().getCurrent() - Long.valueOf(deathConsume).intValue() - Long.valueOf(injuredConsume).intValue());
|
||||
}
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
|
|
|
@ -134,8 +134,12 @@ public class Room implements AutoCloseable {
|
|||
log.error("error::", e);
|
||||
}
|
||||
});
|
||||
//清除房间缓存数据
|
||||
this.clearScenarioCache();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
|
@ -233,6 +237,7 @@ public class Room implements AutoCloseable {
|
|||
}
|
||||
|
||||
public void initRoomParam() {
|
||||
long begTime = System.currentTimeMillis();
|
||||
if (scenarioService == null) {
|
||||
scenarioService = SpringUtil.getBean(com.hivekion.statistic.service.ScenarioService.class);
|
||||
}
|
||||
|
@ -257,7 +262,8 @@ public class Room implements AutoCloseable {
|
|||
scenario.getResourceList().forEach(resource -> {
|
||||
scenarioResourceMap.put(resource.getId(), resource);
|
||||
});
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("======cost time============={}===================",endTime-begTime);
|
||||
}
|
||||
|
||||
public void addResourcePath(String resourceId, Object obj) {
|
||||
|
@ -293,4 +299,26 @@ public class Room implements AutoCloseable {
|
|||
respObj.setCmdType("room_info");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
}
|
||||
|
||||
private void clearScenarioCache(){
|
||||
try {
|
||||
scenario.setResourceList(SpringUtil.getBean(ScenarioResourceServiceImpl.class)
|
||||
.getResourceListByScenarioId(scenario.getId()));
|
||||
if (redisUtil == null) {
|
||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||
}
|
||||
for (ScenarioResource scenarioResource : this.scenario.getResourceList()) {
|
||||
ScenarioInfo scenarioInfo = scenarioService.listScenarioInfo(scenarioResource.getScenarioId(),
|
||||
roomId, scenarioResource.getId());
|
||||
EditScenarioInfo updScenarioInfo = scenarioService.listEditScenarioInfo(
|
||||
scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
||||
redisUtil.delete(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
||||
redisUtil.delete(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error("===================clear cached fail==========================");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class WsServer {
|
|||
}
|
||||
|
||||
public static void sendMessage(Integer scenarioId, String room, String message) {
|
||||
log.info("send {},{},{}", message, scenarioId, room);
|
||||
log.info("{},{}", scenarioId, room);
|
||||
|
||||
synchronized (lock) {
|
||||
Map<String, Map<String, Session>> roomMap = SESSION_MAP.get(String.valueOf(scenarioId));
|
||||
|
|
Loading…
Reference in New Issue
Block a user