Junjie
2024-04-12 c01f7222dcd48a7263ee414287469c754e7de22c
Merge remote-tracking branch 'origin/Four-Way-Rack' into Four-Way-Rack
9个文件已修改
2个文件已添加
337 ■■■■ 已修改文件
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/utils.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Loc.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java 136 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LocStsType.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/LocStsService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/LocStsServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -200,9 +200,14 @@
        }
    }
    rePerspective = (maxHeight) => {
    rePerspective = (maxHeight, normalHeight) => {
        const height = Math.max(maxHeight, normalHeight)
        const cameraPosScale = 0.7;
        this.camera.position.set(-maxHeight * cameraPosScale, maxHeight * cameraPosScale, maxHeight * cameraPosScale);
        this.camera.position.set(
            -height * cameraPosScale,
            height * cameraPosScale,
            height * cameraPosScale
            );
        this.controls.target = new THREE.Vector3(0, maxHeight * 0.53, 0);
    }
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
@@ -107,7 +107,7 @@
            Promise.all(promises).then(() => {
                shelfThree.setNewSelectedMesh(locNo);
                shelfThree.rePerspective(singleHeight * res.data.length);
                shelfThree.rePerspective(singleHeight * res.data.length, 500);
            }).catch(error => {
                console.error(error);
            });
zy-asrs-flow/src/pages/map/utils.js
@@ -58,7 +58,7 @@
    TRACK: 3,
    LIFT: 67,
    CHARGE: 5,
    DISABLE: 1,
    DISABLE: -1,
})
export const NOTIFY_TYPE = Object.freeze({
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Loc.java
@@ -1,29 +1,24 @@
package com.zy.asrs.wcs.core.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.core.service.LocCtgService;
import com.zy.asrs.wcs.core.service.LocStsService;
import com.zy.asrs.wcs.core.service.ZoneService;
import com.zy.asrs.wcs.system.entity.Host;
import com.zy.asrs.wcs.system.entity.User;
import org.springframework.format.annotation.DateTimeFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModel;
import com.zy.asrs.wcs.system.service.HostService;
import com.zy.asrs.wcs.system.service.UserService;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.system.service.UserService;
import com.zy.asrs.wcs.system.service.HostService;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data
@@ -244,6 +239,15 @@
        return null;
    }
    public String getLocStsFlag(){
        LocStsService service = SpringUtils.getBean(LocStsService.class);
        LocSts locSts = service.getById(this.locSts);
        if (!Cools.isEmpty(locSts)){
            return String.valueOf(locSts.getFlag());
        }
        return null;
    }
    public String getLocCtg$(){
        LocCtgService service = SpringUtils.getBean(LocCtgService.class);
        LocCtg locCtg = service.getById(this.locCtg);
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java
@@ -5,21 +5,35 @@
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.domain.enums.DictType;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.map.controller.param.MapDataParam;
import com.zy.asrs.wcs.core.map.controller.param.MapQueryParam;
import com.zy.asrs.wcs.core.map.controller.result.LiftVo;
import com.zy.asrs.wcs.core.map.controller.result.LocVo;
import com.zy.asrs.wcs.core.map.controller.result.ShuttleVo;
import com.zy.asrs.wcs.core.map.entity.MapItem;
import com.zy.asrs.wcs.core.model.enums.LocStsType;
import com.zy.asrs.wcs.core.service.LocService;
import com.zy.asrs.wcs.core.service.LocStsService;
import com.zy.asrs.wcs.core.utils.Utils;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.entity.DeviceType;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.service.DictService;
import com.zy.asrs.wcs.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by vincent on 3/15/2024
@@ -31,6 +45,14 @@
    private UserService userService;
    @Autowired
    private DictService dictService;
    @Autowired
    private DeviceTypeService deviceTypeService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private LocService locService;
    @Autowired
    private LocStsService locStsService;
    public String getMapFloorList(Long userId) {
        String floorKey = "floor-list";
@@ -56,7 +78,10 @@
        return Optional.ofNullable(dict).map(Dict::getValue).orElse(null);
    }
    @Transactional
    public void saveMapData(MapDataParam param, Long userId) {
        Date now = new Date();
        // dict
        String mapKey = getMapKey(param.getFloor());
        Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey));
        if (Cools.isEmpty(dict)) {
@@ -78,6 +103,51 @@
                throw new CoolException("服务器内部错误");
            }
        }
        // loc
        List<String> newLocList = new ArrayList<>();
        for (MapItem item : param.getItemList()) {
            int row = Integer.parseInt(String.valueOf(item.getProperty().get("row")));
            int bay = Integer.parseInt(String.valueOf(item.getProperty().get("bay")));
            String locNo = Utils.getLocNo(row, bay, param.getFloor());
            newLocList.add(locNo);
        }
        List<String> existLocList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLev, param.getFloor()))
                .stream().map(Loc::getLocNo).collect(Collectors.toList());
        List<String> locListToSave = newLocList.stream().filter(locNo -> !existLocList.contains(locNo)).collect(Collectors.toList());
        List<String> locListToRemove = existLocList.stream().filter(locNo -> !newLocList.contains(locNo)).collect(Collectors.toList());
        List<String> locListInBoth = newLocList.stream().filter(existLocList::contains).collect(Collectors.toList());
        for (String locNo : locListToSave) {
            Loc loc = new Loc();
            loc.setLocNo(locNo);
            loc.setName(locNo);
            loc.setRow(Utils.getRow(locNo));
            loc.setBay(Utils.getBay(locNo));
            loc.setLev(Utils.getLev(locNo));
            loc.setLocSts(LocStsType.O.val());
            loc.setCreateBy(userId);
            loc.setCreateTime(now);
            loc.setUpdateBy(userId);
            loc.setUpdateTime(now);
            if (!locService.save(loc)) {
                throw new CoolException("服务器内部错误");
            }
        }
        for (String locNo : locListToRemove) {
            if (!locService.remove(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo))) {
                throw new CoolException("服务器内部错误");
            }
        }
        for (String locNo : locListInBoth) {
        }
    }
