Commit ac95bc6d authored by hywang's avatar hywang

1.修改上传数据为多次上传

parent 920acb04
......@@ -39,6 +39,7 @@
android:resource="@xml/file_paths" />
</provider>
<!-- android:name=".ui.cattle.activity.CattleMainActivity"-->
<activity
android:name=".ui.login.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
......@@ -122,12 +123,12 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name=".ui.cattle.activity.CattleMainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<!-- <activity-->
<!-- android:name=".ui.cattle.activity.CattleMainActivity"-->
<!-- android:configChanges="keyboardHidden|orientation|screenSize"-->
<!-- android:launchMode="singleTask"-->
<!-- android:screenOrientation="portrait"-->
<!-- android:windowSoftInputMode="stateHidden|adjustResize" />-->
<activity
android:name=".ui.cattle.activity.CattleMarkActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
......
......@@ -3,6 +3,8 @@ package com.phlx.wool;
import com.uhf.linkage.Linkage;
import org.greenrobot.greendao.query.QueryBuilder;
import me.goldze.mvvmhabit.base.BaseApplication;
import me.goldze.mvvmhabit.crash.CaocConfig;
import me.goldze.mvvmhabit.utils.KLog;
......@@ -20,6 +22,8 @@ public class App extends BaseApplication {
instance = this;
//是否开启打印日志
KLog.init(true);
QueryBuilder.LOG_SQL = true;
QueryBuilder.LOG_VALUES = true;
//初始化全局异常崩溃
initCrash();
link = new Linkage();
......
......@@ -69,8 +69,8 @@ public class Configs {
public static PrinterInstance myPrinter;
//是否是锡盟临时项目
public static boolean isCattle = true;
//是否是毛登牧场临时项目
public static boolean isCattle = false;
// public static boolean ISCONNECTED;
......
......@@ -99,7 +99,7 @@ public class VMFactory extends ViewModelProvider.NewInstanceFactory {
return (T) new SlaughterEntryVM(mApplication, repository);
//锡盟临时项目
//毛登牧场临时项目
}else if (modelClass.isAssignableFrom(CattleMainVM.class)) {
return (T) new CattleMainVM(mApplication, repository);
}else if (modelClass.isAssignableFrom(CattleMarkVM.class)) {
......
......@@ -48,14 +48,14 @@ public class RetrofitClient {
private static final int CACHE_TIMEOUT = 10 * 1024 * 1024;
//服务端根路径
public static String baseUrl =
// "58.18.92.126"//阿拉善正式
"39.101.170.186"//锡盟正式
"58.18.92.126"//阿拉善正式
// "39.101.170.186"//锡盟正式
// "192.168.12.105"//锡盟张敏测试
// "192.168.8.189"//张敏
;
public static String port =
// "899"//阿拉善正式
"8999"//锡盟正式/ 张敏
"899"//阿拉善正式
// "8999"//锡盟正式/ 张敏
// "80"
;
......
......@@ -94,11 +94,11 @@ public class CattleMainVM extends BackBarVM<Repository> {
public BindingCommand onDownloadClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
if (Configs.isOnLine) {
// if (Configs.isOnLine) {
DbUtil.getInstance().deleteAll(Unit.class);
farmerPageIndex = 0;
queryFarmerInputTime(farmerPageIndex, 10000);
}
// }
}
});
......
......@@ -92,6 +92,9 @@ public class CattleMarkVM extends BackBarVM<Repository> {
long idNo = IdUtil.createSnowflake(3, 1).nextId();
entity.setId(idNo + "");
entity.setPastureUnitId(SPUtils.getInstance().getString(Configs.SP_UNIT_CODE, ""));
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
entity.setBirthdate(dateFormat.format(new Date()));
entity.setWeight(100 + "");
markeImgUrl = Environment.getExternalStorageDirectory().getAbsolutePath() +
"/tracing/picture/"
......
......@@ -54,7 +54,7 @@ public class CattleUploadVM extends BackBarVM<Repository> {
private void uploadMarking() {
QueryBuilder<CattleLabelEntity> builder =
DbUtil.getInstance().getQueryBuilder(CattleLabelEntity.class);
DbUtil.getInstance().getQueryBuilder(CattleLabelEntity.class).limit(20);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<CattleLabelEntity>() {
@Override
public void onSuccess(List<CattleLabelEntity> result) {
......@@ -74,18 +74,17 @@ public class CattleUploadVM extends BackBarVM<Repository> {
.subscribe((Consumer<CattleResponse<List<CattleLabelEntity>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
refreshUploadCount();
}else{
uploadMarking();
} else {
ToastUtils.showShort("删除基础数据失败");
}
}
}).deleteAsyncAll(CattleLabelEntity.class);
}).deleteAsyncBatch(CattleLabelEntity.class, result);
} else {
dismissDialog();
ToastUtils.showShort("基础数据上传失败");
......@@ -96,6 +95,8 @@ public class CattleUploadVM extends BackBarVM<Repository> {
})
);
} else {
dismissDialog();
refreshUploadCount();
}
}
......
......@@ -25,10 +25,7 @@ import com.phlx.wool.db.gen.LabelDao;
import com.phlx.wool.db.interf.DbIDUCallBack;
import com.phlx.wool.db.interf.DbQueryCallBack;
import com.phlx.wool.entity.CacheLabel;
import com.phlx.wool.entity.EntryRegistrationEntity;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.event.EventMsg;
import com.phlx.wool.event.EventTag;
import com.phlx.wool.rfid.ModuleManager;
......@@ -400,7 +397,6 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
ToastUtils.showShort("请扫描耳标");
}
}
/**
......
......@@ -35,6 +35,7 @@ import com.phlx.wool.ui.base.BackBarVM;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.functions.Consumer;
......@@ -175,7 +176,7 @@ public class UploadVM extends BackBarVM<Repository> {
public void onSuccess(List<VillusBuyEntity> result) {
if (result != null) {
villusBuyLabelNum.set("绒毛购买 " + "(" + result.size() + ")");
}else{
} else {
villusBuyLabelNum.set("绒毛购买 " + "(0)");
}
}
......@@ -238,7 +239,7 @@ public class UploadVM extends BackBarVM<Repository> {
QueryBuilder<Marking> builder =
DbUtil.getInstance().getQueryBuilder(Marking.class).
where(MarkingDao.Properties.Status.eq(1));
where(MarkingDao.Properties.Status.eq(1)).limit(100);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Marking>() {
@Override
public void onSuccess(List<Marking> result) {
......@@ -278,13 +279,14 @@ public class UploadVM extends BackBarVM<Repository> {
@Override
public void onNotification(boolean result) {
if (result) {
uploadMarking();
} else {
dismissDialog();
}else{
toastStr += "删除标签数据失败;";
}
uploadNext();
}
}).deleteAsyncAll(Marking.class);
}
}).deleteAsyncBatch(Marking.class, result);
} else {
dismissDialog();
toastStr += "marking上传失败;";
......@@ -298,6 +300,7 @@ public class UploadVM extends BackBarVM<Repository> {
})
);
} else {
dismissDialog();
uploadNext();
}
}
......@@ -318,12 +321,13 @@ public class UploadVM extends BackBarVM<Repository> {
private void uploadQuarantine() {
QueryBuilder<Quarantine> builder =
DbUtil.getInstance().getQueryBuilder(Quarantine.class).
where(QuarantineDao.Properties.Status.eq(1));
where(QuarantineDao.Properties.Status.eq(1)).limit(20);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Quarantine>() {
@Override
public void onSuccess(List<Quarantine> result) {
isQuarantineUpload = true;
if (result != null && result.size() > 0) {
List<QuarantineDetail> quarantineDetails = new ArrayList<>();
KLog.e(result.toString());
for (Quarantine quarantine : result) {
if (quarantine.getList() != null && quarantine.getList().size() > 0) {
......@@ -332,8 +336,8 @@ public class UploadVM extends BackBarVM<Repository> {
QueryBuilder<QuarantineDetail> builder =
DbUtil.getInstance().getQueryBuilder(QuarantineDetail.class).
where(QuarantineDetailDao.Properties.QuarantineId.eq(quarantine.getId()));
List<QuarantineDetail> quarantineDetails =
DbUtil.getInstance().queryAll(QuarantineDetail.class, builder);
;
quarantineDetails.addAll(DbUtil.getInstance().queryAll(QuarantineDetail.class, builder));
quarantine.setList(quarantineDetails);
}
KLog.e(result.toString());
......@@ -356,12 +360,15 @@ public class UploadVM extends BackBarVM<Repository> {
@Override
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(QuarantineDetail.class);
if (quarantineDetails != null && quarantineDetails.size() > 0) {
DbUtil.getInstance().deleteList(quarantineDetails);
uploadQuarantine();
}
} else {
ToastUtils.showShort("删除检疫数据失败");
}
uploadNext();
}
}
}).deleteAsyncBatch(Quarantine.class, result);
} else {
toastStr += "上传检疫数据失败;";
......@@ -393,13 +400,14 @@ public class UploadVM extends BackBarVM<Repository> {
private void uploadHarmless() {
QueryBuilder<Harmless> builder =
DbUtil.getInstance().getQueryBuilder(Harmless.class).
where(HarmlessDao.Properties.Status.eq(1));
where(HarmlessDao.Properties.Status.eq(1)).limit(20);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Harmless>() {
@Override
public void onSuccess(List<Harmless> result) {
isHarmlessUpload = true;
if (result != null && result.size() > 0) {
KLog.e(result.toString());
List<HarmlessDetail> harmlessDetails = new ArrayList<>();
for (Harmless harmless : result) {
if (harmless.getList() != null && harmless.getList().size() > 0) {
harmless.setList(null);
......@@ -407,8 +415,8 @@ public class UploadVM extends BackBarVM<Repository> {
QueryBuilder<HarmlessDetail> builder =
DbUtil.getInstance().getQueryBuilder(HarmlessDetail.class).
where(HarmlessDetailDao.Properties.HarmlessId.eq(harmless.getId()));
List<HarmlessDetail> harmlessDetails =
DbUtil.getInstance().queryAll(HarmlessDetail.class, builder);
harmlessDetails.addAll(
DbUtil.getInstance().queryAll(HarmlessDetail.class, builder));
harmless.setList(harmlessDetails);
}
KLog.e(result.toString());
......@@ -431,14 +439,19 @@ public class UploadVM extends BackBarVM<Repository> {
@Override
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(HarmlessDetail.class);
if (harmlessDetails != null && harmlessDetails.size() > 0) {
DbUtil.getInstance().deleteList(harmlessDetails);
uploadHarmless();
}
} else {
dismissDialog();
ToastUtils.showShort("删除无害化数据失败");
}
uploadNext();
}
}
}).deleteAsyncBatch(Harmless.class, result);
} else {
dismissDialog();
toastStr += "上传无害化失败;";
ToastUtils.showShort("上传无害化失败");
uploadNext();
......@@ -468,7 +481,7 @@ public class UploadVM extends BackBarVM<Repository> {
QueryBuilder<VillusBuyEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusBuyEntity.class).
where(VillusBuyEntityDao.Properties.Status.eq(1));
where(VillusBuyEntityDao.Properties.Status.eq(1)).limit(100);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusBuyEntity>() {
@Override
public void onSuccess(List<VillusBuyEntity> result) {
......@@ -497,11 +510,12 @@ public class UploadVM extends BackBarVM<Repository> {
@Override
public void onNotification(boolean result) {
if (result) {
uploadVillusBuy();
} else {
ToastUtils.showShort("更新绒毛购买数据失败");
}
uploadNext();
}
}
}).updateAsyncBatch(VillusBuyEntity.class, result);
} else {
toastStr += "上传绒毛购买数据失败;";
......@@ -532,7 +546,7 @@ public class UploadVM extends BackBarVM<Repository> {
private void uploadVillusGauge() {
QueryBuilder<VillusGaugeEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusGaugeEntity.class).
where(VillusGaugeEntityDao.Properties.Status.eq(1));
where(VillusGaugeEntityDao.Properties.Status.eq(1)).limit(100);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusGaugeEntity>() {
@Override
public void onSuccess(List<VillusGaugeEntity> result) {
......@@ -554,20 +568,20 @@ public class UploadVM extends BackBarVM<Repository> {
KLog.e(response.getCode() + response.getMsg());
dismissDialog();
if (response.getCode() == 0) {
for (VillusGaugeEntity villusGaugeEntity : result) {
villusGaugeEntity.setStatus(0);
}
// for (VillusGaugeEntity villusGaugeEntity : result) {
// villusGaugeEntity.setStatus(0);
// }
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(VillusGaugeEntity.class);
uploadVillusGauge();
} else {
ToastUtils.showShort("删除绒毛测量数据失败");
}
uploadNext();
}
}).updateAsyncBatch(VillusGaugeEntity.class, result);
}
}).deleteAsyncBatch(VillusGaugeEntity.class, result);
} else {
toastStr += "上传绒毛测量数据失败;";
ToastUtils.showShort("上传绒毛测量数据失败");
......@@ -597,7 +611,7 @@ public class UploadVM extends BackBarVM<Repository> {
private void uploadSlaughterEntry() {
QueryBuilder<EntryRegistrationEntity> builder =
DbUtil.getInstance().getQueryBuilder(EntryRegistrationEntity.class).
where(EntryRegistrationEntityDao.Properties.Status.eq(1));
where(EntryRegistrationEntityDao.Properties.Status.eq(1)).limit(100);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<EntryRegistrationEntity>() {
@Override
public void onSuccess(List<EntryRegistrationEntity> result) {
......@@ -619,20 +633,20 @@ public class UploadVM extends BackBarVM<Repository> {
KLog.e(response.getCode() + response.getMsg());
dismissDialog();
if (response.getCode() == 0) {
for (EntryRegistrationEntity entryRegistrationEntity : result) {
entryRegistrationEntity.setStatus(0);
}
// for (EntryRegistrationEntity entryRegistrationEntity : result) {
// entryRegistrationEntity.setStatus(0);
// }
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(EntryRegistrationEntity.class);
uploadSlaughterEntry();
} else {
ToastUtils.showShort("删除屠宰进场数据失败");
}
uploadNext();
}
}).updateAsyncBatch(EntryRegistrationEntity.class, result);
}
}).deleteAsyncBatch(EntryRegistrationEntity.class, result);
} else {
toastStr += "上传屠宰进场数据失败;";
ToastUtils.showShort("上传屠宰进场数据失败");
......
......@@ -205,6 +205,7 @@
android:hint="请输入体重"
android:inputType="numberDecimal"
android:maxLines="1"
android:maxLength="10"
android:text="@={viewModel.entity.weight}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/weight_edit"
......@@ -232,6 +233,7 @@
android:background="@drawable/input_frame_bg"
android:hint="请输入胸围"
android:maxLines="1"
android:maxLength="10"
android:inputType="numberDecimal"
android:text="@={viewModel.entity.bust}"
android:textSize="@dimen/edit_size"
......@@ -260,6 +262,7 @@
android:background="@drawable/input_frame_bg"
android:hint="请输入管维"
android:maxLines="1"
android:maxLength="10"
android:inputType="numberDecimal"
android:text="@={viewModel.entity.tubeCircumference}"
android:textSize="@dimen/edit_size"
......@@ -289,6 +292,7 @@
android:background="@drawable/input_frame_bg"
android:hint="请输入体高"
android:maxLines="1"
android:maxLength="10"
android:inputType="numberDecimal"
android:text="@={viewModel.entity.bodyHeight}"
android:textSize="@dimen/edit_size"
......@@ -319,6 +323,7 @@
android:hint="请输入体斜长"
android:maxLines="1"
android:inputType="numberDecimal"
android:maxLength="10"
android:text="@={viewModel.entity.bodyObliqueLength}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/twin_sheep_cb"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment