添加章源钨业接口 1.获取重量 2.获取滚筒线信息

This commit is contained in:
熟小柿 2024-02-23 15:05:00 +08:00
parent 817539c75e
commit 52700959b0
5 changed files with 193 additions and 4 deletions

View File

@ -2,15 +2,13 @@ package com.wcs.back.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.wcs.back.domain.WcsResult;
import com.wcs.back.domain.WcsResult2;
import com.wcs.back.service.IWcsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@ -78,4 +76,24 @@ public class WcsController {
return wcsResult;
}
/**
* 称重
*/
@ApiOperation("称重")
@GetMapping("/GetWeight")
public WcsResult2 GetWeight(String rollerID) throws JsonProcessingException {
WcsResult2 wcsResult = wcsService.GetWeight(rollerID);
return wcsResult;
}
/**
* 获取滚筒线信息
*/
@ApiOperation("获取滚筒线信息")
@GetMapping("/GetRollerInfo")
public WcsResult2 GetRollerInfo() throws JsonProcessingException {
WcsResult2 wcsResult = wcsService.GetRollerInfo();
return wcsResult;
}
}

View File

@ -0,0 +1,45 @@
package com.wcs.back.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 滚筒线信息Vo
*
* @author zf
* @date 2024/2/4
*/
@Data
public class RollerInfoVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 滚筒线编号 */
@ApiModelProperty("滚筒线编号")
private String rollerID;
/** 是否在线 */
@ApiModelProperty("是否在线")
private boolean connectState;
/** 模式【0手动、1自动】 */
@ApiModelProperty("模式【0手动、1自动】")
private int mode;
/** 出入库状态【0其他、1出库中、2入库中】 */
@ApiModelProperty("出入库状态【0其他、1出库中、2入库中】")
private int inOutStatus;
/** 传送带上剩余桶数量 */
@ApiModelProperty("传送带上剩余桶数量")
private int number;
/** 急停状态【0急停、1正常】 */
@ApiModelProperty("急停状态【0急停、1正常】")
private int eStopStatus;
/** 故障状态【0故障、1正常】 */
@ApiModelProperty("故障状态【0故障、1正常】")
private int faultStatus;
}

View File

@ -0,0 +1,67 @@
package com.wcs.back.domain;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* wcs返回信息
*
* @author 中xue
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WcsResult2 {
private static final long serialVersionUID = 1L;
/**
* 信息编码0失败1成功其他信息可自定义
*/
@JsonProperty("code")
private Integer code;
/**
* true成功false失败
*/
@JsonProperty("state")
private Boolean state;
/**
* 反馈信息说明
*/
@JsonProperty("message")
private String message;
/**
* 数据
*/
@JsonProperty("dataInfo")
private Object dataInfo;
/**
* 返回成功消息
*
* @return 成功消息
*/
public static JSONObject success()
{
String result = "{\"message\":\"成功\",\"code\":1\"}";
return JSONObject.parseObject(result);
}
/**
* 返回错误消息
*
* @return 失败消息
*/
public static JSONObject error()
{
String result = "{\"message\":\"失败\",\"code\":0\"}";
return JSONObject.parseObject(result);
}
}

View File

@ -2,6 +2,7 @@ package com.wcs.back.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.wcs.back.domain.WcsResult;
import com.wcs.back.domain.WcsResult2;
import javax.servlet.http.HttpServletRequest;
@ -50,4 +51,18 @@ public interface IWcsService {
* @return
*/
WcsResult Directives(String json, HttpServletRequest request) throws JsonProcessingException;
/**
* 获取重量
* @param rollerID
* @return
*/
WcsResult2 GetWeight(String rollerID);
/**
* 获取滚筒线信息
* @return
*/
WcsResult2 GetRollerInfo();
}

View File

@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@ -315,6 +316,49 @@ public class WcsServiceImpl implements IWcsService {
return wcsResult;
}
/**
* 获取重量
*
* @param rollerID
* @return
*/
@Override
public WcsResult2 GetWeight(String rollerID) {
WcsResult2 wcsResult2 = new WcsResult2();
wcsResult2.setCode(1);
wcsResult2.setState(true);
wcsResult2.setMessage("");
wcsResult2.setDataInfo(100);
return wcsResult2;
}
/**
* 获取滚筒线信息
*
* @return
*/
@Override
public WcsResult2 GetRollerInfo() {
WcsResult2 wcsResult2 = new WcsResult2();
wcsResult2.setCode(1);
wcsResult2.setState(true);
wcsResult2.setMessage("");
List<RollerInfoVo> rollerInfoVos = new ArrayList<>();
RollerInfoVo rollerInfoVo = new RollerInfoVo();
rollerInfoVo.setRollerID("1");
rollerInfoVo.setConnectState(true);
rollerInfoVo.setMode(1);
rollerInfoVo.setInOutStatus(2);
rollerInfoVo.setNumber(0);
rollerInfoVo.setEStopStatus(1);
rollerInfoVo.setFaultStatus(1);
rollerInfoVos.add(rollerInfoVo);
wcsResult2.setDataInfo(rollerInfoVos);
return wcsResult2;
}
// 发送 HTTP POST 请求
private <T> WcsResult sendHttpPost(T taskCallBack, String url) {
String jsonString = JSON.toJSONString(taskCallBack);