@@ -85,12 +155,9 @@
        List<LocVo> locVos = new ArrayList<>();
        int row = Utils.getRow(locNo);
        int bay = Utils.getBay(locNo);
        String[] statusOptions = {"F", "D", "O"};
        Random random = new Random();
        for (int lev = 1; lev < 6; lev++) {
            locVos.add(new LocVo(Utils.getLocNo(row, bay, lev), statusOptions[random.nextInt(statusOptions.length)]));
        List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getRow, row).eq(Loc::getBay, bay).orderByAsc(Loc::getLev));
        for (Loc loc : locList) {
            locVos.add(new LocVo(loc.getLocNo(), loc.getLocStsFlag()));
        }
        return locVos;
    }
@@ -98,21 +165,32 @@
    public ShuttleVo getShuttleInfo(String shuttleNo) {
        ShuttleVo vo = new ShuttleVo();
        vo.setShuttleNo(shuttleNo);
        ShuttleProtocol protocol = new ShuttleProtocol();
        // todo checkout protocol
//        vo.setTaskNo(String.valueOf(protocol.getTaskNo()));
//        vo.setStatus(protocol.getProtocolStatusType().desc);
//        vo.setOriginLocNo(protocol.getSourceLocNo());
//        vo.setDestLocNo(protocol.getLocNo());
//        vo.setCurrentCode(protocol.getCurrentCode());
//        vo.setBatteryPower(protocol.getBatteryPower());
//        vo.setErrorCode(protocol.getErrorCode());
//        vo.setBatteryTemp(protocol.getBatteryTemp());
//        vo.setHasLift(protocol.getHasLift());
//        vo.setHasPallet(protocol.getHasPallet());
//        vo.setHasCharge(protocol.getHasCharge());
//        vo.setBatteryVoltage(String.valueOf(protocol.getBatteryVoltage()));
//        vo.setPakMk(protocol.getPakMk());
        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>().eq(DeviceType::getFlag, SlaveType.Shuttle.toString()));
        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>().eq(Device::getDeviceType, deviceType.getId()).eq(Device::getDeviceNo, shuttleNo));
        if (null == device) {
            return vo;
        }
        ShuttleThread thread = (ShuttleThread)SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
        if (null == thread) {
            return vo;
        }
        ShuttleProtocol protocol = thread.getStatus();
        if (null == protocol) {
            return vo;
        }
        vo.setTaskNo(String.valueOf(protocol.getTaskNo()));
        vo.setStatus(protocol.getProtocolStatusType().desc);
        vo.setOriginLocNo(protocol.getSourceLocNo());
        vo.setDestLocNo(protocol.getLocNo());
        vo.setCurrentCode(protocol.getCurrentCode());
        vo.setBatteryPower(protocol.getBatteryPower());
        vo.setErrorCode(protocol.getErrorCode());
        vo.setBatteryTemp(protocol.getBatteryTemp());
        vo.setHasLift(protocol.getHasLift());
        vo.setHasPallet(protocol.getHasPallet());
        vo.setHasCharge(protocol.getHasCharge());
        vo.setBatteryVoltage(String.valueOf(protocol.getBatteryVoltage()));
        vo.setPakMk(protocol.getPakMk());
        return vo;
    }
