Commit bf8ea70f authored by hywang's avatar hywang

1.修复清除数据卡死bug;

2.修复羊绒购买无法上传完成的bug;
3.增加同步数据页面本地数量。
parent c112a7f3
......@@ -8,8 +8,8 @@ android {
applicationId "com.phlx.wool"
minSdkVersion 21
targetSdkVersion 29
versionCode 18
versionName "1.1.8"
versionCode 19
versionName "1.1.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
......@@ -59,7 +59,7 @@ public class Configs {
public static final String WORK_TYPE_H = "work_type_harmless";
//0 高频,1低频
public static String FREQUENCY_CONFIG = "0";
public static String FREQUENCY_CONFIG = "1";
/** 蓝牙 */
public static boolean isConnected = false;// 蓝牙连接状态
......
......@@ -44,6 +44,14 @@ public class ClearVM extends BackBarVM<Repository> {
public ObservableField<Boolean> isClearAll = new ObservableField<Boolean>(false);
public ObservableInt clearDataVisibility = new ObservableInt();
public ObservableField<String> markingLabelNum = new ObservableField<>("打标记录");
public ObservableField<String> harmlessLabelNum = new ObservableField<>("无害化处理");
public ObservableField<String> quarantineLabelNum = new ObservableField<>("检疫记录");
public ObservableField<String> villusBuyLabelNum = new ObservableField<>("绒毛购买");
public ObservableField<String> villusgaugelabelNum = new ObservableField<>("绒毛测量");
private String toastStr;
private boolean isMarkingClear, isHarmlessClear, isQuarantineClear, isVillusBuyClear, isVillusGaugeClear;
public ClearVM(@NonNull Application application, Repository repository) {
......@@ -124,31 +132,52 @@ public class ClearVM extends BackBarVM<Repository> {
isQuarantineClear = false;
isVillusBuyClear = false;
isVillusGaugeClear = false;
toastStr = "";
clearNext();
});
private void clearNext() {
if (isClearMarking.get() && !isMarkingClear) {
deleteAllMarking();
} else if (isClearQuarantine.get() && !isHarmlessClear) {
} else if (isClearQuarantine.get() && !isQuarantineClear) {
deleteAllQuarantine();
} else if (isClearHarmless.get() && !isQuarantineClear) {
} else if (isClearHarmless.get() && !isHarmlessClear) {
deleteAllHarmless();
} else if (isClearVillusBuy.get() && !isVillusBuyClear) {
deleteAllVillusBuy();
} else if (isClearVillusGauge.get() && !isVillusGaugeClear) {
deleteAllVillusGauge();
} else {
refreshUploadCount();
if ("".equals(toastStr)) {
ToastUtils.showShort("清除数据成功");
} else {
ToastUtils.showShort(toastStr);
}
}
}
//查询每项记录数量
public void refreshUploadCount() {
markingLabelNum.set("打标记录 " + "(" + DbUtil.getInstance().count(Marking.class) + ")");
harmlessLabelNum.set("无害化处理 " + "(" + DbUtil.getInstance().count(Harmless.class) + ")");
quarantineLabelNum.set("检疫记录 " + "(" + DbUtil.getInstance().count(Quarantine.class) + ")");
villusBuyLabelNum.set("绒毛购买 " + "(" + DbUtil.getInstance().count(VillusBuyEntity.class) + ")");
villusgaugelabelNum.set("绒毛测量 " + "(" + DbUtil.getInstance().count(VillusGaugeEntity.class) + ")");
;
}
private void deleteAllMarking() {
showDialog("正在清除数据,请勿关闭屏幕或退出程序");
showDialog("正在清除标签数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isMarkingClear = true;
if (result) {
dismissDialog();
}else{
toastStr += "清除标签数据失败;";
}
clearNext();
}
......@@ -156,7 +185,7 @@ public class ClearVM extends BackBarVM<Repository> {
}
private void deleteAllQuarantine() {
showDialog("正在清除数据,请勿关闭屏幕或退出程序");
showDialog("正在清除检疫数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
......@@ -164,6 +193,8 @@ public class ClearVM extends BackBarVM<Repository> {
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(QuarantineDetail.class);
}else{
toastStr += "清除检疫数据失败;";
}
clearNext();
}
......@@ -171,7 +202,7 @@ public class ClearVM extends BackBarVM<Repository> {
}
private void deleteAllHarmless() {
showDialog("正在清除数据,请勿关闭屏幕或退出程序");
showDialog("正在清除无害化数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
......@@ -179,6 +210,8 @@ public class ClearVM extends BackBarVM<Repository> {
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(HarmlessDetail.class);
}else{
toastStr += "清除无害化数据失败;";
}
clearNext();
}
......@@ -193,7 +226,8 @@ public class ClearVM extends BackBarVM<Repository> {
isVillusBuyClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(VillusBuyEntity.class);
}else{
toastStr += "清除绒毛购买数据失败;";
}
clearNext();
}
......@@ -208,12 +242,17 @@ public class ClearVM extends BackBarVM<Repository> {
isVillusGaugeClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(VillusGaugeEntity.class);
}else{
toastStr += "清除绒毛测量数据失败;";
}
clearNext();
}
}).deleteAsyncAll(VillusGaugeEntity.class);
}
@Override
public void onResume() {
super.onResume();
refreshUploadCount();
}
}
......@@ -13,16 +13,24 @@ import com.phlx.wool.data.Repository;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.db.interf.DbIDUCallBack;
import com.phlx.wool.db.interf.DbQueryCallBack;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.TreatmentMethod;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.Variety;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusBuyEntityDao;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
import com.phlx.wool.params.PostParams;
import com.phlx.wool.ui.base.BackBarVM;
import com.phlx.wool.ui.main.MainActivity;
import org.greenrobot.greendao.query.QueryBuilder;
import org.greenrobot.greendao.query.WhereCondition;
import java.text.ParseException;
......@@ -68,6 +76,12 @@ public class DownloadVM extends BackBarVM<Repository> {
public ObservableField<Boolean> isDownloadAll = new ObservableField<Boolean>(false);
public ObservableInt downloadDataVisibility = new ObservableInt();
public ObservableField<String> markingLabelNum = new ObservableField<>("发标记录");
public ObservableField<String> unitNum = new ObservableField<>("养殖单位");
public ObservableField<String> basicNum = new ObservableField<>("基础信息");
public ObservableField<String> veterinaryNum = new ObservableField<>("兽医");
public ObservableField<String> villusBuyNum = new ObservableField<>("绒毛购买");
private boolean isLabelDownload, isBasicDownload, isUnitDownload, isVeterinaryDownload, isVillusBuyDownload;
public DownloadVM(@NonNull Application application, Repository repository) {
......@@ -122,7 +136,7 @@ public class DownloadVM extends BackBarVM<Repository> {
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isDownloadVeterinary.set(isChecked);
isDownloadVillusBuy.set(isChecked);
}
});
......@@ -167,18 +181,27 @@ public class DownloadVM extends BackBarVM<Repository> {
} else if (isDownloadVillusBuy.get() && !isVillusBuyDownload) {
requestVillusBuy();
} else {
refreshUploadCount();
startActivity(MainActivity.class);
finish();
}
}
//查询每项记录数量
public void refreshUploadCount() {
markingLabelNum.set("发标记录 " + "(" + DbUtil.getInstance().count(Label.class) + ")");
unitNum.set("养殖单位 " + "(" + DbUtil.getInstance().count(Unit.class) + ")");
basicNum.set("基础信息 " + "(" + DbUtil.getInstance().count(TreatmentMethod.class) + "-" + DbUtil.getInstance().count(Variety.class) + ")");
veterinaryNum.set("兽医 " + "(" + DbUtil.getInstance().count(Veterinary.class) + ")");
villusBuyNum.set("绒毛购买 " + "(" + DbUtil.getInstance().count(VillusBuyEntity.class) + ")");
}
private void baseDateUpload() {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
String sql = "TIMESTAMP IN " + "(SELECT MAX(TIMESTAMP) FROM LABEL)";
WhereCondition.StringCondition stringCondition =
new WhereCondition.StringCondition(sql);
WhereCondition.StringCondition stringCondition = new WhereCondition.StringCondition(sql);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Label>() {
@Override
public void onSuccess(List<Label> result) {
......@@ -391,8 +414,7 @@ public class DownloadVM extends BackBarVM<Repository> {
postParams.setPageNum(1);
postParams.setPageSize(200);
// postParams.setYears("2018");
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(postParams));
addSubscribe(model.getVillusBuyList(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
......@@ -442,8 +464,7 @@ public class DownloadVM extends BackBarVM<Repository> {
postParams.setPageNum(1);
postParams.setPageSize(200);
postParams.setYears("");
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(postParams));
addSubscribe(model.getBasicInfo(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
......@@ -474,4 +495,9 @@ public class DownloadVM extends BackBarVM<Repository> {
);
}
@Override
public void onResume() {
super.onResume();
refreshUploadCount();
}
}
......@@ -151,7 +151,25 @@ public class UploadVM extends BackBarVM<Repository> {
markingLabelNum.set("打标记录 " + "(" + DbUtil.getInstance().count(Marking.class) + ")");
harmlessLabelNum.set("无害化处理 " + "(" + DbUtil.getInstance().count(Harmless.class) + ")");
quarantineLabelNum.set("检疫记录 " + "(" + DbUtil.getInstance().count(Quarantine.class) + ")");
villusBuyLabelNum.set("绒毛购买 " + "(" + DbUtil.getInstance().count(VillusBuyEntity.class) + ")");
QueryBuilder<VillusBuyEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusBuyEntity.class)
.where(VillusBuyEntityDao.Properties.Status.eq(1));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusBuyEntity>() {
@Override
public void onSuccess(List<VillusBuyEntity> result) {
if (result != null) {
villusBuyLabelNum.set("绒毛购买 " + "(" + result.size() + ")");
}else{
villusBuyLabelNum.set("绒毛购买 " + "(0)");
}
}
@Override
public void onFailed() {
villusBuyLabelNum.set("绒毛购买 " + "(" + "-" + ")");
}
}).queryAsyncAll(VillusBuyEntity.class, builder);
villusgaugelabelnum.set("绒毛测量 " + "(" + DbUtil.getInstance().count(VillusGaugeEntity.class) + ")");
;
}
......@@ -199,7 +217,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));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Marking>() {
@Override
public void onSuccess(List<Marking> result) {
......@@ -267,7 +285,7 @@ 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));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Quarantine>() {
@Override
public void onSuccess(List<Quarantine> result) {
......@@ -342,7 +360,7 @@ 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));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Harmless>() {
@Override
public void onSuccess(List<Harmless> result) {
......@@ -417,7 +435,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));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusBuyEntity>() {
@Override
public void onSuccess(List<VillusBuyEntity> result) {
......@@ -481,7 +499,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));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusGaugeEntity>() {
@Override
public void onSuccess(List<VillusGaugeEntity> result) {
......
......@@ -35,7 +35,7 @@
android:layout_marginStart="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearMarking}"
android:text="打标记录"
android:text="@{viewModel.markingLabelNum}"
android:textColor="@color/black"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toTopOf="parent"
......@@ -48,7 +48,7 @@
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:checked="@{viewModel.isClearHarmless}"
android:text="无害化处理"
android:text="@{viewModel.harmlessLabelNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintEnd_toEndOf="parent"
......@@ -61,7 +61,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearQuarantine}"
android:text="检疫记录"
android:text="@{viewModel.quarantineLabelNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/marking_info_desc"
......@@ -74,7 +74,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearVillusBuy}"
android:text="绒毛购买"
android:text="@{viewModel.villusBuyLabelNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/harmless_info_desc"
......@@ -87,7 +87,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearVillusGauge}"
android:text="绒毛测量"
android:text="@{viewModel.villusgaugelabelNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/quarantine_info_desc"
......
......@@ -36,7 +36,7 @@
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isDownloadLabel}"
binding:onCheckedChangedCommand="@{viewModel.onDownloadLabelCommand}"
android:text="发标记录"
android:text="@{viewModel.markingLabelNum}"
android:textColor="@color/black"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toTopOf="parent" />
......@@ -47,7 +47,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:text="养殖单位"
android:text="@{viewModel.unitNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
android:checked="@{viewModel.isDownloadUnit}"
......@@ -60,7 +60,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:text="基础信息"
android:text="@{viewModel.basicNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/label_info_desc"
......@@ -74,7 +74,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:text="兽医"
android:text="@{viewModel.veterinaryNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
android:checked="@{viewModel.isDownloadVeterinary}"
......@@ -88,7 +88,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:text="绒毛购买"
android:text="@{viewModel.villusBuyNum}"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
android:checked="@{viewModel.isDownloadVillusBuy}"
......
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