Compare commits
2 Commits
b24681426f
...
40b5173b18
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40b5173b18 | ||
![]() |
96abc0ddef |
|
@ -12,6 +12,7 @@ import com.hivekion.common.entity.TreeNode;
|
|||
import com.hivekion.common.enums.OperationTypeEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
@ -88,4 +89,9 @@ public class TblEntityController extends TreeController {
|
|||
service.updateById(entity);
|
||||
return ResponseData.success(true);
|
||||
}
|
||||
//为了响应一个需求,增加一个DBTOOL_TABLECODE中tableName字段,各个表的数量和
|
||||
@GetMapping("/getCount")
|
||||
public ResponseData<Long> getAllTableCount() throws SQLException {
|
||||
return ResponseData.success(service.getAllTableCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.hivekion.baseData.domain.TblEntityVo.TblEntityModelVo;
|
|||
import com.hivekion.baseData.domain.TblEntityVo.TblEntityUpdateNameVo;
|
||||
import com.hivekion.baseData.domain.TblEntityVo.TblEntityUpdateRemarkVo;
|
||||
import com.hivekion.common.entity.TreeNode;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -30,4 +31,5 @@ public interface ITblEntityService extends IService<TblEntity> {
|
|||
|
||||
List<TblEntity> selectAllChild(Integer id);
|
||||
Map<Integer,TblEntity> entityMap();
|
||||
Long getAllTableCount() throws SQLException;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,18 @@ import com.hivekion.common.core.SystemConstant;
|
|||
import com.hivekion.common.entity.TreeNode;
|
||||
import com.hivekion.common.exception.BusinessException;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -38,6 +44,8 @@ public class TblEntityServiceImpl extends ServiceImpl<TblEntityMapper, TblEntity
|
|||
|
||||
@Autowired
|
||||
private ITblAircraftService aircraftService;
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Override
|
||||
public boolean remove(Integer id) {
|
||||
|
@ -60,19 +68,19 @@ public class TblEntityServiceImpl extends ServiceImpl<TblEntityMapper, TblEntity
|
|||
Long s = System.currentTimeMillis();
|
||||
Date date = new Date(s);
|
||||
entity.setCreateTime(date);
|
||||
if(vo.getParentId() != -1) {
|
||||
if (vo.getParentId() != -1) {
|
||||
entity.setEntityType(getParentID(vo.getParentId()));
|
||||
}else{
|
||||
} else {
|
||||
entity.setEntityType(vo.getEntityType());
|
||||
}
|
||||
if (checkNameUnique(String.valueOf(entity.getId()), entity.getEntityName(), vo.getParentId())) {
|
||||
throw new BusinessException(500, "该名称已存在");
|
||||
} else {
|
||||
if(entity.getId() != null) {
|
||||
if (entity.getId() != null) {
|
||||
LambdaUpdateWrapper<TblEntity> tWrapper = new LambdaUpdateWrapper<TblEntity>()
|
||||
.eq(TblEntity::getId, entity.getId());
|
||||
.eq(TblEntity::getId, entity.getId());
|
||||
return this.saveOrUpdate(entity);
|
||||
}else{
|
||||
} else {
|
||||
return this.save(entity);
|
||||
}
|
||||
}
|
||||
|
@ -297,4 +305,31 @@ public class TblEntityServiceImpl extends ServiceImpl<TblEntityMapper, TblEntity
|
|||
return this.list().stream().collect(Collectors.toMap(TblEntity::getId, x -> x));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getAllTableCount() throws SQLException {
|
||||
|
||||
String sql = "SELECT COUNT(*) AS total_count\n"
|
||||
+ "FROM (\n"
|
||||
+ " SELECT 1 FROM TBL_SHIP\n"
|
||||
+ " UNION ALL\n"
|
||||
+ " SELECT 1 FROM TBL_AIRCRAFT\n"
|
||||
+ " UNION ALL\n"
|
||||
+ " SELECT 1 FROM TBL_FACILITY\n"
|
||||
+ ") t;";
|
||||
|
||||
|
||||
// 3. 查询总数
|
||||
long total = 0;
|
||||
try (
|
||||
Connection connection = dataSource.getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet rs = statement.executeQuery(sql)
|
||||
) {
|
||||
if (rs.next()) {
|
||||
total = rs.getLong(1);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.hivekion.common;
|
|||
import com.hivekion.common.exception.BusinessException;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
|
@ -99,9 +100,10 @@ public class utils {
|
|||
long hours = duration.toHours();
|
||||
long minutes = duration.minusHours(hours).toMinutes();
|
||||
long seconds = duration.minusHours(hours).minusMinutes(minutes).getSeconds();
|
||||
return MessageFormat.format("{0}小时{1}分钟{2}秒", hours, minutes, seconds);
|
||||
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(utils.formatSeconds(3601));
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import com.hivekion.supplier.entity.SupplierRequest;
|
|||
import com.hivekion.supplier.service.impl.SupplierRequestServiceImpl;
|
||||
import com.hivekion.team.entity.Teaminfo;
|
||||
import com.hivekion.team.service.impl.TeaminfoServiceImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -427,8 +429,26 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
String updJsonStr = (String) redisUtil.hget(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"updScenarioInfo");
|
||||
EditScenarioInfo editScenarioInfo = JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
||||
//设置食品
|
||||
editScenarioInfo.getJbxx().getFood().setCurrent(new BigDecimal( editScenarioInfo.getJbxx().getFood().getCurrent()).setScale(3,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//设置油
|
||||
editScenarioInfo.getJbxx().getFuel().setCurrent(new BigDecimal( editScenarioInfo.getJbxx().getFuel().getCurrent()).setScale(3,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//设置弹药
|
||||
editScenarioInfo.getJbxx().getAmmunition().setCurrent(new BigDecimal( editScenarioInfo.getJbxx().getAmmunition().getCurrent()).setScale(3,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//设置药材
|
||||
editScenarioInfo.getJbxx().getMedical().setCurrent(new BigDecimal( editScenarioInfo.getJbxx().getMedical().getCurrent()).setScale(3,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
//设置水
|
||||
editScenarioInfo.getJbxx().getWater().setCurrent(new BigDecimal( editScenarioInfo.getJbxx().getWater().getCurrent()).setScale(3,
|
||||
RoundingMode.HALF_UP).doubleValue());
|
||||
|
||||
|
||||
ResponseCmdInfo<String> respUpdObj = new ResponseCmdInfo<>();
|
||||
respUpdObj.setData(updJsonStr);
|
||||
respUpdObj.setData(JSON.toJSONString(editScenarioInfo));
|
||||
respUpdObj.setRoom(roomId);
|
||||
respUpdObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respUpdObj.setCmdType("updScenarioInfo");
|
||||
|
|
|
@ -13,6 +13,8 @@ import com.hivekion.scenario.entity.ScenarioTask;
|
|||
import com.hivekion.scenario.service.impl.BattleConsumeServiceImpl;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -107,7 +109,7 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
|||
//修改油料
|
||||
EditScenarioInfo editScenarioInfo = getEditScenarioInfo(
|
||||
this.scenarioTask.getResourceId());
|
||||
|
||||
;
|
||||
editScenarioInfo.getJbxx().getFuel().setCurrent(editScenarioInfo.getJbxx().getFuel().getCurrent()-currentUseUp);
|
||||
setEditScenarioInfo(editScenarioInfo,scenarioTask.getResourceId());
|
||||
|
||||
|
|
|
@ -232,6 +232,7 @@ public class Room implements AutoCloseable {
|
|||
private void sendRemainTime(long remainTime) {
|
||||
log.info("remain_time{}", remainTime);
|
||||
Map<String, Object> timeMap = new HashMap<>();
|
||||
timeMap.put("scenario_time", df.format(scenario.getStartTime()));
|
||||
timeMap.put("update_time_str", utils.formatSeconds(remainTime));
|
||||
timeMap.put("remain_time", remainTime);
|
||||
timeMap.put("during_time", duringTime.get());
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.hivekion.room.bean;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
|
@ -50,8 +53,10 @@ public class SupplierTask extends AbtParentTask implements TaskAction {
|
|||
break;
|
||||
}
|
||||
//推送最新状态信息
|
||||
log.info("===========begin=====pushStatus supplierAmmunition======={}====={}=================",scenarioTask.getResourceId(),scenarioTask.getInsureResourceId());
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
pushStatus(scenarioTask.getInsureResourceId());
|
||||
log.info("============end====pushStatus supplierAmmunition=========={}===={}===============",scenarioTask.getResourceId(),scenarioTask.getInsureResourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,13 +112,24 @@ public class SupplierTask extends AbtParentTask implements TaskAction {
|
|||
if (supplierInfo != null && insuranceInfo != null) {
|
||||
double insuranceCurrent = insuranceInfo.getJbxx().getAmmunition().getCurrent();
|
||||
|
||||
supplierInfo.getJbxx().getAmmunition().setCurrent(
|
||||
supplierInfo.getJbxx().getAmmunition().getCurrent() - insuranceCurrent < 0 ? 0
|
||||
: (supplierInfo.getJbxx().getAmmunition().getCurrent() - insuranceCurrent));
|
||||
supplierInfo.getJbxx().getAmmunition().setCurrent((supplierInfo.getJbxx().getAmmunition().getTotal()));
|
||||
|
||||
insuranceInfo.getJbxx().getAmmunition()
|
||||
.setCurrent(insuranceInfo.getJbxx().getAmmunition().getTotal());
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"updScenarioInfo", JSONObject.toJSONString(insuranceInfo));
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"updScenarioInfo-ammunition", String.valueOf(insuranceInfo.getJbxx().getAmmunition().getTotal()));
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"updScenarioInfo",JSONObject.toJSONString(supplierInfo));
|
||||
log.info("===============supplierAmmunition end==========={}====={}=======",scenarioTask.getResourceId(),scenarioTask.getInsureResourceId());
|
||||
log.info("===============supplierAmmunition end==========={}====={}=======",insuranceInfo.getJbxx().getAmmunition().getCurrent(),supplierInfo.getJbxx().getAmmunition().getCurrent());
|
||||
}else{
|
||||
log.info("===============supplierAmmunition null==========={}====={}=======",scenarioTask.getResourceId(),scenarioTask.getInsureResourceId());
|
||||
// log.info("===============supplierAmmunition null==========={}====={}=======",insuranceInfo.getJbxx().getAmmunition().getCurrent(),supplierInfo.getJbxx().getAmmunition().getCurrent());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
injured.warn = 20
|
||||
death.warn = 2
|
||||
ammunition.warn = 3
|
||||
food.warn = 3
|
||||
water.warn = 3
|
||||
injured.warn = 19
|
||||
death.warn = 5
|
||||
ammunition.warn = 70
|
||||
food.warn = 8
|
||||
water.warn = 9
|
||||
fuel.warn = 55.80
|
||||
medical.warn = 1
|
||||
death.spreed = 3
|
||||
|
|
Loading…
Reference in New Issue
Block a user