| | |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) { |
| | | if (ObjectUtils.isNotNull(deviceLedger.getStartRuntimeTime()) && ObjectUtils.isNotNull(deviceLedger.getEndRuntimeTime())){ |
| | | //计算运行时长 |
| | | long start = deviceLedger.getStartRuntimeTime().toEpochSecond(ZoneOffset.UTC) * 1000; |
| | | long end = deviceLedger.getEndRuntimeTime().toEpochSecond(ZoneOffset.UTC) * 1000; |
| | | long diffMillis = Math.abs(end - start); |
| | | double time = diffMillis / (1000.0 * 60 * 60);// 毫秒 -> 秒 -> 分钟 -> 小时 |
| | | deviceLedger.setRuntimeDuration(time+"h"); |
| | | } |
| | | if (this.updateById(deviceLedger)) { |
| | | return AjaxResult.success(); |
| | | } |