opt:增加自动充电功能
This commit is contained in:
@@ -148,4 +148,16 @@ public interface AcsConfig {
|
||||
* 选择A点还是B点
|
||||
*/
|
||||
String CHOOSE = "choose";
|
||||
|
||||
String ELECTRIC ="electric";
|
||||
|
||||
String ELECTRIC2 ="electric2";
|
||||
|
||||
String ELECTRIC_BEGIN ="electric_begin";
|
||||
|
||||
String ELECTRIC_END ="electric_end";
|
||||
|
||||
String IS_ATUO_ELECTRIC ="is_atuo_electric";
|
||||
|
||||
String IS_ATUO_CAR ="is_atuo_car";
|
||||
}
|
||||
|
||||
@@ -84,4 +84,6 @@ public interface NDCAgvService {
|
||||
* @return
|
||||
*/
|
||||
public boolean createChargingTaskToNDC(String carno);
|
||||
|
||||
public void charge(String carno);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,13 @@ import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -36,7 +39,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ISysParamService paramService;
|
||||
// private final AcsToWmsService acsToWmsService;
|
||||
|
||||
private final ISysDictService dictService;
|
||||
private final DeviceExecuteLogService logServer;
|
||||
|
||||
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
||||
@@ -441,6 +444,69 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
return new byte[0];
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void charge(String carno) {
|
||||
//检查数据字典station为0的参数
|
||||
//分配车辆
|
||||
Dict dict = dictService.getDictByName3("station",carno,null);
|
||||
int satation=0;
|
||||
if(ObjectUtil.isNotEmpty(dict)){
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
|
||||
return;
|
||||
}
|
||||
Dict temp = dictService.getDictByName2("station");
|
||||
if(ObjectUtil.isNotEmpty(temp)){
|
||||
satation = Integer.parseInt(temp.getPara1());
|
||||
}
|
||||
if(satation!=0){
|
||||
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
|
||||
byte satationhigh = (byte) IntToHexHigh(satation);
|
||||
byte satationlow = (byte) IntToHexLow(satation);
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
str += "carno:" + (Integer.parseInt(carno));
|
||||
str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
|
||||
str += "/satation:" + (satation);
|
||||
str1 += "/satation:" + hexToString(satationhigh & 0xFF) + hexToString(satationlow & 0xFF);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0E,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X64, (byte) 0X80,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) carhigh, (byte) carlow,
|
||||
(byte) satationhigh, (byte) satationlow
|
||||
|
||||
};
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try{
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
} catch (Exception e){
|
||||
log.error("下发充电任务失败{}{}",e,e.getMessage());
|
||||
}
|
||||
|
||||
temp.setValue("1");
|
||||
temp.setPara2(carno);
|
||||
temp.setPara3("下发充电");
|
||||
dictService.updateDetail(temp);
|
||||
|
||||
}else{
|
||||
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createChargingTaskToNDC(String carno) {
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -68,7 +70,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
AutoRunService autoRunService;
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService;
|
||||
|
||||
@Autowired
|
||||
ISysDictService dictService;
|
||||
|
||||
public TwoNDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
@@ -163,6 +166,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
int agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
//充电桩站点号
|
||||
int station = arr[25];
|
||||
Instruction inst = null;
|
||||
if (ikey != 0) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
@@ -330,7 +335,30 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
} else {
|
||||
log.info(device_code + "对应设备号为空!");
|
||||
}
|
||||
} else {
|
||||
} else if (phase == 0x64){
|
||||
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
|
||||
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
|
||||
if (ObjectUtil.isNotEmpty(dict)){
|
||||
dict.setValue("1");
|
||||
dict.setPara2(String.valueOf(agvaddr));
|
||||
dict.setPara3("下发成功");
|
||||
dictService.updateDetail(dict);
|
||||
}
|
||||
//充电成功
|
||||
}else if (phase == 0x65){
|
||||
log.info("AGV车号{}反馈充电中,充电桩{}",agvaddr,station);
|
||||
//充电取消上报
|
||||
}else if (phase == 0x66){
|
||||
log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
|
||||
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
|
||||
if (ObjectUtil.isNotEmpty(dict)){
|
||||
dict.setValue("0");
|
||||
dict.setPara2("");
|
||||
dict.setPara3("充电桩空闲");
|
||||
dictService.updateDetail(dict);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//上报异常信息
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
@@ -42,9 +43,12 @@ import org.nl.acs.task.service.impl.TaskServiceImpl;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -70,6 +74,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
TwoAgvPhase twoAgvPhase = new TwoAgvPhase();
|
||||
ISysDictService dictService = SpringContextHolder.getBean(ISysDictService.class);
|
||||
|
||||
String error_code = "0";
|
||||
int agvaddr = 0;
|
||||
@@ -93,6 +98,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
String error_type = "agv_error_type";
|
||||
Boolean isonline = true;
|
||||
Boolean iserror = false;
|
||||
boolean isCharge = false;
|
||||
|
||||
private synchronized void setErrorInfo(int error, String error_code, String error_message) {
|
||||
this.error = error;
|
||||
@@ -2206,6 +2212,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
} else if (phase == 0x73) {
|
||||
log.info("接收agv上报信息,phase == 0x73:" + phase);
|
||||
//agv电量
|
||||
electric_qty = ikey;
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
@@ -2214,6 +2221,53 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
//自动充电的车号
|
||||
String is_atuo_car = ISysParamService.findByCode(AcsConfig.IS_ATUO_CAR).getValue();
|
||||
//当前上报的车号
|
||||
String now_car = String.valueOf(this.agvaddr);
|
||||
//如果配置的车号是诺宝车号
|
||||
if(now_car.equals(is_atuo_car)){
|
||||
//是否开启自动充电
|
||||
String is_atuo_electric = ISysParamService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue();
|
||||
log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric);
|
||||
if("1".equals(is_atuo_electric)){
|
||||
String electric_begin = ISysParamService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue();
|
||||
String[] begins = electric_begin.split(":");
|
||||
String electric_end = ISysParamService.findByCode(AcsConfig.ELECTRIC_END).getValue();
|
||||
String[] ends = electric_end.split(":");
|
||||
// 定义时间段
|
||||
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();
|
||||
// 判断当前时间是否在时间段内
|
||||
boolean isInRange = !now.isBefore(startTime) && !now.isAfter(endTime);
|
||||
int electric = 0 ;
|
||||
//早上8-22点
|
||||
if(isInRange){
|
||||
electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC).getValue());
|
||||
}else{
|
||||
electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC2).getValue());
|
||||
}
|
||||
if (electric_qty>0 && electric_qty < electric) {
|
||||
log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty,electric);
|
||||
//判断是否已下发充电任务
|
||||
Dict dict1 = dictService.getDictByName3("station",String.valueOf(this.agvaddr),null);
|
||||
if(ObjectUtil.isNotEmpty(dict1)){
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",this.agvaddr,dict1.getPara1());
|
||||
}else{
|
||||
//未下发,判断是否有空闲充电桩
|
||||
Dict dict = dictService.getDictByName2("station");
|
||||
if(ObjectUtil.isNotEmpty(dict)){
|
||||
ndcAgvService.charge(String.valueOf(this.agvaddr));
|
||||
isCharge =true;
|
||||
}else{
|
||||
log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty,electric);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (phase == 0x74) {
|
||||
//三色灯状态
|
||||
status = ikey;
|
||||
|
||||
@@ -120,6 +120,17 @@ public class SysDictController {
|
||||
dictService.deleteDetail(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/initDict")
|
||||
@Log("初始化充电桩点位信息")
|
||||
public ResponseEntity<Object> initDict(@Validated @RequestBody Dict dto){
|
||||
dictService.initDict(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@GetMapping("/showDetail2")
|
||||
@Log("查询字典明细")
|
||||
public ResponseEntity<Object> showDetail2(@RequestParam String name){
|
||||
return new ResponseEntity<>(dictService.getDictByName(name), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,18 @@ class SysParamController {
|
||||
public ResponseEntity<Object> getValueByCode(@PathVariable String code) {
|
||||
return new ResponseEntity<>(paramService.findByCode(code), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/queryParam")
|
||||
@Log("查询自动充电配置")
|
||||
public ResponseEntity<Object> queryParam(){
|
||||
return new ResponseEntity<>(paramService.queryParam(), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/setParam")
|
||||
@Log("保存参数")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> setParam(@RequestBody Map whereJson) {
|
||||
paramService.setParam(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,4 +85,22 @@ public interface ISysDictService extends IService<Dict> {
|
||||
* @return
|
||||
*/
|
||||
List<Dict> queryAll();
|
||||
/**
|
||||
* 初始化充电桩点位信息
|
||||
* @param dto
|
||||
*/
|
||||
void initDict(Dict dto);
|
||||
/**
|
||||
* 获取字典明细
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Dict getDictByName2(String name);
|
||||
|
||||
/**
|
||||
* 获取字典明细
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Dict getDictByName3(String name,String carno,String station);
|
||||
}
|
||||
|
||||
@@ -205,4 +205,55 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
.groupBy(Dict::getCode, Dict::getName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void initDict(Dict dto) {
|
||||
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||
if (ObjectUtil.isEmpty(dict)) {
|
||||
throw new BadRequestException("字典不存在");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentNickName = SecurityUtils.getCurrentNickName();
|
||||
dict.setValue("0");
|
||||
dict.setPara2("");
|
||||
dict.setPara3("充电桩空闲");
|
||||
dict.setUpdate_id(currentUserId);
|
||||
dict.setUpdate_name(currentNickName);
|
||||
dict.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.updateById(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict getDictByName2(String name) {
|
||||
Dict dict = null;
|
||||
List<Dict> dictList = sysDictMapper.selectList(
|
||||
new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getCode, name)
|
||||
.eq(Dict::getValue, "0")
|
||||
.and(slam -> slam.isNull(Dict::getPara2)
|
||||
.or()
|
||||
.eq(Dict::getPara2, ""))
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dictList) && dictList.size()>0){
|
||||
dict = dictList.get(0);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict getDictByName3(String name,String carno,String station) {
|
||||
Dict dict = null;
|
||||
List<Dict> dictList = sysDictMapper.selectList(
|
||||
new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getCode, name)
|
||||
.eq(ObjectUtil.isNotEmpty(carno),Dict::getPara2, carno)
|
||||
.eq(ObjectUtil.isNotEmpty(station),Dict::getPara1, station)
|
||||
.eq(Dict::getValue,"1")
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dictList) && dictList.size()>0){
|
||||
dict = dictList.get(0);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,8 @@ public interface ISysParamService extends IService<Param> {
|
||||
* @return Param
|
||||
*/
|
||||
Param findByCode(String code);
|
||||
|
||||
Map<String, Object> queryParam();
|
||||
|
||||
void setParam(Map whereJson);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.acs.task.domain.Task;
|
||||
import org.nl.acs.utils.PageUtil;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -102,4 +104,70 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
Param param = paramMapper.selectOne(queryWrapper);
|
||||
return param;
|
||||
}
|
||||
|
||||
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 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,28 @@
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission" >
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-position"
|
||||
size="mini"
|
||||
@click="divOpen"
|
||||
>
|
||||
配置自动充电
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-position"
|
||||
size="mini"
|
||||
@click="divOpenStation"
|
||||
>
|
||||
充电桩管理
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
@@ -67,6 +88,8 @@
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
<tube-dialog2 :dialog-show.sync="showView2" @AddChanged="querytable" />
|
||||
<station-dialog :dialog-show.sync="showStation" @AddChanged="querytable" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -76,6 +99,8 @@ import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import TubeDialog2 from '@/views/system/param/tubeDialog2.vue'
|
||||
import StationDialog from '@/views/system/param/stationDialog.vue'
|
||||
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
@@ -90,7 +115,7 @@ const defaultForm = {
|
||||
}
|
||||
export default {
|
||||
name: 'Param',
|
||||
components: { pagination, crudOperation, udOperation },
|
||||
components: { pagination, crudOperation, udOperation, TubeDialog2, StationDialog },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: 'menu.table_title.SystemParam', url: 'api/param', idField: 'id', sort: 'id,desc', crudMethod: { ...crudParam },
|
||||
@@ -110,7 +135,8 @@ export default {
|
||||
edit: ['admin', 'param:edit'],
|
||||
del: ['admin', 'param:del']
|
||||
},
|
||||
|
||||
showView2: false,
|
||||
showStation: false,
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: this.$t('SysParam.rules.NotNull'), trigger: 'blur' }
|
||||
@@ -151,6 +177,15 @@ export default {
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
querytable() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
divOpen() {
|
||||
this.showView2 = true
|
||||
},
|
||||
divOpenStation() {
|
||||
this.showStation = true
|
||||
},
|
||||
webSocket() {
|
||||
const that = this
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
|
||||
@@ -30,5 +30,35 @@ export function getValueByCode(code) {
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
export function queryParam() {
|
||||
return request({
|
||||
url: '/api/param/queryParam',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getValueByCode }
|
||||
export function setParam(data) {
|
||||
return request({
|
||||
url: 'api/param/setParam',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function showDetail2(params) {
|
||||
return request({
|
||||
url: 'api/dict/showDetail2',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function initDict(data) {
|
||||
return request({
|
||||
url: 'api/dict/initDict',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getValueByCode, queryParam, setParam, showDetail2, initDict }
|
||||
|
||||
150
acs2/nladmin-ui/src/views/system/param/stationDialog.vue
Normal file
150
acs2/nladmin-ui/src/views/system/param/stationDialog.vue
Normal file
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
append-to-body
|
||||
v-loading.fullscreen.lock="fullscreenLoading"
|
||||
title="充电桩管理"
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1200px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<div class="grid-container">
|
||||
<el-table
|
||||
ref="table2"
|
||||
:data="tableDtl"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
:cell-style="cellStyle"
|
||||
border
|
||||
:highlight-current-row="true"
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
>
|
||||
<el-table-column v-if="false" prop="dict_id" label="uuid" align="center" />
|
||||
<el-table-column min-width="60" prop="label" label="充电桩名称" align="center" />
|
||||
<el-table-column prop="value" label="是否分配车辆(1是0否)" align="center" width="150" />
|
||||
<el-table-column min-width="60" prop="para1" label="充电桩站点" align="center" />
|
||||
<el-table-column min-width="50" prop="para2" label="当前车号" align="center" />
|
||||
<el-table-column min-width="60" prop="use_time" label="充电时长(H)" align="center" :formatter="Myduration" />
|
||||
<el-table-column min-width="60" prop="para3" label="充电状态" align="center" />
|
||||
<el-table-column prop="update_time" label="修改时间" align="center" />
|
||||
<el-table-column prop="update_name" label="修改人" align="center" />
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
label="操作"
|
||||
width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="handleClick(scope.row)" type="danger" size="small">初始化充电桩信息</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudParam, {updateDict} from '@/views/system/param/param'
|
||||
import { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'StationDialog',
|
||||
components: { },
|
||||
mixins: [crud()],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fullscreenLoading: false,
|
||||
tableDtl: [],
|
||||
form: {
|
||||
electric: 0,
|
||||
electric2: 0,
|
||||
electric_begin: '06:00',
|
||||
electric_end: '18:00'
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.queryTableDtl()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.tableDtl = []
|
||||
this.$emit('AddChanged')
|
||||
},
|
||||
Myduration(row, column) {
|
||||
const start = new Date(row.update_time)
|
||||
const end = new Date()
|
||||
const diffTime = Math.abs(end - start)
|
||||
let diffDays = 0
|
||||
if (row.para2 && row.para2 !== null) {
|
||||
diffDays = Math.ceil(diffTime / (1000 * 60 * 60)) // 转换为H
|
||||
}
|
||||
return diffDays
|
||||
},
|
||||
handleClick(row) {
|
||||
this.$confirm('此操作将初始化充电桩信息, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.fullscreenLoading = true
|
||||
debugger
|
||||
crudParam.initDict(row).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '初始化成功!'
|
||||
})
|
||||
this.fullscreenLoading = false
|
||||
this.queryTableDtl()
|
||||
}).catch(() => {
|
||||
this.fullscreenLoading = false
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消操作'
|
||||
})
|
||||
})
|
||||
},
|
||||
cellStyle({ row, column, rowIndex, columnIndex }) {
|
||||
if (column.property === 'use_time') {
|
||||
const start = new Date(row.update_time)
|
||||
const end = new Date()
|
||||
const diffTime = Math.abs(end - start)
|
||||
let diffDays = 0
|
||||
if (row.para2 && row.para2 !== null) {
|
||||
diffDays = Math.ceil(diffTime / (1000 * 60 * 60)) // 转换为H
|
||||
}
|
||||
|
||||
if (diffDays > 0 && diffDays <= 3) {
|
||||
return 'background: #13ce66'
|
||||
} else if (diffDays > 3) {
|
||||
return 'background: red'
|
||||
}
|
||||
}
|
||||
},
|
||||
queryTableDtl() {
|
||||
crudParam.showDetail2({ 'name': 'station' }).then(res => {
|
||||
this.tableDtl = res
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
136
acs2/nladmin-ui/src/views/system/param/tubeDialog2.vue
Normal file
136
acs2/nladmin-ui/src/views/system/param/tubeDialog2.vue
Normal file
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
append-to-body
|
||||
title="自动充电配置"
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="800px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" :inline-message="true" label-width="150px">
|
||||
<el-form-item label="白班充电阈值(%):" prop="electric">
|
||||
<el-input-number v-model="form.electric" size="medium" :min="1" :max="100" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="晚班充电阈值(%):" prop="electric2">
|
||||
<el-input-number v-model="form.electric2" size="medium" :min="1" :max="100" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="白班开始时间:" prop="electric_begin">
|
||||
<el-time-select
|
||||
v-model="form.electric_begin"
|
||||
size="medium"
|
||||
:picker-options="{
|
||||
start: '06:00',
|
||||
step: '00:15',
|
||||
end: '12:00'
|
||||
}"
|
||||
placeholder="白班开始时间">
|
||||
</el-time-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="白班结束时间:" prop="electric_end">
|
||||
<el-time-select
|
||||
v-model="form.electric_end"
|
||||
size="medium"
|
||||
:picker-options="{
|
||||
start: '18:00',
|
||||
step: '00:15',
|
||||
end: '23:45'
|
||||
}"
|
||||
placeholder="白班结束时间">
|
||||
</el-time-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="save">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudParam from '@/views/system/param/param'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'TubeDialog2',
|
||||
components: { },
|
||||
mixins: [crud()],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
rules: {
|
||||
electric: [
|
||||
{ required: true, message: '请输入白班充电阈值(%)', trigger: 'blur' }
|
||||
],
|
||||
electric2: [
|
||||
{ required: true, message: '请输入晚班充电阈值(%)', trigger: 'blur' }
|
||||
],
|
||||
electric_begin: [
|
||||
{ required: true, message: '请输入白班开始时间', trigger: 'blur' }
|
||||
],
|
||||
electric_end: [
|
||||
{ required: true, message: '请输入白班结束时间', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
form: {
|
||||
electric: 0,
|
||||
electric2: 0,
|
||||
electric_begin: '06:00',
|
||||
electric_end: '18:00'
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.queryTableDtl()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.form.electric = 0
|
||||
this.form.electric2 = 0
|
||||
this.form.electric_begin = '06:00'
|
||||
this.form.electric_end = '18:00'
|
||||
this.$emit('AddChanged')
|
||||
},
|
||||
save() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.save_my()
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
save_my() {
|
||||
crudParam.setParam(this.form).then(res => {
|
||||
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.close()
|
||||
})
|
||||
},
|
||||
queryTableDtl() {
|
||||
crudParam.queryParam().then(res => {
|
||||
this.form.electric = res.electric
|
||||
this.form.electric2 = res.electric2
|
||||
this.form.electric_begin = res.electric_begin
|
||||
this.form.electric_end = res.electric_end
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user