parent
f55c06a626
commit
3e3635b912
|
@ -146,14 +146,16 @@ public class YiYangAbilityImpl implements DisposeAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean getDeviceLinkStatus() {
|
public boolean getDeviceLinkStatus() {
|
||||||
try {
|
try {
|
||||||
|
String url = urlRootPath + "dispose_device/information/linkstatus";
|
||||||
|
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode err = restfulInterface.getLinkStatus(urlRootPath, token);
|
ErrorCode err = restfulInterface.getLinkStatus(url, token);
|
||||||
|
|
||||||
if (err == ErrorCode.ERR_LOGOUT) {
|
if (err == ErrorCode.ERR_LOGOUT) {
|
||||||
err = restfulInterface.getLinkStatus(urlRootPath, token);
|
err = restfulInterface.getLinkStatus(url, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err == ErrorCode.ERR_OK;
|
return err == ErrorCode.ERR_OK;
|
||||||
|
@ -188,7 +190,8 @@ public class YiYangAbilityImpl implements DisposeAbility {
|
||||||
*/
|
*/
|
||||||
private void upgradeToken() {
|
private void upgradeToken() {
|
||||||
try {
|
try {
|
||||||
ProtocolRespDTO<YiYangLoginRsp> logInfo = restfulInterface.login(urlRootPath, username, password);
|
String url = urlRootPath + "dispose_device/auth/login";
|
||||||
|
ProtocolRespDTO<YiYangLoginRsp> logInfo = restfulInterface.login(url, username, password);
|
||||||
|
|
||||||
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||||
this.token = logInfo.getMsgContent().getToken();
|
this.token = logInfo.getMsgContent().getToken();
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang dispose ability info.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangDisposeAbilityInfo {
|
||||||
|
/**
|
||||||
|
* The Type.
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Object type.
|
||||||
|
*/
|
||||||
|
private Integer objectType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Ip type.
|
||||||
|
*/
|
||||||
|
private Integer IPType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Protect ip.
|
||||||
|
*/
|
||||||
|
private String disposeIp;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang dispose ability rsp.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangDisposeAbilityRsp extends YiYangBaseResp {
|
||||||
|
/**
|
||||||
|
* The Device name.
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Capacity.
|
||||||
|
*/
|
||||||
|
List<YiYangDisposeAbilityInfo> capacity;
|
||||||
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package com.dispose.yiyang.dispose.common;
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -15,11 +13,9 @@ import lombok.NoArgsConstructor;
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@JsonPropertyOrder({"userName", "token", "logTime", "expireTime", "status", "message"})
|
|
||||||
public class YiYangLoginRsp extends YiYangBaseResp {
|
public class YiYangLoginRsp extends YiYangBaseResp {
|
||||||
/**
|
/**
|
||||||
* The User name.
|
* The User name.
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang start task items.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YiYangStartTaskItem {
|
||||||
|
/**
|
||||||
|
* The Task req id.
|
||||||
|
*/
|
||||||
|
private String taskReqId;
|
||||||
|
/**
|
||||||
|
* The Type.
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* The Object type.
|
||||||
|
*/
|
||||||
|
private Integer objectType;
|
||||||
|
/**
|
||||||
|
* The Dispose object.
|
||||||
|
*/
|
||||||
|
private String disposeObject;
|
||||||
|
/**
|
||||||
|
* The Dispose time.
|
||||||
|
*/
|
||||||
|
private Long disposeTime;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang start task req.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YiYangStartTaskReq {
|
||||||
|
/**
|
||||||
|
* The Items.
|
||||||
|
*/
|
||||||
|
List<YiYangStartTaskItem> items;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang start task rsp.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangStartTaskRsp {
|
||||||
|
/**
|
||||||
|
* The Device name.
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Items.
|
||||||
|
*/
|
||||||
|
List<YiYangStartedItem> items;
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang started item.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangStartedItem extends YiYangBaseResp {
|
||||||
|
/**
|
||||||
|
* The Task req id.
|
||||||
|
*/
|
||||||
|
private String taskReqId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Task id.
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Expire time.
|
||||||
|
*/
|
||||||
|
private Long expireTime;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang stop task req.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YiYangStopTaskReq {
|
||||||
|
/**
|
||||||
|
* The Task id.
|
||||||
|
*/
|
||||||
|
private String[] taskId;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang stop task rsp.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangStopTaskRsp {
|
||||||
|
/**
|
||||||
|
* The Device name.
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
/**
|
||||||
|
* The Items.
|
||||||
|
*/
|
||||||
|
private List<YiYangStoppedItem> items;
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.dispose.yiyang.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Yi yang stopped item.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class YiYangStoppedItem extends YiYangBaseResp {
|
||||||
|
/**
|
||||||
|
* The Task id.
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
/**
|
||||||
|
* The Type.
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* The Object type.
|
||||||
|
*/
|
||||||
|
private Integer objectType;
|
||||||
|
/**
|
||||||
|
* The Dispose object.
|
||||||
|
*/
|
||||||
|
private String disposeObject;
|
||||||
|
/**
|
||||||
|
* The Left time.
|
||||||
|
*/
|
||||||
|
private Long leftTime;
|
||||||
|
}
|
|
@ -5,11 +5,18 @@ import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.restful.RestfulInterface;
|
import com.dispose.restful.RestfulInterface;
|
||||||
import com.dispose.yiyang.dispose.common.YiYangBaseResp;
|
import com.dispose.yiyang.dispose.common.YiYangBaseResp;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangDisposeAbilityRsp;
|
||||||
import com.dispose.yiyang.dispose.common.YiYangLoginReq;
|
import com.dispose.yiyang.dispose.common.YiYangLoginReq;
|
||||||
import com.dispose.yiyang.dispose.common.YiYangLoginRsp;
|
import com.dispose.yiyang.dispose.common.YiYangLoginRsp;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangStartTaskItem;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangStartTaskReq;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangStartTaskRsp;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangStopTaskReq;
|
||||||
|
import com.dispose.yiyang.dispose.common.YiYangStopTaskRsp;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Yi yang interface.
|
* The type Yi yang interface.
|
||||||
|
@ -58,7 +65,7 @@ public class YiYangInterface {
|
||||||
reqInfo.setVer(this.ver);
|
reqInfo.setVer(this.ver);
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
|
||||||
return RestfulInterface.baseProRun(baseUrlPath + "dispose_device/auth/login",
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
null,
|
null,
|
||||||
reqInfo,
|
reqInfo,
|
||||||
YiYangLoginRsp.class,
|
YiYangLoginRsp.class,
|
||||||
|
@ -73,7 +80,7 @@ public class YiYangInterface {
|
||||||
* @return the link status
|
* @return the link status
|
||||||
*/
|
*/
|
||||||
public ErrorCode getLinkStatus(String baseUrlPath, String token) {
|
public ErrorCode getLinkStatus(String baseUrlPath, String token) {
|
||||||
ProtocolRespDTO<YiYangBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath + "dispose_device/information/linkstatus",
|
ProtocolRespDTO<YiYangBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
null,
|
null,
|
||||||
YiYangBaseResp.class,
|
YiYangBaseResp.class,
|
||||||
|
@ -88,4 +95,69 @@ public class YiYangInterface {
|
||||||
|
|
||||||
return ErrorCode.ERR_UNKNOWNCMD;
|
return ErrorCode.ERR_UNKNOWNCMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start dispose task protocol resp dto.
|
||||||
|
*
|
||||||
|
* @param baseUrlPath the base url path
|
||||||
|
* @param token the token
|
||||||
|
* @param items the items
|
||||||
|
* @return the protocol resp dto
|
||||||
|
*/
|
||||||
|
public ProtocolRespDTO<YiYangStartTaskRsp> startDisposeTask(String baseUrlPath, String token,
|
||||||
|
List<YiYangStartTaskItem> items) {
|
||||||
|
BaseProtocolDTO<YiYangStartTaskReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
|
reqInfo.setMsgContent(new YiYangStartTaskReq());
|
||||||
|
|
||||||
|
reqInfo.getMsgContent().setItems(items);
|
||||||
|
reqInfo.setCryptoType(this.cryptoType);
|
||||||
|
reqInfo.setVer(this.ver);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
|
token,
|
||||||
|
reqInfo,
|
||||||
|
YiYangStartTaskRsp.class,
|
||||||
|
RequestMethod.POST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop dispose task protocol resp dto.
|
||||||
|
*
|
||||||
|
* @param baseUrlPath the base url path
|
||||||
|
* @param token the token
|
||||||
|
* @param taskId the task id
|
||||||
|
* @return the protocol resp dto
|
||||||
|
*/
|
||||||
|
public ProtocolRespDTO<YiYangStopTaskRsp> stopDisposeTask(String baseUrlPath, String token, String[] taskId) {
|
||||||
|
BaseProtocolDTO<YiYangStopTaskReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
|
|
||||||
|
reqInfo.setMsgContent(new YiYangStopTaskReq());
|
||||||
|
|
||||||
|
reqInfo.getMsgContent().setTaskId(taskId);
|
||||||
|
reqInfo.setCryptoType(this.cryptoType);
|
||||||
|
reqInfo.setVer(this.ver);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
|
token,
|
||||||
|
reqInfo,
|
||||||
|
YiYangStopTaskRsp.class,
|
||||||
|
RequestMethod.POST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets device dispose ability.
|
||||||
|
*
|
||||||
|
* @param baseUrlPath the base url path
|
||||||
|
* @param token the token
|
||||||
|
* @return the device dispose ability
|
||||||
|
*/
|
||||||
|
public ProtocolRespDTO<YiYangDisposeAbilityRsp> getDeviceDisposeAbility(String baseUrlPath, String token) {
|
||||||
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
|
token,
|
||||||
|
null,
|
||||||
|
YiYangDisposeAbilityRsp.class,
|
||||||
|
RequestMethod.GET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue