战斗任务消耗资源代码
This commit is contained in:
parent
d57e9d1948
commit
4409df8984
|
@ -8,7 +8,9 @@ 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.scenario.entity.BattleConsume;
|
||||||
import com.hivekion.scenario.entity.ScenarioTask;
|
import com.hivekion.scenario.entity.ScenarioTask;
|
||||||
|
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||||
import com.hivekion.statistic.bean.*;
|
import com.hivekion.statistic.bean.*;
|
||||||
import com.hivekion.statistic.service.StatisticService;
|
import com.hivekion.statistic.service.StatisticService;
|
||||||
import com.hivekion.statistic.service.impl.StatisticServiceImpl;
|
import com.hivekion.statistic.service.impl.StatisticServiceImpl;
|
||||||
|
@ -18,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -42,6 +45,8 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
|
|
||||||
private ISupplierRequestService supplierRequestService;
|
private ISupplierRequestService supplierRequestService;
|
||||||
|
|
||||||
|
private IBattleConsumeService battleConsumeService;
|
||||||
|
|
||||||
private static final Integer DEATH_SPREED = 3;
|
private static final Integer DEATH_SPREED = 3;
|
||||||
private static final Integer INJURED_SPREED = 3;
|
private static final Integer INJURED_SPREED = 3;
|
||||||
private static final Double AMMUNITION_SPREED = 2.6D;
|
private static final Double AMMUNITION_SPREED = 2.6D;
|
||||||
|
@ -66,6 +71,9 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
if(supplierRequestService == null){
|
if(supplierRequestService == null){
|
||||||
supplierRequestService = SpringUtil.getBean(ISupplierRequestService.class);
|
supplierRequestService = SpringUtil.getBean(ISupplierRequestService.class);
|
||||||
}
|
}
|
||||||
|
if(battleConsumeService == null){
|
||||||
|
battleConsumeService = SpringUtil.getBean(IBattleConsumeService.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//执行一次
|
//执行一次
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,11 +93,11 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
|
|
||||||
// statisticBean.getAmmunition().getCurrent()
|
// statisticBean.getAmmunition().getCurrent()
|
||||||
//初始化本次战斗任务各种资源数
|
//初始化本次战斗任务各种资源数
|
||||||
battleParams.put("ammunition",Double.valueOf(statisticBean.getAmmunition().getCurrent()).toString());
|
battleParams.put("ammunition",Double.valueOf(statisticBean.getAmmunition().getTotal()).toString());
|
||||||
battleParams.put("food",Double.valueOf(statisticBean.getFood().getCurrent()).toString());
|
battleParams.put("food",Double.valueOf(statisticBean.getFood().getTotal()).toString());
|
||||||
battleParams.put("fuel",Double.valueOf(statisticBean.getFuel().getCurrent()).toString());
|
battleParams.put("fuel",Double.valueOf(statisticBean.getFuel().getTotal()).toString());
|
||||||
battleParams.put("medical",Double.valueOf(statisticBean.getMedical().getCurrent()).toString());
|
battleParams.put("medical",Double.valueOf(statisticBean.getMedical().getTotal()).toString());
|
||||||
battleParams.put("water",Double.valueOf(statisticBean.getWater().getCurrent()).toString());
|
battleParams.put("water",Double.valueOf(statisticBean.getWater().getTotal()).toString());
|
||||||
battleParams.put("death",Double.valueOf(statisticBean.getPerson().getDeath()).toString());
|
battleParams.put("death",Double.valueOf(statisticBean.getPerson().getDeath()).toString());
|
||||||
battleParams.put("injured",Double.valueOf(statisticBean.getPerson().getInjured()).toString());
|
battleParams.put("injured",Double.valueOf(statisticBean.getPerson().getInjured()).toString());
|
||||||
battleParams.put("teamLat",statisticBean.getTeam().getLat().toString());
|
battleParams.put("teamLat",statisticBean.getTeam().getLat().toString());
|
||||||
|
@ -169,23 +177,34 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
jsonObject.put("teamLng",teamLng);
|
jsonObject.put("teamLng",teamLng);
|
||||||
sendConsumeMsg.setData(jsonObject);
|
sendConsumeMsg.setData(jsonObject);
|
||||||
Global.sendCmdInfoQueue.add(sendConsumeMsg);
|
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(deathConsume.toString()));
|
||||||
|
battleConsume.setInjured(Integer.valueOf(injuredConsume.toString()));
|
||||||
|
battleConsume.setFood(foodConsume);
|
||||||
|
battleConsume.setFuel(fuelConsume);
|
||||||
|
battleConsume.setMedical(medicalConsume);
|
||||||
|
battleConsume.setWater(waterConsume);
|
||||||
|
battleConsume.setResourceId(scenarioTask.getResourceId());
|
||||||
|
battleConsumeService.save(battleConsume);
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
log.error("==================推送消耗數據 失败============================================",ex.getMessage());
|
log.error("==================推送消耗數據 失败============================================",ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||||
String death = SpringUtil.getBean(Environment.class).getProperty("battle.death.warn");
|
String death = SpringUtil.getBean(Environment.class).getProperty("death.warn");
|
||||||
String injured = SpringUtil.getBean(Environment.class).getProperty("battle.injured.warn");
|
String injured = SpringUtil.getBean(Environment.class).getProperty("injured.warn");
|
||||||
String ammunition = SpringUtil.getBean(Environment.class).getProperty("battle.ammunition.warn");
|
String ammunition = SpringUtil.getBean(Environment.class).getProperty("ammunition.warn");
|
||||||
log.info("===========person ammunition==={}===={}====={}========",death,injured,ammunition);
|
log.info("===========person ammunition==={}===={}====={}========",death,injured,ammunition);
|
||||||
// String food = SpringUtil.getBean(Environment.class).getProperty("battle.food.warn");
|
HashMap<String,Object> battleConsumeMap = (HashMap<String, Object>) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId());
|
||||||
// String water = SpringUtil.getBean(Environment.class).getProperty("battle.water.warn");
|
Double restAmmunition = Double.valueOf(battleConsumeMap.get("ammunition").toString());
|
||||||
// String fuel = SpringUtil.getBean(Environment.class).getProperty("battle.fuel.warn");
|
StatisticBean battleResourceStat = statisticService.statistic(scenarioTask.getResourceId());
|
||||||
// String medical = SpringUtil.getBean(Environment.class).getProperty("battle.medical.warn");
|
Double ammunitionConsumeRate = restAmmunition/battleResourceStat.getAmmunition().getTotal()*100;
|
||||||
|
if(Double.valueOf(ammunitionConsumeRate) <= Double.valueOf(ammunition) && suppleFlagMap.get("ammunition") == false){
|
||||||
if(Double.valueOf(battleParams.get("ammunition").toString()) <= 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());
|
||||||
|
@ -197,7 +216,9 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
supplierRequestService.save(supplierRequest);
|
supplierRequestService.save(supplierRequest);
|
||||||
suppleFlagMap.put("ammunition",true) ;
|
suppleFlagMap.put("ammunition",true) ;
|
||||||
}
|
}
|
||||||
if(Long.valueOf(battleParams.get("death").toString()) <= Long.valueOf(death) && suppleFlagMap.get("death") == false){
|
Long restNoDeath = Long.valueOf(battleConsumeMap.get("death").toString());
|
||||||
|
Long deathConsumeRate = restNoDeath*100/battleResourceStat.getPerson().getDeath();
|
||||||
|
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());
|
||||||
|
@ -209,7 +230,9 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
supplierRequestService.save(supplierRequest);
|
supplierRequestService.save(supplierRequest);
|
||||||
suppleFlagMap.put("death",true) ;
|
suppleFlagMap.put("death",true) ;
|
||||||
}
|
}
|
||||||
if(Long.valueOf(battleParams.get("injured").toString()) <= Long.valueOf(injured) && suppleFlagMap.get("injured") == false){
|
Long restNoInjured = Long.valueOf(battleConsumeMap.get("injured").toString());
|
||||||
|
Long injuredConsumeRate = restNoInjured*100/battleResourceStat.getPerson().getDeath();
|
||||||
|
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());
|
||||||
|
@ -229,14 +252,11 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.hivekion.scenario.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 战斗消耗 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author liDongYu
|
||||||
|
* @since 2025-09-19
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/scenario/battleConsume")
|
||||||
|
public class BattleConsumeController {
|
||||||
|
|
||||||
|
}
|
153
src/main/java/com/hivekion/scenario/entity/BattleConsume.java
Normal file
153
src/main/java/com/hivekion/scenario/entity/BattleConsume.java
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
package com.hivekion.scenario.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 战斗消耗
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author liDongYu
|
||||||
|
* @since 2025-09-19
|
||||||
|
*/
|
||||||
|
@TableName("TBL_BATTLE_CONSUME")
|
||||||
|
@ApiModel(value = "BattleConsume对象", description = "战斗消耗")
|
||||||
|
public class BattleConsume implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("物理主键")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("资源编号")
|
||||||
|
private String resourceId;
|
||||||
|
|
||||||
|
private Double ammunition;
|
||||||
|
|
||||||
|
private Integer death;
|
||||||
|
|
||||||
|
private Integer injured;
|
||||||
|
|
||||||
|
private Double fuel;
|
||||||
|
|
||||||
|
private Double food;
|
||||||
|
|
||||||
|
private Double water;
|
||||||
|
|
||||||
|
private Double medical;
|
||||||
|
|
||||||
|
private String lat;
|
||||||
|
|
||||||
|
private String lng;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceId() {
|
||||||
|
return resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceId(String resourceId) {
|
||||||
|
this.resourceId = resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getDeath() {
|
||||||
|
return death;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeath(Integer death) {
|
||||||
|
this.death = death;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getInjured() {
|
||||||
|
return injured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInjured(Integer injured) {
|
||||||
|
this.injured = injured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAmmunition() {
|
||||||
|
return ammunition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmmunition(Double ammunition) {
|
||||||
|
this.ammunition = ammunition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getFuel() {
|
||||||
|
return fuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFuel(Double fuel) {
|
||||||
|
this.fuel = fuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getFood() {
|
||||||
|
return food;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood(Double food) {
|
||||||
|
this.food = food;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getWater() {
|
||||||
|
return water;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWater(Double water) {
|
||||||
|
this.water = water;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getMedical() {
|
||||||
|
return medical;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMedical(Double medical) {
|
||||||
|
this.medical = medical;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLat() {
|
||||||
|
return lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLat(String lat) {
|
||||||
|
this.lat = lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLng() {
|
||||||
|
return lng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLng(String lng) {
|
||||||
|
this.lng = lng;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BattleConsume{" +
|
||||||
|
"id = " + id +
|
||||||
|
", resourceId = " + resourceId +
|
||||||
|
", ammunition = " + ammunition +
|
||||||
|
", death = " + death +
|
||||||
|
", injured = " + injured +
|
||||||
|
", fuel = " + fuel +
|
||||||
|
", food = " + food +
|
||||||
|
", water = " + water +
|
||||||
|
", medical = " + medical +
|
||||||
|
", lat = " + lat +
|
||||||
|
", lng = " + lng +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.hivekion.scenario.mapper;
|
||||||
|
|
||||||
|
import com.hivekion.scenario.entity.BattleConsume;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 战斗消耗 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author liDongYu
|
||||||
|
* @since 2025-09-19
|
||||||
|
*/
|
||||||
|
public interface BattleConsumeMapper extends BaseMapper<BattleConsume> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.hivekion.scenario.service;
|
||||||
|
|
||||||
|
import com.hivekion.scenario.entity.BattleConsume;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 战斗消耗 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author liDongYu
|
||||||
|
* @since 2025-09-19
|
||||||
|
*/
|
||||||
|
public interface IBattleConsumeService extends IService<BattleConsume> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.hivekion.scenario.service.impl;
|
||||||
|
|
||||||
|
import com.hivekion.scenario.entity.BattleConsume;
|
||||||
|
import com.hivekion.scenario.mapper.BattleConsumeMapper;
|
||||||
|
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 战斗消耗 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author liDongYu
|
||||||
|
* @since 2025-09-19
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BattleConsumeServiceImpl extends ServiceImpl<BattleConsumeMapper, BattleConsume> implements IBattleConsumeService {
|
||||||
|
|
||||||
|
}
|
|
@ -7,8 +7,8 @@ fuel.warn = 2
|
||||||
medical.warn = 1
|
medical.warn = 1
|
||||||
death.spreed = 3;
|
death.spreed = 3;
|
||||||
injured.spreed = 3;
|
injured.spreed = 3;
|
||||||
ammunition_spreed = 2.6;
|
ammunition.spreed = 2.6;
|
||||||
food_spreed = 2.3;
|
food.spreed = 2.3;
|
||||||
water_spreed = 3.6;
|
water.spreed = 3.6;
|
||||||
fuel_spreed = 3.6;
|
fuel.spreed = 3.6;
|
||||||
medical_spreed = 1.6;
|
medical.spreed = 1.6;
|
5
src/main/resources/mapper/tbl/BattleConsumeMapper.xml
Normal file
5
src/main/resources/mapper/tbl/BattleConsumeMapper.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hivekion.scenario.mapper.BattleConsumeMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user