初次提交
This commit is contained in:
parent
1525954f1a
commit
2f40a8556c
|
|
@ -33,5 +33,6 @@ public class OrgSupplier implements Serializable {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.hivekion.baseData.mapper;
|
||||||
|
|
||||||
import com.hivekion.baseData.entity.OrgSupplier;
|
import com.hivekion.baseData.entity.OrgSupplier;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import java.util.List;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Mapper 接口
|
* Mapper 接口
|
||||||
|
|
@ -12,5 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
* @since 2025-09-14
|
* @since 2025-09-14
|
||||||
*/
|
*/
|
||||||
public interface OrgSupplierMapper extends BaseMapper<OrgSupplier> {
|
public interface OrgSupplierMapper extends BaseMapper<OrgSupplier> {
|
||||||
|
List<OrgSupplier> selectByOrgIds(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,6 @@ import java.util.List;
|
||||||
* @since 2025-09-14
|
* @since 2025-09-14
|
||||||
*/
|
*/
|
||||||
public interface OrgSupplierService extends IService<OrgSupplier> {
|
public interface OrgSupplierService extends IService<OrgSupplier> {
|
||||||
public List<OrgSupplier> getByOrgId(Integer orgId);
|
List<OrgSupplier> getByOrgId(Integer orgId);
|
||||||
|
List<OrgSupplier> selectByOrgIds(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,9 @@ public class OrgSupplierServiceImpl extends ServiceImpl<OrgSupplierMapper, OrgSu
|
||||||
queryWrapper.eq("org_id", orgId);
|
queryWrapper.eq("org_id", orgId);
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrgSupplier> selectByOrgIds(List<Integer> ids) {
|
||||||
|
return this.baseMapper.selectByOrgIds(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,5 @@ public interface IScenarioOrgPostService extends IService<ScenarioOrgPost> {
|
||||||
void removeByCondition(ScenarioOrgPost scenarioOrgPost);
|
void removeByCondition(ScenarioOrgPost scenarioOrgPost);
|
||||||
List<ScenarioOrgPost> selectByCondition(ScenarioOrgPost scenarioOrgPost);
|
List<ScenarioOrgPost> selectByCondition(ScenarioOrgPost scenarioOrgPost);
|
||||||
List<Integer> getSelectOrgId(ScenarioOrgPost scenarioOrgPost);
|
List<Integer> getSelectOrgId(ScenarioOrgPost scenarioOrgPost);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,33 +136,50 @@ public class ScenarioTaskServiceImpl extends
|
||||||
* @param roomId 房间ID
|
* @param roomId 房间ID
|
||||||
*/
|
*/
|
||||||
private void weatherTrigger(Scenario currentScenario, String roomId) {
|
private void weatherTrigger(Scenario currentScenario, String roomId) {
|
||||||
try {
|
//获取到 reids中天气数据
|
||||||
QueryWrapper<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>();
|
//每个天气开始遍历
|
||||||
weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId());
|
//获取天气开始的时间 ,最好加一个状态,提示天气任务的开始,运行
|
||||||
List<WeatherResource> weatherResourceList = this.weatherResourceService.list(weatherResourceQueryWrapper);
|
//想定的开始时间+想定目前持续的时间
|
||||||
ResponseCmdInfo<JSONArray> responseCmdInfo = new ResponseCmdInfo();
|
|
||||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
|
||||||
responseCmdInfo.setRoom(roomId);
|
|
||||||
JSONArray weatherMsgArray = new JSONArray();
|
|
||||||
for (WeatherResource weatherResource : weatherResourceList) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
jsonObject.putOnce("begTime", dtf.format(weatherResource.getLastBegTime()));
|
|
||||||
jsonObject.putOnce("endTime", dtf.format(weatherResource.getLastEndTime()));
|
|
||||||
weatherMsgArray.add(jsonObject);
|
|
||||||
responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType());
|
|
||||||
}
|
|
||||||
responseCmdInfo.setData(weatherMsgArray);
|
|
||||||
System.out.println(responseCmdInfo.toString());
|
|
||||||
Global.sendCmdInfoQueue.add(responseCmdInfo);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
|
|
||||||
log.error(ex.getMessage());
|
// try {
|
||||||
}
|
// QueryWrapper<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>();
|
||||||
|
// weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId());
|
||||||
|
// List<WeatherResource> weatherResourceList = this.weatherResourceService.list(weatherResourceQueryWrapper);
|
||||||
|
// ResponseCmdInfo<JSONArray> responseCmdInfo = new ResponseCmdInfo();
|
||||||
|
// responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||||
|
// responseCmdInfo.setRoom(roomId);
|
||||||
|
// JSONArray weatherMsgArray = new JSONArray();
|
||||||
|
// for (WeatherResource weatherResource : weatherResourceList) {
|
||||||
|
// JSONObject jsonObject = new JSONObject();
|
||||||
|
// DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
// jsonObject.putOnce("begTime", dtf.format(weatherResource.getLastBegTime()));
|
||||||
|
// jsonObject.putOnce("endTime", dtf.format(weatherResource.getLastEndTime()));
|
||||||
|
// weatherMsgArray.add(jsonObject);
|
||||||
|
// responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType());
|
||||||
|
// }
|
||||||
|
// responseCmdInfo.setData(weatherMsgArray);
|
||||||
|
// System.out.println(responseCmdInfo.toString());
|
||||||
|
// Global.sendCmdInfoQueue.add(responseCmdInfo);
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
//
|
||||||
|
// log.error(ex.getMessage());
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取当前想定从开始到现在时间
|
||||||
|
* @param scenario
|
||||||
|
* @param roomId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int getCurrentDuringTime(Scenario scenario, String roomId) {
|
||||||
|
Object duringTime = redisUtil.hget(roomId + "_" + scenario.getId(), "duringTime");
|
||||||
|
if (duringTime != null) {
|
||||||
|
return (Integer) duringTime;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
private void taskTrigger(Scenario currentScenario, String roomId) {
|
private void taskTrigger(Scenario currentScenario, String roomId) {
|
||||||
try{
|
try{
|
||||||
Object statusObj = redisUtil.hget(roomId + "_" + currentScenario.getId(), "status");
|
Object statusObj = redisUtil.hget(roomId + "_" + currentScenario.getId(), "status");
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
||||||
Global.sendCmdInfoQueue.add(cmdInfo);
|
Global.sendCmdInfoQueue.add(cmdInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前想定从开始到现在时间
|
||||||
|
* @param scenario
|
||||||
|
* @param roomId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private int getCurrentDuringTime(Scenario scenario, String roomId) {
|
private int getCurrentDuringTime(Scenario scenario, String roomId) {
|
||||||
Object duringTime = redisUtil.hget(roomId + "_" + scenario.getId(), "duringTime");
|
Object duringTime = redisUtil.hget(roomId + "_" + scenario.getId(), "duringTime");
|
||||||
if (duringTime != null) {
|
if (duringTime != null) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ package com.hivekion.statistic.service.impl;
|
||||||
|
|
||||||
import com.hivekion.baseData.entity.OrgSupplier;
|
import com.hivekion.baseData.entity.OrgSupplier;
|
||||||
import com.hivekion.baseData.service.OrgSupplierService;
|
import com.hivekion.baseData.service.OrgSupplierService;
|
||||||
|
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
||||||
import com.hivekion.scenario.entity.ScenarioResource;
|
import com.hivekion.scenario.entity.ScenarioResource;
|
||||||
|
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;
|
||||||
|
|
@ -10,7 +12,9 @@ import com.hivekion.supplier.entity.SuppliesDict;
|
||||||
import com.hivekion.supplier.service.SuppliesDictService;
|
import com.hivekion.supplier.service.SuppliesDictService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||||
* @since 2025/7/22
|
* @since 2025/7/22
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class StatisticServiceImpl implements StatisticService {
|
public class StatisticServiceImpl implements StatisticService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -31,7 +36,8 @@ public class StatisticServiceImpl implements StatisticService {
|
||||||
private OrgSupplierService orgSupplierService;
|
private OrgSupplierService orgSupplierService;
|
||||||
@Resource
|
@Resource
|
||||||
private SuppliesDictService suppliesDictService;
|
private SuppliesDictService suppliesDictService;
|
||||||
|
@Resource
|
||||||
|
private IScenarioOrgPostService scenarioOrgPostService;
|
||||||
@Override
|
@Override
|
||||||
public StatisticBean statistic(String resourceId) {
|
public StatisticBean statistic(String resourceId) {
|
||||||
StatisticBean statisticBean = new StatisticBean();
|
StatisticBean statisticBean = new StatisticBean();
|
||||||
|
|
@ -40,37 +46,50 @@ public class StatisticServiceImpl implements StatisticService {
|
||||||
if(resourceInstance == null){
|
if(resourceInstance == null){
|
||||||
return statisticBean;
|
return statisticBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
statisticBean.getTeam().setTeamName(resourceInstance.getResourceName());
|
statisticBean.getTeam().setTeamName(resourceInstance.getResourceName());
|
||||||
|
//获取关联的组织机构信息
|
||||||
|
ScenarioOrgPost post = new ScenarioOrgPost();
|
||||||
|
post.setResourceId(resourceId);
|
||||||
|
List<ScenarioOrgPost> orgPostList = scenarioOrgPostService.selectByCondition(post);
|
||||||
|
List<Integer> orgList = orgPostList.stream().map(ScenarioOrgPost::getOrgId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
//获取人员信息
|
||||||
|
|
||||||
//获取物资信息
|
//获取物资信息
|
||||||
List<OrgSupplier> suppliers = orgSupplierService.getByOrgId(resourceInstance.getResourceId());
|
List<OrgSupplier> suppliers = orgSupplierService.selectByOrgIds(orgList);
|
||||||
|
log.info("suppliers size::{}",suppliers.size());
|
||||||
Map<String, SuppliesDict> supplierMap = suppliesDictService.supplierDictMap();
|
Map<String, SuppliesDict> supplierMap = suppliesDictService.supplierDictMap();
|
||||||
|
log.info("supplierMap::{}",supplierMap);
|
||||||
suppliers.forEach(supplier -> {
|
suppliers.forEach(supplier -> {
|
||||||
SuppliesDict dict = supplierMap.get(supplier.getId());
|
log.info("supplier:{},{}",supplier,supplier.getId());
|
||||||
|
SuppliesDict dict = supplierMap.get(supplier.getSupplierId());
|
||||||
|
log.info("dict:{}",dict);
|
||||||
if (dict != null) {
|
if (dict != null) {
|
||||||
switch (dict.getCode()) {
|
switch (dict.getCode()) {
|
||||||
case "FOOD":
|
case "FOOD":
|
||||||
statisticBean.getFood().setTotal(supplier.getAccount());
|
statisticBean.getFood().setTotal(statisticBean.getFood().getTotal()+supplier.getAccount());
|
||||||
statisticBean.getFood().setCurrent(supplier.getAccount());
|
statisticBean.getFood().setCurrent(statisticBean.getFood().getCurrent()+supplier.getAccount());
|
||||||
break;
|
break;
|
||||||
case "WATER":
|
case "WATER":
|
||||||
statisticBean.getWater().setTotal(supplier.getAccount());
|
statisticBean.getWater().setTotal(statisticBean.getWater().getTotal()+supplier.getAccount());
|
||||||
statisticBean.getWater().setCurrent(supplier.getAccount());
|
statisticBean.getWater().setCurrent(statisticBean.getWater().getCurrent()+supplier.getAccount());
|
||||||
break;
|
break;
|
||||||
case "FUEL":
|
case "FUEL":
|
||||||
statisticBean.getFuel().setTotal(supplier.getAccount());
|
statisticBean.getFuel().setTotal(statisticBean.getFuel().getTotal()+supplier.getAccount());
|
||||||
statisticBean.getFuel().setCurrent(supplier.getAccount());
|
statisticBean.getFuel().setCurrent(statisticBean.getFuel().getCurrent()+supplier.getAccount());
|
||||||
break;
|
break;
|
||||||
case "MEDICAL":
|
case "MEDICAL":
|
||||||
statisticBean.getMedical().setTotal(supplier.getAccount());
|
statisticBean.getMedical().setTotal( statisticBean.getMedical().getTotal()+supplier.getAccount());
|
||||||
statisticBean.getMedical().setCurrent(supplier.getAccount());
|
statisticBean.getMedical().setCurrent( statisticBean.getMedical().getCurrent()+supplier.getAccount());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "AMMUNITION":
|
case "AMMUNITION":
|
||||||
statisticBean.getAmmunition().setTotal(supplier.getAccount());
|
statisticBean.getAmmunition().setTotal( statisticBean.getAmmunition().getTotal()+supplier.getAccount());
|
||||||
statisticBean.getAmmunition().setCurrent(supplier.getAccount());
|
statisticBean.getAmmunition().setCurrent(statisticBean.getAmmunition().getCurrent()+supplier.getAccount());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.hivekion.ws;
|
package com.hivekion.ws;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.hivekion.Global;
|
import com.hivekion.Global;
|
||||||
import com.hivekion.common.entity.RequestCmdInfo;
|
import com.hivekion.common.entity.RequestCmdInfo;
|
||||||
|
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.websocket.OnClose;
|
import javax.websocket.OnClose;
|
||||||
|
|
@ -57,6 +60,12 @@ public class WsServer {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
try{
|
||||||
|
session.getBasicRemote().sendText(testWeatherJson());
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("error::",e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,10 +120,24 @@ public class WsServer {
|
||||||
if (roomMap.containsKey(room)) {
|
if (roomMap.containsKey(room)) {
|
||||||
Map<String, Session> singleRoomMap = roomMap.get(room);
|
Map<String, Session> singleRoomMap = roomMap.get(room);
|
||||||
singleRoomMap.forEach((sessionId, session) -> {
|
singleRoomMap.forEach((sessionId, session) -> {
|
||||||
session.getAsyncRemote().sendText(message);
|
try{
|
||||||
|
session.getBasicRemote().sendText(message);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("error::",e);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private String testWeatherJson(){
|
||||||
|
ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo();
|
||||||
|
responseCmdInfo.setCmdType("66-raining");
|
||||||
|
responseCmdInfo.setRoom("123");
|
||||||
|
responseCmdInfo.setScenarioId(2746);
|
||||||
|
Map<String,Object> data = new HashMap<>();
|
||||||
|
data.put("begTime","2028-03-09 10:00:00");
|
||||||
|
data.put("endTime","2028-03-19 00:20:00");
|
||||||
|
return JSON.toJSONString(responseCmdInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.hivekion.baseData.mapper.OrgSupplierMapper">
|
<mapper namespace="com.hivekion.baseData.mapper.OrgSupplierMapper">
|
||||||
|
<resultMap id="DMOrgSupplier" type="com.hivekion.baseData.entity.OrgSupplier">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="supplierId" column="supplier_id"/>
|
||||||
|
<result property="account" column="account"/>
|
||||||
|
<result property="orgId" column="org_id"/>
|
||||||
|
<result property="name" column="name"/>
|
||||||
|
<result property="code" column="code"/>
|
||||||
|
<!-- 其他字段 -->
|
||||||
|
</resultMap>
|
||||||
|
<select id="selectByOrgIds" resultMap="DMOrgSupplier">
|
||||||
|
select * from TBL_ORG_SUPPLIER where org_id in
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user