配置充电时间
This commit is contained in:
parent
25082c5784
commit
c850f2e315
@ -39,4 +39,15 @@ public class CommonConfigVO {
|
||||
@Schema(description = "遇障告警设置-等待时间")
|
||||
private Integer warnWaitTime;
|
||||
|
||||
@Schema(description = "每天(0:未勾选(1次)、1:勾选)")
|
||||
private Integer everyDay;
|
||||
|
||||
@Schema(description = "未勾选(1次)--开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime onceStartTime;
|
||||
|
||||
@Schema(description = "未勾选(1次)--结束时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime onceEndTime;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.system.enums.robot;
|
||||
package cn.iocoder.yudao.module.system.enums.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.system.job.robot;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotTaskService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.job.AutoChargeService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.job.RobotTaskAutoMoveService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.pathplanning.RobotPathPlanningService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -37,8 +39,11 @@ public class RobotJob {
|
||||
@Autowired
|
||||
private AutoChargeService autoChargeService;
|
||||
|
||||
//下发任务给车机
|
||||
@XxlJob("DistributeTasksJob")
|
||||
@Autowired
|
||||
private RobotPathPlanningService robotPathPlanningService;
|
||||
|
||||
//下发任务给车机---废弃---因为这一版没有结合路径规划
|
||||
// @XxlJob("DistributeTasksJob")
|
||||
@TenantJob
|
||||
public void distributeTasksJob() throws InterruptedException {
|
||||
log.info("----下发任务给车机----");
|
||||
@ -57,8 +62,8 @@ public class RobotJob {
|
||||
}
|
||||
}
|
||||
|
||||
//下发自动移库任务
|
||||
@XxlJob("DistributeAutoMoveJob")
|
||||
//下发自动移库任务--- 废弃---产品不要自动移库
|
||||
// @XxlJob("DistributeAutoMoveJob")
|
||||
@TenantJob
|
||||
public void distributeAutoMoveJob() throws InterruptedException {
|
||||
log.info("----下发自动移库任务----");
|
||||
@ -101,6 +106,27 @@ public class RobotJob {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发任务给路径规划
|
||||
*/
|
||||
@XxlJob("DistributeTasksToPathPlanningJob")
|
||||
@TenantJob
|
||||
public void DistributeTasksToPathPlanningJob() {
|
||||
|
||||
RLock lock = redissonUtils.getLock(RobotCacheLockEnum.ROBOT_TASK_DISTRIBUTE_LOCK.getKey());
|
||||
if (lock.tryLock()){
|
||||
try {
|
||||
log.info("----下发任务给路径规划----");
|
||||
robotPathPlanningService.sendTaskToPP();
|
||||
} catch (Exception e) {
|
||||
log.error("下发任务给路径规划现异常 :{}",e);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}else {
|
||||
log.info("下发任务给路径规划未获取到锁");
|
||||
throw exception(REDISSON_NOT_OBTAIN_LOCK);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,23 @@
|
||||
package cn.iocoder.yudao.module.system.service.config;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.config.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.config.CommonConfigMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -35,17 +43,80 @@ public class CommonConfigServiceImpl implements CommonConfigService {
|
||||
public Long createConfig(CommonConfigSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
CommonConfigDO config = BeanUtils.toBean(createReqVO, CommonConfigDO.class);
|
||||
|
||||
if (ZeroOneEnum.ONE.getType().equals(config.getConfigType())) {
|
||||
CommonConfigVO chargeConfig= JSONUtil.toBean(config.getConfigStr(),CommonConfigVO.class);
|
||||
//一次
|
||||
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
||||
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
||||
setOnceStartTimeConfig(config,chargeConfig);
|
||||
}
|
||||
}
|
||||
|
||||
configMapper.insert(config);
|
||||
// 返回
|
||||
return config.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置一次的开始时间和结束时间
|
||||
* @param config
|
||||
* @param chargeConfig
|
||||
*/
|
||||
private void setOnceStartTimeConfig(CommonConfigDO config, CommonConfigVO chargeConfig) {
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime nowEnd = LocalDateTime.now();
|
||||
|
||||
if (now.isAfter(chargeConfig.getScheduleChargeEndTime())) {
|
||||
now.plusDays(1);
|
||||
nowEnd.plusDays(1);
|
||||
}
|
||||
|
||||
LocalDateTime s = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(),
|
||||
chargeConfig.getScheduleChargeStartTime().getHour(),
|
||||
chargeConfig.getScheduleChargeStartTime().getMinute(), 00);
|
||||
|
||||
LocalDateTime e = LocalDateTime.of(nowEnd.getYear(), nowEnd.getMonth(), nowEnd.getDayOfMonth(),
|
||||
chargeConfig.getScheduleChargeEndTime().getHour(),
|
||||
chargeConfig.getScheduleChargeEndTime().getMinute(), 00);
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String onceStartTime = s.format(formatter);
|
||||
String onceEndTime = e.format(formatter);
|
||||
|
||||
JSONObject jsonObject = new JSONObject(config.getConfigStr());
|
||||
jsonObject.put("onceStartTime", onceStartTime);
|
||||
jsonObject.put("onceEndTime", onceEndTime);
|
||||
|
||||
String str = JSON.toJSONString(jsonObject);
|
||||
|
||||
config.setConfigStr(str);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfig(CommonConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateConfigExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CommonConfigDO updateObj = BeanUtils.toBean(updateReqVO, CommonConfigDO.class);
|
||||
|
||||
if (ZeroOneEnum.ONE.getType().equals(updateReqVO.getConfigType())) {
|
||||
CommonConfigVO chargeConfig= JSONUtil.toBean(updateReqVO.getConfigStr(),CommonConfigVO.class);
|
||||
//一次
|
||||
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
||||
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
||||
setOnceStartTimeConfig(updateObj,chargeConfig);
|
||||
}else if(ZeroOneEnum.ONE.getType().equals(chargeConfig.getEveryDay()) ) {
|
||||
JSONObject jsonObject = new JSONObject(updateObj.getConfigStr());
|
||||
jsonObject.put("onceStartTime", "");
|
||||
jsonObject.put("onceEndTime", "");
|
||||
String str = JSON.toJSONString(jsonObject);
|
||||
updateObj.setConfigStr(str);
|
||||
}
|
||||
}
|
||||
|
||||
configMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotChargeLogMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.config.CommandConfigTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
|
||||
@ -155,6 +156,8 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
||||
|
||||
chargeLogMapper.insertBatch(logs);
|
||||
|
||||
//todo 发送给路PP
|
||||
|
||||
//改成异步
|
||||
logs.stream().forEach(v -> {
|
||||
String chargeModelKey = RobotTaskChcheConstant.ROBOT_CHARGE_MODEL +v.getRobotNo();
|
||||
|
@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskAutoMoveMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -0,0 +1,5 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot.pathplanning;
|
||||
|
||||
public interface RobotPathPlanningService {
|
||||
void sendTaskToPP();
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot.pathplanning;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.RobotTaskApi;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.config.CommonConfigMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
@Autowired
|
||||
private RobotInformationMapper robotInformationMapper;
|
||||
|
||||
@Autowired
|
||||
private RobotTaskMapper robotTaskMapper;
|
||||
|
||||
@Autowired
|
||||
private RobotTaskDetailMapper robotTaskDetailMapper;
|
||||
|
||||
@Resource
|
||||
private RobotTaskApi robotTaskApi;
|
||||
|
||||
@Resource
|
||||
private PositionMapItemMapper positionMapItemMapper;
|
||||
|
||||
@Value("${zn.init_height:0.0}")
|
||||
private double initHeight;
|
||||
|
||||
@Value("${zn.scan_height:0.4}")
|
||||
private double scanHeight;
|
||||
|
||||
@Value("${zn.parm:5000}")
|
||||
private Integer parm;
|
||||
|
||||
@Value("${zn.lift_height:0.1}")
|
||||
private double liftHeight;
|
||||
|
||||
@Value("${zn.move_height:0.1}")
|
||||
private double moveHeight;
|
||||
|
||||
@Value("${zn.full_electricity:100}")
|
||||
private String fullElectricity;
|
||||
|
||||
@Resource
|
||||
private CommonConfigMapper configMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private WareHouseLocationMapper locationMapper;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 下发任务给PP
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendTaskToPP() {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user