|
|
@ -9,6 +9,7 @@ import com.hivekion.Global;
|
|
|
|
import com.hivekion.common.entity.ResponseCmdInfo;
|
|
|
|
import com.hivekion.common.entity.ResponseCmdInfo;
|
|
|
|
import com.hivekion.common.redis.RedisUtil;
|
|
|
|
import com.hivekion.common.redis.RedisUtil;
|
|
|
|
import com.hivekion.common.uuid.IdUtils;
|
|
|
|
import com.hivekion.common.uuid.IdUtils;
|
|
|
|
|
|
|
|
import com.hivekion.room.RoomManager;
|
|
|
|
import com.hivekion.scenario.entity.BattleConsume;
|
|
|
|
import com.hivekion.scenario.entity.BattleConsume;
|
|
|
|
import com.hivekion.scenario.entity.ScenarioTask;
|
|
|
|
import com.hivekion.scenario.entity.ScenarioTask;
|
|
|
|
import com.hivekion.scenario.service.IBattleConsumeService;
|
|
|
|
import com.hivekion.scenario.service.IBattleConsumeService;
|
|
|
@ -49,10 +50,10 @@ public class BattleRootTask extends AbtParentTask {
|
|
|
|
private IBattleConsumeService battleConsumeService;
|
|
|
|
private IBattleConsumeService battleConsumeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Double FOOD_SPREED = 2.3D;
|
|
|
|
private static final Double FOOD_SPREED = 0.3D;
|
|
|
|
private static final Double WATER_SPREED = 3.6D;
|
|
|
|
private static final Double WATER_SPREED = 0.1D;
|
|
|
|
private static final Double FUEL_SPREED = 3.6D;
|
|
|
|
// private static final Double FUEL_SPREED = 3.6D;
|
|
|
|
private static final Double MEDICAL_SPREED = 1.6D;
|
|
|
|
private static final Double MEDICAL_SPREED = 0.2D;
|
|
|
|
|
|
|
|
|
|
|
|
private final AtomicBoolean isAlreadyProduceTask = new AtomicBoolean(false);
|
|
|
|
private final AtomicBoolean isAlreadyProduceTask = new AtomicBoolean(false);
|
|
|
|
|
|
|
|
|
|
|
@ -82,19 +83,7 @@ public class BattleRootTask extends AbtParentTask {
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime",String.valueOf(initDuringTime));
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime",String.valueOf(initDuringTime));
|
|
|
|
String jsonStr = (String)redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
|
|
|
String jsonStr = (String)redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
|
|
|
ScenarioInfo scenarioInfo =JSONObject.parseObject(jsonStr,ScenarioInfo.class);
|
|
|
|
ScenarioInfo scenarioInfo =JSONObject.parseObject(jsonStr,ScenarioInfo.class);
|
|
|
|
HashMap<String,Object> battleParams = new HashMap<>();
|
|
|
|
|
|
|
|
//初始化本次战斗任务各种资源数
|
|
|
|
|
|
|
|
battleParams.put("ammunition",Double.valueOf(scenarioInfo.getAmmunition().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("food",Double.valueOf(scenarioInfo.getFood().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("fuel",Double.valueOf(scenarioInfo.getFuel().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("medical",Double.valueOf(scenarioInfo.getMedical().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("water",Double.valueOf(scenarioInfo.getWater().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("person",Integer.valueOf(scenarioInfo.getPerson().getTotal()).toString());
|
|
|
|
|
|
|
|
battleParams.put("death",Integer.valueOf(scenarioInfo.getPerson().getDeath()).toString());
|
|
|
|
|
|
|
|
battleParams.put("injured",Integer.valueOf(scenarioInfo.getPerson().getInjured()).toString());
|
|
|
|
|
|
|
|
battleParams.put("teamLat",scenarioInfo.getTeam().getLat().toString());
|
|
|
|
|
|
|
|
battleParams.put("teamLng",scenarioInfo.getTeam().getLng().toString());
|
|
|
|
|
|
|
|
battleParams.put("duringTime",Long.valueOf(initDuringTime).toString());
|
|
|
|
|
|
|
|
log.info("===============================初始化本次战斗任务各种资源数====================================");
|
|
|
|
log.info("===============================初始化本次战斗任务各种资源数====================================");
|
|
|
|
double suppleAmount =scenarioInfo.getAmmunition().getTotal();
|
|
|
|
double suppleAmount =scenarioInfo.getAmmunition().getTotal();
|
|
|
|
int suppleDeath =scenarioInfo.getPerson().getDeath();
|
|
|
|
int suppleDeath =scenarioInfo.getPerson().getDeath();
|
|
|
@ -113,185 +102,208 @@ public class BattleRootTask extends AbtParentTask {
|
|
|
|
Double ammunitionConsume = null;
|
|
|
|
Double ammunitionConsume = null;
|
|
|
|
Double foodConsume = null;
|
|
|
|
Double foodConsume = null;
|
|
|
|
Double waterConsume = null;
|
|
|
|
Double waterConsume = null;
|
|
|
|
Double fuelConsume = null;
|
|
|
|
// Double fuelConsume = null;
|
|
|
|
Double medicalConsume = null;
|
|
|
|
Double medicalConsume = null;
|
|
|
|
String teamLat = null;
|
|
|
|
String teamLat = null;
|
|
|
|
String teamLng = null;
|
|
|
|
String teamLng = null;
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
String jsonStr = (String)redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
|
|
|
|
|
|
|
ScenarioInfo scenarioInfoOnTime =JSONObject.parseObject(jsonStr,ScenarioInfo.class);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
long duringTime = getDuringTime();
|
|
|
|
long duringTime = getDuringTime();
|
|
|
|
long lastDuringTime = Long.valueOf(redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime").toString());
|
|
|
|
long lastDuringTime = Long.valueOf(redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime").toString());
|
|
|
|
long intervalDuringTime = duringTime - lastDuringTime;
|
|
|
|
long intervalDuringTime = duringTime - lastDuringTime;
|
|
|
|
double ammunition = Double.valueOf(battleParams.get("ammunition").toString());
|
|
|
|
double ammunition = Double.valueOf(scenarioInfoOnTime.getAmmunition().getCurrent());
|
|
|
|
double food = Double.valueOf(battleParams.get("food").toString());
|
|
|
|
double food = Double.valueOf(scenarioInfoOnTime.getFood().getCurrent());
|
|
|
|
double fuel = Double.valueOf(battleParams.get("fuel").toString());
|
|
|
|
double medical = Double.valueOf(scenarioInfoOnTime.getMedical().getCurrent());
|
|
|
|
double medical = Double.valueOf(battleParams.get("medical").toString());
|
|
|
|
double water = Double.valueOf(scenarioInfoOnTime.getWater().getCurrent());
|
|
|
|
double water = Double.valueOf(battleParams.get("water").toString());
|
|
|
|
long death = Long.valueOf(scenarioInfoOnTime.getPerson().getDeath());
|
|
|
|
long death = Long.valueOf(battleParams.get("death").toString());
|
|
|
|
long injured = Long.valueOf(scenarioInfoOnTime.getPerson().getInjured());
|
|
|
|
long injured = Long.valueOf(battleParams.get("injured").toString());
|
|
|
|
teamLat = scenarioInfoOnTime.getTeam().getLat().toString();
|
|
|
|
teamLat = battleParams.get( "teamLat").toString();
|
|
|
|
teamLng = scenarioInfoOnTime.getTeam().getLng().toString();
|
|
|
|
teamLng = battleParams.get( "teamLng").toString();
|
|
|
|
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
deathConsume = RandomUtil.getSecureRandom().nextInt(3) * intervalDuringTime;
|
|
|
|
deathConsume = RandomUtil.getSecureRandom().nextInt(2) * intervalDuringTime* RoomManager.getMag(roomId);
|
|
|
|
injuredConsume = RandomUtil.getSecureRandom().nextInt(6) * intervalDuringTime;
|
|
|
|
injuredConsume = RandomUtil.getSecureRandom().nextInt(3) * intervalDuringTime* RoomManager.getMag(roomId);
|
|
|
|
ammunitionConsume = intervalDuringTime * (1D+RandomUtil.getSecureRandom().nextDouble());
|
|
|
|
ammunitionConsume = intervalDuringTime * (0.1D + RandomUtil.getSecureRandom().nextDouble())* RoomManager.getMag(roomId);
|
|
|
|
foodConsume = intervalDuringTime * FOOD_SPREED;
|
|
|
|
foodConsume = intervalDuringTime * FOOD_SPREED* RoomManager.getMag(roomId);
|
|
|
|
waterConsume = intervalDuringTime * WATER_SPREED;
|
|
|
|
waterConsume = intervalDuringTime * WATER_SPREED* RoomManager.getMag(roomId);
|
|
|
|
fuelConsume = intervalDuringTime * FUEL_SPREED;
|
|
|
|
|
|
|
|
medicalConsume = intervalDuringTime * MEDICAL_SPREED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
battleParams.put("ammunition",Double.valueOf(ammunition - ammunitionConsume).toString());
|
|
|
|
medicalConsume = intervalDuringTime * MEDICAL_SPREED* RoomManager.getMag(roomId);
|
|
|
|
battleParams.put("food",Double.valueOf(food - foodConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("fuel",Double.valueOf(fuel - fuelConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("medical",Double.valueOf(medical - medicalConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("water",Double.valueOf(water - waterConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("death",Long.valueOf(death+deathConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("injured",Long.valueOf(injured +injuredConsume).toString());
|
|
|
|
|
|
|
|
battleParams.put("duringTime",Long.valueOf(duringTime).toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scenarioInfo.getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
|
|
|
|
|
|
|
scenarioInfo.getFood().setCurrent(Double.valueOf(food - foodConsume));
|
|
|
|
|
|
|
|
scenarioInfo.getFuel().setCurrent(Double.valueOf(fuel - fuelConsume));
|
|
|
|
|
|
|
|
scenarioInfo.getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
|
|
|
|
|
|
|
scenarioInfo.getWater().setCurrent(Double.valueOf(water - waterConsume));
|
|
|
|
|
|
|
|
scenarioInfo.getPerson().setDeath(Long.valueOf(death+deathConsume).intValue());
|
|
|
|
|
|
|
|
scenarioInfo.getPerson().setInjured(Long.valueOf(injured +injuredConsume).intValue());
|
|
|
|
|
|
|
|
scenarioInfo.getPerson().setCurrent(scenarioInfo.getPerson().getCurrent()-Long.valueOf(death+deathConsume).intValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String updJsonStr= (String) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"updScenarioInfo");
|
|
|
|
if(scenarioInfoOnTime.getAmmunition().getCurrent() >0) {
|
|
|
|
EditScenarioInfo updScenarioInfo = JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
|
|
|
scenarioInfoOnTime.getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
|
|
|
updScenarioInfo.getJbxx().getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
|
|
|
}
|
|
|
|
updScenarioInfo.getJbxx().getFood().setCurrent(Double.valueOf(food - foodConsume));
|
|
|
|
if(scenarioInfoOnTime.getFood().getCurrent() > 0) {
|
|
|
|
updScenarioInfo.getJbxx().getFuel().setCurrent(Double.valueOf(fuel - fuelConsume));
|
|
|
|
scenarioInfoOnTime.getFood().setCurrent(Double.valueOf(food - foodConsume));
|
|
|
|
updScenarioInfo.getJbxx().getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
|
|
|
}
|
|
|
|
updScenarioInfo.getJbxx().getWater().setCurrent(Double.valueOf(water - waterConsume));
|
|
|
|
if(scenarioInfoOnTime.getMedical().getCurrent() > 0) {
|
|
|
|
updScenarioInfo.getJbxx().getPerson().setDeath(Long.valueOf(death+deathConsume).intValue());
|
|
|
|
scenarioInfoOnTime.getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
|
|
|
updScenarioInfo.getJbxx().getPerson().setInjured(Long.valueOf(injured +injuredConsume).intValue());
|
|
|
|
}
|
|
|
|
updScenarioInfo.getJbxx().getPerson().setCurrent(updScenarioInfo.getJbxx().getPerson().getCurrent()-Long.valueOf(death+deathConsume).intValue());
|
|
|
|
if(scenarioInfoOnTime.getWater().getCurrent() > 0) {
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
|
|
|
scenarioInfoOnTime.getWater().setCurrent(Double.valueOf(water - waterConsume));
|
|
|
|
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
|
|
|
}
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
scenarioInfoOnTime.getPerson().setDeath(Long.valueOf(death + deathConsume).intValue());
|
|
|
|
respObj.setData(JSON.toJSONString(updScenarioInfo));
|
|
|
|
scenarioInfoOnTime.getPerson().setInjured(Long.valueOf(injured + injuredConsume).intValue());
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
scenarioInfoOnTime.getPerson().setCurrent(scenarioInfo.getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue());
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
|
|
|
|
respObj.setCmdType("updScenarioInfo");
|
|
|
|
String updJsonStr = (String) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "updScenarioInfo");
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
EditScenarioInfo updScenarioInfo = JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime",String.valueOf(duringTime));
|
|
|
|
if(updScenarioInfo.getJbxx().getAmmunition().getCurrent() >0) {
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "scenarioInfo",JSONObject.toJSONString(scenarioInfo));
|
|
|
|
updScenarioInfo.getJbxx().getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(updScenarioInfo.getJbxx().getFood().getCurrent() > 0) {
|
|
|
|
|
|
|
|
updScenarioInfo.getJbxx().getFood().setCurrent(Double.valueOf(food - foodConsume));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// updScenarioInfo.getJbxx().getFuel().setCurrent(Double.valueOf(fuel - fuelConsume));
|
|
|
|
|
|
|
|
if(updScenarioInfo.getJbxx().getMedical().getCurrent() > 0) {
|
|
|
|
|
|
|
|
updScenarioInfo.getJbxx().getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(updScenarioInfo.getJbxx().getWater().getCurrent() > 0) {
|
|
|
|
|
|
|
|
updScenarioInfo.getJbxx().getWater().setCurrent(Double.valueOf(water - waterConsume));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
|
|
|
|
|
|
|
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
|
|
|
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
|
|
|
|
respObj.setData(JSON.toJSONString(updScenarioInfo));
|
|
|
|
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
|
|
|
|
respObj.setCmdType("updScenarioInfo");
|
|
|
|
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "duringTime", String.valueOf(duringTime));
|
|
|
|
|
|
|
|
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "scenarioInfo", JSONObject.toJSONString(scenarioInfoOnTime));
|
|
|
|
|
|
|
|
}
|
|
|
|
}catch (Exception ex){
|
|
|
|
}catch (Exception ex){
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
log.error("==============================设置消耗信息失败=============================================",ex.getMessage());
|
|
|
|
log.error("==============================设置消耗信息失败=============================================",ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//推送消耗數據
|
|
|
|
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
|
|
|
ResponseCmdInfo<String> sendConsumeMsg = new ResponseCmdInfo<>();
|
|
|
|
//推送消耗數據
|
|
|
|
jsonObject.put("deathConsume", deathConsume);
|
|
|
|
String battleConsumeStr = "";
|
|
|
|
jsonObject.put("injuredConsume", injuredConsume);
|
|
|
|
ResponseCmdInfo<String> sendConsumeMsg = new ResponseCmdInfo<>();
|
|
|
|
jsonObject.put("ammunitionConsume", ammunitionConsume);
|
|
|
|
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
jsonObject.put("foodConsume", foodConsume);
|
|
|
|
battleConsumeStr += currentDateTime.toString() + " 战斗消耗 [";
|
|
|
|
jsonObject.put("waterConsume", waterConsume);
|
|
|
|
battleConsumeStr += "死亡人数:" + deathConsume;
|
|
|
|
jsonObject.put("fuelConsume", fuelConsume);
|
|
|
|
battleConsumeStr += "受伤人数:" + injuredConsume;
|
|
|
|
jsonObject.put("medicalConsume", medicalConsume);
|
|
|
|
battleConsumeStr += "弹药消耗:" + ammunitionConsume;
|
|
|
|
jsonObject.put("teamLat",teamLat);
|
|
|
|
battleConsumeStr += "食品消耗:" + foodConsume;
|
|
|
|
jsonObject.put("teamLng",teamLng);
|
|
|
|
battleConsumeStr += "用水消耗:" + waterConsume;
|
|
|
|
jsonObject.put("resourceId",scenarioTask.getResourceId());
|
|
|
|
battleConsumeStr += "药材消耗:" + medicalConsume + "]";
|
|
|
|
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
jsonObject.put("teamLat",teamLat);
|
|
|
|
jsonObject.put("consumeDate",currentDateTime);
|
|
|
|
jsonObject.put("teamLng",teamLng);
|
|
|
|
sendConsumeMsg.setData(jsonObject.toString());
|
|
|
|
jsonObject.put("resourceId", scenarioTask.getResourceId());
|
|
|
|
sendConsumeMsg.setRoom(roomId);
|
|
|
|
|
|
|
|
sendConsumeMsg.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
|
|
|
|
sendConsumeMsg.setCmdType("battleConsume");
|
|
|
|
|
|
|
|
Global.sendCmdInfoQueue.add(sendConsumeMsg);
|
|
|
|
|
|
|
|
BattleConsume battleConsume = new BattleConsume();
|
|
|
|
|
|
|
|
battleConsume.setLat(teamLat);
|
|
|
|
|
|
|
|
battleConsume.setLng(teamLng);
|
|
|
|
|
|
|
|
battleConsume.setId(IdUtils.simpleUUID());
|
|
|
|
|
|
|
|
battleConsume.setAmmunition(ammunitionConsume);
|
|
|
|
|
|
|
|
battleConsume.setDeath(Integer.valueOf(Double.valueOf(deathConsume).intValue()));
|
|
|
|
|
|
|
|
battleConsume.setInjured(Integer.valueOf(Double.valueOf(injuredConsume).intValue()));
|
|
|
|
|
|
|
|
battleConsume.setFood(foodConsume);
|
|
|
|
|
|
|
|
battleConsume.setFuel(fuelConsume);
|
|
|
|
|
|
|
|
battleConsume.setMedical(medicalConsume);
|
|
|
|
|
|
|
|
battleConsume.setWater(waterConsume);
|
|
|
|
|
|
|
|
battleConsume.setResourceId(scenarioTask.getResourceId());
|
|
|
|
|
|
|
|
battleConsume.setConsumeDate(currentDateTime);
|
|
|
|
|
|
|
|
battleConsumeService.save(battleConsume);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonObject.put("消耗时间", currentDateTime);
|
|
|
|
|
|
|
|
jsonObject.put("日志类型", "战斗消耗");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendConsumeMsg.setData(battleConsumeStr);
|
|
|
|
|
|
|
|
sendConsumeMsg.setRoom(roomId);
|
|
|
|
|
|
|
|
sendConsumeMsg.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
|
|
|
|
sendConsumeMsg.setCmdType("battleConsume");
|
|
|
|
|
|
|
|
Global.sendCmdInfoQueue.add(sendConsumeMsg);
|
|
|
|
|
|
|
|
BattleConsume battleConsume = new BattleConsume();
|
|
|
|
|
|
|
|
battleConsume.setLat(teamLat);
|
|
|
|
|
|
|
|
battleConsume.setLng(teamLng);
|
|
|
|
|
|
|
|
battleConsume.setId(IdUtils.simpleUUID());
|
|
|
|
|
|
|
|
battleConsume.setAmmunition(ammunitionConsume);
|
|
|
|
|
|
|
|
battleConsume.setDeath(Integer.valueOf(Double.valueOf(deathConsume).intValue()));
|
|
|
|
|
|
|
|
battleConsume.setInjured(Integer.valueOf(Double.valueOf(injuredConsume).intValue()));
|
|
|
|
|
|
|
|
battleConsume.setFood(foodConsume);
|
|
|
|
|
|
|
|
// battleConsume.setFuel(fuelConsume);
|
|
|
|
|
|
|
|
battleConsume.setMedical(medicalConsume);
|
|
|
|
|
|
|
|
battleConsume.setWater(waterConsume);
|
|
|
|
|
|
|
|
battleConsume.setResourceId(scenarioTask.getResourceId());
|
|
|
|
|
|
|
|
battleConsume.setConsumeDate(currentDateTime);
|
|
|
|
|
|
|
|
battleConsumeService.save(battleConsume);
|
|
|
|
|
|
|
|
if (injuredConsume > 2 && !isAlreadyProduceTask.get()) {
|
|
|
|
|
|
|
|
//产生一个
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}catch (Exception ex){
|
|
|
|
}catch (Exception ex){
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
|
log.error("==================推送消耗數據 失败============================================",ex.getMessage());
|
|
|
|
log.error("==================推送消耗數據 失败============================================",ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
|
|
|
String death = SpringUtil.getBean(Environment.class).getProperty("death.warn");
|
|
|
|
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
String injured = SpringUtil.getBean(Environment.class).getProperty("injured.warn");
|
|
|
|
String death = SpringUtil.getBean(Environment.class).getProperty("death.warn");
|
|
|
|
String ammunition = SpringUtil.getBean(Environment.class).getProperty("ammunition.warn");
|
|
|
|
String injured = SpringUtil.getBean(Environment.class).getProperty("injured.warn");
|
|
|
|
// log.info("===========person ammunition==={}===={}====={}========",death,injured,ammunition);
|
|
|
|
String ammunition = SpringUtil.getBean(Environment.class).getProperty("ammunition.warn");
|
|
|
|
String saveJsonStr= (String) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
|
|
|
log.info("===========person ammunition==={}===={}====={}========", death, injured, ammunition);
|
|
|
|
ScenarioInfo scenarioInfo =JSONObject.parseObject(saveJsonStr,ScenarioInfo.class);
|
|
|
|
|
|
|
|
Double restAmmunition = Double.valueOf(scenarioInfo.getAmmunition().getCurrent());
|
|
|
|
Double restAmmunition = Double.valueOf(scenarioInfoOnTime.getAmmunition().getCurrent());
|
|
|
|
// StatisticBean battleResourceStat = statisticService.statistic(scenarioTask.getResourceId());
|
|
|
|
// StatisticBean battleResourceStat = statisticService.statistic(scenarioTask.getResourceId());
|
|
|
|
Double ammunitionConsumeRate = restAmmunition/scenarioInfo.getAmmunition().getTotal()*100;
|
|
|
|
Double ammunitionConsumeRate = restAmmunition / scenarioInfoOnTime.getAmmunition().getTotal() * 100;
|
|
|
|
if(Double.valueOf(ammunitionConsumeRate) <= Double.valueOf(ammunition) && suppleFlagMap.get("ammunition") == false){
|
|
|
|
if (Double.valueOf(ammunitionConsumeRate) <= Double.valueOf(ammunition) && suppleFlagMap.get("ammunition") == false) {
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleAmount));
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleAmount));
|
|
|
|
supplierRequest.setSupplierType("ammunition");
|
|
|
|
supplierRequest.setSupplierType("ammunition");
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setCmdType("ammunitionRequest");
|
|
|
|
respObj.setCmdType("ammunitionRequest");
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
suppleFlagMap.put("ammunition",true) ;
|
|
|
|
suppleFlagMap.put("ammunition", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Long restDeath = Long.valueOf(scenarioInfo.getPerson().getDeath());
|
|
|
|
Long restDeath = Long.valueOf(scenarioInfo.getPerson().getDeath());
|
|
|
|
Long deathConsumeRate = 0L;
|
|
|
|
Long deathConsumeRate = 0L;
|
|
|
|
if(scenarioInfo.getPerson().getTotal() !=0) {
|
|
|
|
if (scenarioInfo.getPerson().getTotal() != 0) {
|
|
|
|
deathConsumeRate = restDeath * 100 / scenarioInfo.getPerson().getTotal();
|
|
|
|
deathConsumeRate = restDeath * 100 / scenarioInfoOnTime.getPerson().getTotal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(deathConsumeRate >= Long.valueOf(death) && suppleFlagMap.get("death") == false){
|
|
|
|
if (deathConsumeRate >= Long.valueOf(death) && suppleFlagMap.get("death") == false) {
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleDeath));
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleDeath));
|
|
|
|
supplierRequest.setSupplierType("death");
|
|
|
|
supplierRequest.setSupplierType("death");
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setCmdType("deathRequest");
|
|
|
|
respObj.setCmdType("deathRequest");
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
suppleFlagMap.put("death",true) ;
|
|
|
|
suppleFlagMap.put("death", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Long restInjured = Long.valueOf(scenarioInfo.getPerson().getInjured());
|
|
|
|
Long restInjured = Long.valueOf(scenarioInfoOnTime.getPerson().getInjured());
|
|
|
|
Long injuredConsumeRate = restInjured*100/scenarioInfo.getPerson().getTotal();
|
|
|
|
Long injuredConsumeRate = restInjured * 100 / scenarioInfoOnTime.getPerson().getTotal();
|
|
|
|
if(Long.valueOf(injuredConsumeRate) <= Long.valueOf(injured) && suppleFlagMap.get("injured") == false){
|
|
|
|
if (Long.valueOf(injuredConsumeRate) <= Long.valueOf(injured) && suppleFlagMap.get("injured") == false) {
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
SupplierRequest supplierRequest = new SupplierRequest();
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setId(IdUtils.simpleUUID());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleInjured));
|
|
|
|
supplierRequest.setSupplierNum(String.valueOf(suppleInjured));
|
|
|
|
supplierRequest.setSupplierType("injured");
|
|
|
|
supplierRequest.setSupplierType("injured");
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setGeneralTime(currentDateTime);
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
supplierRequestService.save(supplierRequest);
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setData(JSON.toJSONString(supplierRequest));
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setRoom(roomId);
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setScenarioId(scenarioTask.getScenarioId());
|
|
|
|
respObj.setCmdType("injuredRequest");
|
|
|
|
respObj.setCmdType("injuredRequest");
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
Global.sendCmdInfoQueue.add(respObj);
|
|
|
|
suppleFlagMap.put("injured",true) ;
|
|
|
|
suppleFlagMap.put("injured", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception ex){
|
|
|
|
}catch (Exception ex){
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
|