Commit 50287ea2 authored by hywang's avatar hywang

修改一些bug

parent 825466bc
...@@ -39,6 +39,7 @@ public class Configs { ...@@ -39,6 +39,7 @@ public class Configs {
public static final String SP_USER_NAME = "sp_user_name"; public static final String SP_USER_NAME = "sp_user_name";
public static final String SP_ID = "sp_id"; public static final String SP_ID = "sp_id";
public static final String SP_NAME = "sp_name"; public static final String SP_NAME = "sp_name";
public static final String SP_FREQUENCY = "sp_frequency";
public static final String SP_USER_PASSWORD = "sp_user_password"; public static final String SP_USER_PASSWORD = "sp_user_password";
public static final String SP_USER_EMAIL = "sp_user_email"; public static final String SP_USER_EMAIL = "sp_user_email";
public static final String SP_FREQUENCY_CONFIG = "sp_frequency_config"; public static final String SP_FREQUENCY_CONFIG = "sp_frequency_config";
......
...@@ -32,7 +32,7 @@ import java.util.List; ...@@ -32,7 +32,7 @@ import java.util.List;
*/ */
public class DbUtil { public class DbUtil {
private static final String DEFAULT_DATABASE_NAME = "CattleManager.db"; private static final String DEFAULT_DATABASE_NAME = "WoolManager.db";
private static final String DEFAULT_DATABASE_PASSWORD = "phx123456"; private static final String DEFAULT_DATABASE_PASSWORD = "phx123456";
private DaoSession mDaoSession; private DaoSession mDaoSession;
private DaoMaster mDaoMaster; private DaoMaster mDaoMaster;
......
...@@ -50,7 +50,7 @@ public class Label extends BaseObservable implements Parcelable { ...@@ -50,7 +50,7 @@ public class Label extends BaseObservable implements Parcelable {
/** /**
* 耳标tid * 耳标tid
*/ */
@Index(name = "LabelTid", unique = true) @Index(name = "LabelTid", unique = false)
@SerializedName("innercode") @SerializedName("innercode")
private String Tid; private String Tid;
......
...@@ -47,7 +47,7 @@ public class RetrofitClient { ...@@ -47,7 +47,7 @@ public class RetrofitClient {
//缓存时间 //缓存时间
private static final int CACHE_TIMEOUT = 10 * 1024 * 1024; private static final int CACHE_TIMEOUT = 10 * 1024 * 1024;
//服务端根路径 //服务端根路径
public static String baseUrl = "192.168.8.182"; public static String baseUrl = "192.168.8.189";
public static String port = "80"; public static String port = "80";
private static Context mContext = Utils.getContext(); private static Context mContext = Utils.getContext();
......
...@@ -208,9 +208,10 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis ...@@ -208,9 +208,10 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
legalCount = 0; legalCount = 0;
KLog.e(mList.toString()); KLog.e(mList.toString());
for (int i = 0; i < mList.size(); i++) { for (int i = 0; i < mList.size(); i++) {
List<Label> allLablel = DbUtil.getInstance().queryAll(Label.class);
QueryBuilder<Label> builder = QueryBuilder<Label> builder =
DbUtil.getInstance().getQueryBuilder(Label.class) DbUtil.getInstance().getQueryBuilder(Label.class)
.where(LabelDao.Properties.Tid.eq(mList.get(i).getTid())); .where(LabelDao.Properties.Epc.eq(mList.get(i).getEpc()));
List<Label> labels = DbUtil.getInstance().queryAll(Label.class, builder); List<Label> labels = DbUtil.getInstance().queryAll(Label.class, builder);
//合法状态 0 非法 1 合法 //合法状态 0 非法 1 合法
if (labels.size() == 0) { if (labels.size() == 0) {
......
...@@ -127,7 +127,7 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> { ...@@ -127,7 +127,7 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
//设置强制更新 //设置强制更新
.setForcedUpgrade(true); .setForcedUpgrade(true);
DownloadManager manager = DownloadManager.getInstance(this); DownloadManager manager = DownloadManager.getInstance(this);
manager.setApkName("CattleManager.apk") manager.setApkName("WoolManager.apk")
.setApkUrl(downloadUrl) .setApkUrl(downloadUrl)
.setSmallIcon(R.mipmap.ic_launcher) .setSmallIcon(R.mipmap.ic_launcher)
.setShowNewerToast(true) .setShowNewerToast(true)
......
...@@ -141,6 +141,7 @@ public class LoginVM extends BackBarVM<Repository> { ...@@ -141,6 +141,7 @@ public class LoginVM extends BackBarVM<Repository> {
model.saveBreed(response.getData().getUser().getDept().getDeptName()); model.saveBreed(response.getData().getUser().getDept().getDeptName());
SPUtils.getInstance().put(Configs.SP_ID, response.getData().getUser().getUserId()); SPUtils.getInstance().put(Configs.SP_ID, response.getData().getUser().getUserId());
SPUtils.getInstance().put(Configs.SP_NAME, response.getData().getUser().getUserName()); SPUtils.getInstance().put(Configs.SP_NAME, response.getData().getUser().getUserName());
SPUtils.getInstance().put(Configs.SP_FREQUENCY, response.getData().getUser().getFrequencyConfig());
} }
VMFactory.getInstance(getApplication()).refreshRepository(); VMFactory.getInstance(getApplication()).refreshRepository();
if (SPUtils.getInstance().getBoolean("isFirst", true)) { if (SPUtils.getInstance().getBoolean("isFirst", true)) {
...@@ -191,6 +192,7 @@ public class LoginVM extends BackBarVM<Repository> { ...@@ -191,6 +192,7 @@ public class LoginVM extends BackBarVM<Repository> {
ToastUtils.showShort("密码错误"); ToastUtils.showShort("密码错误");
return; return;
} }
Configs.FREQUENCY_CONFIG = SPUtils.getInstance().getString(Configs.SP_FREQUENCY);
startActivity(MainActivity.class); startActivity(MainActivity.class);
finish(); finish();
} else { } else {
......
...@@ -53,7 +53,7 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashVM ...@@ -53,7 +53,7 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashVM
if (result != null && result.size() > 0) { if (result != null && result.size() > 0) {
inputTime = result.get(0).getTimestamp(); inputTime = result.get(0).getTimestamp();
} }
viewModel.requestLabel(0, inputTime, 100000); viewModel.requestLabel(1, inputTime, 100000);
} }
@Override @Override
......
...@@ -38,7 +38,7 @@ public class SplashVM extends MainBarVM<Repository> { ...@@ -38,7 +38,7 @@ public class SplashVM extends MainBarVM<Repository> {
public SingleLiveEvent<String> errorEvent = new SingleLiveEvent<>(); public SingleLiveEvent<String> errorEvent = new SingleLiveEvent<>();
private int labelPageIndex = 0; private int labelPageIndex = 1;
private int unitPageIndex = 0; private int unitPageIndex = 0;
public SplashVM(@NonNull Application application, Repository repository) { public SplashVM(@NonNull Application application, Repository repository) {
......
...@@ -145,9 +145,9 @@ public class UploadVM extends BackBarVM<Repository> { ...@@ -145,9 +145,9 @@ public class UploadVM extends BackBarVM<Repository> {
uploadHarmless(); uploadHarmless();
} else if (isUploadQuarantine.get() && !isQuarantineUpload) { } else if (isUploadQuarantine.get() && !isQuarantineUpload) {
uploadQuarantine(); uploadQuarantine();
} else if (isUploadMarking.get() && !isVillusBuyUpload) { } else if (isUploadVillusBuy.get() && !isVillusBuyUpload) {
uploadVillusBuy(); uploadVillusBuy();
} else if (isUploadMarking.get() && !isVillusGaugeUpload) { } else if (isUploadVillusGauge.get() && !isVillusGaugeUpload) {
uploadVillusGauge(); uploadVillusGauge();
} else { } else {
ToastUtils.showShort("请选择上传的项目"); ToastUtils.showShort("请选择上传的项目");
......
...@@ -5,6 +5,7 @@ import android.os.Bundle; ...@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -58,7 +59,7 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -58,7 +59,7 @@ public class VillusBuyVM extends BackBarVM<Repository> {
public VillusBuyEntity entity; public VillusBuyEntity entity;
public List<IKeyAndValue> superiorPertainItemData; public List<IKeyAndValue> superiorPertainItemData;
public List<IKeyAndValue> pertainItemData; public List<IKeyAndValue> pertainItemData;
private List<String> lists ; private List<String> lists;
private List<VillusBuyEntity> uploadData; private List<VillusBuyEntity> uploadData;
...@@ -71,10 +72,14 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -71,10 +72,14 @@ public class VillusBuyVM extends BackBarVM<Repository> {
private ArrayAdapter<String> spinnerAdapter; private ArrayAdapter<String> spinnerAdapter;
private Long id;
public VillusBuyVM(@NonNull Application application, Repository model) { public VillusBuyVM(@NonNull Application application, Repository model) {
super(application, model); super(application, model);
id = IdUtil.createSnowflake(3, 1).nextId();
if (entity == null) { if (entity == null) {
entity = new VillusBuyEntity(); entity = new VillusBuyEntity();
} }
...@@ -144,7 +149,7 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -144,7 +149,7 @@ public class VillusBuyVM extends BackBarVM<Repository> {
} }
}); });
public ArrayAdapter getAdapter(VillusBuyActivity cls){ public ArrayAdapter getAdapter(VillusBuyActivity cls) {
spinnerAdapter = new ArrayAdapter<>(cls, R.layout.simple_spinner_item, lists); spinnerAdapter = new ArrayAdapter<>(cls, R.layout.simple_spinner_item, lists);
spinnerAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinnerAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
return spinnerAdapter; return spinnerAdapter;
...@@ -178,7 +183,7 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -178,7 +183,7 @@ public class VillusBuyVM extends BackBarVM<Repository> {
} }
uploadData = new ArrayList<>(); uploadData = new ArrayList<>();
entity.setId(IdUtil.createSnowflake(3, 1).nextId()); entity.setId(id);
entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME)); entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME));
entity.setCreateTime(dateFormat.format(new Date())); entity.setCreateTime(dateFormat.format(new Date()));
entity.setStatus(1); entity.setStatus(1);
...@@ -199,6 +204,7 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -199,6 +204,7 @@ public class VillusBuyVM extends BackBarVM<Repository> {
if (Configs.isOnLine) { if (Configs.isOnLine) {
uploadVillusBuy(); uploadVillusBuy();
} else { } else {
ToastUtils.showShort("绒毛购买保存成功");
backMain(); backMain();
} }
} }
...@@ -230,13 +236,14 @@ public class VillusBuyVM extends BackBarVM<Repository> { ...@@ -230,13 +236,14 @@ public class VillusBuyVM extends BackBarVM<Repository> {
public void onNotification(boolean result) { public void onNotification(boolean result) {
if (result) { if (result) {
dismissDialog(); dismissDialog();
ToastUtils.showShort("绒毛购买上传成功");
printEvent.call(); printEvent.call();
} }
} }
}).insertAsyncBatch(VillusBuyEntity.class, uploadData); }).insertAsyncBatch(VillusBuyEntity.class, uploadData);
} else { } else {
dismissDialog(); dismissDialog();
ToastUtils.showShort("上传失败"); ToastUtils.showShort("绒毛购买上传失败");
} }
}, (Consumer<ResponseThrowable>) throwable -> { }, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog(); dismissDialog();
......
...@@ -48,10 +48,13 @@ public class VillusGaugeVM extends BackBarVM<Repository> { ...@@ -48,10 +48,13 @@ public class VillusGaugeVM extends BackBarVM<Repository> {
private List<VillusGaugeEntity> uploadData; private List<VillusGaugeEntity> uploadData;
private Long id;
public VillusGaugeVM(@NonNull Application application, Repository model) { public VillusGaugeVM(@NonNull Application application, Repository model) {
super(application, model); super(application, model);
id = IdUtil.createSnowflake(3, 1).nextId();
if (entity == null) { if (entity == null) {
entity = new VillusGaugeEntity(); entity = new VillusGaugeEntity();
} }
...@@ -123,7 +126,7 @@ public class VillusGaugeVM extends BackBarVM<Repository> { ...@@ -123,7 +126,7 @@ public class VillusGaugeVM extends BackBarVM<Repository> {
} }
uploadData = new ArrayList<>(); uploadData = new ArrayList<>();
entity.setId(IdUtil.createSnowflake(3, 1).nextId()); entity.setId(id);
entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME)); entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME));
entity.setCreateTime(dateFormat.format(new Date())); entity.setCreateTime(dateFormat.format(new Date()));
entity.setStatus(1); entity.setStatus(1);
......
...@@ -52,7 +52,7 @@ public class HarmlessVM extends BackBarVM<Repository> { ...@@ -52,7 +52,7 @@ public class HarmlessVM extends BackBarVM<Repository> {
public SingleLiveEvent<Boolean> showSearch = new SingleLiveEvent<>(); public SingleLiveEvent<Boolean> showSearch = new SingleLiveEvent<>();
private ArrayList<Label> labels; private ArrayList<Label> labels;
private SimpleDateFormat dateFormat; private SimpleDateFormat dateFormat;
private long parentId; private long parentId= -1;
public HarmlessVM(@NonNull Application application, Repository repository) { public HarmlessVM(@NonNull Application application, Repository repository) {
super(application, repository); super(application, repository);
...@@ -184,13 +184,13 @@ public class HarmlessVM extends BackBarVM<Repository> { ...@@ -184,13 +184,13 @@ public class HarmlessVM extends BackBarVM<Repository> {
QueryBuilder<HarmlessDetail> builder = QueryBuilder<HarmlessDetail> builder =
DbUtil.getInstance().getQueryBuilder(HarmlessDetail.class). DbUtil.getInstance().getQueryBuilder(HarmlessDetail.class).
where(HarmlessDetailDao.Properties.HarmlessId.eq(parentId)); where(HarmlessDetailDao.Properties.HarmlessId.eq(parentId));
List<HarmlessDetail> harmlessDetails = DbUtil.getInstance().queryAll(HarmlessDetail.class List<HarmlessDetail> harmlessDetails = DbUtil.getInstance().queryAll(HarmlessDetail.class, builder);
, builder);
harmless.setList(harmlessDetails); harmless.setList(harmlessDetails);
String postInfoStr = String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<Harmless>(harmless)); new GsonBuilder().serializeNulls()
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), // .excludeFieldsWithoutExposeAnnotation()
postInfoStr); .create().toJson(new UploadParams<Harmless>(harmless));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr); KLog.e(postInfoStr);
addSubscribe(model.submitHarmless(body) addSubscribe(model.submitHarmless(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider())) .compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
......
...@@ -206,7 +206,9 @@ public class MarkingVM extends BackBarVM<Repository> { ...@@ -206,7 +206,9 @@ public class MarkingVM extends BackBarVM<Repository> {
*/ */
private void uploadMarking() { private void uploadMarking() {
String postInfoStr = String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<List<Marking>>(uploadData)); new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<Marking>>(uploadData));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
postInfoStr); postInfoStr);
KLog.e(postInfoStr); KLog.e(postInfoStr);
......
...@@ -185,7 +185,9 @@ public class QuarantineVM extends BackBarVM<Repository> { ...@@ -185,7 +185,9 @@ public class QuarantineVM extends BackBarVM<Repository> {
DbUtil.getInstance().queryAll(QuarantineDetail.class, builder); DbUtil.getInstance().queryAll(QuarantineDetail.class, builder);
quarantine.setList(quarantineDetails); quarantine.setList(quarantineDetails);
String postInfoStr = String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<Quarantine>(quarantine)); new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<Quarantine>(quarantine));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
postInfoStr); postInfoStr);
KLog.e(postInfoStr); KLog.e(postInfoStr);
......
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