@@ -148,22 +226,6 @@
            "    {\n" +
            "        label: '1F',\n" +
            "        value: 1\n" +
            "    },\n" +
            "    {\n" +
            "        label: '2F',\n" +
            "        value: 2\n" +
            "    },\n" +
            "    {\n" +
            "        label: '3F',\n" +
            "        value: 3\n" +
            "    },\n" +
            "    {\n" +
            "        label: '4F',\n" +
            "        value: 4\n" +
            "    },\n" +
            "    {\n" +
            "        label: '5F',\n" +
            "        value: 5\n" +
            "    },\n" +
            "]";
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java
New file
@@ -0,0 +1,69 @@
package com.zy.asrs.wcs.core.map.websocket;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.map.entity.MapWsShuttleVo;
import com.zy.asrs.wcs.core.map.entity.MapWsVo;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.service.BasShuttleService;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by vincent on 4/11/2024
 */
@Component
public class MapRealTimeDataScheduler {
    @Autowired
    private DeviceTypeService deviceTypeService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private BasShuttleService basShuttleService;
    @Scheduled(cron = "0/1 * * * * ? ")
    public void sync() {
        MapWsVo wsVo = new MapWsVo();
        // shuttle
        wsVo.setShuttleVos(syncShuttle());
        MapWebSocket.broadcast(JSON.toJSONString(wsVo));
    }
    private List<MapWsShuttleVo> syncShuttle() {
        List<MapWsShuttleVo> shuttleVos = new ArrayList<>();
        List<Device> deviceList = deviceService.list(new LambdaQueryWrapper<Device>().eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()));
        for (Device device : deviceList) {
//            basShuttleService.
            ShuttleThread thread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
            if (null == thread) {
                continue;
            }
            ShuttleProtocol protocol = thread.getStatus();
            if (null == protocol) {
                continue;
            }
            MapWsShuttleVo shuttleVo = new MapWsShuttleVo();
//            shuttleVo.setShuttleNo();
            shuttleVos.add(shuttleVo);
        }
        return shuttleVos;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java
@@ -87,41 +87,4 @@
        return fullPath;
    }
    private List<String> generatePreTravelPath(int currentRow, int currentBay, int currentLev, boolean increasingBay, int pathLength) {
        List<String> path = new ArrayList<>();
        int tempRow = currentRow;
        int tempBay = currentBay;
        boolean tempIncreaseBay = increasingBay;
        for (int i = 0; i < pathLength; i++) {
            if (tempIncreaseBay) {
                if (tempBay < 30) {
                    tempBay++;
                } else {
                    if (tempRow < 10) {
                        tempRow++;
                    } else {
                        tempRow = 1;  // 如果 row 已经是最大,则回到起始位置
                    }
                    tempIncreaseBay = false;
                }
            } else {
                if (tempBay > 1) {
                    tempBay--;
                } else {
                    if (tempRow < 10) {
                        tempRow++;
                    } else {
                        tempRow = 1;  // 如果 row 已经是最大,则回到起始位置
                    }
                    tempIncreaseBay = true;
                }
            }
            // 将生成的库位号加入路径列表
            path.add(Utils.getLocNo(tempRow, tempBay, currentLev));
        }
        return path;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LocStsType.java
New file
@@ -0,0 +1,38 @@
package com.zy.asrs.wcs.core.model.enums;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.entity.LocSts;
import com.zy.asrs.wcs.core.service.LocStsService;
public enum LocStsType {
    D,
    F,
    O,
    X,
    ;
    LocStsType() {
    }
    public long val() {
        LocStsService service = SpringUtils.getBean(LocStsService.class);
        LocSts entity = service.selectByFlag(this.toString());
        if (entity == null) {
            throw new CoolException("LocStsType Error!");
        }
        return entity.getId();
    }
    public static LocStsType get(String el) {
        for (LocStsType value : LocStsType.values()) {
            if (el.equals(value.toString())) {
                return value;
            }
        }
        return null;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/LocStsService.java
@@ -5,4 +5,6 @@
public interface LocStsService extends IService<LocSts> {
    LocSts selectByFlag(String flag);
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/LocStsServiceImpl.java
@@ -1,5 +1,6 @@
package com.zy.asrs.wcs.core.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.mapper.LocStsMapper;
import com.zy.asrs.wcs.core.entity.LocSts;
import com.zy.asrs.wcs.core.service.LocStsService;
@@ -9,4 +10,9 @@
@Service("locStsService")
public class LocStsServiceImpl extends ServiceImpl<LocStsMapper, LocSts> implements LocStsService {
    @Override
    public LocSts selectByFlag(String flag) {
        return this.getOne(new LambdaQueryWrapper<LocSts>().eq(LocSts::getFlag, flag));
    }
}
zy-asrs-wcs/src/main/resources/application.yml
@@ -20,7 +20,7 @@
#    password: zy@123
    url: jdbc:mysql://127.0.0.1:3306/asrs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root
    password: xltys1995
#    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
#    url: jdbc:sqlserver://47.97.1.152:51433;databasename=jkasrs
#    username: sa