优化对外接口
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 作业统计 Controller
|
||||
* 作业统计 Controller-展示大屏
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.api.domain.ReMaterialParam;
|
||||
import com.ruoyi.api.domain.RequestEnter;
|
||||
import com.ruoyi.api.domain.WmsJobRequest;
|
||||
import com.ruoyi.api.service.IToWmsService;
|
||||
@@ -34,21 +35,12 @@ public class ToWmsApiController {
|
||||
@PostMapping("/requestEnterByTrayCode")
|
||||
public AjaxResult requestEnterByTrayCode(@RequestBody RequestEnter requestEnter) {
|
||||
AjaxResult ajaxResult = toWmsService.requestEnterByTrayCode(requestEnter);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "InJobByTrayCode",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);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(requestEnter), "入库任务请求(托盘)",ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小车接收开始信号
|
||||
*/
|
||||
@@ -83,9 +75,9 @@ public class ToWmsApiController {
|
||||
* 放货有货,重新分配货位
|
||||
*/
|
||||
@PostMapping("/reAssign")
|
||||
public AjaxResult reAssign(@RequestBody MydoJob mydoJob) {
|
||||
AjaxResult ajaxResult = toWmsService.reAssign(mydoJob);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(mydoJob), "reAssign",ajaxResult);
|
||||
public AjaxResult reAssign(@RequestBody ReMaterialParam reMaterialParam) {
|
||||
AjaxResult ajaxResult = toWmsService.reAssign(reMaterialParam);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reAssign",ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
@@ -94,9 +86,9 @@ public class ToWmsApiController {
|
||||
* 取货无货,重新分配物料
|
||||
*/
|
||||
@PostMapping("/reMaterial")
|
||||
public AjaxResult reMaterial(@RequestBody MydoJob mydoJob) {
|
||||
AjaxResult ajaxResult = toWmsService.reMaterial(mydoJob);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(mydoJob), "reMaterial",ajaxResult);
|
||||
public AjaxResult reMaterial(@RequestBody ReMaterialParam reMaterialParam) {
|
||||
AjaxResult ajaxResult = toWmsService.reMaterial(reMaterialParam);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(reMaterialParam), "reMaterial",ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 仓库和点位API接口
|
||||
*
|
||||
* 仓库和点位API接口--拣选大屏
|
||||
*
|
||||
* @author lsy
|
||||
* @date 2025-06-23
|
||||
*/
|
||||
@@ -29,10 +29,10 @@ import java.util.HashMap;
|
||||
@RestController
|
||||
@RequestMapping("/api/warehouse")
|
||||
public class WarehousePortController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IProductPortService productPortService;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class WarehousePortController extends BaseController {
|
||||
"FROM bas_warehouse " +
|
||||
"WHERE is_current = 'Y' " +
|
||||
"ORDER BY warehouse_no";
|
||||
|
||||
|
||||
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
||||
return success(list);
|
||||
} catch (Exception e) {
|
||||
@@ -126,4 +126,4 @@ public class WarehousePortController extends BaseController {
|
||||
return error("查询工位任务数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
import com.ruoyi.api.domain.ReMaterialParam;
|
||||
import com.ruoyi.api.domain.RequestEnter;
|
||||
import com.ruoyi.api.domain.WmsJobRequest;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
@@ -15,10 +16,7 @@ public interface IToWmsService {
|
||||
* 入库任务请求根据托盘码
|
||||
*/
|
||||
AjaxResult requestEnterByTrayCode(RequestEnter requestEnter);
|
||||
/**
|
||||
* 入库任务请求
|
||||
*/
|
||||
AjaxResult requestEnterByEnterId(RequestEnter requestEnter);
|
||||
|
||||
/**
|
||||
* 入库、出库 任务完成回传
|
||||
* 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.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.ReMaterialParam;
|
||||
import com.ruoyi.api.domain.RequestEnter;
|
||||
import com.ruoyi.api.domain.RequestEnterResponse;
|
||||
import com.ruoyi.api.domain.WmsJobRequest;
|
||||
import com.ruoyi.api.service.IToWmsService;
|
||||
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||
@@ -80,28 +82,9 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
mydoJob.setStatus("2");
|
||||
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
|
||||
public AjaxResult jobFinish(WmsJobRequest wmsJobRequest) {
|
||||
@@ -218,9 +201,9 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
}
|
||||
|
||||
@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();
|
||||
BasCargoSpace basCargoSpace = basCargoSpaceService.selectEmptyCargoSpaceByWarehouseId(warehouseId);
|
||||
if (basCargoSpace == null){
|
||||
@@ -230,14 +213,14 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
mydoJob.setCargoSpaceId(basCargoSpace.getCargoSpaceId());
|
||||
mydoJob.setFaultFlag("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
return AjaxResult.success(mydoJob);
|
||||
return AjaxResult.success(new RequestEnterResponse(basCargoSpace.getCargoSpaceId(), null, mydoJob.getJobId()));
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
mydoJobDetailParam.setJobId(mydoJob.getJobId());
|
||||
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 {
|
||||
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;//累加 校验
|
||||
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
|
||||
*/
|
||||
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);
|
||||
String green = String.format("%04x", Convert.toInt(tagTask.getNum()));
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TagInReadThread implements Runnable {
|
||||
basTagService.updateBasTag(basTag);
|
||||
|
||||
while (true) {
|
||||
try (Socket socket = getSocket(basTag.getIp(), 20108)) {
|
||||
try (Socket socket = getSocket(basTag.getIp())) {
|
||||
basTag = basTagService.selectBasTagById(tagId);
|
||||
if (basTag == null) {
|
||||
break;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TagOutReadThread implements Runnable {
|
||||
TagTask tagTaskParam = new TagTask();
|
||||
tagTaskParam.setTagId(basTag.getId());
|
||||
List<TagTask> allTagTasks = null;
|
||||
try (Socket socket = getSocket(basTag.getIp(), 20108)) {
|
||||
try (Socket socket = getSocket(basTag.getIp())) {
|
||||
while (true) {
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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 javax.xml.bind.DatatypeConverter;
|
||||
@@ -141,9 +143,11 @@ public class ElectronicTagClient {
|
||||
/**
|
||||
* 获取socket
|
||||
*/
|
||||
public static Socket getSocket(String ip, int port) {
|
||||
public static Socket getSocket(String ip) {
|
||||
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;
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user