Initial commit
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user