#
Junjie
20 小时以前 a40b871aa511865d1a7363c88ffb733f6b084d35
#
1个文件已添加
5个文件已修改
228 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/StationController.java 90 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/param/StationCommandBarcodeParam.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/command/StationCommand.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/components/DevpCard.js 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/StationController.java
@@ -1,12 +1,18 @@
package com.zy.asrs.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.domain.param.StationCommandBarcodeParam;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.DeviceConfigService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.StationCommandType;
import com.zy.core.model.StationObjModel;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -29,10 +35,16 @@
@RequestMapping("/station")
public class StationController {
    @Value("${mainProcessPlugin}")
    private String mainProcessPlugin;
    @Autowired
    private BasDevpService basDevpService;
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private ConfigService configService;
    @Autowired
    private DeviceConfigService deviceConfigService;
    @PostMapping("/command/move")
    public R commandMove(@RequestBody StationCommandMoveParam param) {
@@ -44,21 +56,7 @@
        Integer taskNo = param.getTaskNo();
        Integer targetStationId = param.getTargetStationId();
        StationObjModel finalStation = null;
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
        for (BasDevp basDevp : basDevps) {
            List<StationObjModel> list = basDevp.getStationList$();
            for (StationObjModel entity : list) {
                if(entity.getStationId().equals(stationId)){
                    finalStation = entity;
                    break;
                }
            }
            if(finalStation != null){
                break;
            }
        }
        StationObjModel finalStation = findStation(stationId);
        if(finalStation == null){
            return R.error("站点不存在");
@@ -76,6 +74,51 @@
        return R.ok();
    }
    @PostMapping("/command/barcode")
    public R commandBarcode(@RequestBody StationCommandBarcodeParam param) {
        if (Cools.isEmpty(param) || Cools.isEmpty(param.getStationId())) {
            return R.error("缺少参数");
        }
        if (!mainProcessPlugin.contains("Fake")) {
            return R.error("当前系统未启用仿真插件");
        }
        Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
        if (enableFakeConfig == null || !"Y".equals(enableFakeConfig.getValue())) {
            return R.error("当前非仿真运行模式,禁止修改条码");
        }
        Integer stationId = param.getStationId();
        StationObjModel finalStation = findStation(stationId);
        if (finalStation == null) {
            return R.error("站点不存在");
        }
        Integer devpNo = finalStation.getDeviceNo();
        DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>()
                .eq("device_no", devpNo)
                .eq("device_type", String.valueOf(SlaveType.Devp)));
        if (deviceConfig == null || deviceConfig.getFake() == null || deviceConfig.getFake() != 1) {
            return R.error("当前站点设备未启用仿真,禁止修改条码");
        }
        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, devpNo);
        if (stationThread == null) {
            return R.error("线程不存在");
        }
        String barcode = param.getBarcode();
        if (barcode == null) {
            barcode = "";
        }
        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9997, stationId, stationId, 0);
        command.setBarcode(barcode.trim());
        MessageQueue.offer(SlaveType.Devp, devpNo, new Task(2, command));
        return R.ok();
    }
    @PostMapping("/command/reset")
    public R commandReset(@RequestBody StationCommandMoveParam param) {
        if (Cools.isEmpty(param)) {
@@ -87,4 +130,21 @@
        return R.ok();
    }
    private StationObjModel findStation(Integer stationId) {
        if (Cools.isEmpty(stationId)) {
            return null;
        }
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
        for (BasDevp basDevp : basDevps) {
            List<StationObjModel> list = basDevp.getStationList$();
            for (StationObjModel entity : list) {
                if (entity.getStationId().equals(stationId)) {
                    return entity;
                }
            }
        }
        return null;
    }
}
src/main/java/com/zy/asrs/domain/param/StationCommandBarcodeParam.java
New file
@@ -0,0 +1,14 @@
package com.zy.asrs.domain.param;
import lombok.Data;
@Data
public class StationCommandBarcodeParam {
    // 站点编号
    private Integer stationId;
    // 条码值(允许为空字符串)
    private String barcode;
}
src/main/java/com/zy/core/model/command/StationCommand.java
@@ -23,4 +23,7 @@
    private StationCommandType commandType;
    // 仿真模式下可选:手工指定条码
    private String barcode;
}
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -129,6 +129,10 @@
        }
        if(commandType == StationCommandType.WRITE_INFO){
            if (command.getBarcode() != null) {
                updateStationBarcode(deviceNo, stationId, command.getBarcode());
                return;
            }
            if (taskNo == 9998 && targetStationId == 0) {
                //生成出库站点仿真数据
                generateFakeOutStationData(deviceNo, stationId);
@@ -199,6 +203,23 @@
        }
    }
    private void updateStationBarcode(Integer deviceNo, Integer stationId, String barcode) {
        List<ZyStationStatusEntity> statusList = deviceStatusMap.get(deviceNo);
        if (statusList == null) {
            return;
        }
        ZyStationStatusEntity status = statusList.stream()
                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
        if (status == null) {
            return;
        }
        synchronized (status) {
            status.setBarcode(barcode);
        }
    }
    private void currentLevCommand(StationCommand command, boolean generateBarcode) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
