小车充电调度初始化

This commit is contained in:
liuhanqing
2025-11-21 16:49:58 +08:00
parent e58b6ce7c4
commit 23633601cf
7 changed files with 962 additions and 4 deletions

View File

@@ -0,0 +1,104 @@
package com.ruoyi.job.charg.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.job.charg.domain.SrgvChargingJob;
import com.ruoyi.job.charg.service.ISrgvChargingJobService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 充电任务Controller
*
* @author ruoyi
* @date 2025-11-21
*/
@RestController
@RequestMapping("/job/charging")
public class SrgvChargingJobController extends BaseController
{
@Autowired
private ISrgvChargingJobService srgvChargingJobService;
/**
* 查询充电任务列表
*/
@PreAuthorize("@ss.hasPermi('job:charging:list')")
@GetMapping("/list")
public TableDataInfo list(SrgvChargingJob srgvChargingJob)
{
startPage();
List<SrgvChargingJob> list = srgvChargingJobService.selectSrgvChargingJobList(srgvChargingJob);
return getDataTable(list);
}
/**
* 导出充电任务列表
*/
@PreAuthorize("@ss.hasPermi('job:charging:export')")
@Log(title = "充电任务", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SrgvChargingJob srgvChargingJob)
{
List<SrgvChargingJob> list = srgvChargingJobService.selectSrgvChargingJobList(srgvChargingJob);
ExcelUtil<SrgvChargingJob> util = new ExcelUtil<SrgvChargingJob>(SrgvChargingJob.class);
util.exportExcel(response, list, "充电任务数据");
}
/**
* 获取充电任务详细信息
*/
@PreAuthorize("@ss.hasPermi('job:charging:query')")
@GetMapping(value = "/{guid}")
public AjaxResult getInfo(@PathVariable("guid") String guid)
{
return success(srgvChargingJobService.selectSrgvChargingJobByGuid(guid));
}
/**
* 新增充电任务
*/
@PreAuthorize("@ss.hasPermi('job:charging:add')")
@Log(title = "充电任务", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SrgvChargingJob srgvChargingJob)
{
return toAjax(srgvChargingJobService.insertSrgvChargingJob(srgvChargingJob));
}
/**
* 修改充电任务
*/
@PreAuthorize("@ss.hasPermi('job:charging:edit')")
@Log(title = "充电任务", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SrgvChargingJob srgvChargingJob)
{
return toAjax(srgvChargingJobService.updateSrgvChargingJob(srgvChargingJob));
}
/**
* 删除充电任务
*/
@PreAuthorize("@ss.hasPermi('job:charging:remove')")
@Log(title = "充电任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{guids}")
public AjaxResult remove(@PathVariable String[] guids)
{
return toAjax(srgvChargingJobService.deleteSrgvChargingJobByGuids(guids));
}
}

View File

