Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package com.ubt.jimu.transport;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
/* loaded from: classes2.dex */
class ConfigItemTransporter {
ConfigItemTransporter() {
new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
new JimuMotionDbHandler(DatabaseUtils.getDaoSession(true).o());
new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
}
}

View File

@@ -0,0 +1,35 @@
package com.ubt.jimu.transport;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.utils.SystemUtils;
/* loaded from: classes2.dex */
class FileTransporter {
private DiyRobotDbHandler a = new DiyRobotDbHandler(DatabaseUtils.getDaoSession(true).d());
private TransportFileDbHandler b = new TransportFileDbHandler(DatabaseUtils.getDaoSession(true).v());
FileTransporter() {
}
public void a(String str, DiyDBModel diyDBModel) {
if (diyDBModel == null) {
return;
}
this.a.delete(diyDBModel);
this.b.deleteModelFiles(str, diyDBModel.getCustomModelId());
}
public void a(DiyDBModel diyDBModel) {
if (diyDBModel == null) {
return;
}
long a = SystemUtils.a();
diyDBModel.setIsDelete(true);
diyDBModel.setModify(true);
diyDBModel.setModifyTime(a);
this.a.update(diyDBModel);
}
}

View File

@@ -0,0 +1,69 @@
package com.ubt.jimu.transport;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.base.http.ApiClient;
import com.ubt.jimu.base.http.ApiConstants;
import com.ubt.jimu.base.http.ApiObserver;
import com.ubt.jimu.base.http.ApiResponse;
import com.ubt.jimu.base.http.manager.Manager;
import com.ubt.jimu.transport.api.ConfigItemService;
import com.ubt.jimu.transport.api.DiyRobotService;
import com.ubt.jimu.transport.api.TransportFileService;
import com.ubt.jimu.transport.model.ConfigItem;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.transport.request.UploadFileParam;
import com.ubt.jimu.transport.request.UploadSingleConfigItemParam;
import com.ubt.jimu.transport.request.UploadSingleFileParam;
import io.reactivex.Observable;
import io.reactivex.schedulers.Schedulers;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/* loaded from: classes2.dex */
class TransportManager extends Manager {
private ConfigItemService a;
private DiyRobotService b;
private TransportFileService c;
private static class TransportManagerHelper {
public static TransportManager a = new TransportManager();
}
public static TransportManager getInstance() {
return TransportManagerHelper.a;
}
public Observable<ApiResponse<ConfigItem>> a(String str, String str2, ConfigItem configItem, ApiObserver<ApiResponse<ConfigItem>> apiObserver) {
Observable<ApiResponse<ConfigItem>> uploadConfigFile = this.a.uploadConfigFile(new UploadSingleConfigItemParam(str, str2, configItem));
toSubscribe(uploadConfigFile, apiObserver);
return uploadConfigFile;
}
private TransportManager() {
this.a = (ConfigItemService) ApiClient.getService(ConfigItemService.class);
this.b = (DiyRobotService) ApiClient.getService(DiyRobotService.class);
this.c = (TransportFileService) ApiClient.getService(TransportFileService.class);
}
public Observable<ApiResponse<TransportFile>> a(String str, String str2, String str3, TransportFile transportFile, ApiObserver<ApiResponse<TransportFile>> apiObserver) throws IOException {
Observable<ApiResponse<TransportFile>> uploadFile = this.c.uploadFile(new UploadSingleFileParam(str, str2, str3, transportFile));
uploadFile.subscribeOn(Schedulers.b()).observeOn(Schedulers.b()).subscribe(apiObserver);
return uploadFile;
}
public Observable<ApiResponse<List<TransportFile>>> a(String str, String str2, String str3, List<TransportFile> list, ApiObserver<ApiResponse<List<TransportFile>>> apiObserver) throws IOException {
Observable<ApiResponse<List<TransportFile>>> uploadBatchFile = this.c.uploadBatchFile(new UploadFileParam(str, str2, str3, list));
uploadBatchFile.subscribeOn(Schedulers.b()).observeOn(Schedulers.b()).subscribe(apiObserver);
return uploadBatchFile;
}
public Observable<ApiResponse<DiyDBModel>> a(String str, String str2, ApiObserver<ApiResponse<DiyDBModel>> apiObserver) {
Map<String, Object> baseParams = ApiConstants.getBaseParams();
baseParams.put("modelCreatedId", str);
baseParams.put("modelId", str2);
Observable<ApiResponse<DiyDBModel>> deleteModel = this.b.deleteModel(baseParams);
deleteModel.subscribeOn(Schedulers.b()).observeOn(Schedulers.b()).subscribe(apiObserver);
return deleteModel;
}
}

View File

@@ -0,0 +1,313 @@
package com.ubt.jimu.transport;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.base.entities.User;
import com.ubt.jimu.base.http.ApiObserver;
import com.ubt.jimu.base.http.ApiResponse;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.transport.model.ConfigItem;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.utils.SystemUtils;
import com.ubt.jimu.widgets.LoadingView;
import com.ubtrobot.log.ALog;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import java.io.File;
import java.util.HashMap;
import java.util.List;
/* loaded from: classes2.dex */
public class Transporter {
private static final String f = "Transporter";
private static HashMap<String, Transporter> g = new HashMap<>();
private String a;
private String b;
private FileTransporter c;
private ConfigItemDbHandler d;
private TransportFileDbHandler e;
private Transporter(String str, String str2) {
new ConfigItemTransporter();
this.c = new FileTransporter();
this.d = new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
this.e = new TransportFileDbHandler(DatabaseUtils.getDaoSession(true).v());
new DiyRobotDbHandler(DatabaseUtils.getDaoSession(true).d());
this.a = str;
this.b = str2;
}
public static Transporter b() {
User user = Cache.getInstance().getUser();
String valueOf = user == null ? "local" : String.valueOf(user.getUserId());
Transporter transporter = g.get(valueOf);
if (transporter == null) {
synchronized (Transporter.class) {
transporter = g.get(valueOf);
if (transporter == null) {
transporter = new Transporter(valueOf, user == null ? "" : user.getUserName());
g.put(valueOf, transporter);
}
}
}
return transporter;
}
public synchronized void a(String str, final ConfigItem configItem) {
if ("local".equals(this.a)) {
ALog.a(f).d("本地账户,不需要同步到服务器:" + this.a);
return;
}
configItem.setUploadState(1);
this.d.update(configItem);
TransportManager.getInstance().a(configItem.getUserId(), str, configItem, new ApiObserver<ApiResponse<ConfigItem>>(null) { // from class: com.ubt.jimu.transport.Transporter.2
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onComplete() {
super.onComplete();
configItem.setUploadState(0);
Transporter.this.d.update(configItem);
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onError(Throwable th) {
super.onError(th);
Log.e(Transporter.f, "uploadConfigItem onError:" + th.getMessage());
th.printStackTrace();
configItem.setUploadState(0);
Transporter.this.d.update(configItem);
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
super.onSubscribe(disposable);
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onNext(ApiResponse<ConfigItem> apiResponse) {
ConfigItem a;
super.onNext((AnonymousClass2) apiResponse);
ConfigItem models = apiResponse.getModels();
if (models == null || (a = Transporter.this.d.a(apiResponse.getModels())) == null) {
return;
}
a.setIsModify(false);
a.setServerID("0000");
a.setId(models.getId());
Transporter.this.d.update(a);
}
});
}
public boolean b(File file) {
TransportFile fileBean = this.e.getFileBean(this.a, file);
if (fileBean == null) {
return false;
}
long a = SystemUtils.a();
fileBean.setModifyTime(a);
fileBean.setLastUploadTime(a);
if (!fileBean.getIsModify()) {
fileBean.setIsModify(true);
}
this.e.update(fileBean);
if ("local".equals(this.a)) {
ALog.a(f).d("本地账户,不需要同步到服务器:" + this.a);
return true;
}
a("update", fileBean);
return true;
}
public Observable<ApiResponse<DiyDBModel>> a(final DiyDBModel diyDBModel) {
LoadingView loadingView = null;
if (diyDBModel == null || diyDBModel.getModelId().intValue() == 0) {
return null;
}
if ("local".equals(this.a)) {
ALog.a(f).d("本地账户,不需要同步到服务器:" + this.a);
return null;
}
if (diyDBModel.getModelId().intValue() < 1) {
this.c.a(this.a, diyDBModel);
return null;
}
this.c.a(diyDBModel);
final List<TransportFile> modelFilesDeleted = this.e.setModelFilesDeleted(this.a, diyDBModel.getCustomModelId());
return TransportManager.getInstance().a(diyDBModel.getModelCreatedId(), String.valueOf(diyDBModel.getModelId()), new ApiObserver<ApiResponse<DiyDBModel>>(loadingView) { // from class: com.ubt.jimu.transport.Transporter.5
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onNext(ApiResponse<DiyDBModel> apiResponse) {
super.onNext((AnonymousClass5) apiResponse);
Transporter.this.c.a(Transporter.this.a, diyDBModel);
Transporter.this.a("delete", (List<TransportFile>) modelFilesDeleted);
}
});
}
public boolean a(long j, String str, String str2, File file) {
long insert = this.e.insert(new TransportFile(this.a, (int) j, str, str2, "", TransportFileDbHandler.getFilePath(file), file.getName()));
if ("local".equals(this.a)) {
ALog.a(f).d("本地账户,不需要同步到服务器:" + this.a);
return true;
}
a("add", this.e.selectById(Long.valueOf(insert)));
return true;
}
public boolean a(File file) {
TransportFile fileBean = this.e.getFileBean(this.a, file);
if (fileBean == null) {
return false;
}
long a = SystemUtils.a();
fileBean.setModifyTime(a);
fileBean.setLastUploadTime(a);
fileBean.setIsDeleted(true);
fileBean.setIsModify(true);
if (file != null && file.exists()) {
file.delete();
}
this.e.update(fileBean);
if ("local".equals(this.a)) {
ALog.a(f).d("本地账户,不需要同步到服务器:" + this.a);
return true;
}
a("delete", fileBean);
return true;
}
private void a(final String str, final TransportFile transportFile) {
if (transportFile.getModelId() < 0) {
return;
}
try {
TransportManager.getInstance().a(this.a, this.b, str, transportFile, new ApiObserver<ApiResponse<TransportFile>>(null) { // from class: com.ubt.jimu.transport.Transporter.9
private void a(TransportFile transportFile2) {
TransportFile selectUnique = Transporter.this.e.selectUnique(transportFile);
if (selectUnique == null) {
return;
}
selectUnique.setFileId(transportFile2.getFileId());
selectUnique.setModifyTime(transportFile2.getModifyTime());
selectUnique.setLastUploadTime(transportFile2.getLastUploadTime());
selectUnique.setFileVersion(transportFile2.getFileVersion());
selectUnique.setIsModify(false);
Transporter.this.e.update(selectUnique);
ALog.a(Transporter.f).d(str + ":" + transportFile.getFilePath() + transportFile.getFileName() + "成功");
}
private void b(TransportFile transportFile2) {
TransportFile selectUnique = Transporter.this.e.selectUnique(transportFile);
if (selectUnique == null) {
return;
}
selectUnique.setIsModify(false);
selectUnique.setLastUploadTime(transportFile2.getLastUploadTime());
selectUnique.setModifyTime(transportFile2.getModifyTime());
selectUnique.setFileVersion(transportFile2.getFileVersion());
Transporter.this.e.update(selectUnique);
ALog.a(Transporter.f).d(str + ":" + transportFile.getFilePath() + transportFile.getFileName() + "成功");
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onComplete() {
super.onComplete();
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onError(Throwable th) {
super.onError(th);
Log.e(Transporter.f, str + ":" + transportFile.getFilePath() + transportFile.getFileName() + "失败");
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onNext(ApiResponse<TransportFile> apiResponse) {
TransportFile models;
super.onNext((AnonymousClass9) apiResponse);
ALog.a(Transporter.f).d(str + ":" + transportFile.getFilePath() + transportFile.getFileName() + "返回");
if (apiResponse == null || (models = apiResponse.getModels()) == null) {
return;
}
String str2 = str;
char c = 65535;
int hashCode = str2.hashCode();
if (hashCode != -1335458389) {
if (hashCode != -838846263) {
if (hashCode == 96417 && str2.equals("add")) {
c = 0;
}
} else if (str2.equals("update")) {
c = 1;
}
} else if (str2.equals("delete")) {
c = 2;
}
if (c == 0) {
a(models);
} else if (c == 1) {
b(models);
} else {
if (c != 2) {
return;
}
b(models);
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(final String str, final List<TransportFile> list) {
if (list == null || list.size() < 1 || TextUtils.isEmpty(str)) {
return;
}
try {
TransportManager.getInstance().a(this.a, this.b, str, list, new ApiObserver<ApiResponse<List<TransportFile>>>(null) { // from class: com.ubt.jimu.transport.Transporter.10
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onComplete() {
super.onComplete();
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onError(Throwable th) {
super.onError(th);
Log.e(Transporter.f, "上传多个文件失败:" + th.getMessage());
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
super.onSubscribe(disposable);
}
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
public void onNext(ApiResponse<List<TransportFile>> apiResponse) {
List<TransportFile> models;
super.onNext((AnonymousClass10) apiResponse);
if (apiResponse == null || (models = apiResponse.getModels()) == null || models.size() == 0) {
return;
}
Log.i(Transporter.f, "同步成功:" + str + "-" + models.size());
if ("delete".equals(str)) {
Transporter.this.e.deleteInTx(list);
Log.i(Transporter.f, "delete:" + list.size());
return;
}
for (TransportFile transportFile : list) {
transportFile.setFileId("1");
transportFile.setIsModify(false);
}
Transporter.this.e.updateInTx(list);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,13 @@
package com.ubt.jimu.transport;
import android.util.Base64;
import com.ubtech.utils.FileHelper;
import java.io.File;
import java.io.IOException;
/* loaded from: classes2.dex */
public class Utils {
public static String a(File file) throws IOException {
return Base64.encodeToString(FileHelper.b(file), 0);
}
}

View File

@@ -0,0 +1,23 @@
package com.ubt.jimu.transport.api;
import com.ubt.jimu.base.http.ApiResponse;
import com.ubt.jimu.transport.model.ConfigItem;
import com.ubt.jimu.transport.request.UploadConfigItemParam;
import com.ubt.jimu.transport.request.UploadSingleConfigItemParam;
import io.reactivex.Observable;
import java.util.List;
import java.util.Map;
import retrofit2.http.Body;
import retrofit2.http.POST;
/* loaded from: classes2.dex */
public interface ConfigItemService {
@POST("https://jimu.ubtrobot.com/jimu/syncfile/querySyncConfigFiles")
Observable<ApiResponse<List<ConfigItem>>> querySyncConfigFiles(@Body Map<String, String> map);
@POST("https://jimu.ubtrobot.com/jimu/syncfile/uploadBatchConfigFile")
Observable<ApiResponse<List<ConfigItem>>> uploadBatchConfigFile(@Body UploadConfigItemParam uploadConfigItemParam);
@POST("https://jimu.ubtrobot.com/jimu/syncfile/uploadConfigFile")
Observable<ApiResponse<ConfigItem>> uploadConfigFile(@Body UploadSingleConfigItemParam uploadSingleConfigItemParam);
}

View File

@@ -0,0 +1,29 @@
package com.ubt.jimu.transport.api;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.base.db.diy.SyncDbModel;
import com.ubt.jimu.base.http.ApiResponse;
import com.ubt.jimu.transport.request.CreateDiyRobotParam;
import io.reactivex.Observable;
import java.util.List;
import java.util.Map;
import retrofit2.http.Body;
import retrofit2.http.POST;
/* loaded from: classes2.dex */
public interface DiyRobotService {
@POST("https://jimu.ubtrobot.com/jimu/model/createCustomModel")
Observable<ApiResponse<DiyDBModel>> createCustomModel(@Body CreateDiyRobotParam createDiyRobotParam);
@POST("https://jimu.ubtrobot.com/jimu/model/createMultiCustomModel")
Observable<ApiResponse<List<DiyDBModel>>> createMultiCustomModel(@Body Map<String, Object> map);
@POST("https://jimu.ubtrobot.com/jimu/model/deleteModel")
Observable<ApiResponse<DiyDBModel>> deleteModel(@Body Map<String, Object> map);
@POST("https://jimu.ubtrobot.com/jimu/model/deleteMultiModel")
Observable<ApiResponse<List<DiyDBModel>>> deleteMultiModel(@Body Map<String, Object> map);
@POST("https://jimu.ubtrobot.com/jimu/model/queryCustomModelListByUser")
Observable<ApiResponse<List<SyncDbModel>>> queryCustomModelListByUser(@Body Map<String, Object> map);
}

View File

@@ -0,0 +1,23 @@
package com.ubt.jimu.transport.api;
import com.ubt.jimu.base.http.ApiResponse;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.transport.request.UploadFileParam;
import com.ubt.jimu.transport.request.UploadSingleFileParam;
import io.reactivex.Observable;
import java.util.List;
import java.util.Map;
import retrofit2.http.Body;
import retrofit2.http.POST;
/* loaded from: classes2.dex */
public interface TransportFileService {
@POST("https://jimu.ubtrobot.com/jimu/syncfile/querySyncFiles")
Observable<ApiResponse<List<TransportFile>>> querySyncFiles(@Body Map<String, String> map);
@POST("https://jimu.ubtrobot.com/jimu/syncfile/uploadBatchFile")
Observable<ApiResponse<List<TransportFile>>> uploadBatchFile(@Body UploadFileParam uploadFileParam);
@POST("https://jimu.ubtrobot.com/jimu/syncfile/uploadFile")
Observable<ApiResponse<TransportFile>> uploadFile(@Body UploadSingleFileParam uploadSingleFileParam);
}

View File

@@ -0,0 +1,109 @@
package com.ubt.jimu.transport.dao;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.base.db.AbstractDaoHandler;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.blockly.bean.BlocklyProject;
import com.ubt.jimu.blockly.bean.JimuMotion;
import com.ubt.jimu.blockly.bean.JimuSound;
import com.ubt.jimu.gen.ConfigItemDao;
import com.ubt.jimu.transport.model.ConfigItem;
import com.ubt.jimu.utils.SystemUtils;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.QueryBuilder;
/* loaded from: classes2.dex */
public class ConfigItemDbHandler extends AbstractDaoHandler<ConfigItem> {
private static ConfigItemDbHandler b;
private final String a;
public ConfigItemDbHandler(AbstractDao<ConfigItem, Long> abstractDao) {
super(abstractDao);
this.a = ConfigItemDbHandler.class.getSimpleName();
}
public static synchronized ConfigItemDbHandler getInstance() {
ConfigItemDbHandler configItemDbHandler;
synchronized (ConfigItemDbHandler.class) {
if (b == null) {
b = new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
}
configItemDbHandler = b;
}
return configItemDbHandler;
}
public ConfigItem a(ConfigItem configItem) {
if (configItem == null) {
return null;
}
return a(configItem.getUserId(), configItem.getCustomModelId(), configItem.getType(), configItem.getFileName());
}
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
/* renamed from: b, reason: merged with bridge method [inline-methods] */
public ConfigItem selectUnique(ConfigItem configItem) {
if (configItem == null) {
return null;
}
try {
return a(configItem.getUserId(), configItem.getCustomModelId(), configItem.getType(), configItem.getFileName());
} catch (Exception e) {
e.printStackTrace();
Log.e(this.a, "ConfigItemDbHandler#selectUnique:" + e.getMessage());
return null;
}
}
public void c(ConfigItem configItem) {
configItem.setIsDeleted("1");
configItem.setIsModify(true);
configItem.setFileModifyTime(SystemUtils.a());
update(configItem);
}
public ConfigItem a(BlocklyProject blocklyProject) {
if (blocklyProject == null) {
return null;
}
return a(blocklyProject.getUserId(), blocklyProject.getCustomModelId(), blocklyProject.getBlocklyType(), blocklyProject.getXmlId());
}
public ConfigItem a(JimuSound jimuSound) {
if (jimuSound == null) {
return null;
}
return a(jimuSound.getUserId(), "0", "audio", jimuSound.getKey());
}
public ConfigItem a(JimuMotion jimuMotion) {
if (jimuMotion == null) {
return null;
}
return a(jimuMotion.getUserId(), jimuMotion.getCustomModelId(), ConfigItem.TYPE_MOTION, jimuMotion.getActionID());
}
private ConfigItem a(String str, String str2, String str3, String str4) {
QueryBuilder k = this.dao.k();
if (TextUtils.isEmpty(str2)) {
k.a(ConfigItemDao.Properties.UserId.a((Object) str), ConfigItemDao.Properties.Type.a((Object) str3), ConfigItemDao.Properties.FileName.a((Object) str4));
} else {
k.a(ConfigItemDao.Properties.UserId.a((Object) str), ConfigItemDao.Properties.Type.a((Object) str3), ConfigItemDao.Properties.CustomModelId.a((Object) str2), ConfigItemDao.Properties.FileName.a((Object) str4));
}
List<ConfigItem> b2 = k.b();
if (b2 == null || b2.size() == 0) {
return null;
}
if (b2.size() == 1) {
return (ConfigItem) b2.get(0);
}
for (ConfigItem configItem : b2) {
if (!"1".equals(configItem.getIsDeleted())) {
return configItem;
}
}
return (ConfigItem) b2.get(0);
}
}

View File

@@ -0,0 +1,279 @@
package com.ubt.jimu.transport.dao;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.db.AbstractDaoHandler;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.gen.TransportFileDao;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.unity.ModelType;
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
import com.ubt.jimu.utils.SystemUtils;
import com.ubtech.utils.FileHelper;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.QueryBuilder;
import org.greenrobot.greendao.query.WhereCondition;
/* loaded from: classes2.dex */
public class TransportFileDbHandler extends AbstractDaoHandler<TransportFile> {
private static final String TAG = "TransportFileDbHandler";
public TransportFileDbHandler(AbstractDao<TransportFile, Long> abstractDao) {
super(abstractDao);
}
public static File getFile(TransportFile transportFile) {
return new File(DiyRobotDbHandler.getUserHome(transportFile.getUserId()) + transportFile.getFilePath() + File.separator + transportFile.getFileName());
}
public static String getFilePath(File file) {
if (file == null) {
return null;
}
String str = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "users" + File.separator;
String absolutePath = file.getAbsolutePath();
String name = file.getName();
String replace = absolutePath.replace(str, "");
return replace.substring(replace.indexOf(File.separator) + 1).replace(File.separator + name, "");
}
public void deleteModelFiles(String str, String str2) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.CustomModelId.a((Object) str2));
List b = k.b();
if (b != null && b.size() > 0) {
deleteInTx(b);
}
File file = new File(DiyRobotDbHandler.getCustomModelPath(str) + str2);
if (file.exists()) {
FileHelper.a(file);
}
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#deleteModelFiles:" + e.getMessage());
e.printStackTrace();
}
}
public boolean deleteTransportFile(TransportFile transportFile) {
if (transportFile == null) {
return false;
}
TransportFile transportFile2 = null;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FileName.a((Object) (transportFile.getFileName() + "")), TransportFileDao.Properties.CustomModelId.a((Object) transportFile.getCustomModelId()), TransportFileDao.Properties.FileType.a((Object) transportFile.getFileType()));
transportFile2 = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
}
if (transportFile2 == null) {
return false;
}
File file = new File(transportFile.getFilePath());
if (file.exists()) {
file.delete();
}
this.dao.b((AbstractDao<T, Long>) transportFile2);
return true;
}
public TransportFile getFileBean(String str, File file) {
if (file == null) {
return null;
}
String filePath = getFilePath(file);
String name = file.getName();
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.FilePath.a((Object) filePath), TransportFileDao.Properties.FileName.a((Object) name));
return (TransportFile) k.c();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFileBean():" + e.getMessage());
e.printStackTrace();
return null;
}
}
public List<TransportFile> getFiles(String str) {
List<TransportFile> list;
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), new WhereCondition[0]);
list = k.b();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFiles(String):" + e.getMessage());
e.printStackTrace();
list = null;
}
return list == null ? new ArrayList() : list;
}
public long insertOrUpdate2(TransportFile transportFile) {
TransportFile selectUnique = selectUnique(transportFile);
if (selectUnique == null) {
return insert(transportFile);
}
transportFile.setCustomFileId(selectUnique.getCustomFileId());
update(transportFile);
return selectUnique.getCustomFileId().longValue();
}
public boolean isFirstUpload(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
if (z) {
transportFile.setId(1L);
} else {
transportFile.setId(0L);
}
update(transportFile);
return true;
}
public void setFileModelId(DiyDBModel diyDBModel) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) diyDBModel.getModelCreatedId()), TransportFileDao.Properties.CustomModelId.a((Object) diyDBModel.getCustomModelId()));
List b = k.b();
if (b == null || b.size() <= 0) {
return;
}
Iterator it = b.iterator();
while (it.hasNext()) {
((TransportFile) it.next()).setModelId(diyDBModel.getModelId().intValue());
}
updateInTx(b);
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#setFileModelId:" + e.getMessage());
e.printStackTrace();
}
}
public List<TransportFile> setModelFilesDeleted(String str, String str2) {
List<TransportFile> files = getFiles(str, str2);
long a = SystemUtils.a();
for (TransportFile transportFile : files) {
transportFile.setIsDeleted(true);
transportFile.setModifyTime(a);
transportFile.setLastUploadTime(a);
transportFile.setIsModify(true);
}
try {
updateInTx(files);
} catch (Exception e) {
e.printStackTrace();
}
return files;
}
public boolean updataTransportFile(TransportFile transportFile) {
TransportFile selectUnique;
if (transportFile == null || (selectUnique = selectUnique(transportFile)) == null) {
return false;
}
transportFile.setCustomFileId(selectUnique.getCustomFileId());
update(transportFile);
return true;
}
public boolean updateQiNiuState(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
transportFile.setUploaded(z);
update(transportFile);
return true;
}
public boolean updateUbtSyncState(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
transportFile.setIsModify(z);
update(transportFile);
return true;
}
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
public TransportFile selectUnique(TransportFile transportFile) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) transportFile.getUserId()), TransportFileDao.Properties.CustomModelId.a((Object) transportFile.getCustomModelId()), TransportFileDao.Properties.FileType.a((Object) transportFile.getFileType()), TransportFileDao.Properties.FileName.a((Object) transportFile.getFileName()));
return (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
return null;
}
}
public List<TransportFile> getFiles(String str, String str2) {
List<TransportFile> list;
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.CustomModelId.a((Object) str2));
list = k.b();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFiles(String,String):" + e.getMessage());
e.printStackTrace();
list = null;
}
return list == null ? new ArrayList() : list;
}
}

