@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource ;
import javax.validation.Valid ;
import java.io.IOException ;
import java.lang.reflect.Field ;
import java.util.* ;
/ * *
@ -210,6 +211,7 @@ public class DcDeviceController extends BaseController {
/ * *
* 查询当天设备指定属性列表
*
* @param deviceId 设备id
* @param propertyId 属性id
* @return 属性列表
@ -454,6 +456,13 @@ public class DcDeviceController extends BaseController {
JSONObject functionJSONObject = JSONObject . parseObject ( String . valueOf ( function ) ) ;
String functionId = functionJSONObject . getString ( "functionId" ) ;
JSONObject jsonObject = functionJSONObject . getJSONObject ( "params" ) ;
resultArray . add ( getResult ( device , iotDeviceId , functionId , jsonObject ) ) ;
}
}
return AjaxResult . success ( resultArray ) ;
}
private JSONObject getResult ( DcDevice device , String iotDeviceId , String functionId , JSONObject jsonObject ) throws HttpException , IOException {
HashMap < String , Object > params = jsonObject . toJavaObject ( new TypeReference < HashMap < String , Object > > ( ) {
} ) ;
JSONObject result = new JSONObject ( ) ;
@ -463,12 +472,45 @@ public class DcDeviceController extends BaseController {
} else {
result . put ( "result" , invokedFunction ( iotDeviceId , functionId , params ) ) ;
}
resultArray . add ( result ) ;
return result ;
}
/ * *
* 批量设备功能调用
*
* @param props 调用参数列表
* @return 调用结果
* /
@ApiOperation ( "批量激光疲劳设备功能调用" )
@PostMapping ( "/batchLaserFatigueInvokedFunction" )
public AjaxResult batchLaserFatigueInvokedFunction ( @RequestBody Map < String , Object > props ) throws HttpException , IOException , InterruptedException {
String deviceId = ( String ) props . get ( "deviceId" ) ;
String functionId = ( String ) props . get ( "functionId" ) ;
ArrayList params = ( ArrayList ) props . get ( "params" ) ;
JSONArray resultArray = new JSONArray ( ) ;
for ( Object param : params ) {
resultArray . add ( invokedFunction ( deviceId , functionId , ( HashMap < String , Object > ) param ) ) ;
}
HashMap < String , Object > hashMap = new HashMap < > ( ) ;
hashMap . put ( "SET" , "7" ) ;
invokedFunction ( deviceId , "SETMD" , hashMap ) ;
return AjaxResult . success ( resultArray ) ;
}
public HashMap < String , Object > objectToMap ( Object obj ) {
Map < String , Object > map = new HashMap < > ( ) ;
for ( Field field : obj . getClass ( ) . getDeclaredFields ( ) ) {
try {
field . setAccessible ( true ) ;
map . put ( field . getName ( ) , field . get ( obj ) ) ;
} catch ( IllegalAccessException e ) {
e . printStackTrace ( ) ;
}
}
return ( HashMap < String , Object > ) map ;
}
/ * *
* 查询物联设备事件数据
*