feat(cargo): 添加货位排序及分组编码生成功能

- 在BasCargoSpaceMapper.xml中添加货位排序规则
- 新增SRGV设备监控线程处理逻辑
- 完善SRGV设备读取测试代码
- 修改道路缓存服务中的参数设置
- 注释掉调度线程中不必要的SRGV读取任务
- 实现货位分组编码自动生成接口
This commit is contained in:
liuhanqing
2025-12-10 09:06:32 +08:00
parent 5a26847351
commit cff1580954
6 changed files with 71 additions and 23 deletions

View File

@@ -1,37 +1,75 @@
package com.ruoyi.api.controller;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.api.service.ITestService;
import com.ruoyi.bas.cargospace.domain.BasCargoSpace;
import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/test")
public class TestController {
@Resource
private ITestService testService;
private IBasCargoSpaceService basCargoSpaceService;
@GetMapping("/sendSsjData")
public String sendSsjData(Integer id) {
boolean b = testService.sendSsjData(id);
if (!b) {
return "error";
@GetMapping("/gen")
public String gen() {
List<BasCargoSpace> basCargoSpaces = basCargoSpaceService.selectBasCargoSpaceList(new BasCargoSpace());
Map<Long, List<BasCargoSpace>> floorMap = basCargoSpaces.stream().collect(Collectors.groupingBy(BasCargoSpace::getTheFloor));
int x = 1;
for (Long floor : floorMap.keySet()) {
List<BasCargoSpace> floorList = floorMap.get(floor);
Map<Long, List<BasCargoSpace>> columnList = floorList.stream().collect(Collectors.groupingBy(BasCargoSpace::getTheColumn));
for (Long column : columnList.keySet()) {
List<BasCargoSpace> basCargoSpacesList = columnList.get(column);
Map<String, List<BasCargoSpace>> collect = basCargoSpacesList.stream().collect(Collectors.groupingBy(y -> {
if (y.getThePlatoon() > 5) {
return "2";
} else {
return "1";
}
}));
for (String s : collect.keySet()) {
List<BasCargoSpace> basCargoSpacesList1 = collect.get(s);
int x1 = 1;
if ("1".equals(s)){
basCargoSpacesList1.sort(Comparator.comparing(BasCargoSpace::getTheColumn));
CollUtil.reverse(basCargoSpacesList1);
for (BasCargoSpace basCargoSpace : basCargoSpacesList1) {
basCargoSpace.setGroupCoding(x1+"");
basCargoSpace.setGroupCodingNo(String.format("%03d", x));
x1++;
basCargoSpaceService.updateBasCargoSpace(basCargoSpace);
}
}else if ("2".equals(s)){
basCargoSpacesList1.sort(Comparator.comparing(BasCargoSpace::getTheColumn));
for (BasCargoSpace basCargoSpace : basCargoSpacesList1) {
basCargoSpace.setGroupCoding(x1+"");
basCargoSpace.setGroupCodingNo(String.format("%03d", x));
x1++;
basCargoSpaceService.updateBasCargoSpace(basCargoSpace);
}
}
x++;
}
}
}
return "success";
return null;
}
@GetMapping("/sendDdjData")
public String sendDdjData(Integer id) {
boolean b = testService.sendDdjData(id);
if (!b) {
return "error";
}
return "success";
}
}

View File

@@ -41,7 +41,8 @@ public class RoadCacheServiceImpl implements RoadCacheService {
for (WcsSrgvMap wcsSrgvMap : wcsSrgvMaps) {
maps.put(wcsSrgvMap.getSiteId(), wcsSrgvMap);
}
param.setAxy("7,7");
param = new WcsSrgvMap();
param.setRemark("tsj");
List<WcsSrgvMap> tsjMap = wcsSrgvMapMapper.selectWcsSrgvMapList(param);
for (WcsSrgvMap wcsSrgvMap : tsjMap) {
maps.put("tsj",wcsSrgvMap);

View File

@@ -126,11 +126,11 @@ public class ScheduleThread {
Thread plcSrgvReadThread2 = new Thread((plcSrgvRead2));
plcSrgvReadCustomThread2=new CustomThread<PlcSrgvRead>(plcSrgvReadThread2,plcSrgvRead2);
break;
case 3:
/*case 3:
PlcSrgvRead plcSrgvRead3=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
Thread plcSrgvReadThread3 = new Thread((plcSrgvRead3));
plcSrgvReadCustomThread3=new CustomThread<PlcSrgvRead>(plcSrgvReadThread3,plcSrgvRead3);
break;
break;*/
}
}

View File

@@ -68,6 +68,7 @@ public class PlcSrgvRead implements Runnable {
} else {
reConnect();
}*/
//todo 测试使用
IDeviceSrgvService deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();

View File

@@ -2,9 +2,11 @@ package com.ruoyi.schedule.scheduleTask.monit;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import lombok.extern.slf4j.Slf4j;
@@ -18,11 +20,13 @@ public class MonitoringThread implements Runnable {
private IDeviceSsjService deviceSsjService;
private IMsgDdjService msgDdjService;
private IDeviceSrgvService deviceSrgvService;
public void init() {
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
}
@Override
@@ -34,9 +38,12 @@ public class MonitoringThread implements Runnable {
deviceSsj.setTraySize(deviceSsj.getModel());
deviceSsjService.updateDeviceSsj(deviceSsj);
}
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode));
for (String sRgv : PlcSrgvRead.deviceSrgvMap.keySet()) {
deviceSrgvService.updateDeviceSrgv(PlcSrgvRead.deviceSrgvMap.get(sRgv));
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {

View File

@@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="thisCargoArea != null and thisCargoArea != ''"> and this_cargo_area = #{thisCargoArea}</if>
<if test="wmsCargoSpaceId != null and wmsCargoSpaceId != ''"> and wms_cargo_space_id = #{wmsCargoSpaceId}</if>
</where>
order by the_platoon,the_column,the_floor
</select>
<select id="selectBasCargoSpaceByCargoSpaceId" parameterType="String" resultMap="BasCargoSpaceResult">