View File

@@ -0,0 +1,316 @@
package com.ubt.jimu.transport.model;
import android.text.TextUtils;
import com.google.gson.reflect.TypeToken;
import com.ubt.jimu.blockly.Utils;
import com.ubt.jimu.blockly.bean.BlocklyProject;
import com.ubt.jimu.blockly.bean.JimuMotion;
import com.ubt.jimu.blockly.bean.JimuSound;
import com.ubt.jimu.utils.JsonHelper;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes2.dex */
public class ConfigItem {
public static final String STATE_UPLOADED = "0000";
public static final String TAG = "ConfigItem";
public static final String TYPE_AUDIO = "audio";
public static final String TYPE_BLOCKLY = "blockly";
public static final String TYPE_MOTION = "motion";
public static final String TYPE_NEW_BLOCKLY = "newBlockly";
public String blocklyVersion;
private String content;
private String customModelId;
private String description;
private long fileCreateTime;
private long fileModifyTime;
private String fileName;
private String icon;
private long id;
private String isDefault;
private String isDeleted;
private boolean isModify;
private Long localId;
private String modelType;
private String serverID;
private String type;
private int uploadState;
private String userId;
public ConfigItem(Long l, long j, String str, String str2, String str3, long j2, long j3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, boolean z, String str11, int i, String str12) {
this.isDefault = "0";
this.localId = l;
this.id = j;
this.type = str;
this.fileName = str2;
this.description = str3;
this.fileCreateTime = j2;
this.fileModifyTime = j3;
this.serverID = str4;
this.isDeleted = str5;
this.icon = str6;
this.blocklyVersion = str7;
this.modelType = str8;
this.customModelId = str9;
this.isDefault = str10;
this.isModify = z;
this.userId = str11;
this.uploadState = i;
this.content = str12;
}
public static ConfigItem fromBlocklyProject(BlocklyProject blocklyProject) {
if (blocklyProject == null) {
return null;
}
ConfigItem configItem = new ConfigItem();
configItem.userId = blocklyProject.getUserId();
configItem.modelType = blocklyProject.getModelType();
configItem.customModelId = blocklyProject.getCustomModelId();
configItem.type = TextUtils.isEmpty(blocklyProject.getBlocklyType()) ? "blockly" : blocklyProject.getBlocklyType();
configItem.fileName = blocklyProject.getXmlId();
configItem.description = blocklyProject.getXmlName();
configItem.blocklyVersion = blocklyProject.getBlocklyVersion();
configItem.fileCreateTime = Utils.formatFileCreateTime(blocklyProject.getXmlId());
configItem.isDeleted = blocklyProject.getIsDeleted();
return configItem;
}
public static ConfigItem fromJimuMotion(JimuMotion jimuMotion) {
if (jimuMotion == null) {
return null;
}
ConfigItem configItem = new ConfigItem();
configItem.type = TYPE_MOTION;
configItem.userId = jimuMotion.getUserId();
configItem.modelType = jimuMotion.getModelType();
configItem.customModelId = jimuMotion.getCustomModelId();
configItem.fileName = jimuMotion.getActionID();
configItem.description = jimuMotion.getActionName();
configItem.content = JsonHelper.a(jimuMotion.actionData);
configItem.fileCreateTime = Utils.formatFileCreateTime(jimuMotion.getActionID());
configItem.fileModifyTime = configItem.fileCreateTime;
return configItem;
}
public static ConfigItem fromJimuSound(JimuSound jimuSound) {
if (jimuSound == null) {
return null;
}
ConfigItem configItem = new ConfigItem();
configItem.userId = jimuSound.getUserId();
configItem.type = "audio";
configItem.fileName = jimuSound.getKey();
configItem.description = jimuSound.getDescription();
configItem.icon = jimuSound.getIcon();
configItem.setCustomModelId("0");
configItem.setModelType("0");
configItem.fileCreateTime = Utils.formatFileCreateTime(jimuSound.getKey());
configItem.content = jimuSound.getDuration();
return configItem;
}
public static BlocklyProject toBlocklyProject(ConfigItem configItem) {
BlocklyProject blocklyProject = new BlocklyProject();
blocklyProject.setUserId(configItem.userId);
blocklyProject.setModelType(configItem.getModelType());
blocklyProject.setCustomModelId(configItem.getCustomModelId());
blocklyProject.setBlocklyVersion(configItem.blocklyVersion);
blocklyProject.setIsDefault(false);
blocklyProject.setXmlId(configItem.fileName);
blocklyProject.setXmlName(configItem.description);
blocklyProject.setBlocklyType(configItem.getType());
blocklyProject.setIsDeleted(configItem.getIsDeleted());
return blocklyProject;
}
public static JimuMotion toJimuMotion(ConfigItem configItem) {
JimuMotion jimuMotion = new JimuMotion();
jimuMotion.setUserId(configItem.userId);
jimuMotion.setModelType(configItem.modelType);
jimuMotion.setCustomModelId(configItem.customModelId);
jimuMotion.setActionID(configItem.fileName);
jimuMotion.setActionName(configItem.description);
jimuMotion.setIsDeleted(configItem.isDeleted);
jimuMotion.actionData = (ArrayList) JsonHelper.a(configItem.content, new TypeToken<List<JimuMotion.JimuServo>>() { // from class: com.ubt.jimu.transport.model.ConfigItem.1
}.getType());
return jimuMotion;
}
public static JimuSound toJimuSound(ConfigItem configItem) {
JimuSound jimuSound = new JimuSound();
jimuSound.setUserId(configItem.getUserId());
jimuSound.setKey(configItem.fileName);
jimuSound.setDescription(configItem.description);
jimuSound.setType(JimuSound.TYPE_RECORDING);
jimuSound.setIcon(configItem.icon);
jimuSound.setDuration(configItem.content);
jimuSound.setIsDeleted(configItem.isDeleted);
return jimuSound;
}
public String getBlocklyVersion() {
return this.blocklyVersion;
}
public String getContent() {
return this.content;
}
public String getCustomModelId() {
return this.customModelId;
}
public String getDescription() {
return this.description;
}
public long getFileCreateTime() {
return this.fileCreateTime;
}
public long getFileModifyTime() {
return this.fileModifyTime;
}
public String getFileName() {
return this.fileName;
}
public String getIcon() {
return this.icon;
}
public long getId() {
return this.id;
}
public String getIsDefault() {
return this.isDefault;
}
public String getIsDeleted() {
return this.isDeleted;
}
public boolean getIsModify() {
return this.isModify;
}
public Long getLocalId() {
return this.localId;
}
public String getModelType() {
return this.modelType;
}
public String getServerID() {
return this.serverID;
}
public String getType() {
return this.type;
}
public int getUploadState() {
return this.uploadState;
}
public String getUserId() {
return this.userId;
}
public void setBlocklyVersion(String str) {
this.blocklyVersion = str;
}
public void setContent(String str) {
this.content = str;
}
public void setCustomModelId(String str) {
this.customModelId = str;
}
public void setDescription(String str) {
this.description = str;
}
public void setFileCreateTime(long j) {
this.fileCreateTime = j;
}
public void setFileModifyTime(long j) {
this.fileModifyTime = j;
}
public void setFileName(String str) {
this.fileName = str;
}
public void setIcon(String str) {
this.icon = str;
}
public void setId(long j) {
this.id = j;
}
public void setIsDefault(String str) {
this.isDefault = str;
}
public void setIsDeleted(String str) {
this.isDeleted = str;
}
public void setIsModify(boolean z) {
this.isModify = z;
}
public void setLocalId(Long l) {
this.localId = l;
}
public void setModelType(String str) {
this.modelType = str;
}
public void setServerID(String str) {
this.serverID = str;
}
public void setType(String str) {
this.type = str;
}
public void setUploadState(int i) {
this.uploadState = i;
}
public void setUserId(String str) {
this.userId = str;
}
public static ConfigItem fromBlocklyProject(String str, String str2, String str3, BlocklyProject blocklyProject) {
if (blocklyProject == null) {
return null;
}
ConfigItem configItem = new ConfigItem();
configItem.userId = str;
configItem.type = TextUtils.isEmpty(blocklyProject.getBlocklyType()) ? "blockly" : blocklyProject.getBlocklyType();
configItem.fileName = blocklyProject.getXmlId();
configItem.description = blocklyProject.getXmlName();
configItem.blocklyVersion = blocklyProject.getBlocklyVersion();
configItem.customModelId = str2;
configItem.modelType = str3;
configItem.fileCreateTime = Utils.formatFileCreateTime(blocklyProject.getXmlId());
configItem.fileModifyTime = configItem.fileCreateTime;
return configItem;
}
public ConfigItem() {
this.isDefault = "0";
}
}