@@ -411,6 +411,10 @@
        }
        if (command.getCommandType() == StationCommandType.WRITE_INFO) {
            if (command.getBarcode() != null) {
                updateStationBarcode(deviceNo, stationId, command.getBarcode());
                return;
            }
            if (taskNo == 9998 && targetStationId == 0) {
                // 生成出库站点仿真数据
                generateFakeOutStationData(deviceNo, stationId);
@@ -466,6 +470,23 @@
        }
    }
    private void updateStationBarcode(Integer deviceNo, Integer stationId, String barcode) {
        List<ZyStationStatusEntity> statusList = deviceStatusMap.get(deviceNo);
        if (statusList == null) {
            return;
        }
        ZyStationStatusEntity status = statusList.stream()
                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
        if (status == null) {
            return;
        }
        synchronized (status) {
            status.setBarcode(barcode);
        }
    }
    // segmentedPathCommand 方法已删除,功能已整合到 runTaskLoop
    private Integer getDeviceNoByStationId(Integer stationId) {
src/main/webapp/components/DevpCard.js
@@ -53,9 +53,9 @@
                      />
                      <div style="margin-top: 4px; font-size: 12px; word-break: break-all;">{{ item.barcode }}</div>
                    </div>
                    <span slot="reference" style="cursor: pointer; color: #409EFF;">{{ item.barcode }}</span>
                    <span slot="reference" @click.stop="handleBarcodeClick(item)" style="cursor: pointer; color: #409EFF;">{{ item.barcode }}</span>
                  </el-popover>
                  <span v-else>-</span>
                  <span v-else @click.stop="handleBarcodeClick(item)" style="cursor: pointer; color: #409EFF;">-</span>
                </el-descriptions-item>
                <el-descriptions-item label="重量">{{ item.weight }}</el-descriptions-item>
                <el-descriptions-item label="故障代码">{{ item.error }}</el-descriptions-item>
@@ -303,6 +303,81 @@
        }
      }
    },
    handleBarcodeClick(item) {
      if (this.readOnly || !item || item.stationId == null) {
        return;
      }
      let that = this;
      $.ajax({
        url: baseUrl + "/openapi/getFakeSystemRunStatus",
        headers: {
          token: localStorage.getItem("token"),
        },
        method: "get",
        success: (res) => {
          if (res.code !== 200 || !res.data || !res.data.isFake || !res.data.running) {
            that.$message({
              message: "仅仿真模式运行中可修改条码",
              type: "warning",
            });
            return;
          }
          that.$prompt("请输入新的条码值(可留空清空)", "修改条码", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            inputValue: item.barcode || "",
            inputPlaceholder: "请输入条码",
          }).then(({ value }) => {
            that.updateStationBarcode(item.stationId, value == null ? "" : String(value).trim());
          }).catch(() => {});
        },
      });
    },
    updateStationBarcode(stationId, barcode) {
      let that = this;
      $.ajax({
        url: baseUrl + "/station/command/barcode",
        headers: {
          token: localStorage.getItem("token"),
        },
        contentType: "application/json",
        method: "post",
        data: JSON.stringify({
          stationId: stationId,
          barcode: barcode,
        }),
        success: (res) => {
          if (res.code == 200) {
            that.syncLocalBarcode(stationId, barcode);
            that.$message({
              message: "条码修改成功",
              type: "success",
            });
          } else {
            that.$message({
              message: res.msg || "条码修改失败",
              type: "warning",
            });
          }
        },
      });
    },
    syncLocalBarcode(stationId, barcode) {
      let updateFn = (list) => {
        if (!list || list.length === 0) {
          return;
        }
        list.forEach((row) => {
          if (row.stationId == stationId) {
            row.barcode = barcode;
          }
        });
      };
      updateFn(this.stationList);
      updateFn(this.fullStationList);
    },
    openControl() {
      this.showControl = !this.showControl;
    },