@@ -0,0 +1,157 @@
package com.ruoyi.job.charg.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 充电任务对象 srgv_charging_job
*
* @author ruoyi
* @date 2025-11-21
*/
public class SrgvChargingJob extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** uuid */
private String guid;
/** 充电桩站点 */
@Excel(name = "充电桩站点")
private String chargingSite;
/** 任务状态:1初始;2允许生成四向车;3执行中 */
@Excel(name = "任务状态:1初始;2允许生成四向车;3执行中")
private String jobStatus;
/** 充电状态:1未充电;2充电中 */
@Excel(name = "充电状态:1未充电;2充电中")
private String chargingStatus;
/** 开始时间 */
@Excel(name = "开始时间")
private String startDate;
/** 充电时间 */
@Excel(name = "充电时间")
private String chargingDate;
/** 任务类型:1去充电;2离开充电 */
@Excel(name = "任务类型:1去充电;2离开充电")
private String jobType;
/** 执行小车 */
@Excel(name = "执行小车")
private String agvId;
/** 充电桩编号 */
@Excel(name = "充电桩编号")
private String chargingId;
public void setGuid(String guid)
{
this.guid = guid;
}
public String getGuid()
{
return guid;
}
public void setChargingSite(String chargingSite)
{
this.chargingSite = chargingSite;
}
public String getChargingSite()
{
return chargingSite;
}
public void setJobStatus(String jobStatus)
{
this.jobStatus = jobStatus;
}
public String getJobStatus()
{
return jobStatus;
}
public void setChargingStatus(String chargingStatus)
{
this.chargingStatus = chargingStatus;
}
public String getChargingStatus()
{
return chargingStatus;
}
public void setStartDate(String startDate)
{
this.startDate = startDate;
}
public String getStartDate()
{
return startDate;
}
public void setChargingDate(String chargingDate)
{
this.chargingDate = chargingDate;
}
public String getChargingDate()
{
return chargingDate;
}
public void setJobType(String jobType)
{
this.jobType = jobType;
}
public String getJobType()
{
return jobType;
}
public void setAgvId(String agvId)
{
this.agvId = agvId;
}
public String getAgvId()
{
return agvId;
}
public void setChargingId(String chargingId)
{
this.chargingId = chargingId;
}
public String getChargingId()
{
return chargingId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("guid", getGuid())
.append("chargingSite", getChargingSite())
.append("jobStatus", getJobStatus())
.append("chargingStatus", getChargingStatus())
.append("startDate", getStartDate())
.append("chargingDate", getChargingDate())
.append("jobType", getJobType())
.append("agvId", getAgvId())
.append("chargingId", getChargingId())
.toString();
}
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.job.charg.mapper;
import java.util.List;
import com.ruoyi.job.charg.domain.SrgvChargingJob;
/**
* 充电任务Mapper接口
*
* @author ruoyi
* @date 2025-11-21
*/
public interface SrgvChargingJobMapper
{
/**
* 查询充电任务
*
* @param guid 充电任务主键
* @return 充电任务
*/
public SrgvChargingJob selectSrgvChargingJobByGuid(String guid);
/**
* 查询充电任务列表
*
* @param srgvChargingJob 充电任务
* @return 充电任务集合
*/
public List<SrgvChargingJob> selectSrgvChargingJobList(SrgvChargingJob srgvChargingJob);
/**
* 新增充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
public int insertSrgvChargingJob(SrgvChargingJob srgvChargingJob);
/**
* 修改充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
public int updateSrgvChargingJob(SrgvChargingJob srgvChargingJob);
/**
* 删除充电任务
*
* @param guid 充电任务主键
* @return 结果
*/
public int deleteSrgvChargingJobByGuid(String guid);
/**
* 批量删除充电任务
*
* @param guids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSrgvChargingJobByGuids(String[] guids);
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.job.charg.service;
import java.util.List;
import com.ruoyi.job.charg.domain.SrgvChargingJob;
/**
* 充电任务Service接口
*
* @author ruoyi
* @date 2025-11-21
*/
public interface ISrgvChargingJobService
{
/**
* 查询充电任务
*
* @param guid 充电任务主键
* @return 充电任务
*/
public SrgvChargingJob selectSrgvChargingJobByGuid(String guid);
/**
* 查询充电任务列表
*
* @param srgvChargingJob 充电任务
* @return 充电任务集合
*/
public List<SrgvChargingJob> selectSrgvChargingJobList(SrgvChargingJob srgvChargingJob);
/**
* 新增充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
public int insertSrgvChargingJob(SrgvChargingJob srgvChargingJob);
/**
* 修改充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
public int updateSrgvChargingJob(SrgvChargingJob srgvChargingJob);
/**
* 批量删除充电任务
*
* @param guids 需要删除的充电任务主键集合
* @return 结果
*/
public int deleteSrgvChargingJobByGuids(String[] guids);
/**
* 删除充电任务信息
*
* @param guid 充电任务主键
* @return 结果
*/
public int deleteSrgvChargingJobByGuid(String guid);
}

View File

@@ -0,0 +1,93 @@
package com.ruoyi.job.charg.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.job.charg.mapper.SrgvChargingJobMapper;
import com.ruoyi.job.charg.domain.SrgvChargingJob;
import com.ruoyi.job.charg.service.ISrgvChargingJobService;
/**
* 充电任务Service业务层处理
*
* @author ruoyi
* @date 2025-11-21
*/
@Service
public class SrgvChargingJobServiceImpl implements ISrgvChargingJobService
{
@Autowired
private SrgvChargingJobMapper srgvChargingJobMapper;
/**
* 查询充电任务
*
* @param guid 充电任务主键
* @return 充电任务
*/
@Override
public SrgvChargingJob selectSrgvChargingJobByGuid(String guid)
{
return srgvChargingJobMapper.selectSrgvChargingJobByGuid(guid);
}
/**
* 查询充电任务列表
*
* @param srgvChargingJob 充电任务
* @return 充电任务
*/
@Override
public List<SrgvChargingJob> selectSrgvChargingJobList(SrgvChargingJob srgvChargingJob)
{
return srgvChargingJobMapper.selectSrgvChargingJobList(srgvChargingJob);
}
/**
* 新增充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
@Override
public int insertSrgvChargingJob(SrgvChargingJob srgvChargingJob)
{
return srgvChargingJobMapper.insertSrgvChargingJob(srgvChargingJob);
}
/**
* 修改充电任务
*
* @param srgvChargingJob 充电任务
* @return 结果
*/
@Override
public int updateSrgvChargingJob(SrgvChargingJob srgvChargingJob)
{
return srgvChargingJobMapper.updateSrgvChargingJob(srgvChargingJob);
}
/**
* 批量删除充电任务
*
* @param guids 需要删除的充电任务主键
* @return 结果
*/
@Override
public int deleteSrgvChargingJobByGuids(String[] guids)
{
return srgvChargingJobMapper.deleteSrgvChargingJobByGuids(guids);
}
/**
* 删除充电任务信息
*
* @param guid 充电任务主键
* @return 结果
*/
@Override
public int deleteSrgvChargingJobByGuid(String guid)
{
return srgvChargingJobMapper.deleteSrgvChargingJobByGuid(guid);
}
}

View File

@@ -4,12 +4,15 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.bas.port.domain.WcsPort;
import com.ruoyi.bas.port.service.IWcsPortService;
import com.ruoyi.common.domain.SendData2;
import com.ruoyi.device.srgv.domain.DeviceSrgv;
import com.ruoyi.job.charg.domain.SrgvChargingJob;
import com.ruoyi.job.charg.service.ISrgvChargingJobService;
import com.ruoyi.queue.srgv.domain.WcsSrgvQueue;
import com.ruoyi.queue.srgv.domain.WcsSrgvQueueFinish;
import com.ruoyi.queue.srgv.service.IWcsSrgvQueueFinishService;
@@ -34,6 +37,8 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
public IWcsPortService wcsPortService;
public ISrgvChargingJobService srgvChargingJobMapper;
public void init() {
@@ -93,13 +98,161 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
* 小车离开充电桩
*/
private void outCharging(DeviceSrgv deviceSrgv, int floor) {
SrgvChargingJob wcsChargingJob = new SrgvChargingJob();
wcsChargingJob.setJobType("2");//离开充电
//wcsChargingJob.setChargingStatus("0");//未接通
List<SrgvChargingJob> wcsChargingJobs = wcsChargingJobMapper.selectWcsChargingJobList(wcsChargingJob);
for (SrgvChargingJob chargingJob : wcsChargingJobs) {
String chargingStatus = chargingJob.getChargingStatus();
String agvId = chargingJob.getAgvId();
String chargingSite = chargingJob.getChargingSite();//充电桩站点
String startDate = chargingJob.getStartDate();
List<SRGVPlc> rgvs = srgvPlcs.stream().filter(srgv -> Objects.equals(srgv.getAgvData().getAgvId(), agvId) && srgv.getAgvData().getStatus() != 3).collect(Collectors.toList());
if ("1".equals(chargingStatus)) {
if (rgvs.size() > 0) {
SRGVPlc srgvPlc = rgvs.get(0);
String currSite = srgvPlc.getAgvData().getCurrSite();
if (!Objects.equals(currSite, chargingSite)) {
wcsChargingJobMapper.deleteWcsChargingJobByGuid(chargingJob.getGuid());//删除任务
}
} else {
//删除
}
continue;
}
//是否已经有任务
WcsSrgvQueue wcsSagvQueue = new WcsSrgvQueue();
wcsSagvQueue.setAgvId(agvId);
List<WcsSrgvQueue> wcsSagvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSagvQueue);
if (wcsSagvQueues.size() > 0) {
//时间大于30分钟,可以删除
boolean overHalfHour = TimeCompareUtil.isOverHalfHour(startDate, 30);
if (overHalfHour) {
wcsChargingJobMapper.deleteWcsChargingJobByGuid(chargingJob.getGuid());//删除任务
}
continue;
}
String currSite = deviceSrgv.getCurrSite();
String endSite = null;
if (!Objects.equals(currSite, chargingSite)) {
//已经在等待点
srgvChargingJobMapper.deleteSrgvChargingJobByGuid(chargingJob.getGuid());//删除任务
}
//获取所有待机点
List<String> collect = waitManager.listWcsFreeWait(floor).stream().map(wf -> wf.getSiteAddress()).collect(Collectors.toList());
//agv不在当前站点,不在待机点添加
if (endSite != null && !Objects.equals(currSite, endSite) && !collect.contains(currSite)) {
//生成去充电的任务
WcsSrgvQueue wsq = new WcsSrgvQueue();
wsq.setGuid(IdUtil.fastSimpleUUID());
/* HashMap<String, String> map = new HashMap<>();
map.put("type", "10");
wcsIdMapper.getTask(map);
String taskNo = map.get("result");*/
wsq.setTaskNo("");
wsq.setTaskType("1");
wsq.setPriority(10L);
wsq.setCargo("2");
wsq.setIssued("0");
wsq.setPathInfo(null);
wsq.setExecutionStatus("1");
wsq.setCargoPickSite(currSite);
wsq.setCargoPlaceSite(endSite);
wsq.setStartSite(currSite);
wsq.setEndSite(endSite);
wsq.setTheFloor(floor + "");
wsq.setTrunPath(null);
wsq.setUpDownSite(currSite);
wsq.setCreateDate(DateUtil.now());
wsq.setDefault06(chargingJob.getGuid());
wsq.setAgvId(agvId);
wsq.setDefault02("4");//点到点任务
wcsSagvQueueMapper.insertWcsSrgvQueue(wsq);
}
}
}
/**
* 小车充电任务
*/
private void inCharging(DeviceSrgv deviceSrgv, int floor) {
SrgvChargingJob wcsChargingJob = new SrgvChargingJob();
wcsChargingJob.setJobType("1");//去充电任务
wcsChargingJob.setJobStatus("1");
//wcsChargingJob.setChargingStatus("1");//未接通
List<SrgvChargingJob> wcsChargingJobs = srgvChargingJobMapper.selectSrgvChargingJobList(wcsChargingJob);
for (SrgvChargingJob chargingJob : wcsChargingJobs) {
String agvId = chargingJob.getAgvId();
String chargingSite = chargingJob.getChargingSite();//充电桩站点
String currSite = deviceSrgv.getCurrSite();
if (!Objects.equals(currSite, chargingSite)) {
//是否已经有任务
WcsSrgvQueue wcsSagvQueue = new WcsSrgvQueue();
wcsSagvQueue.setAgvId(agvId);
List<WcsSrgvQueue> wcsSagvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSagvQueue);
if (wcsSagvQueues.size() == 0) {
//生成去充电的任务
WcsSrgvQueue wsq = new WcsSrgvQueue();
wsq.setGuid(IdUtil.fastSimpleUUID());
/*HashMap<String, String> map = new HashMap<>();
map.put("type", "6");
wcsIdMapper.getTask(map);
String taskNo = map.get("result");*/
wsq.setTaskNo("");
wsq.setTaskType("1");
wsq.setPriority(10L);
wsq.setCargo("2");
wsq.setIssued("0");
wsq.setPathInfo(null);
wsq.setExecutionStatus("1");
wsq.setCargoPickSite(currSite);
wsq.setCargoPlaceSite(chargingSite);
wsq.setStartSite(currSite);
wsq.setEndSite(chargingSite);
wsq.setTheFloor(floor + "");
wsq.setTrunPath(null);
wsq.setUpDownSite(currSite);
wsq.setCreateDate(DateUtil.now());
wsq.setDefault06(chargingJob.getGuid());
wsq.setAgvId(agvId);
wsq.setDefault02("3");//3充电
wcsSagvQueueMapper.insertWcsSrgvQueue(wsq);
}
}
}
}
/**
* 小车发送任务
@@ -162,7 +315,96 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
/**
* 小车发送点对点任务
*/
private void sendPointToPointTask(DeviceSrgv deviceSrgv, WcsSrgvQueue wcsSrgvQueue, String currSite, String startSite, int floor) {
private void sendPointToPointTask(DeviceSrgv deviceSrgv, WcsSrgvQueue wcsSrgvQueue, String startSite, String endSite, int floor) {
//获取当前地图
Map<String, int[]> arrByRoadSite = roadCacheService.getArrByRoadSite(floor);
//获取空载地图
int[][] emptyMap = roadCacheService.findEmptyMap(floor, arrByRoadSite.get(startSite)[0], arrByRoadSite.get(startSite)[1], arrByRoadSite.get(endSite)[0], arrByRoadSite.get(endSite)[1], splc);
//计算最短路径
List<int[]> shortestPath = PathFinder.findShortestPath(emptyMap, arrByRoadSite.get(startSite)[0], arrByRoadSite.get(startSite)[1], arrByRoadSite.get(endSite)[0], arrByRoadSite.get(endSite)[1]);
//判断是否能规划出最短路径
if (shortestPath == null || shortestPath.isEmpty()) {
return;
}
//获取拐点路径
List<int[]> trun = PathFinder.extractInflectionPoints2(shortestPath, emptyMap);
// 路径点拼接
StringBuilder pathBuilder = new StringBuilder();
Map<String, String> roadSiteByArr = roadCacheService.getRoadSiteByArr(floor);
for (int[] point : shortestPath) {
String site = roadSiteByArr.get(point[0] + "," + point[1]);
if (!"000".equals(site)) {
pathBuilder.append(site).append(",");
}
}
if (pathBuilder.length() > 0) {
pathBuilder.setLength(pathBuilder.length() - 1); // 移除最后一个逗号
}
// 拐点拼接
StringBuilder inflectionBuilder = new StringBuilder();
if (!trun.isEmpty()) {
for (int[] ints : trun) {
String site = roadSiteByArr.get(ints[0] + "," + ints[1]);//获取站点
inflectionBuilder.append(site).append(",");
}
if (inflectionBuilder.length() > 0) {
inflectionBuilder.setLength(inflectionBuilder.length() - 1);
}
// 当trun长度小于6时,后面用0拼接
if (trun.size() < 6) {
for (int i = trun.size(); i < 6; i++) {
inflectionBuilder.append(",0");
}
}
}
List<SendData2> sendDataList = new ArrayList<>();
if (!trun.isEmpty()) {
SendData2 path = new SendData2();
path.setAddress("4000");//地址
path.setData(startSite + "," + endSite + "," + inflectionBuilder.toString());
path.setType(2);
sendDataList.add(path);
} else {
SendData2 path = new SendData2();
path.setAddress("4000");//地址
path.setData(startSite + "," + endSite);
path.setType(2);
sendDataList.add(path);
}
//任务号、原、目标数据转换
String siteId = wcsSrgvQueue.getTaskNo() + "1";//+ "," + startSite + "," + endSite;
SendData2 site = new SendData2();
site.setAddress("4400");
site.setData(siteId);
site.setType(2);
sendDataList.add(site);
//任务类型转换
SendData2 taskType = new SendData2();
taskType.setAddress("2200");
taskType.setData(wcsSrgvQueue.getTaskType());
taskType.setType(1);
sendDataList.add(taskType);
//下发标志转换
SendData2 flag = new SendData2();
flag.setAddress("2202");
flag.setData("1");
flag.setType(1);
sendDataList.add(flag);
//下发数据
boolean b = sendCarTask(sendDataList, deviceSrgv);
}
/**
@@ -190,10 +432,157 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
/**
* 小车发送载货任务
*/
private boolean sendFullCarTask(DeviceSrgv deviceSrgv, WcsSrgvQueue wcsSrgvQueue, String currSite, String endSite) {
private boolean sendFullCarTask(DeviceSrgv deviceSrgv, WcsSrgvQueue wcsSrgvQueue, String startSite, String endSite, int floor) {
//0 待机 1去向原站 2 到达原站托盘定位 3 上升至中位顶取货物 4生成去向目标站路径
// 5去向目标站 6下降至低位放货,工作完成,将阶段设置为0. 20:执行点到点命令运行中 21:到达点到目标位置 22:小车充电中
int workPhase = deviceSrgv.getWorkPhase();
int status = deviceSrgv.getStatus();// 0:未知 1:待机 2:运行 3:报警
int workMode = deviceSrgv.getWorkMode();
//取货规划路径和下发,在货底下,并且待机,任务未被下发
if ((workPhase == 0) && status == 1 && workMode == 5) {
//查找载货路径
Map<String, int[]> arrByRoadSite = roadCacheService.getArrByRoadSite(floor);
//获取空载地图(剔除不包含自己的障碍)(250919,排除其他站点)
String noTar0 = null;
String noTar1 = null;
if ("3".equals(wcsSrgvQueue.getCargo())) {
noTar0 = getNoTar(startSite);
noTar1 = getNoTar(endSite);
} else if ("1".equals(wcsSrgvQueue.getCargo())) {
noTar1 = getNoTar(endSite);
} else if ("2".equals(wcsSrgvQueue.getCargo())) {
noTar0 = getNoTar(startSite);
}
int[][] fullMap = null;
if (noTar0 == null && noTar1 == null) {
fullMap = roadCacheService.findFullMap(floor, arrByRoadSite.get(startSite)[0], arrByRoadSite.get(startSite)[1], arrByRoadSite.get(endSite)[0], arrByRoadSite.get(endSite)[1], splc);
} else {
List<String> strings = new ArrayList<>();//排除站点
if (noTar0 != null) {
strings.add(noTar0);
}
if (noTar1 != null) {
strings.add(noTar1);
}
fullMap = roadCacheService.findFullMap(floor, arrByRoadSite.get(startSite)[0], arrByRoadSite.get(startSite)[1], arrByRoadSite.get(endSite)[0], arrByRoadSite.get(endSite)[1], splc, strings);
}
//计算最短路径
List<int[]> shortestPath = PathFinder.findShortestPathFrom2To2Or1(fullMap, arrByRoadSite.get(startSite)[0], arrByRoadSite.get(startSite)[1], arrByRoadSite.get(endSite)[0], arrByRoadSite.get(endSite)[1]);
//判断是否能规划出最短路径
if (shortestPath == null || shortestPath.isEmpty()) {
//空车从当前点去目标点没有可以路径,校验是否是同层其他车影响,要上次其他车避让任务
return false;
}
//获取拐点路径
List<int[]> trun = PathFinder.extractInflectionPoints2(shortestPath, fullMap);
// 路径点拼接
StringBuilder pathBuilder = new StringBuilder();
Map<String, String> roadSiteByArr = roadCacheService.getRoadSiteByArr(Integer.parseInt(wcsSrgvQueue.getTheFloor()));
for (int[] point : shortestPath) {
String site = roadSiteByArr.get(point[0] + "," + point[1]);
if (!"000".equals(site)) {
pathBuilder.append(site).append(",");
}
}
if (pathBuilder.length() > 0) {
pathBuilder.setLength(pathBuilder.length() - 1); // 移除最后一个逗号
}
// 拐点拼接
StringBuilder inflectionBuilder = new StringBuilder();
if (!trun.isEmpty()) {
for (int[] ints : trun) {
String site = roadSiteByArr.get(ints[0] + "," + ints[1]);//获取站点
inflectionBuilder.append(site).append(",");
}
if (inflectionBuilder.length() > 0) {
inflectionBuilder.setLength(inflectionBuilder.length() - 1);
}
// 当trun长度小于6时,后面用0拼接
if (trun.size() < 6) {
for (int i = trun.size(); i < 6; i++) {
inflectionBuilder.append(",0");
}
}
}
List<SendData2> sendDataList = new ArrayList<>();
if (!trun.isEmpty()) {
SendData2 path = new SendData2();
path.setAddress("4000");//地址
path.setData(startSite + "," + endSite + "," + inflectionBuilder);
path.setType(2);
sendDataList.add(path);
} else {
SendData2 path = new SendData2();
path.setAddress("4000");//地址
path.setData(startSite + "," + endSite);
path.setType(2);
sendDataList.add(path);
}
String siteId = wcsSrgvQueue.getTaskNo();//+ "," + startSite + "," + endSite;
SendData2 site = new SendData2();
site.setAddress("4400");
site.setData(siteId);
site.setType(2);
sendDataList.add(site);
//下发类型
SendData2 taskType = new SendData2();
taskType.setAddress("2200");
taskType.setData(wcsSrgvQueue.getTaskType());
taskType.setType(1);
sendDataList.add(taskType);
//下发标志转换
SendData2 flag = new SendData2();
flag.setAddress("2202");
flag.setData("1");
flag.setType(1);
sendDataList.add(flag);
//boolean write = true;
return sendCarTask(sendDataList, deviceSrgv);
}
return false;
}
/*
* 获取特俗区域的母通道排除站点
*
* */
private String getNoTar(String site) {
String s = site.substring(site.length() - 4);
String p = site.substring(0, 2);
int pi = Integer.parseInt(p);
String l = site.substring(2, 4);
int li = Integer.parseInt(l);//排
String tarSite = null;
if (pi > 4 && pi < 15 && li > 30) {
tarSite = "16" + s;
} else {
}
return tarSite;
}
/**
* 小车发送空车任务
*/
@@ -208,7 +597,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
//判断是否能规划出最短路径
if (shortestPath == null || shortestPath.isEmpty()) {
return;
return false;
}
//获取拐点路径
@@ -216,7 +605,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
// 路径点拼接
StringBuilder pathBuilder = new StringBuilder();
Map<String, String> roadSiteByArr = roadCacheService.getRoadSiteByArr(Integer.parseInt(floor));
Map<String, String> roadSiteByArr = roadCacheService.getRoadSiteByArr(floor);
for (int[] point : shortestPath) {
String site = roadSiteByArr.get(point[0] + "," + point[1]);
if (!"000".equals(site)) {

View File

@@ -0,0 +1,93 @@
<?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">
<mapper namespace="com.ruoyi.job.charg.mapper.SrgvChargingJobMapper">
<resultMap type="SrgvChargingJob" id="SrgvChargingJobResult">
<result property="guid" column="guid" />
<result property="chargingSite" column="charging_site" />
<result property="jobStatus" column="job_status" />
<result property="chargingStatus" column="charging_status" />
<result property="startDate" column="start_date" />
<result property="chargingDate" column="charging_date" />
<result property="jobType" column="job_type" />
<result property="agvId" column="agv_id" />
<result property="chargingId" column="charging_id" />
</resultMap>
<sql id="selectSrgvChargingJobVo">
select guid, charging_site, job_status, charging_status, start_date, charging_date, job_type, agv_id, charging_id from srgv_charging_job
</sql>
<select id="selectSrgvChargingJobList" parameterType="SrgvChargingJob" resultMap="SrgvChargingJobResult">
<include refid="selectSrgvChargingJobVo"/>
<where>
<if test="chargingSite != null and chargingSite != ''"> and charging_site = #{chargingSite}</if>
<if test="jobStatus != null and jobStatus != ''"> and job_status = #{jobStatus}</if>
<if test="chargingStatus != null and chargingStatus != ''"> and charging_status = #{chargingStatus}</if>
<if test="startDate != null and startDate != ''"> and start_date = #{startDate}</if>
<if test="chargingDate != null and chargingDate != ''"> and charging_date = #{chargingDate}</if>
<if test="jobType != null and jobType != ''"> and job_type = #{jobType}</if>
<if test="agvId != null and agvId != ''"> and agv_id = #{agvId}</if>
<if test="chargingId != null and chargingId != ''"> and charging_id = #{chargingId}</if>
</where>
</select>
<select id="selectSrgvChargingJobByGuid" parameterType="String" resultMap="SrgvChargingJobResult">
<include refid="selectSrgvChargingJobVo"/>
where guid = #{guid}
</select>
<insert id="insertSrgvChargingJob" parameterType="SrgvChargingJob">
insert into srgv_charging_job
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="guid != null">guid,</if>
<if test="chargingSite != null">charging_site,</if>
<if test="jobStatus != null">job_status,</if>
<if test="chargingStatus != null">charging_status,</if>
<if test="startDate != null">start_date,</if>
<if test="chargingDate != null">charging_date,</if>
<if test="jobType != null">job_type,</if>
<if test="agvId != null">agv_id,</if>
<if test="chargingId != null">charging_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="guid != null">#{guid},</if>
<if test="chargingSite != null">#{chargingSite},</if>
<if test="jobStatus != null">#{jobStatus},</if>
<if test="chargingStatus != null">#{chargingStatus},</if>
<if test="startDate != null">#{startDate},</if>
<if test="chargingDate != null">#{chargingDate},</if>
<if test="jobType != null">#{jobType},</if>
<if test="agvId != null">#{agvId},</if>
<if test="chargingId != null">#{chargingId},</if>
</trim>
</insert>
<update id="updateSrgvChargingJob" parameterType="SrgvChargingJob">
update srgv_charging_job
<trim prefix="SET" suffixOverrides=",">
<if test="chargingSite != null">charging_site = #{chargingSite},</if>
<if test="jobStatus != null">job_status = #{jobStatus},</if>
<if test="chargingStatus != null">charging_status = #{chargingStatus},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="chargingDate != null">charging_date = #{chargingDate},</if>
<if test="jobType != null">job_type = #{jobType},</if>
<if test="agvId != null">agv_id = #{agvId},</if>
<if test="chargingId != null">charging_id = #{chargingId},</if>
</trim>
where guid = #{guid}
</update>
<delete id="deleteSrgvChargingJobByGuid" parameterType="String">
delete from srgv_charging_job where guid = #{guid}
</delete>
<delete id="deleteSrgvChargingJobByGuids" parameterType="String">
delete from srgv_charging_job where guid in
<foreach item="guid" collection="array" open="(" separator="," close=")">
#{guid}
</foreach>
</delete>
</mapper>