View File

@@ -0,0 +1,261 @@
package com.ubt.jimu.transport.model;
import java.io.File;
/* loaded from: classes2.dex */
public class TransportFile {
public static final String MODEL_ACTION_DIR = "actions";
public static final String MODEL_CONTROLLER_CONFIG_DIR = "widgetConfig";
public static final String MODEL_CONTROLLER_DIR = "ControllerData";
public static final String MODEL_SERVO_DIR = "servos";
public static final String MODEL_SHOW_DIR = "Exhibition";
public static final String TYPE_ACTION = "action";
public static final String TYPE_AUDIO = "audio";
public static final String TYPE_AUDIO_SHOW = "showImage";
public static final String TYPE_BG = "bg";
public static final String TYPE_CONN = "conn";
public static final String TYPE_CONTROLLER = "controller";
public static final String TYPE_CONTROLLER_CONFIG = "widgetConfig";
public static final String TYPE_DESC = "desc";
public static final String TYPE_DIY_SHOW = "show";
public static final String TYPE_NONE = "none";
public static final String TYPE_PROGRAM = "program";
public static final long UPLOADED_FILE_ID = 1;
private long createTime;
private Long customFileId;
private String customModelCategory;
private String customModelId;
private String fileContent;
private String fileId;
private String fileName;
private String filePath;
private String fileType;
private String fileUrl;
private String fileVersion;
private long id;
private boolean isDeleted;
private boolean isModify;
private boolean isReleased;
private long lastUploadTime;
private long modelId;
private String modelType;
private long modifyTime;
private boolean uploaded;
private String userId;
public TransportFile(String str, long j, String str2, String str3, String str4, String str5, String str6) {
this.userId = str;
this.modelType = str3;
this.modelId = j;
this.customModelId = str2;
this.fileType = str4;
this.filePath = str5;
this.fileName = str6;
this.isModify = true;
this.isDeleted = false;
this.uploaded = false;
this.createTime = System.currentTimeMillis();
long j2 = this.createTime;
this.modifyTime = j2;
this.lastUploadTime = j2;
}
public long getCreateTime() {
return this.createTime;
}
public Long getCustomFileId() {
return this.customFileId;
}
public String getCustomModelCategory() {
return this.customModelCategory;
}
public String getCustomModelId() {
return this.customModelId;
}
public String getFileContent() {
return this.fileContent;
}
public String getFileId() {
return this.fileId;
}
public String getFileName() {
return this.fileName;
}
public String getFilePath() {
return this.filePath;
}
public String getFileType() {
return this.fileType;
}
public String getFileUrl() {
return this.fileUrl;
}
public String getFileVersion() {
return this.fileVersion;
}
public String getFullPath() {
return this.filePath + File.separator + this.fileName;
}
public long getId() {
return this.id;
}
public boolean getIsDeleted() {
return this.isDeleted;
}
public boolean getIsModify() {
return this.isModify;
}
public boolean getIsReleased() {
return this.isReleased;
}
public long getLastUploadTime() {
return this.lastUploadTime;
}
public long getModelId() {
return this.modelId;
}
public String getModelType() {
return this.modelType;
}
public long getModifyTime() {
return this.modifyTime;
}
public boolean getUploaded() {
return this.uploaded;
}
public String getUserId() {
return this.userId;
}
public void setCreateTime(long j) {
this.createTime = j;
}
public void setCustomFileId(Long l) {
this.customFileId = l;
}
public void setCustomModelCategory(String str) {
this.customModelCategory = str;
}
public void setCustomModelId(String str) {
this.customModelId = str;
}
public void setFileContent(String str) {
this.fileContent = str;
}
public void setFileId(String str) {
this.fileId = str;
}
public void setFileName(String str) {
this.fileName = str;
}
public void setFilePath(String str) {
this.filePath = str;
}
public void setFileType(String str) {
this.fileType = str;
}
public void setFileUrl(String str) {
this.fileUrl = str;
}
public void setFileVersion(String str) {
this.fileVersion = str;
}
public void setId(long j) {
this.id = j;
}
public void setIsDeleted(boolean z) {
this.isDeleted = z;
}
public void setIsModify(boolean z) {
this.isModify = z;
}
public void setIsReleased(boolean z) {
this.isReleased = z;
}
public void setLastUploadTime(long j) {
this.lastUploadTime = j;
}
public void setModelId(long j) {
this.modelId = j;
}
public void setModelType(String str) {
this.modelType = str;
}
public void setModifyTime(long j) {
this.modifyTime = j;
}
public void setUploaded(boolean z) {
this.uploaded = z;
}
public void setUserId(String str) {
this.userId = str;
}
public TransportFile(Long l, String str, String str2, boolean z, String str3, String str4, String str5, String str6, String str7, long j, long j2, String str8, long j3, long j4, boolean z2, boolean z3, String str9, String str10, long j5, String str11, boolean z4) {
this.customFileId = l;
this.customModelId = str;
this.customModelCategory = str2;
this.isReleased = z;
this.userId = str3;
this.fileName = str4;
this.filePath = str5;
this.fileUrl = str6;
this.fileVersion = str7;
this.lastUploadTime = j;
this.modelId = j2;
this.modelType = str8;
this.createTime = j3;
this.modifyTime = j4;
this.isDeleted = z2;
this.isModify = z3;
this.fileId = str9;
this.fileContent = str10;
this.id = j5;
this.fileType = str11;
this.uploaded = z4;
}
public TransportFile() {
}
}

