优化对外接口
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作业统计 Controller
|
* 作业统计 Controller-展示大屏
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api")
|
@RequestMapping("/api")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.api.controller;
|
package com.ruoyi.api.controller;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.ruoyi.api.domain.ReMaterialParam;
|
||||||
import com.ruoyi.api.domain.RequestEnter;
|
import com.ruoyi.api.domain.RequestEnter;
|
||||||
import com.ruoyi.api.domain.WmsJobRequest;
|
import com.ruoyi.api.domain.WmsJobRequest;
|
||||||
import com.ruoyi.api.service.IToWmsService;
|
import com.ruoyi.api.service.IToWmsService;
|
||||||
@@ -34,21 +35,12 @@ public class ToWmsApiController {
|
|||||||
@PostMapping("/requestEnterByTrayCode")
|
@PostMapping("/requestEnterByTrayCode")
|
||||||
public AjaxResult requestEnterByTrayCode(@RequestBody RequestEnter requestEnter) {
|
public AjaxResult requestEnterByTrayCode(@RequestBody RequestEnter requestEnter) {
|
||||||
AjaxResult ajaxResult = toWmsService.requestEnterByTrayCode(requestEnter);
|
AjaxResult ajaxResult = toWmsService.requestEnterByTrayCode(requestEnter);
|
||||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "InJobByTrayCode",ajaxResult);
|
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "入库任务请求(托盘)",ajaxResult);
|
||||||
requestLogService.insertRequestLog(requestLog);
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 入库任务请求
|
|
||||||
*/
|
|
||||||
@PostMapping("/requestEnterByEnterId")
|
|
||||||
public AjaxResult requestEnterByEnterId(@RequestBody RequestEnter requestEnter) {
|
|
||||||
AjaxResult ajaxResult = toWmsService.requestEnterByEnterId(requestEnter);
|
|
||||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "InJobByEnterId",ajaxResult);
|
|
||||||
requestLogService.insertRequestLog(requestLog);
|
requestLogService.insertRequestLog(requestLog);
|
||||||
return ajaxResult;
|
return ajaxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小车接收开始信号
|
* 小车接收开始信号
|
||||||
*/
|
*/
|
||||||
@@ -83,9 +75,9 @@ public class ToWmsApiController {
|
|||||||
* 放货有货,重新分配货位
|
* 放货有货,重新分配货位
|
||||||
*/
|
*/
|
||||||
@PostMapping("/reAssign")
|
@PostMapping("/reAssign")
|
||||||
public AjaxResult reAssign(@RequestBody MydoJob mydoJob) {
|
public AjaxResult reAssign(@RequestBody ReMaterialParam reMaterialParam) {
|
||||||
AjaxResult ajaxResult = toWmsService.reAssign(mydoJob);
|
AjaxResult ajaxResult = toWmsService.reAssign(reMaterialParam);
|
||||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(mydoJob), "reAssign",ajaxResult);
|
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reAssign",ajaxResult);
|
||||||
requestLogService.insertRequestLog(requestLog);
|
requestLogService.insertRequestLog(requestLog);
|
||||||
return ajaxResult;
|
return ajaxResult;
|
||||||
}
|
}
|
||||||
@@ -94,9 +86,9 @@ public class ToWmsApiController {
|
|||||||
* 取货无货,重新分配物料
|
* 取货无货,重新分配物料
|
||||||
*/
|
*/
|
||||||
@PostMapping("/reMaterial")
|
@PostMapping("/reMaterial")
|
||||||
public AjaxResult reMaterial(@RequestBody MydoJob mydoJob) {
|
public AjaxResult reMaterial(@RequestBody ReMaterialParam reMaterialParam) {
|
||||||
AjaxResult ajaxResult = toWmsService.reMaterial(mydoJob);
|
AjaxResult ajaxResult = toWmsService.reMaterial(reMaterialParam);
|
||||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(mydoJob), "reMaterial",ajaxResult);
|
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reMaterial",ajaxResult);
|
||||||
requestLogService.insertRequestLog(requestLog);
|
requestLogService.insertRequestLog(requestLog);
|
||||||
return ajaxResult;
|
return ajaxResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库和点位API接口
|
* 仓库和点位API接口--拣选大屏
|
||||||
*
|
*
|
||||||
* @author lsy
|
* @author lsy
|
||||||
* @date 2025-06-23
|
* @date 2025-06-23
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.ruoyi.api.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ReMaterialParam {
|
||||||
|
private String jobId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.api.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RequestEnterResponse {
|
||||||
|
private String cargoSpaceId;
|
||||||
|
private String trayCode;
|
||||||
|
private String taskNo;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.api.service;
|
package com.ruoyi.api.service;
|
||||||
|
|
||||||
|
import com.ruoyi.api.domain.ReMaterialParam;
|
||||||
import com.ruoyi.api.domain.RequestEnter;
|
import com.ruoyi.api.domain.RequestEnter;
|
||||||
import com.ruoyi.api.domain.WmsJobRequest;
|
import com.ruoyi.api.domain.WmsJobRequest;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
@@ -15,10 +16,7 @@ public interface IToWmsService {
|
|||||||
* 入库任务请求根据托盘码
|
* 入库任务请求根据托盘码
|
||||||
*/
|
*/
|
||||||
AjaxResult requestEnterByTrayCode(RequestEnter requestEnter);
|
AjaxResult requestEnterByTrayCode(RequestEnter requestEnter);
|
||||||
/**
|
|
||||||
* 入库任务请求
|
|
||||||
*/
|
|
||||||
AjaxResult requestEnterByEnterId(RequestEnter requestEnter);
|
|
||||||
/**
|
/**
|
||||||
* 入库、出库 任务完成回传
|
* 入库、出库 任务完成回传
|
||||||
* Map<String, String>
|
* Map<String, String>
|
||||||
@@ -34,11 +32,11 @@ public interface IToWmsService {
|
|||||||
/**
|
/**
|
||||||
* 放货有货,重新分配货位
|
* 放货有货,重新分配货位
|
||||||
*/
|
*/
|
||||||
AjaxResult reAssign(MydoJob mydoJob);
|
AjaxResult reAssign(ReMaterialParam reMaterialParam);
|
||||||
/**
|
/**
|
||||||
* 取货无货,重新分配物料
|
* 取货无货,重新分配物料
|
||||||
*/
|
*/
|
||||||
AjaxResult reMaterial(MydoJob mydoJob);
|
AjaxResult reMaterial(ReMaterialParam reMaterialParam);
|
||||||
/**
|
/**
|
||||||
* 小车接收开始信号
|
* 小车接收开始信号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.ruoyi.api.domain.ReMaterialParam;
|
||||||
import com.ruoyi.api.domain.RequestEnter;
|
import com.ruoyi.api.domain.RequestEnter;
|
||||||
|
import com.ruoyi.api.domain.RequestEnterResponse;
|
||||||
import com.ruoyi.api.domain.WmsJobRequest;
|
import com.ruoyi.api.domain.WmsJobRequest;
|
||||||
import com.ruoyi.api.service.IToWmsService;
|
import com.ruoyi.api.service.IToWmsService;
|
||||||
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||||
@@ -80,28 +82,9 @@ public class ToWmsServiceImpl implements IToWmsService {
|
|||||||
mydoJob.setStatus("2");
|
mydoJob.setStatus("2");
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
}
|
}
|
||||||
return AjaxResult.success(mydoJob);
|
return AjaxResult.success(new RequestEnterResponse(mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AjaxResult requestEnterByEnterId(RequestEnter requestEnter) {
|
|
||||||
MydoJob mydoJobParam = new MydoJob();
|
|
||||||
mydoJobParam.setEntranceId(requestEnter.getEntranceId());
|
|
||||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobListApi(mydoJobParam);
|
|
||||||
if(mydoJobs.isEmpty()){
|
|
||||||
return AjaxResult.warn(MessageUtils.message("warn.message"));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MydoJob mydoJob : mydoJobs) {
|
|
||||||
if ("1".equals(mydoJob.getExecutionPhase())){
|
|
||||||
mydoJob.setExecutionPhase("2");
|
|
||||||
mydoJob.setTrayCode(requestEnter.getTrayCode());
|
|
||||||
mydoJob.setStatus("2");
|
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AjaxResult.success(mydoJobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult jobFinish(WmsJobRequest wmsJobRequest) {
|
public AjaxResult jobFinish(WmsJobRequest wmsJobRequest) {
|
||||||
@@ -218,9 +201,9 @@ public class ToWmsServiceImpl implements IToWmsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult reAssign(MydoJob param) {
|
public AjaxResult reAssign(ReMaterialParam reMaterialParam) {
|
||||||
//重新分配货位
|
//重新分配货位
|
||||||
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(param.getJobId());
|
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(reMaterialParam.getJobId());
|
||||||
String warehouseId = mydoJob.getWarehouseId();
|
String warehouseId = mydoJob.getWarehouseId();
|
||||||
BasCargoSpace basCargoSpace = basCargoSpaceService.selectEmptyCargoSpaceByWarehouseId(warehouseId);
|
BasCargoSpace basCargoSpace = basCargoSpaceService.selectEmptyCargoSpaceByWarehouseId(warehouseId);
|
||||||
if (basCargoSpace == null){
|
if (basCargoSpace == null){
|
||||||
@@ -230,14 +213,14 @@ public class ToWmsServiceImpl implements IToWmsService {
|
|||||||
mydoJob.setCargoSpaceId(basCargoSpace.getCargoSpaceId());
|
mydoJob.setCargoSpaceId(basCargoSpace.getCargoSpaceId());
|
||||||
mydoJob.setFaultFlag("1");
|
mydoJob.setFaultFlag("1");
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
return AjaxResult.success(mydoJob);
|
return AjaxResult.success(new RequestEnterResponse(basCargoSpace.getCargoSpaceId(), null, mydoJob.getJobId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult reMaterial(MydoJob param) {
|
public AjaxResult reMaterial(ReMaterialParam reMaterialParam) {
|
||||||
//重新分配物料
|
//重新分配物料
|
||||||
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(param.getJobId());
|
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(reMaterialParam.getJobId());
|
||||||
MydoJobDetail mydoJobDetailParam = new MydoJobDetail();
|
MydoJobDetail mydoJobDetailParam = new MydoJobDetail();
|
||||||
mydoJobDetailParam.setJobId(mydoJob.getJobId());
|
mydoJobDetailParam.setJobId(mydoJob.getJobId());
|
||||||
List<MydoJobDetail> mydoJobDetails = mydoJobDetailService.selectMydoJobDetailList(mydoJobDetailParam);
|
List<MydoJobDetail> mydoJobDetails = mydoJobDetailService.selectMydoJobDetailList(mydoJobDetailParam);
|
||||||
|
|||||||
@@ -167,20 +167,6 @@ public class TagTaskServiceImpl implements ITagTaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取socket
|
|
||||||
*
|
|
||||||
* @param basTag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Socket getSocket(BasTag basTag) {
|
|
||||||
try {
|
|
||||||
return new Socket(basTag.getIp(), 20108);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error(e.getMessage(),e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 灭灯
|
* 灭灯
|
||||||
@@ -189,7 +175,7 @@ public class TagTaskServiceImpl implements ITagTaskService {
|
|||||||
*/
|
*/
|
||||||
public boolean sendDzbqOff(BasTag basTag) throws IOException {
|
public boolean sendDzbqOff(BasTag basTag) throws IOException {
|
||||||
int address = Convert.toInt(basTag.getId());
|
int address = Convert.toInt(basTag.getId());
|
||||||
Socket socket = getSocket(basTag);
|
Socket socket = ElectronicTagClient.getSocket(basTag.getIp());
|
||||||
int x7 = (address + 0x10 + 0x03 + 0xe8 + 0x03 + 0xe8) % 256;//累加 校验
|
int x7 = (address + 0x10 + 0x03 + 0xe8 + 0x03 + 0xe8) % 256;//累加 校验
|
||||||
return ElectronicTagClient.sendHexData( socket,"FA " + String.format("%02x", address) + " 10 00 03 e8 03 e8 " + String.format("%02x", x7) + " AF");
|
return ElectronicTagClient.sendHexData( socket,"FA " + String.format("%02x", address) + " 10 00 03 e8 03 e8 " + String.format("%02x", x7) + " AF");
|
||||||
}
|
}
|
||||||
@@ -202,7 +188,7 @@ public class TagTaskServiceImpl implements ITagTaskService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean sendMsgDzbq( BasTag basTag ,TagTask tagTask) throws IOException {
|
public boolean sendMsgDzbq( BasTag basTag ,TagTask tagTask) throws IOException {
|
||||||
try (Socket socket = new Socket(basTag.getIp(), 20108)
|
try (Socket socket = ElectronicTagClient.getSocket(basTag.getIp())
|
||||||
){
|
){
|
||||||
//socket.setSoTimeout(5000);
|
//socket.setSoTimeout(5000);
|
||||||
String green = String.format("%04x", Convert.toInt(tagTask.getNum()));
|
String green = String.format("%04x", Convert.toInt(tagTask.getNum()));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class TagInReadThread implements Runnable {
|
|||||||
basTagService.updateBasTag(basTag);
|
basTagService.updateBasTag(basTag);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try (Socket socket = getSocket(basTag.getIp(), 20108)) {
|
try (Socket socket = getSocket(basTag.getIp())) {
|
||||||
basTag = basTagService.selectBasTagById(tagId);
|
basTag = basTagService.selectBasTagById(tagId);
|
||||||
if (basTag == null) {
|
if (basTag == null) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class TagOutReadThread implements Runnable {
|
|||||||
TagTask tagTaskParam = new TagTask();
|
TagTask tagTaskParam = new TagTask();
|
||||||
tagTaskParam.setTagId(basTag.getId());
|
tagTaskParam.setTagId(basTag.getId());
|
||||||
List<TagTask> allTagTasks = null;
|
List<TagTask> allTagTasks = null;
|
||||||
try (Socket socket = getSocket(basTag.getIp(), 20108)) {
|
try (Socket socket = getSocket(basTag.getIp())) {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.out.tagTask.util;
|
package com.ruoyi.out.tagTask.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.druid.sql.visitor.functions.Concat;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
@@ -141,9 +143,11 @@ public class ElectronicTagClient {
|
|||||||
/**
|
/**
|
||||||
* 获取socket
|
* 获取socket
|
||||||
*/
|
*/
|
||||||
public static Socket getSocket(String ip, int port) {
|
public static Socket getSocket(String ip) {
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket(ip, port);
|
String[] split = ip.split(":");
|
||||||
|
Socket socket = new Socket(split[0], Convert.toInt(split[1]));
|
||||||
|
log.info("成功连接到电子标签服务器: " + split[0] + ":" + split[1]);
|
||||||
return socket;
|
return socket;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user