|
@@ -46,6 +46,9 @@ public class ApiInterfaceController {
|
|
@Autowired
|
|
@Autowired
|
|
TAlarmRecordService alarmRecordService;
|
|
TAlarmRecordService alarmRecordService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ TEquipmentDescService equipmentDescService;
|
|
|
|
+
|
|
@ApiOperation("查询设备信息列表")
|
|
@ApiOperation("查询设备信息列表")
|
|
@PostMapping("/getMachineList")
|
|
@PostMapping("/getMachineList")
|
|
public ResponseModel<?> getMachineList(@RequestHeader(value = "x-api-key") String apiKey, @RequestBody InterfaceParam interfaceParam) {
|
|
public ResponseModel<?> getMachineList(@RequestHeader(value = "x-api-key") String apiKey, @RequestBody InterfaceParam interfaceParam) {
|
|
@@ -231,6 +234,43 @@ public class ApiInterfaceController {
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation("查询机器当前状态")
|
|
|
|
+ @PostMapping("/getMachineStatus")
|
|
|
|
+ public ResponseModel<?> getMachineStatus(@RequestHeader("x-api-key") String apiKey, @RequestBody InterfaceParam interfaceParam) {
|
|
|
|
+ // 校验apiKey是否为空
|
|
|
|
+ if (StringUtils.isEmpty(apiKey)) {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "apiKey is null");
|
|
|
|
+ }
|
|
|
|
+ // 校验参数是否为空
|
|
|
|
+ String username = interfaceParam.getUsername();
|
|
|
|
+ String clientId = interfaceParam.getClientId();
|
|
|
|
+ if (StringUtils.isEmpty(username)) {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "username is null");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(clientId)) {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "clientId is null");
|
|
|
|
+ }
|
|
|
|
+ // 校验apiKey是否正确
|
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(TAdmin::getUsername, username);
|
|
|
|
+ wrapper.eq(TAdmin::getApiKey, apiKey);
|
|
|
|
+ TAdmin admin = adminService.getOne(wrapper);
|
|
|
|
+ if (admin == null) {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "Invalid apiKey or username is not exist");
|
|
|
|
+ }
|
|
|
|
+ // 校验clientId是否正确
|
|
|
|
+ LambdaQueryWrapper<TEquipment> equipmentWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ equipmentWrapper.eq(TEquipment::getClientId, clientId);
|
|
|
|
+ equipmentWrapper.eq(TEquipment::getAdminId, admin.getId());
|
|
|
|
+ TEquipment equipment = equipmentService.getOne(equipmentWrapper);
|
|
|
|
+ if(equipment == null) {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "clientId is not exist");
|
|
|
|
+ }
|
|
|
|
+ TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
|
|
+ String status = equipmentDesc.getStatus();
|
|
|
|
+ return R.ok(status);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void remoteResult(String productName, TEquipment equipment, Long adminId) {
|
|
public void remoteResult(String productName, TEquipment equipment, Long adminId) {
|
|
StringBuilder number = new StringBuilder();
|
|
StringBuilder number = new StringBuilder();
|
|
Random random = new Random();
|
|
Random random = new Random();
|