View File

@@ -0,0 +1,60 @@
package com.ubt.jimu.transport.request;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.base.http.ApiConstants;
import com.ubt.jimu.utils.EncryptUtils;
/* loaded from: classes2.dex */
public abstract class BaseParam {
static final String ENCODE_KEY = "UBTech832%1293*6";
private String appSource;
private String appType;
private String requestKey;
private String requestTime;
private String serviceVersion;
private String systemArea;
private String systemLanguage;
public BaseParam() {
long currentTimeMillis = System.currentTimeMillis();
this.appSource = "Jimu";
this.appType = "2";
this.systemArea = JimuApplication.l().c();
this.systemLanguage = JimuApplication.l().g();
this.serviceVersion = ApiConstants.getAppVersion();
this.requestTime = String.valueOf(currentTimeMillis);
this.requestKey = EncryptUtils.a(this.requestTime + "UBTech832%1293*6", 32);
}
public static String getEncodeKey() {
return "UBTech832%1293*6";
}
public String getAppSource() {
return this.appSource;
}
public String getAppType() {
return this.appType;
}
public String getRequestKey() {
return this.requestKey;
}
public String getRequestTime() {
return this.requestTime;
}
public String getServiceVersion() {
return this.serviceVersion;
}
public String getSystemArea() {
return this.systemArea;
}
public String getSystemLanguage() {
return this.systemLanguage;
}
}

