Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.ubt.jimu.base.db.robot;
|
||||
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.entities.FirmwareVersion;
|
||||
import com.ubt.jimu.gen.FirmwareVersionDao;
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FirmwareVersionDbHandler extends AbstractDaoHandler<FirmwareVersion> {
|
||||
private static FirmwareVersionDbHandler instance;
|
||||
|
||||
public FirmwareVersionDbHandler(AbstractDao<FirmwareVersion, Long> abstractDao) {
|
||||
super(abstractDao);
|
||||
}
|
||||
|
||||
public static synchronized FirmwareVersionDbHandler getInstance() {
|
||||
FirmwareVersionDbHandler firmwareVersionDbHandler;
|
||||
synchronized (FirmwareVersionDbHandler.class) {
|
||||
if (instance == null) {
|
||||
instance = new FirmwareVersionDbHandler(DatabaseUtils.getDaoSession(true).k());
|
||||
}
|
||||
firmwareVersionDbHandler = instance;
|
||||
}
|
||||
return firmwareVersionDbHandler;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public FirmwareVersion selectUnique(FirmwareVersion firmwareVersion) {
|
||||
QueryBuilder<FirmwareVersion> queryBuilder = getQueryBuilder();
|
||||
queryBuilder.a(FirmwareVersionDao.Properties.VersionType.a(firmwareVersion.getVersionType()), new WhereCondition[0]);
|
||||
return queryBuilder.c();
|
||||
}
|
||||
}
|
95
sources/com/ubt/jimu/base/db/robot/PackageDbHandler.java
Normal file
95
sources/com/ubt/jimu/base/db/robot/PackageDbHandler.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.ubt.jimu.base.db.robot;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.entities.Package;
|
||||
import com.ubt.jimu.gen.PackageDao;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PackageDbHandler {
|
||||
public static List<Package> findByEan(String str) {
|
||||
List<Package> b = DatabaseUtils.getDaoSession(false).q().k().b();
|
||||
if (b == null || b.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<Package> it = b.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Package next = it.next();
|
||||
if (matchWords(str, next.getEAN())) {
|
||||
arrayList.add(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static List<Package> findByUpc(String str) {
|
||||
List<Package> b = DatabaseUtils.getDaoSession(false).q().k().b();
|
||||
if (b == null || b.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<Package> it = b.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Package next = it.next();
|
||||
if (matchWords(str, next.getUPC())) {
|
||||
arrayList.add(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static List<Package> getPackageList() {
|
||||
QueryBuilder<Package> k = DatabaseUtils.getDaoSession(false).q().k();
|
||||
k.a(PackageDao.Properties.DisplayOrder);
|
||||
return k.b();
|
||||
}
|
||||
|
||||
private static boolean matchWords(String str, String str2) {
|
||||
if (!TextUtils.isEmpty(str2)) {
|
||||
for (String str3 : str2.split(",")) {
|
||||
if (str.equals(str3.trim())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void saveOrUpdate(List<Package> list) {
|
||||
try {
|
||||
DatabaseUtils.getDaoSession(true).q().c((Iterable) list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Package selectById(long j) {
|
||||
try {
|
||||
return DatabaseUtils.getDaoSession(true).q().a(j);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveOrUpdate(Package r1) {
|
||||
try {
|
||||
DatabaseUtils.getDaoSession(true).q().j(r1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.ubt.jimu.base.db.robot;
|
||||
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.entities.PartFileInfo;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PartFileInfoDbHandler extends AbstractDaoHandler<PartFileInfo> {
|
||||
public PartFileInfoDbHandler(AbstractDao<PartFileInfo, Long> abstractDao) {
|
||||
super(abstractDao);
|
||||
}
|
||||
|
||||
public static boolean insertOrUpdate(List<PartFileInfo> list) {
|
||||
try {
|
||||
new PartFileInfoDbHandler(DatabaseUtils.getDaoSession(true).r()).insertOrUpdateInTx(list);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public PartFileInfo selectUnique(PartFileInfo partFileInfo) {
|
||||
return selectById(partFileInfo.getId());
|
||||
}
|
||||
}
|
98
sources/com/ubt/jimu/base/db/robot/RobotDbHandler.java
Normal file
98
sources/com/ubt/jimu/base/db/robot/RobotDbHandler.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.ubt.jimu.base.db.robot;
|
||||
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.gen.RobotDao;
|
||||
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: classes.dex */
|
||||
public class RobotDbHandler extends AbstractDaoHandler<Robot> {
|
||||
private static RobotDbHandler instance;
|
||||
|
||||
public RobotDbHandler(AbstractDao<Robot, Long> abstractDao) {
|
||||
super(abstractDao);
|
||||
}
|
||||
|
||||
public static synchronized RobotDbHandler getInstance() {
|
||||
RobotDbHandler robotDbHandler;
|
||||
synchronized (RobotDbHandler.class) {
|
||||
if (instance == null) {
|
||||
instance = new RobotDbHandler(DatabaseUtils.getDaoSession(true).s());
|
||||
}
|
||||
robotDbHandler = instance;
|
||||
}
|
||||
return robotDbHandler;
|
||||
}
|
||||
|
||||
public static Robot getRobotById(long j) {
|
||||
QueryBuilder<Robot> k = DatabaseUtils.getDaoSession(true).s().k();
|
||||
k.a(RobotDao.Properties.ModelId.a(Long.valueOf(j)), new WhereCondition[0]);
|
||||
return k.c();
|
||||
}
|
||||
|
||||
public static Robot getRobotByModelName(String str) {
|
||||
QueryBuilder<Robot> k = DatabaseUtils.getDaoSession(true).s().k();
|
||||
k.a(RobotDao.Properties.ModelName.a((Object) str), new WhereCondition[0]);
|
||||
return k.c();
|
||||
}
|
||||
|
||||
public static List<Robot> getRobotList(long j) {
|
||||
try {
|
||||
return DatabaseUtils.getDaoSession(true).q().h(Long.valueOf(j)).getRobotList();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveOrUpdate(List<Robot> list) {
|
||||
try {
|
||||
RobotDao s = DatabaseUtils.getDaoSession(true).s();
|
||||
List<Robot> j = s.j();
|
||||
if (j == null || j.size() == 0) {
|
||||
s.c((Iterable) list);
|
||||
}
|
||||
for (Robot robot : list) {
|
||||
Iterator<Robot> it = j.iterator();
|
||||
while (true) {
|
||||
if (it.hasNext()) {
|
||||
Robot next = it.next();
|
||||
if (robot.getModelId() == next.getModelId()) {
|
||||
robot.setDownload(next.getDownload() && robot.getModelUpdateTime() == next.getModelUpdateTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s.c((Iterable) list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRobotDownloadState(Robot robot) {
|
||||
RobotDao s = DatabaseUtils.getDaoSession(true).s();
|
||||
QueryBuilder<Robot> k = s.k();
|
||||
k.a(RobotDao.Properties.ModelName.a((Object) robot.getModelName()), new WhereCondition[0]);
|
||||
List<Robot> b = k.b();
|
||||
if (b == null || b.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Iterator<Robot> it = b.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().setDownload(robot.getDownload());
|
||||
}
|
||||
s.d((Iterable) b);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public Robot selectUnique(Robot robot) {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(RobotDao.Properties.ModelId.a(Long.valueOf(robot.getModelId())), new WhereCondition[0]);
|
||||
return (Robot) k.c();
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.ubt.jimu.base.db.robot;
|
||||
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.entities.RobotPackage;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RobotPackageDbHandler {
|
||||
public static void saveOrUpdate(List<RobotPackage> list) {
|
||||
try {
|
||||
DatabaseUtils.getDaoSession(false).t().c((Iterable) list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user