add:新增充电配置功能
This commit is contained in:
@@ -63,5 +63,9 @@ public interface AcsConfig {
|
||||
|
||||
String ELECTRIC2 ="electric2";
|
||||
|
||||
String ELECTRIC_BEGIN ="electric_begin";
|
||||
|
||||
String ELECTRIC_END ="electric_end";
|
||||
|
||||
String IS_ATUO_ELECTRIC ="is_atuo_electric";
|
||||
}
|
||||
|
||||
@@ -337,10 +337,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
String is_atuo_electric = paramService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue();
|
||||
log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric);
|
||||
if("1".equals(is_atuo_electric)){
|
||||
|
||||
String electric_begin = paramService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue();
|
||||
String[] begins = electric_begin.split(":");
|
||||
String electric_end = paramService.findByCode(AcsConfig.ELECTRIC_END).getValue();
|
||||
String[] ends = electric_end.split(":");
|
||||
// 定义时间段
|
||||
LocalTime startTime = LocalTime.of(8, 0); // 上午8点
|
||||
LocalTime endTime = LocalTime.of(22, 0); // 晚上22点
|
||||
LocalTime startTime = LocalTime.of(Integer.parseInt(begins[0]), Integer.parseInt(begins[1])); // 上午8点
|
||||
LocalTime endTime = LocalTime.of(Integer.parseInt(ends[0]), Integer.parseInt(ends[1])); // 晚上22点
|
||||
// 获取当前时间
|
||||
LocalTime now = LocalTime.now();
|
||||
// 判断当前时间是否在时间段内
|
||||
|
||||
@@ -42,6 +42,12 @@ class SysParamController {
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
|
||||
return new ResponseEntity<>(TableDataInfo.build(paramService.queryPage(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/queryParam")
|
||||
@Log("查询自动充电配置")
|
||||
@ApiOperation("查询自动充电配置")
|
||||
public ResponseEntity<Object> queryParam(){
|
||||
return new ResponseEntity<>(paramService.queryParam(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增系统参数")
|
||||
@@ -79,6 +85,15 @@ class SysParamController {
|
||||
return new ResponseEntity<>(paramService.findByCode(code), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/setParam")
|
||||
@Log("保存参数")
|
||||
@ApiOperation("保存参数")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> setParam(@RequestBody Map whereJson) {
|
||||
paramService.setParam(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface ISysParamService extends IService<Param> {
|
||||
*/
|
||||
Page<Param> queryPage(Map whereJson, PageQuery page);
|
||||
|
||||
Map<String, Object> queryParam();
|
||||
|
||||
/**
|
||||
* 创建参数
|
||||
*
|
||||
@@ -55,4 +57,7 @@ public interface ISysParamService extends IService<Param> {
|
||||
* @return Param
|
||||
*/
|
||||
Param findByCode(String code);
|
||||
|
||||
|
||||
void setParam(Map whereJson);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -19,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -44,7 +47,27 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
Page<Param> paramPage = paramMapper.selectPage(page.build(), queryWrapper);
|
||||
return paramPage;
|
||||
}
|
||||
public Map<String, Object> queryParam(){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
//白班充电阈值
|
||||
Param electric = this.findByCode(AcsConfig.ELECTRIC);
|
||||
if (ObjectUtil.isEmpty(electric)) throw new BadRequestException("白班充电阈值参数异常");
|
||||
//晚班充电阈值
|
||||
Param electric2 = this.findByCode(AcsConfig.ELECTRIC2);
|
||||
if (ObjectUtil.isEmpty(electric2)) throw new BadRequestException("晚班充电阈值参数异常");
|
||||
//白班开始时间
|
||||
Param electric_begin = this.findByCode(AcsConfig.ELECTRIC_BEGIN);
|
||||
if (ObjectUtil.isEmpty(electric_begin)) throw new BadRequestException("白班开始时间参数异常");
|
||||
//白班结束时间
|
||||
Param electric_end = this.findByCode(AcsConfig.ELECTRIC_END);
|
||||
if (ObjectUtil.isEmpty(electric_end)) throw new BadRequestException("白班结束时间参数异常");
|
||||
|
||||
map.put("electric",electric.getValue());
|
||||
map.put("electric2",electric2.getValue());
|
||||
map.put("electric_begin",electric_begin.getValue());
|
||||
map.put("electric_end",electric_end.getValue());
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Param param) {
|
||||
@@ -94,4 +117,48 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
Param param = paramMapper.selectOne(queryWrapper);
|
||||
return param;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void setParam(Map whereJson){
|
||||
Integer electric = (Integer) whereJson.get("electric");
|
||||
Integer electric2 = (Integer) whereJson.get("electric2");
|
||||
String electric_begin = (String) whereJson.get("electric_begin");
|
||||
String electric_end = (String) whereJson.get("electric_end");
|
||||
|
||||
String now_time = DateUtil.now();
|
||||
//白班充电阈值
|
||||
Param param_electric = this.findByCode(AcsConfig.ELECTRIC);
|
||||
if (ObjectUtil.isEmpty(param_electric)) throw new BadRequestException("白班充电阈值参数异常");
|
||||
param_electric.setValue(electric.toString());
|
||||
param_electric.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
param_electric.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
param_electric.setUpdate_time(now_time);
|
||||
paramMapper.updateById(param_electric);
|
||||
//晚班充电阈值
|
||||
Param param_electric2 = this.findByCode(AcsConfig.ELECTRIC2);
|
||||
if (ObjectUtil.isEmpty(param_electric2)) throw new BadRequestException("晚班充电阈值参数异常");
|
||||
param_electric2.setValue(electric2.toString());
|
||||
param_electric2.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
param_electric2.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
param_electric2.setUpdate_time(now_time);
|
||||
paramMapper.updateById(param_electric2);
|
||||
//白班开始时间
|
||||
Param param_electric_begin = this.findByCode(AcsConfig.ELECTRIC_BEGIN);
|
||||
if (ObjectUtil.isEmpty(param_electric_begin)) throw new BadRequestException("白班开始时间参数异常");
|
||||
param_electric_begin.setValue(electric_begin);
|
||||
param_electric_begin.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
param_electric_begin.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
param_electric_begin.setUpdate_time(now_time);
|
||||
paramMapper.updateById(param_electric_begin);
|
||||
//白班结束时间
|
||||
Param param_electric_end = this.findByCode(AcsConfig.ELECTRIC_END);
|
||||
if (ObjectUtil.isEmpty(param_electric_end)) throw new BadRequestException("白班开始时间参数异常");
|
||||
param_electric_end.setValue(electric_end);
|
||||
param_electric_end.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
param_electric_end.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
param_electric_end.setUpdate_time(now_time);
|
||||
paramMapper.updateById(param_electric_end);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user