View File

@@ -0,0 +1,52 @@
package com.ubt.jimu.transport.request;
import java.util.List;
/* loaded from: classes2.dex */
public class CreateDiyRobotParam extends BaseParam {
private String customModelCategory;
private long customModelCreatetime;
private String customModelId;
private List<UploadModelFile> fileUploadInfos;
private String modelCreatedId;
private String modelDescription;
private String modelName;
public CreateDiyRobotParam(String str, String str2, String str3, String str4, String str5, long j, List<UploadModelFile> list) {
this.modelCreatedId = str;
this.customModelId = str2;
this.modelName = str3;
this.modelDescription = str4;
this.customModelCategory = str5;
this.customModelCreatetime = j;
this.fileUploadInfos = list;
}
public String getCustomModelCategory() {
return this.customModelCategory;
}
public long getCustomModelCreatetime() {
return this.customModelCreatetime;
}
public String getCustomModelId() {
return this.customModelId;
}
public List<UploadModelFile> getFileUploadInfos() {
return this.fileUploadInfos;
}
public String getModelDescription() {
return this.modelDescription;
}
public String getModelName() {
return this.modelName;
}
public String getUserId() {
return this.modelCreatedId;
}
}

View File

@@ -0,0 +1,50 @@
package com.ubt.jimu.transport.request;
import com.ubt.jimu.transport.model.ConfigItem;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes2.dex */
public class UploadConfigItem {
public String blocklyVersion;
public String content;
public String customModelId;
public String description;
public long fileCreateTime;
public long fileModifyTime;
public String fileName;
public String icon;
public String isDefault = "0";
public String isDeleted;
public String modelType;
public String type;
public static UploadConfigItem fromConfigItem(ConfigItem configItem) {
UploadConfigItem uploadConfigItem = new UploadConfigItem();
uploadConfigItem.type = configItem.getType();
uploadConfigItem.fileName = configItem.getFileName();
uploadConfigItem.description = configItem.getDescription();
uploadConfigItem.fileCreateTime = configItem.getFileCreateTime();
uploadConfigItem.fileModifyTime = configItem.getFileModifyTime();
uploadConfigItem.icon = configItem.getIcon();
uploadConfigItem.blocklyVersion = configItem.blocklyVersion;
uploadConfigItem.modelType = configItem.getModelType();
uploadConfigItem.customModelId = configItem.getCustomModelId();
uploadConfigItem.isDefault = configItem.getIsDefault();
uploadConfigItem.isDeleted = configItem.getIsDeleted();
uploadConfigItem.content = configItem.getContent();
return uploadConfigItem;
}
public static List<UploadConfigItem> fromConfigItems(List<ConfigItem> list) {
ArrayList arrayList = new ArrayList();
if (list != null && list.size() != 0) {
Iterator<ConfigItem> it = list.iterator();
while (it.hasNext()) {
arrayList.add(fromConfigItem(it.next()));
}
}
return arrayList;
}
}

View File

@@ -0,0 +1,17 @@
package com.ubt.jimu.transport.request;
import com.ubt.jimu.transport.model.ConfigItem;
import java.util.List;
/* loaded from: classes2.dex */
public class UploadConfigItemParam extends BaseParam {
private List<UploadConfigItem> batchConfigFileList;
private String opType;
private String userId;
public UploadConfigItemParam(String str, String str2, List<ConfigItem> list) {
this.userId = str;
this.opType = str2;
this.batchConfigFileList = UploadConfigItem.fromConfigItems(list);
}
}

