websocket接收msg
This commit is contained in:
parent
6a117c0a79
commit
41e82f91c1
|
|
@ -227,11 +227,15 @@ public class BattleRootTask extends AbtParentTask {
|
||||||
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("");
|
||||||
Global.sendCmdInfoQueue.add(respObj);
|
Global.sendCmdInfoQueue.add(respObj);
|
||||||
suppleFlagMap.put("ammunition",true) ;
|
suppleFlagMap.put("ammunition",true) ;
|
||||||
}
|
}
|
||||||
Long restDeath = Long.valueOf(battleConsumeMap.get("death").toString());
|
Long restDeath = Long.valueOf(battleConsumeMap.get("death").toString());
|
||||||
Long deathConsumeRate = restDeath*100/battleResourceStat.getPerson().getTotal();
|
Long deathConsumeRate = 0L;
|
||||||
|
if(battleResourceStat.getPerson().getTotal() !=0) {
|
||||||
|
deathConsumeRate = restDeath * 100 / battleResourceStat.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());
|
||||||
|
|
|
||||||
24
src/main/java/com/hivekion/scenario/bean/BattleSuppleVo.java
Normal file
24
src/main/java/com/hivekion/scenario/bean/BattleSuppleVo.java
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.hivekion.scenario.bean;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BattleSuppleVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String battleResourceId;
|
||||||
|
|
||||||
|
private String supplierResourceId;
|
||||||
|
|
||||||
|
private String supplierResourceName;
|
||||||
|
|
||||||
|
private String battleResourceName;
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
package com.hivekion.scenario.controller;
|
package com.hivekion.scenario.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.hivekion.common.entity.ResponseData;
|
import com.hivekion.common.entity.ResponseData;
|
||||||
import com.hivekion.common.uuid.IdUtils;
|
import com.hivekion.common.uuid.IdUtils;
|
||||||
|
import com.hivekion.scenario.bean.BattleSuppleVo;
|
||||||
import com.hivekion.scenario.entity.BattleSupplier;
|
import com.hivekion.scenario.entity.BattleSupplier;
|
||||||
import com.hivekion.scenario.entity.ScenarioResource;
|
import com.hivekion.scenario.entity.ScenarioResource;
|
||||||
import com.hivekion.scenario.service.IBattleSupplierService;
|
import com.hivekion.scenario.service.IBattleSupplierService;
|
||||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||||
import com.hivekion.team.entity.Teaminfo;
|
import com.hivekion.team.entity.Teaminfo;
|
||||||
import com.hivekion.team.service.ITeaminfoService;
|
import com.hivekion.team.service.ITeaminfoService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -42,7 +47,10 @@ public class BattleSupplierController {
|
||||||
public ResponseData<Void> save(@RequestBody BattleSupplier battleSupplier) {
|
public ResponseData<Void> save(@RequestBody BattleSupplier battleSupplier) {
|
||||||
if (battleSupplier.getId() == null) {
|
if (battleSupplier.getId() == null) {
|
||||||
battleSupplier.setId(IdUtils.simpleUUID());
|
battleSupplier.setId(IdUtils.simpleUUID());
|
||||||
battleSupplierService.save(battleSupplier);
|
BattleSupplier tmp = battleSupplierService.getOne(new QueryWrapper<BattleSupplier>().eq("BATTLE_RESOURCE_ID",battleSupplier.getBattleResourceId()).or().eq("SUPPLIER_RESOURCE_ID",battleSupplier.getSupplierResourceId()));
|
||||||
|
if(Objects.isNull(tmp)) {
|
||||||
|
battleSupplierService.save(battleSupplier);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
battleSupplierService.updateById(battleSupplier);
|
battleSupplierService.updateById(battleSupplier);
|
||||||
}
|
}
|
||||||
|
|
@ -56,20 +64,24 @@ public class BattleSupplierController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public ResponseData<List<BattleSupplier>> list(String supplierId) {
|
public ResponseData<List<BattleSuppleVo>> list(String supplierId) {
|
||||||
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
||||||
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
||||||
QueryWrapper<BattleSupplier> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BattleSupplier> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("supplier_resource_id", supplierId);
|
queryWrapper.eq("supplier_resource_id", supplierId);
|
||||||
List<BattleSupplier> list = battleSupplierService.list(queryWrapper);
|
List<BattleSupplier> list = battleSupplierService.list(queryWrapper);
|
||||||
|
List<BattleSuppleVo> qryList = new ArrayList<>();
|
||||||
list.forEach(item -> {
|
list.forEach(item -> {
|
||||||
|
BattleSuppleVo battleSuppleVo = new BattleSuppleVo();
|
||||||
|
BeanUtil.copyProperties(item,battleSuppleVo);
|
||||||
if (resourceMap.get(item.getBattleResourceId()) != null) {
|
if (resourceMap.get(item.getBattleResourceId()) != null) {
|
||||||
ScenarioResource resource = resourceMap.get(item.getBattleResourceId());
|
ScenarioResource resource = resourceMap.get(item.getBattleResourceId());
|
||||||
if (map.get(resource.getResourceId()) != null) {
|
if (map.get(resource.getResourceId()) != null) {
|
||||||
item.setSupplierResourceName(map.get(resource.getResourceId()).getName());
|
battleSuppleVo.setSupplierResourceName(map.get(resource.getResourceId()).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qryList.add(battleSuppleVo);
|
||||||
});
|
});
|
||||||
return ResponseData.success(list);
|
return ResponseData.success(qryList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ public class BattleConsume implements Serializable {
|
||||||
|
|
||||||
private String lng;
|
private String lng;
|
||||||
|
|
||||||
|
@TableField(value="CONSUME_DATE")
|
||||||
private LocalDateTime consumeDate;
|
private LocalDateTime consumeDate;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,5 @@ public class BattleSupplier implements Serializable {
|
||||||
@TableField(value = "supplier_resource_id")
|
@TableField(value = "supplier_resource_id")
|
||||||
private String supplierResourceId;
|
private String supplierResourceId;
|
||||||
|
|
||||||
private String supplierResourceName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package com.hivekion.statistic.bean;
|
package com.hivekion.statistic.bean;
|
||||||
|
|
||||||
|
import com.hivekion.scenario.bean.BattleSuppleVo;
|
||||||
|
import com.hivekion.scenario.entity.BattleSupplier;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [类的简要说明]
|
* [类的简要说明]
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -26,4 +30,6 @@ public class StatisticBean {
|
||||||
//药材
|
//药材
|
||||||
private MedicalInfo medical = new MedicalInfo();
|
private MedicalInfo medical = new MedicalInfo();
|
||||||
private String status = "init";
|
private String status = "init";
|
||||||
|
|
||||||
|
private List<BattleSuppleVo> battleSuppliers;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component("WebsocketScenarioService")
|
||||||
public class ScenarioServiceImpl implements ScenarioService {
|
public class ScenarioServiceImpl implements ScenarioService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -65,7 +65,7 @@ public class ScenarioServiceImpl implements ScenarioService {
|
||||||
scenarioTask.setResourceId(resourceId);
|
scenarioTask.setResourceId(resourceId);
|
||||||
List<ScenarioTask> scenarioTasks = scenarioTaskService.queryTaskList(scenarioTask);
|
List<ScenarioTask> scenarioTasks = scenarioTaskService.queryTaskList(scenarioTask);
|
||||||
|
|
||||||
List<SupplierRequest> supplierRequests = supplierRequestService.list(new QueryWrapper<SupplierRequest>().eq("resource_id",resourceId));
|
List<SupplierRequest> supplierRequests = supplierRequestService.list(new QueryWrapper<SupplierRequest>().eq("FROM_RESOURCE_ID",resourceId));
|
||||||
ScenarioInfo scenarioInfo = new ScenarioInfo();
|
ScenarioInfo scenarioInfo = new ScenarioInfo();
|
||||||
scenarioInfo.setScenarioTasks(scenarioTasks);
|
scenarioInfo.setScenarioTasks(scenarioTasks);
|
||||||
scenarioInfo.setStaffList(staffList);
|
scenarioInfo.setStaffList(staffList);
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,32 @@
|
||||||
package com.hivekion.statistic.service.impl;
|
package com.hivekion.statistic.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.hivekion.baseData.entity.Fightpowerstaff;
|
import com.hivekion.baseData.entity.Fightpowerstaff;
|
||||||
import com.hivekion.baseData.entity.OrgSupplier;
|
import com.hivekion.baseData.entity.OrgSupplier;
|
||||||
import com.hivekion.baseData.service.FightpowerstaffService;
|
import com.hivekion.baseData.service.FightpowerstaffService;
|
||||||
import com.hivekion.baseData.service.OrgSupplierService;
|
import com.hivekion.baseData.service.OrgSupplierService;
|
||||||
|
import com.hivekion.scenario.bean.BattleSuppleVo;
|
||||||
|
import com.hivekion.scenario.entity.BattleSupplier;
|
||||||
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
||||||
import com.hivekion.scenario.entity.ScenarioResource;
|
import com.hivekion.scenario.entity.ScenarioResource;
|
||||||
|
import com.hivekion.scenario.service.IBattleSupplierService;
|
||||||
import com.hivekion.scenario.service.IScenarioOrgPostService;
|
import com.hivekion.scenario.service.IScenarioOrgPostService;
|
||||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||||
import com.hivekion.statistic.bean.StatisticBean;
|
import com.hivekion.statistic.bean.StatisticBean;
|
||||||
import com.hivekion.statistic.service.StatisticService;
|
import com.hivekion.statistic.service.StatisticService;
|
||||||
import com.hivekion.supplier.entity.SuppliesDict;
|
import com.hivekion.supplier.entity.SuppliesDict;
|
||||||
import com.hivekion.supplier.service.SuppliesDictService;
|
import com.hivekion.supplier.service.SuppliesDictService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.hivekion.team.entity.Teaminfo;
|
||||||
|
import com.hivekion.team.service.ITeaminfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -43,6 +53,17 @@ public class StatisticServiceImpl implements StatisticService {
|
||||||
private IScenarioOrgPostService scenarioOrgPostService;
|
private IScenarioOrgPostService scenarioOrgPostService;
|
||||||
@Resource
|
@Resource
|
||||||
private FightpowerstaffService fightpowerstaffService;
|
private FightpowerstaffService fightpowerstaffService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IBattleSupplierService battleSupplierService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITeaminfoService teamInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ScenarioResourceService resourceService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatisticBean statistic(String resourceId) {
|
public StatisticBean statistic(String resourceId) {
|
||||||
StatisticBean statisticBean = new StatisticBean();
|
StatisticBean statisticBean = new StatisticBean();
|
||||||
|
|
@ -51,7 +72,33 @@ public class StatisticServiceImpl implements StatisticService {
|
||||||
if(resourceInstance == null){
|
if(resourceInstance == null){
|
||||||
return statisticBean;
|
return statisticBean;
|
||||||
}
|
}
|
||||||
|
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
||||||
|
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
||||||
|
List<BattleSupplier> battleSuppliers = battleSupplierService.list(new QueryWrapper<BattleSupplier>()
|
||||||
|
.eq("BATTLE_RESOURCE_ID",resourceId).or().eq("SUPPLIER_RESOURCE_ID",resourceId));
|
||||||
|
if(CollectionUtil.isEmpty(battleSuppliers)) {
|
||||||
|
battleSuppliers = new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<BattleSuppleVo> qryList = new ArrayList<>();
|
||||||
|
battleSuppliers.stream().forEach(battleSupplier -> {
|
||||||
|
BattleSuppleVo battleSuppleVo = new BattleSuppleVo();
|
||||||
|
BeanUtil.copyProperties(battleSupplier,battleSuppleVo);
|
||||||
|
if (resourceMap.get(battleSupplier.getBattleResourceId()) != null) {
|
||||||
|
ScenarioResource resource = resourceMap.get(battleSupplier.getBattleResourceId());
|
||||||
|
if (map.get(resource.getResourceId()) != null) {
|
||||||
|
battleSuppleVo.setBattleResourceName(map.get(resource.getResourceId()).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resourceMap.get(battleSupplier.getSupplierResourceId()) != null) {
|
||||||
|
ScenarioResource resource = resourceMap.get(battleSupplier.getSupplierResourceId());
|
||||||
|
if (map.get(resource.getResourceId()) != null) {
|
||||||
|
battleSuppleVo.setSupplierResourceName(map.get(resource.getResourceId()).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qryList.add(battleSuppleVo);
|
||||||
|
});
|
||||||
|
|
||||||
|
statisticBean.setBattleSuppliers(qryList);
|
||||||
statisticBean.getTeam().setType(resourceInstance.getType());
|
statisticBean.getTeam().setType(resourceInstance.getType());
|
||||||
statisticBean.getTeam().setLat(resourceInstance.getLat());
|
statisticBean.getTeam().setLat(resourceInstance.getLat());
|
||||||
statisticBean.getTeam().setLng(resourceInstance.getLng());
|
statisticBean.getTeam().setLng(resourceInstance.getLng());
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ public class WebsocketMsgWrapper {
|
||||||
responseCmdInfo.setRoom(roomId);
|
responseCmdInfo.setRoom(roomId);
|
||||||
try {
|
try {
|
||||||
JSONObject msgObj = (JSONObject) JSON.parse(msg);
|
JSONObject msgObj = (JSONObject) JSON.parse(msg);
|
||||||
if(msgObj.getString("msgType").equals("scenarioInfo")){
|
|
||||||
|
if(msgObj.getString("cmdType").equals("scenarioInfo")){
|
||||||
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
||||||
if(scenarioService != null){
|
if(scenarioService != null){
|
||||||
ScenarioInfo scenarioInfo= scenarioService.listScenarioInfo(scenarioId,roomId,resourceId);
|
ScenarioInfo scenarioInfo= scenarioService.listScenarioInfo(scenarioId,roomId,resourceId);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ spring.datasource.dynamic.datasource.dm.username=simulation
|
||||||
spring.datasource.dynamic.datasource.dm.password=Simulation001
|
spring.datasource.dynamic.datasource.dm.password=Simulation001
|
||||||
|
|
||||||
spring.redis.database=0
|
spring.redis.database=0
|
||||||
spring.redis.host=192.168.0.53
|
spring.redis.host=192.168.0.225
|
||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
#spring.redis.password=123
|
#spring.redis.password=123
|
||||||
spring.redis.timeout=5000
|
spring.redis.timeout=5000
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user