View File

@@ -0,0 +1,68 @@
package com.ubt.jimu.transport.request;
import android.util.Base64;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import com.ubt.jimu.utils.DeviceUtils;
import com.ubtech.utils.FileHelper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/* loaded from: classes2.dex */
public class UploadFileParam extends BaseParam {
private String accountName;
private String opType;
private String userId;
private String sequenceNo = DeviceUtils.a(JimuApplication.l());
private List<HashMap<String, Object>> batchFileList = new ArrayList();
public UploadFileParam(String str, String str2, String str3, List<TransportFile> list) throws IOException {
this.userId = str;
this.accountName = str2;
this.opType = str3;
for (TransportFile transportFile : list) {
File file = TransportFileDbHandler.getFile(transportFile);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("modelId", Long.valueOf(transportFile.getModelId()));
hashMap.put(UnityActivity.pModelType, transportFile.getModelType());
hashMap.put("filePath", transportFile.getFilePath());
hashMap.put("fileName", transportFile.getFileName());
hashMap.put("lastUploadTime", Long.valueOf(transportFile.getLastUploadTime()));
if ("delete".equals(str3)) {
hashMap.put("fileContent", "");
} else {
hashMap.put("fileContent", file2Base64Str(file));
}
this.batchFileList.add(hashMap);
}
}
private String file2Base64Str(File file) throws IOException {
return Base64.encodeToString(FileHelper.b(file), 0);
}
public String getAccountName() {
return this.accountName;
}
public List<HashMap<String, Object>> getBatchFileList() {
return this.batchFileList;
}
public String getOpType() {
return this.opType;
}
public String getSequenceNo() {
return this.sequenceNo;
}
public String getUserId() {
return this.userId;
}
}

View File

@@ -0,0 +1,10 @@
package com.ubt.jimu.transport.request;
/* loaded from: classes2.dex */
public class UploadModelFile {
public String fileName;
public String filePath;
public String fileString;
public String fileType;
public String orderNum;
}

View File

@@ -0,0 +1,88 @@
package com.ubt.jimu.transport.request;
import com.ubt.jimu.transport.model.ConfigItem;
/* loaded from: classes2.dex */
public class UploadSingleConfigItemParam extends BaseParam {
private String blocklyVersion;
private String content;
private String customModelId;
private String description;
private long fileCreateTime;
private long fileModifyTime;
private String fileName;
private String icon;
private String isDefault;
private String modelType;
private String opType;
private String type;
private String userId;
public UploadSingleConfigItemParam(String str, String str2, ConfigItem configItem) {
this.userId = str;
this.opType = str2;
this.fileName = configItem.getFileName();
this.type = configItem.getType();
this.description = configItem.getDescription();
this.icon = configItem.getIcon();
this.fileCreateTime = configItem.getFileCreateTime();
this.fileModifyTime = configItem.getFileModifyTime();
this.customModelId = configItem.getCustomModelId();
this.isDefault = configItem.getIsDefault();
this.modelType = configItem.getModelType();
this.blocklyVersion = configItem.getBlocklyVersion();
this.content = configItem.getContent();
}
public String getBlocklyVersion() {
return this.blocklyVersion;
}
public String getContent() {
return this.content;
}
public String getCustomModelId() {
return this.customModelId;
}
public String getDescription() {
return this.description;
}
public long getFileCreateTime() {
return this.fileCreateTime;
}
public long getFileModifyTime() {
return this.fileModifyTime;
}
public String getFileName() {
return this.fileName;
}
public String getIcon() {
return this.icon;
}
public String getIsDefault() {
return this.isDefault;
}
public String getModelType() {
return this.modelType;
}
public String getOpType() {
return this.opType;
}
public String getType() {
return this.type;
}
public String getUserId() {
return this.userId;
}
}

View File

@@ -0,0 +1,77 @@
package com.ubt.jimu.transport.request;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.transport.Utils;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.utils.DeviceUtils;
import java.io.IOException;
/* loaded from: classes2.dex */
public class UploadSingleFileParam extends BaseParam {
private String accountName;
private String fileContent;
private String fileName;
private String filePath;
private long lastUploadTime;
private long modelId;
private String modelType;
private String opType;
private String sequenceNo = DeviceUtils.a(JimuApplication.l());
private String userId;
public UploadSingleFileParam(String str, String str2, String str3, TransportFile transportFile) throws IOException {
this.userId = str;
this.accountName = str2;
this.opType = str3;
this.modelId = transportFile.getModelId();
this.modelType = transportFile.getModelType();
this.filePath = transportFile.getFilePath();
this.fileName = transportFile.getFileName();
this.lastUploadTime = transportFile.getLastUploadTime();
if ("delete".equals(str3)) {
return;
}
this.fileContent = Utils.a(TransportFileDbHandler.getFile(transportFile));
}
public String getAccountName() {
return this.accountName;
}
public String getFileContent() {
return this.fileContent;
}
public String getFileName() {
return this.fileName;
}
public String getFilePath() {
return this.filePath;
}
public long getLastUploadTime() {
return this.lastUploadTime;
}
public long getModelId() {
return this.modelId;
}
public String getModelType() {
return this.modelType;
}
public String getOpType() {
return this.opType;
}
public String getSequenceNo() {
return this.sequenceNo;
}
public String getUserId() {
return this.userId;
}
}

View File

@@ -0,0 +1,349 @@
package com.ubt.jimu.transport.update;
import android.app.Activity;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.R;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.base.entities.User;
import com.ubt.jimu.blockly.bean.BlocklyProject;
import com.ubt.jimu.blockly.bean.JimuMotion;
import com.ubt.jimu.blockly.bean.JimuSound;
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.gen.BlocklyProjectDao;
import com.ubt.jimu.gen.DiyModelActionDao;
import com.ubt.jimu.gen.JimuMotionDao;
import com.ubt.jimu.gen.JimuSoundDao;
import com.ubt.jimu.gen.TransportFileDao;
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.transport3.dao.DiyModelActionDBHandler;
import com.ubt.jimu.transport3.model.DiyModelAction;
import com.ubt.jimu.utils.LogUtils;
import com.ubtech.utils.FileHelper;
import com.ubtech.view.dialog.SimpleDialog;
import com.ubtrobot.log.ALog;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import org.greenrobot.greendao.query.QueryBuilder;
import org.greenrobot.greendao.query.WhereCondition;
/* loaded from: classes2.dex */
public class MergeTool {
private static final String k = "MergeTool";
private DiyRobotDbHandler a = new DiyRobotDbHandler(DatabaseUtils.getDaoSession(true).d());
private BlocklyProjectDbHandler b;
private JimuSoundDbHandler c;
private JimuMotionDbHandler d;
private TransportFileDbHandler e;
private DiyModelActionDBHandler f;
private final String g;
private final String h;
private final String i;
private final String j;
public interface IMergeListener {
void a(boolean z);
void onFailed();
void onStart();
}
public MergeTool(String str, String str2) {
new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
this.b = new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
this.c = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
this.d = new JimuMotionDbHandler(DatabaseUtils.getDaoSession(true).o());
this.e = new TransportFileDbHandler(DatabaseUtils.getDaoSession(true).v());
this.f = DiyModelActionDBHandler.getInstance();
this.g = str;
this.i = str2;
this.h = DiyRobotDbHandler.getUserHome(str);
this.j = DiyRobotDbHandler.getUserHome(str2);
}
private boolean c() {
String str = this.h;
String str2 = this.j;
File file = new File(str);
File file2 = new File(str2);
if (!file.exists()) {
return false;
}
try {
FileHelper.a(file, file2);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private boolean d() {
QueryBuilder<DiyModelAction> queryBuilder = this.f.getQueryBuilder();
queryBuilder.a(DiyModelActionDao.Properties.UserId.a((Object) this.g), new WhereCondition[0]);
queryBuilder.a(1);
List<DiyModelAction> query = this.f.query(queryBuilder);
return query != null && query.size() > 0;
}
private boolean e() {
QueryBuilder<BlocklyProject> queryBuilder = this.b.getQueryBuilder();
queryBuilder.a(BlocklyProjectDao.Properties.UserId.a((Object) this.g), new WhereCondition[0]);
queryBuilder.a(1);
List<BlocklyProject> query = this.b.query(queryBuilder);
return query != null && query.size() > 0;
}
private boolean f() {
return this.a.hasDiyDbModel(this.g);
}
private boolean g() {
QueryBuilder<JimuMotion> queryBuilder = this.d.getQueryBuilder();
queryBuilder.a(JimuMotionDao.Properties.UserId.a((Object) this.g), new WhereCondition[0]);
queryBuilder.a(1);
List<JimuMotion> query = this.d.query(queryBuilder);
return query != null && query.size() > 0;
}
private boolean h() {
QueryBuilder<TransportFile> queryBuilder = this.e.getQueryBuilder();
queryBuilder.a(TransportFileDao.Properties.UserId.a((Object) this.g), new WhereCondition[0]);
queryBuilder.a(1);
List<TransportFile> query = this.e.query(queryBuilder);
return query != null && query.size() > 0;
}
private boolean i() {
QueryBuilder<JimuSound> queryBuilder = this.c.getQueryBuilder();
queryBuilder.a(JimuSoundDao.Properties.UserId.a((Object) this.g), new WhereCondition[0]);
queryBuilder.a(1);
List<JimuSound> query = this.c.query(queryBuilder);
return query != null && query.size() > 0;
}
private void j() {
boolean m = m();
boolean l = l();
boolean o = o();
boolean n = n();
boolean p = p();
k();
if (m && l && o && n && p) {
ALog.a(k).d("merge data success");
} else {
ALog.a(k).d("merge data failed");
}
}
private void k() {
List<DiyModelAction> userActions = this.f.getUserActions(this.g);
if (userActions == null || userActions.size() == 0) {
return;
}
Iterator<DiyModelAction> it = userActions.iterator();
while (it.hasNext()) {
it.next().setUserId(this.i);
}
this.f.updateInTx(userActions);
}
private boolean l() {
List<BlocklyProject> blocklyProject = this.b.getBlocklyProject(this.g);
if (blocklyProject != null && blocklyProject.size() > 0) {
Iterator<BlocklyProject> it = blocklyProject.iterator();
while (it.hasNext()) {
it.next().setUserId(this.i);
}
try {
this.b.updateInTx(blocklyProject);
} catch (Exception e) {
e.getMessage();
Log.e(k, "合并BlocklyPro到目标用户失败" + e.getMessage());
return false;
}
}
return true;
}
private boolean m() {
List<DiyDBModel> userModels = this.a.getUserModels(this.g);
if (userModels != null && userModels.size() > 0) {
for (DiyDBModel diyDBModel : userModels) {
diyDBModel.setModelCreatedId(this.i);
if (!TextUtils.isEmpty(diyDBModel.getFilePath())) {
diyDBModel.setFilePath(diyDBModel.getFilePath().replace(this.g, this.i));
}
}
try {
this.a.updateInTx(userModels);
} catch (Exception e) {
e.getMessage();
Log.e(k, "合并DiyDBModel到目标用户失败" + e.getMessage());
return false;
}
}
return true;
}
private boolean n() {
List<JimuMotion> userModelMotions = this.d.getUserModelMotions(this.g);
if (userModelMotions != null && userModelMotions.size() > 0) {
Iterator<JimuMotion> it = userModelMotions.iterator();
while (it.hasNext()) {
it.next().setUserId(this.i);
}
try {
this.d.updateInTx(userModelMotions);
} catch (Exception e) {
e.getMessage();
Log.e(k, "合并JimuMotion到目标用户失败" + e.getMessage());
return false;
}
}
return true;
}
private boolean o() {
List<JimuSound> jimuSounds = this.c.getJimuSounds(this.g);
if (jimuSounds != null && jimuSounds.size() > 0) {
Iterator<JimuSound> it = jimuSounds.iterator();
while (it.hasNext()) {
it.next().setUserId(this.i);
}
try {
this.c.updateInTx(jimuSounds);
} catch (Exception e) {
e.getMessage();
Log.e(k, "合并JimuSound到目标用户失败" + e.getMessage());
return false;
}
}
return true;
}
private boolean p() {
List<TransportFile> files = this.e.getFiles(this.g);
if (files != null && files.size() > 0) {
for (TransportFile transportFile : files) {
transportFile.setUserId(this.i);
if ("1".equals(transportFile.getModelType()) && !"local".equals(Cache.getInstance().getUserId())) {
this.e.deleteTransportFile(transportFile);
}
}
try {
this.e.updateInTx(files);
} catch (Exception e) {
e.getMessage();
Log.e(k, "合并TransportFile到目标用户失败:" + e.getMessage());
return false;
}
}
return true;
}
public void a(IMergeListener iMergeListener) {
if (iMergeListener != null) {
iMergeListener.onStart();
}
if (!c()) {
if (iMergeListener != null) {
iMergeListener.onFailed();
return;
}
return;
}
j();
File file = new File(this.h);
if (file.exists()) {
FileHelper.a(file);
}
if (iMergeListener != null) {
iMergeListener.a(true);
}
}
public boolean a() {
return f() || d() || e() || g() || i() || h();
}
public static void a(Activity activity, final IMergeListener iMergeListener) {
User user = Cache.getInstance().getUser();
if (user == null) {
if (iMergeListener != null) {
iMergeListener.a(false);
return;
}
return;
}
MergeTool mergeTool = new MergeTool("local", String.valueOf(user.getUserId()));
if (!mergeTool.a()) {
if (iMergeListener != null) {
iMergeListener.a(true);
}
} else {
SimpleDialog a = new SimpleDialog.Builder(activity).a(true).a(activity.getString(R.string.ok)).b(activity.getString(R.string.cancel)).a((CharSequence) activity.getString(R.string.tips_merge_data)).c(R.mipmap.course_miss_parts).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.transport.update.MergeTool.2
@Override // android.content.DialogInterface.OnClickListener
public void onClick(final DialogInterface dialogInterface, int i) {
Observable.just("merge").observeOn(AndroidSchedulers.a()).subscribeOn(Schedulers.b()).subscribe(new Observer<String>() { // from class: com.ubt.jimu.transport.update.MergeTool.2.1
@Override // io.reactivex.Observer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void onNext(String str) {
ALog.a(MergeTool.k).d(str);
LogUtils.c("数据合并onNext");
dialogInterface.dismiss();
}
@Override // io.reactivex.Observer
public void onComplete() {
LogUtils.c("数据合并onComplete");
}
@Override // io.reactivex.Observer
public void onError(Throwable th) {
th.printStackTrace();
Log.e(MergeTool.k, th.getMessage());
LogUtils.c("数据合并onError");
dialogInterface.dismiss();
}
@Override // io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
MergeTool.this.a(iMergeListener);
}
});
}
}).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.transport.update.MergeTool.1
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
ALog.a(MergeTool.k).d("用户取消合并数据,将不会删除本地数据");
dialogInterface.dismiss();
IMergeListener iMergeListener2 = IMergeListener.this;
if (iMergeListener2 != null) {
iMergeListener2.a(false);
}
}
}).a();
if (activity.isFinishing() || activity.isDestroyed()) {
return;
}
a.show();
}
}
}