Commit ca9728fd authored by hywang's avatar hywang

1.增加错误数据上传功能;

2.基础信息页面增重显示;
3.登录超时跳转登录页;
4.所有功能的备注功能;
5.修复一些bug
parent 53296ef1
......@@ -5,6 +5,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import com.phlx.anchorcollect.entity.CattleResumeEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
......@@ -115,6 +116,8 @@ public class Configs {
public static String tempRfid = "";
//临时存放列表查询unid
public static Long tempUnid;
//临时存放耳标数据
public static CattleResumeEntity tempCattleResume;
//首页fragment标签
public static int mainPosition;
......
......@@ -103,7 +103,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadPerformanceList(RequestBody body) {
public Observable<ListResponse<Long>> uploadPerformanceList(RequestBody body) {
return mHttpDataSource.uploadPerformanceList(body);
}
......@@ -118,7 +118,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadBreedingRecordList(RequestBody body) {
public Observable<ListResponse<Long>> uploadBreedingRecordList(RequestBody body) {
return mHttpDataSource.uploadBreedingRecordList(body);
}
......@@ -133,7 +133,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadBreedingRecordDetailList(RequestBody body) {
public Observable<ListResponse<Long>> uploadBreedingRecordDetailList(RequestBody body) {
return mHttpDataSource.uploadBreedingRecordDetailList(body);
}
......@@ -148,7 +148,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadWeightManList(RequestBody body) {
public Observable<ListResponse<Long>> uploadWeightManList(RequestBody body) {
return mHttpDataSource.uploadWeightManList(body);
}
......@@ -163,7 +163,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadMedicalRecordList(RequestBody body) {
public Observable<ListResponse<Long>> uploadMedicalRecordList(RequestBody body) {
return mHttpDataSource.uploadMedicalRecordList(body);
}
......@@ -178,7 +178,7 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadImmuneBatchList(RequestBody body) {
public Observable<ListResponse<Long>> uploadImmuneBatchList(RequestBody body) {
return mHttpDataSource.uploadImmuneBatchList(body);
}
......@@ -193,10 +193,15 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
}
@Override
public Observable<CollectResponse> uploadImmuneBatchDetailList(RequestBody body) {
public Observable<ListResponse<Long>> uploadImmuneBatchDetailList(RequestBody body) {
return mHttpDataSource.uploadImmuneBatchDetailList(body);
}
@Override
public Observable<CollectResponse> uploadErrorData(RequestBody body) {
return mHttpDataSource.uploadErrorData(body);
}
/****************************************************************************/
@Override
......
......@@ -102,7 +102,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/performance/add")
Observable<CollectResponse> uploadPerformanceList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadPerformanceList(@Body RequestBody body);
/**
* 获取-配种记录主表-列表
......@@ -124,7 +124,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/cattlematingMaster/add")
Observable<CollectResponse> uploadBreedingRecordList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadBreedingRecordList(@Body RequestBody body);
/**
* 获取-配种记录子表-列表
......@@ -146,7 +146,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/cattlematingDetaill/add")
Observable<CollectResponse> uploadBreedingRecordDetailList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadBreedingRecordDetailList(@Body RequestBody body);
/**
* 获取-称重管理-列表
......@@ -168,7 +168,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/weightMan/add")
Observable<CollectResponse> uploadWeightManList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadWeightManList(@Body RequestBody body);
/**
* 获取-诊疗记录-列表
......@@ -190,7 +190,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/medicalrecords/add")
Observable<CollectResponse> uploadMedicalRecordList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadMedicalRecordList(@Body RequestBody body);
/**
* 获取-免疫记录-列表
......@@ -212,7 +212,7 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/immunebatch/add")
Observable<CollectResponse> uploadImmuneBatchList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadImmuneBatchList(@Body RequestBody body);
/**
* 获取-免疫记录-子表-列表
......@@ -234,9 +234,14 @@ public interface ApiService {
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/immunebatchDetail/add")
Observable<CollectResponse> uploadImmuneBatchDetailList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadImmuneBatchDetailList(@Body RequestBody body);
/**
* 上传-错误记录
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/api/error/add")
Observable<CollectResponse> uploadErrorData(@Body RequestBody body);
......
......@@ -82,7 +82,7 @@ public interface HttpDataSource {
/**
* 上传性能测定列表
*/
Observable<CollectResponse> uploadPerformanceList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadPerformanceList(@Body RequestBody body);
/**
* 获取-配种记录主表-列表
......@@ -98,7 +98,7 @@ public interface HttpDataSource {
/**
* 上传-配种记录主表-列表
*/
Observable<CollectResponse> uploadBreedingRecordList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadBreedingRecordList(@Body RequestBody body);
/**
* 获取-配种记录子表-列表
......@@ -114,7 +114,7 @@ public interface HttpDataSource {
/**
* 上传-配种记录子表-列表
*/
Observable<CollectResponse> uploadBreedingRecordDetailList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadBreedingRecordDetailList(@Body RequestBody body);
/**
* 获取-称重管理-列表
......@@ -130,7 +130,7 @@ public interface HttpDataSource {
/**
* 上传-称重管理-列表
*/
Observable<CollectResponse> uploadWeightManList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadWeightManList(@Body RequestBody body);
/**
* 获取-诊疗记录-列表
......@@ -146,7 +146,7 @@ public interface HttpDataSource {
/**
* 上传-诊疗记录-列表
*/
Observable<CollectResponse> uploadMedicalRecordList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadMedicalRecordList(@Body RequestBody body);
/**
* 获取-免疫记录-列表
......@@ -162,7 +162,7 @@ public interface HttpDataSource {
/**
* 上传-免疫记录-列表
*/
Observable<CollectResponse> uploadImmuneBatchList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadImmuneBatchList(@Body RequestBody body);
/**
* 获取-免疫记录-子表-列表
......@@ -178,5 +178,10 @@ public interface HttpDataSource {
/**
* 上传-免疫记录-子表-列表
*/
Observable<CollectResponse> uploadImmuneBatchDetailList(@Body RequestBody body);
Observable<ListResponse<Long>> uploadImmuneBatchDetailList(@Body RequestBody body);
/**
* 上传-错误记录
*/
Observable<CollectResponse> uploadErrorData(@Body RequestBody body);
}
......@@ -95,7 +95,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadPerformanceList(RequestBody body) {
public Observable<ListResponse<Long>> uploadPerformanceList(RequestBody body) {
return apiService.uploadPerformanceList(body);
}
......@@ -110,7 +110,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadBreedingRecordList(RequestBody body) {
public Observable<ListResponse<Long>> uploadBreedingRecordList(RequestBody body) {
return apiService.uploadBreedingRecordList(body);
}
......@@ -125,7 +125,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadBreedingRecordDetailList(RequestBody body) {
public Observable<ListResponse<Long>> uploadBreedingRecordDetailList(RequestBody body) {
return apiService.uploadBreedingRecordDetailList(body);
}
......@@ -140,7 +140,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadWeightManList(RequestBody body) {
public Observable<ListResponse<Long>> uploadWeightManList(RequestBody body) {
return apiService.uploadWeightManList(body);
}
......@@ -155,7 +155,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadMedicalRecordList(RequestBody body) {
public Observable<ListResponse<Long>> uploadMedicalRecordList(RequestBody body) {
return apiService.uploadMedicalRecordList(body);
}
......@@ -170,7 +170,7 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadImmuneBatchList(RequestBody body) {
public Observable<ListResponse<Long>> uploadImmuneBatchList(RequestBody body) {
return apiService.uploadImmuneBatchList(body);
}
......@@ -185,7 +185,12 @@ public class HttpDataSourceImpl implements HttpDataSource {
}
@Override
public Observable<CollectResponse> uploadImmuneBatchDetailList(RequestBody body) {
public Observable<ListResponse<Long>> uploadImmuneBatchDetailList(RequestBody body) {
return apiService.uploadImmuneBatchDetailList(body);
}
@Override
public Observable<CollectResponse> uploadErrorData(RequestBody body) {
return apiService.uploadErrorData(body);
}
}
......@@ -69,7 +69,7 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
/**
* 配种成功
*/
private Integer pregnancy;
private String pregnancy;
/**
* 部门id
......@@ -123,11 +123,7 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
isReturn = in.readString();
backLoveDate = in.readString();
dueDate = in.readString();
if (in.readByte() == 0) {
pregnancy = null;
} else {
pregnancy = in.readInt();
}
pregnancy = in.readString();
if (in.readByte() == 0) {
deptId = null;
} else {
......@@ -142,10 +138,10 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
remark = in.readString();
}
@Generated(hash = 1374135081)
@Generated(hash = 933327768)
public BreedingRecordDetailEntity(Long unid, Long fUnid, String matingStyle, Long cattleresumeId,
String frozenSemenBatch, String matingDate, String isReturn, String backLoveDate, String dueDate,
Integer pregnancy, Long deptId, String uploadStatus, String searchValue, String createBy,
String pregnancy, Long deptId, String uploadStatus, String searchValue, String createBy,
String createTime, String updateBy, String updateTime, String remark) {
this.unid = unid;
this.fUnid = fUnid;
......@@ -193,12 +189,7 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
dest.writeString(isReturn);
dest.writeString(backLoveDate);
dest.writeString(dueDate);
if (pregnancy == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeInt(pregnancy);
}
dest.writeString(pregnancy);
if (deptId == null) {
dest.writeByte((byte) 0);
} else {
......@@ -303,11 +294,11 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
this.dueDate = dueDate;
}
public Integer getPregnancy() {
public String getPregnancy() {
return pregnancy;
}
public void setPregnancy(Integer pregnancy) {
public void setPregnancy(String pregnancy) {
this.pregnancy = pregnancy;
}
......@@ -407,4 +398,5 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
this.fUnid = fUnid;
}
}
......@@ -15,7 +15,6 @@ import org.greenrobot.greendao.annotation.Generated;
@Entity
public class DictEntity extends BaseObservable implements Parcelable {
private static final long serialVersionUID = 1L;
/** 字典编码 */
// @Id(autoincrement = false)
......@@ -251,8 +250,8 @@ public class DictEntity extends BaseObservable implements Parcelable {
@Override
public String toString() {
return "DictEntity{" +
"dictCode='" + dictCode + '\'' +
", dictSort='" + dictSort + '\'' +
"dictCode=" + dictCode +
", dictSort=" + dictSort +
", dictLabel='" + dictLabel + '\'' +
", dictValue='" + dictValue + '\'' +
", dictType='" + dictType + '\'' +
......
package com.phlx.anchorcollect.entity;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.databinding.BaseObservable;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
public class ErrorEntity extends BaseObservable implements Parcelable {
/**
* 主键
*/
private Long id;
/**
* 类型
*/
private String type;
/**
* 内容
*/
private String content;
/**
* 部门id
*/
private Long deptId;
/**
* 创建者
*/
private String createBy;
/**
* 创建时间 "yyyy-MM-dd HH:mm:ss"
*/
private String createTime;
public ErrorEntity() {
}
protected ErrorEntity(Parcel in) {
if (in.readByte() == 0) {
id = null;
} else {
id = in.readLong();
}
type = in.readString();
content = in.readString();
if (in.readByte() == 0) {
deptId = null;
} else {
deptId = in.readLong();
}
createBy = in.readString();
createTime = in.readString();
}
@Generated(hash = 573013660)
public ErrorEntity(Long id, String type, String content, Long deptId,
String createBy, String createTime) {
this.id = id;
this.type = type;
this.content = content;
this.deptId = deptId;
this.createBy = createBy;
this.createTime = createTime;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
if (id == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeLong(id);
}
dest.writeString(type);
dest.writeString(content);
if (deptId == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeLong(deptId);
}
dest.writeString(createBy);
dest.writeString(createTime);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<ErrorEntity> CREATOR = new Creator<ErrorEntity>() {
@Override
public ErrorEntity createFromParcel(Parcel in) {
return new ErrorEntity(in);
}
@Override
public ErrorEntity[] newArray(int size) {
return new ErrorEntity[size];
}
};
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "ErrorEntity{" +
"id=" + id +
", type='" + type + '\'' +
", content='" + content + '\'' +
", deptId=" + deptId +
", createBy='" + createBy + '\'' +
", createTime='" + createTime + '\'' +
'}';
}
}
......@@ -50,12 +50,12 @@ public class GenTableColumn extends BaseObservable implements Parcelable {
private String isRequired;
/**
* 是否为插入字段(1是)新增时是否显示字段
* 是否为插入字段(1是)新增时是否显示字段(暂时没有用到)
*/
private String isInsert;
/**
* 是否编辑字段(1是)修改时是否可编辑
* 是否编辑字段(1是)是否可以修改
*/
private String isEdit;
......@@ -65,7 +65,7 @@ public class GenTableColumn extends BaseObservable implements Parcelable {
private String isList;
/**
* 是否查询字段(1是)暂时保留
* 是否查询字段(1是)用来控制是否显示
*/
private String isQuery;
......
......@@ -29,7 +29,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
/**
* 年龄
*/
private Integer age;
private String age;
/**
* 测量日期
......@@ -166,11 +166,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
} else {
cattleresumeId = in.readLong();
}
if (in.readByte() == 0) {
age = null;
} else {
age = in.readInt();
}
age = in.readString();
measureDate = in.readString();
if (in.readByte() == 0) {
height = null;
......@@ -260,8 +256,8 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
remark = in.readString();
}
@Generated(hash = 750638439)
public PerformanceEntity(Long unid, Long cattleresumeId, Integer age, String measureDate,
@Generated(hash = 2014621603)
public PerformanceEntity(Long unid, Long cattleresumeId, String age, String measureDate,
Double height, Double length, Double bust, Double weight, Double chestWidth,
Double chestDeep, Double waistWidth, Double crossWidth, Double guanWei,
Double eyeMuscleArea, String grade, Double hairLength, Double hairFineness, Double shearing,
......@@ -314,12 +310,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
dest.writeByte((byte) 1);
dest.writeLong(cattleresumeId);
}
if (age == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeInt(age);
}
dest.writeString(age);
dest.writeString(measureDate);
if (height == null) {
dest.writeByte((byte) 0);
......@@ -457,11 +448,11 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
this.cattleresumeId = cattleresumeId;
}
public Integer getAge() {
public String getAge() {
return age;
}
public void setAge(Integer age) {
public void setAge(String age) {
this.age = age;
}
......
......@@ -303,4 +303,29 @@ public class UserEntity extends BaseObservable implements Parcelable {
public void setRoles(List<UserRoleEntity> roles) {
this.roles = roles;
}
@Override
public String toString() {
return "UserEntity{" +
"userId=" + userId +
", deptId=" + deptId +
", parentId=" + parentId +
", roleId=" + roleId +
", loginName='" + loginName + '\'' +
", userName='" + userName + '\'' +
", userType='" + userType + '\'' +
", email='" + email + '\'' +
", phonenumber='" + phonenumber + '\'' +
", sex='" + sex + '\'' +
", avatar='" + avatar + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", status='" + status + '\'' +
", delFlag='" + delFlag + '\'' +
", loginIp='" + loginIp + '\'' +
", loginDate='" + loginDate + '\'' +
", pwdUpdateDate='" + pwdUpdateDate + '\'' +
", roles=" + roles +
'}';
}
}
......@@ -189,14 +189,6 @@ public class WeightManEntity extends BaseObservable implements Parcelable {
this.weight = weight;
}
public String getwTime() {
return wTime;
}
public void setwTime(String wTime) {
this.wTime = wTime;
}
public String getUploadStatus() {
return uploadStatus;
}
......
......@@ -50,12 +50,14 @@ public class RetrofitClient {
private static final int CACHE_TIMEOUT = 10 * 1024 * 1024;
//服务端根路径
public static String baseUrl =
"39.101.170.186"//正式
// "serve.xlglmnmyzspt.org.cn"//正式
"39.101.170.186"//阿里云测试
// "192.168.8.135"//董
// "192.168.43.154"//张敏
;
public static String port =
"9000"//正式
// ""//正式
"9000"//阿里云测试
// "9000"//董
;
......
......@@ -331,14 +331,14 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......
......@@ -145,10 +145,10 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
viewModel.onNotifyAllEvent.observe(getActivity(), new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
viewModel.clearParamList();
viewModel.clearDetailParamList();
}
// if (aBoolean) {
// viewModel.clearParamList();
// viewModel.clearDetailParamList();
// }
for (GenTableColumn gtc : viewModel.uiList) {
gtc.notifyChange();
......@@ -157,8 +157,10 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
binding.rvCollect.getAdapter().notifyDataSetChanged();
binding.rvCollectDetail.getAdapter().notifyDataSetChanged();
if (aBoolean) {
updateRecordData();
}
}
});
viewModel.onShowDialogEvent.observe(getActivity(), new Observer<String>() {
......@@ -244,12 +246,34 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
inputType = InputType.TYPE_CLASS_TEXT;
}
int finalInputType = inputType;
//判断下限制的长度
int columnSize = 500;//不限制的设置成500
if (uiParamEntity.getColumnType().indexOf("(") > -1 && uiParamEntity.getColumnType().indexOf(")") > -1) {
if (uiParamEntity.getColumnType().indexOf(",") > -1) {//有“,”说明是Duoble
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(",")
)
);
} else {
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(")")
)
);
}
}
new MaterialDialog.Builder(getActivity())
.title(uiParamEntity.getColumnComment())
// .iconRes(R.drawable.ic_logo)
.content("请输入")
// .widgetColor(Color.BLUE)//输入框光标的颜色
.inputType(inputType)//可以输入的类型
.inputRangeRes(0, columnSize, android.R.color.black)
//前2个一个是hint一个是预输入的文字
.input("输入" + uiParamEntity.getColumnComment(), uiParamEntity.getShowName(), new MaterialDialog.InputCallback() {
......@@ -265,14 +289,14 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......@@ -408,7 +432,7 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
viewModel.initDetaileData(rowData);
viewModel.queryBreedingRecordDetail(rowData.getUnid());
}
}
}).show();
......
......@@ -231,12 +231,34 @@ public class ImmunRecordFragment extends BaseFragment<FragmentImmunRecordBinding
inputType = InputType.TYPE_CLASS_TEXT;
}
int finalInputType = inputType;
//判断下限制的长度
int columnSize = 500;//不限制的设置成500
if (uiParamEntity.getColumnType().indexOf("(") > -1 && uiParamEntity.getColumnType().indexOf(")") > -1) {
if (uiParamEntity.getColumnType().indexOf(",") > -1) {//有“,”说明是Duoble
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(",")
)
);
} else {
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(")")
)
);
}
}
new MaterialDialog.Builder(getActivity())
.title(uiParamEntity.getColumnComment())
// .iconRes(R.drawable.ic_logo)
.content("请输入")
// .widgetColor(Color.BLUE)//输入框光标的颜色
.inputType(inputType)//可以输入的类型
.inputRangeRes(0, columnSize, android.R.color.black)
//前2个一个是hint一个是预输入的文字
.input("输入" + uiParamEntity.getColumnComment(), uiParamEntity.getShowName(), new MaterialDialog.InputCallback() {
......@@ -252,14 +274,14 @@ public class ImmunRecordFragment extends BaseFragment<FragmentImmunRecordBinding
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......
......@@ -229,12 +229,34 @@ public class MedicalRecordFragment extends BaseFragment<FragmentMedicalRecordBin
inputType = InputType.TYPE_CLASS_TEXT;
}
int finalInputType = inputType;
//判断下限制的长度
int columnSize = 500;//不限制的设置成500
if (uiParamEntity.getColumnType().indexOf("(") > -1 && uiParamEntity.getColumnType().indexOf(")") > -1) {
if (uiParamEntity.getColumnType().indexOf(",") > -1) {//有“,”说明是Duoble
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(",")
)
);
} else {
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(")")
)
);
}
}
new MaterialDialog.Builder(getActivity())
.title(uiParamEntity.getColumnComment())
// .iconRes(R.drawable.ic_logo)
.content("请输入")
// .widgetColor(Color.BLUE)//输入框光标的颜色
.inputType(inputType)//可以输入的类型
.inputRangeRes(0, columnSize, android.R.color.black)
//前2个一个是hint一个是预输入的文字
.input("输入" + uiParamEntity.getColumnComment(), uiParamEntity.getShowName(), new MaterialDialog.InputCallback() {
......@@ -250,14 +272,14 @@ public class MedicalRecordFragment extends BaseFragment<FragmentMedicalRecordBin
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......
......@@ -2,6 +2,7 @@ package com.phlx.anchorcollect.ui.fragment;
import android.Manifest;
import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
......@@ -161,6 +162,7 @@ public class PerformanceFragment extends BaseFragment<FragmentPerformanceBinding
}).show();
}
});
}
......@@ -230,12 +232,34 @@ public class PerformanceFragment extends BaseFragment<FragmentPerformanceBinding
inputType = InputType.TYPE_CLASS_TEXT;
}
int finalInputType = inputType;
//判断下限制的长度
int columnSize = 500;//不限制的设置成500
if (uiParamEntity.getColumnType().indexOf("(") > -1 && uiParamEntity.getColumnType().indexOf(")") > -1) {
if (uiParamEntity.getColumnType().indexOf(",") > -1) {//有“,”说明是Duoble
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(",")
)
);
} else {
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(")")
)
);
}
}
new MaterialDialog.Builder(getActivity())
.title(uiParamEntity.getColumnComment())
// .iconRes(R.drawable.ic_logo)
.content("请输入")
// .widgetColor(Color.BLUE)//输入框光标的颜色
.inputType(inputType)//可以输入的类型
.inputRangeRes(0, columnSize, android.R.color.black)
//前2个一个是hint一个是预输入的文字
.input("输入" + uiParamEntity.getColumnComment(), uiParamEntity.getShowName(), new MaterialDialog.InputCallback() {
......@@ -251,14 +275,14 @@ public class PerformanceFragment extends BaseFragment<FragmentPerformanceBinding
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......
......@@ -40,6 +40,7 @@ import com.phlx.anchorcollect.data.VMFactory;
import com.phlx.anchorcollect.databinding.FragmentWeightmanBinding;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.entity.WeightManEntity;
import com.phlx.anchorcollect.event.EventTag;
import com.phlx.anchorcollect.ui.fragment.vm.WeightManVM;
import com.phlx.anchorcollect.ui.info.CattleActivity;
......@@ -123,7 +124,7 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
viewModel.addInventoryListener();
viewModel.initDataForUnid(Configs.tempUnid);
Configs.currentEvent = EventTag.EVENT_WEIGHT_DATA_WEIGHT;
}else{
} else {
viewModel.removeInventoryListener();
Configs.currentEvent = "";
App.getInstance().getLinkage().stopInventory();
......@@ -240,6 +241,37 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
binding.rvCollect.getAdapter().notifyDataSetChanged();
}
});
viewModel.onCoverRecordEvent.observe(this, new Observer<WeightManEntity>() {
@Override
public void onChanged(WeightManEntity weightManEntity) {
new MaterialDialog.Builder(getActivity()).title("系统提示").content(weightManEntity.getWTime() + "已有称重记录,是否覆盖").positiveText("确定").negativeText("取消").onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
viewModel.saveWeightMan(weightManEntity);
}
}
}).show();
}
});
viewModel.onShowDialogEvent.observe(getActivity(), new Observer<String>() {
@Override
public void onChanged(String s) {
new MaterialDialog.Builder(getActivity()).title("系统提示").content(s).positiveText("确定").onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
}
}
}).show();
}
});
}
......@@ -310,12 +342,34 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
}
int finalInputType = inputType;
//判断下限制的长度
int columnSize = 500;//不限制的设置成500
if (uiParamEntity.getColumnType().indexOf("(") > -1 && uiParamEntity.getColumnType().indexOf(")") > -1) {
if (uiParamEntity.getColumnType().indexOf(",") > -1) {//有“,”说明是Duoble
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(",")
)
);
} else {
columnSize = Integer.parseInt(
uiParamEntity.getColumnType().substring(
uiParamEntity.getColumnType().indexOf("(") + 1, uiParamEntity.getColumnType().indexOf(")")
)
);
}
}
new MaterialDialog.Builder(getActivity())
.title(uiParamEntity.getColumnComment())
// .iconRes(R.drawable.ic_logo)
.content("请输入")
// .widgetColor(Color.BLUE)//输入框光标的颜色
.inputType(inputType)//可以输入的类型
.inputRangeRes(0, columnSize, android.R.color.black)
//前2个一个是hint一个是预输入的文字
.input("输入" + uiParamEntity.getColumnComment(), uiParamEntity.getShowName(), new MaterialDialog.InputCallback() {
......@@ -332,14 +386,14 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
String inputStr = dialog.getInputEditText().getText().toString();
if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
ToastUtils.showShort("输入长度超长");
} else {
// if (finalInputType == InputType.TYPE_CLASS_TEXT && inputStr.length() > 10) {
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel.currentParamEntity.setShowName(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.setContent(dialog.getInputEditText().getText().toString());
viewModel.currentParamEntity.notifyChange();
}
// }
}
})
.show();
......
......@@ -26,10 +26,12 @@ import com.phlx.anchorcollect.data.Repository;
import com.phlx.anchorcollect.db.DbUtil;
import com.phlx.anchorcollect.db.gen.CattleResumeEntityDao;
import com.phlx.anchorcollect.db.gen.DictEntityDao;
import com.phlx.anchorcollect.db.gen.WeightManEntityDao;
import com.phlx.anchorcollect.db.interf.DbQueryCallBack;
import com.phlx.anchorcollect.entity.CattleResumeEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.entity.WeightManEntity;
import com.phlx.anchorcollect.event.EventMsg;
import com.phlx.anchorcollect.event.EventTag;
import com.phlx.anchorcollect.ui.fragment.list.CollectGridItem;
......@@ -43,7 +45,11 @@ import com.uhf.structures.OnInventoryListener;
import org.greenrobot.greendao.query.QueryBuilder;
import java.io.File;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import io.reactivex.disposables.Disposable;
......@@ -83,10 +89,19 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public ObservableField<String> rfid = new ObservableField<>("");
public ObservableField<String> weight = new ObservableField<>("----");
public ObservableField<Double> lastGainWeight = new ObservableField<>(0.0);//上次增重
public ObservableField<Double> adgGainWeight = new ObservableField<>(0.0);//日增重
public ObservableField<Double> totalGainWeight = new ObservableField<>(0.0);//总增重
public ObservableField<String> lastGainDate = new ObservableField<>("");//上次增重日期
public ObservableField<String> adgGainDate = new ObservableField<>("");//日增重日期
public ObservableField<String> totalGainDate = new ObservableField<>("");//总增重日期
private SoundPool soundPool;//盘点到标签时的提示音
private SparseIntArray musicId;
private SimpleDateFormat dateFormat;
public boolean isScan = false;//是否在扫描
private String rfidTag = "";//扫描到的标记
......@@ -143,6 +158,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
......@@ -215,6 +231,71 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
// }
}
//查询 上次称重 日增重 总体增重
private void queryGainWeight() {
lastGainWeight.set(0.0);
adgGainWeight.set(0.0);
totalGainWeight.set(0.0);
QueryBuilder<WeightManEntity> builder3 =
DbUtil.getInstance().getQueryBuilder(WeightManEntity.class)
.where(WeightManEntityDao.Properties.CattleresumeId.eq(Configs.tempUnid))
.orderDesc(WeightManEntityDao.Properties.WTime);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<WeightManEntity>() {
@Override
public void onSuccess(List<WeightManEntity> result) {
if (result != null && result.size() > 0) {
//总增重
if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) {
totalGainWeight.set(result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy());
lastGainDate.set(result.get(0).getWTime());
adgGainDate.set(result.get(0).getWTime());
totalGainDate.set(result.get(0).getWTime());
// Log.e("weight", "totalGainWeight:" + totalGainWeight.get());
}
if (result.size() >= 1) {
lastGainWeight.set(result.get(0).getWeight());
//// Log.e("weight", "lastGainWeight:" + lastGainWeight.get());
if (result.size() > 1) {//两条以上记录
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar frontCalendar = Calendar.getInstance();
Calendar laterCurcalendar = Calendar.getInstance();
try {
frontCalendar.setTime(dateFormat.parse(result.get(1).getWTime()));
laterCurcalendar.setTime(dateFormat.parse(result.get(0).getWTime()));
// Log.e("weight", "qian" + result.get(1).getWTime());
// Log.e("weight", "hou" + result.get(0).getWTime());
} catch (ParseException e) {
e.printStackTrace();
}
int days = 0; //定义一个变量来计算相隔天数
while (frontCalendar.before(laterCurcalendar)) {
frontCalendar.add(Calendar.DATE, 1);
days++;
}
double doubleADG = (result.get(0).getWeight() - result.get(1).getWeight()) / days;
adgGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doubleADG)));
// Log.e("weight", "days:" + days);
// Log.e("weight", "qian-weight:" + result.get(1).getWeight());
// Log.e("weight", "hou-weight:" + result.get(0).getWeight());
// Log.e("weight", "adgGainWeight:" + adgGainWeight.get());
}
}
}
}
@Override
public void onFailed() {
cn.wandersnail.commons.util.ToastUtils.showShort("查询称重记录失败!");
dismissDialog();
}
}).queryAsyncAll(WeightManEntity.class, builder3);
}
public void onItemClick(GenTableColumn entity) {
if (!"1".equals(entity.getIsEdit())) return;
......@@ -310,6 +391,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
+ "/anchorCiq" + result.get(0).getUnid() + ".jpg";
imgFile = new File(imgUrl);
Configs.tempCattleResume = result.get(0);
Configs.tempTag = result.get(0).getIndividualNo();
Configs.tempRfid = result.get(0).getRegistrationNo();
Configs.tempUnid = result.get(0).getUnid();
......@@ -317,6 +399,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
rfid.set(Configs.tempRfid);
remarkParamEntity.setShowName(result.get(0).getRemark());
queryGainWeight();
String[] filedName = EntityUtils.getFiledName(result.get(0));
for (String name : filedName) {
......@@ -437,6 +521,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
Configs.tempTag = "";
Configs.tempUnid = null;
Configs.tempRfid = "";
Configs.tempCattleResume = null;
tag.set("");
rfid.set("");
rfidTag = "";
......
......@@ -25,6 +25,7 @@ import com.phlx.anchorcollect.entity.BreedingRecordDetailEntity;
import com.phlx.anchorcollect.entity.BreedingRecordEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.entity.PerformanceEntity;
import com.phlx.anchorcollect.ui.fragment.list.CollectGridItem;
import com.phlx.anchorcollect.util.DateUtils;
import com.phlx.anchorcollect.util.EntityUtils;
......@@ -116,6 +117,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
......@@ -133,17 +135,19 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
public void onSuccess(List<BreedingRecordEntity> result) {
clearDetailParamList();
detailList = new ArrayList<>();
if (result != null && result.size() > 0) {
initData(result.get(0));
} else {
initData(null);
onNotifyAllEvent.setValue(true);
onNotifyAllEvent.setValue(false);
}
}
@Override
public void onFailed() {
onNotifyAllEvent.setValue(true);
clearDetailParamList();
onNotifyAllEvent.setValue(false);
ToastUtils.showShort("配种记录主表-数据库查询失败");
}
}).queryAsyncAll(BreedingRecordEntity.class, builder);
......@@ -202,6 +206,74 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
}
}
//详情列表点击查询
public void queryBreedingRecordDetail(Long clikeUnid) {
QueryBuilder<BreedingRecordDetailEntity> builder = DbUtil.getInstance().getQueryBuilder(BreedingRecordDetailEntity.class)
.where(BreedingRecordDetailEntityDao.Properties.Unid.eq(clikeUnid));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<BreedingRecordDetailEntity>() {
@Override
public void onSuccess(List<BreedingRecordDetailEntity> result) {
if (result != null && result.size() > 0)
initDetaileData(result.get(0));
}
@Override
public void onFailed() {
clearDetailParamList();
onNotifyAllEvent.setValue(false);
ToastUtils.showShort("配种记录子表-数据库查询失败");
}
}).queryAsyncAll(BreedingRecordDetailEntity.class, builder);
}
//初始化子表
public void initDetaileData(BreedingRecordDetailEntity brdEntity) {
tempDetailEntity = brdEntity;
if (brdEntity != null) {
remarkParamEntity.setShowName(brdEntity.getRemark());
remarkParamEntity.setContent(brdEntity.getRemark());
String[] filedName = EntityUtils.getFiledName(brdEntity);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
if (name.equals(gtc.getJavaField())) {
try {
Object fieldValueByName = EntityUtils.getFieldValueByName(name, brdEntity);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("fieldValue:", "key:" + name + " | value:" + value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
if (!StringUtils.isEmpty(gtc.getDictType())) {
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.where(DictEntityDao.Properties.DictType.eq(gtc.getDictType())
, DictEntityDao.Properties.DictValue.eq(value));
List<DictEntity> dictEntities = DbUtil.getInstance().queryAll(DictEntity.class, builder);
if (dictEntities != null && dictEntities.size() > 0) {
showName = dictEntities.get(0).getDictLabel();
}
}
gtc.setShowName(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
onNotifyAllEvent.setValue(false);
}
}
//初始化详情列表
private void initDetailList(BreedingRecordEntity breedingRecordEntity) {
......@@ -216,7 +288,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
detailList = result;
}
onNotifyAllEvent.setValue(false);
onNotifyAllEvent.setValue(true);
ToastUtils.showShort("查询-配种记录子表-成功!");
}
......@@ -228,33 +300,28 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
}).queryAsyncAll(BreedingRecordDetailEntity.class, builder);
}
//回显列表的数据
public List<BreedingRecordDetailEntity> getDetail() {
return detailList;
}
public void initDetaileData(BreedingRecordDetailEntity brdEntity) {
List<BreedingRecordDetailEntity> resultList = new ArrayList<>();
if (brdEntity != null) {
// onNotifyAllEvent.setValue(true);
// } else {
if (detailList == null) {
return resultList;
}
//拿到unid 创建人 创建时间 部门id
tempDetailEntity.setUnid(brdEntity.getUnid());
tempDetailEntity.setCreateBy(brdEntity.getCreateBy());
tempDetailEntity.setCreateTime(brdEntity.getCreateTime());
tempDetailEntity.setDeptId(brdEntity.getDeptId());
tempDetailEntity.setCattleresumeId(brdEntity.getCattleresumeId());
for (BreedingRecordDetailEntity pe : detailList) {
String[] filedName = EntityUtils.getFiledName(brdEntity);
String[] filedName = EntityUtils.getFiledName(pe);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
if (name.equals(gtc.getJavaField())) {
try {
Object fieldValueByName = EntityUtils.getFieldValueByName(name, brdEntity);
// Log.e("key:", name);
Object fieldValueByName = EntityUtils.getFieldValueByName(name, pe);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("fieldValue:", "key:" + name + " | value:" + value);
// Log.e("value:", value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
......@@ -269,21 +336,47 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
}
}
gtc.setShowName(showName);
gtc.setContent(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
onNotifyAllEvent.setValue(false);
}
//再把格式bean里的数据转换为数据bean
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
Long unidTemp = pe.getUnid();
pe = gson.fromJson(jsonObject, BreedingRecordDetailEntity.class);
pe.setUnid(unidTemp);
resultList.add(pe);
}
clearDetailParamList();
return resultList;
}
public void onItemClick(GenTableColumn entity) {
if (Configs.tempUnid==null) {
if (Configs.tempUnid == null) {
ToastUtils.showShort("请扫描耳标或者输入耳标信息");
return;
}
......@@ -296,7 +389,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
public void click(int id) {
if (Configs.tempUnid==null) {
if (Configs.tempUnid == null) {
ToastUtils.showShort("请扫描耳标或者输入耳标信息");
return;
}
......@@ -319,6 +412,21 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
public BindingCommand onSaveClick = new BindingCommand(new BindingAction() {
@Override
public void call() {
//判断必填
for (GenTableColumn gtc : Configs.cattlematingMaster) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
saveBreedingRecord();
}
});
......@@ -328,6 +436,17 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.cattlematingMaster) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
......@@ -335,7 +454,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
BreedingRecordEntity breedingRecordEntity = gson.fromJson(jsonObject, BreedingRecordEntity.class);
if (tempEntity.getUnid() == null) {//新增
breedingRecordEntity.setUnid(IdUtil.createSnowflake(3, 1).nextId());
breedingRecordEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
breedingRecordEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
breedingRecordEntity.setCattleresumeId(Configs.tempUnid);
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
breedingRecordEntity.setCreateTime(dateFormat.format(new Date()));
......@@ -377,6 +496,17 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
......@@ -384,7 +514,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
BreedingRecordDetailEntity breedingRecordDetailEntity = gson.fromJson(jsonObject, BreedingRecordDetailEntity.class);
if (tempDetailEntity.getUnid() == null) {//新增
breedingRecordDetailEntity.setUnid(IdUtil.createSnowflake(3, 1).nextId());
breedingRecordDetailEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
breedingRecordDetailEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
breedingRecordDetailEntity.setCattleresumeId(Configs.tempUnid);
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
breedingRecordDetailEntity.setCreateTime(dateFormat.format(new Date()));
......@@ -401,6 +531,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
}
breedingRecordDetailEntity.setUploadStatus("0");
breedingRecordDetailEntity.setfUnid(tempDetailEntity.getfUnid());
breedingRecordDetailEntity.setRemark(remarkParamEntity.getContent());
detailUploadData = new ArrayList<>();
detailUploadData.add(breedingRecordDetailEntity);
......@@ -410,7 +541,7 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
public void onNotification(boolean result) {
dismissDialog();
if (result) {
clearDetailParamList();
// clearDetailParamList();
initDetailList(tempEntity);
} else {
ToastUtils.showShort("保存-配种记录子表-失败");
......
......@@ -47,6 +47,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
......@@ -115,12 +116,15 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
private void initData(ImmuneBatchEntity immuneBatchEntity) {
remarkParamEntity.setShowName(immuneBatchEntity.getRemark());
remarkParamEntity.setContent(immuneBatchEntity.getRemark());
String[] filedName = EntityUtils.getFiledName(immuneBatchEntity);
for (String name : filedName) {
......@@ -185,10 +189,10 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
public void onItemClick(GenTableColumn entity) {
if (Configs.tempUnid == null) {
ToastUtils.showShort("请扫描耳标或者输入耳标信息");
return;
}
// if (Configs.tempUnid == null) {
// ToastUtils.showShort("请扫描耳标或者输入耳标信息");
// return;
// }
if (!"1".equals(entity.getIsEdit()) && isModify) {
ToastUtils.showShort("此数据无法修改!!");
......@@ -221,6 +225,15 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
public BindingCommand onSaveClick = new BindingCommand(new BindingAction() {
@Override
public void call() {
//判断必填
for (GenTableColumn gtc : Configs.immunebatch) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
saveImmunRecord();
}
});
......@@ -229,6 +242,17 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.immunebatch) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
......@@ -245,12 +269,13 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
} else {//新增
uuid = IdUtil.createSnowflake(3, 1).nextId();
immuneBatchEntity.setUnid(uuid);
immuneBatchEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
immuneBatchEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
immuneBatchEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
immuneBatchEntity.setCreateTime(dateFormat.format(new Date()));
}
immuneBatchEntity.setUploadStatus("0");
immuneBatchEntity.setRemark(remarkParamEntity.getContent());
uploadData = new ArrayList<>();
detailUploadData = new ArrayList<>();
......@@ -263,18 +288,23 @@ public class ImmunRecordVM extends BaseViewModel<Repository> {
QueryBuilder<CattleResumeEntity> builder =
DbUtil.getInstance().getQueryBuilder(CattleResumeEntity.class)
.where(CattleResumeEntityDao.Properties.CircleNo.eq(circleNo));
.where(CattleResumeEntityDao.Properties.CircleNo.eq(circleNo)
, CattleResumeEntityDao.Properties.DeptId.eq(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)))
);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<CattleResumeEntity>() {
@Override
public void onSuccess(List<CattleResumeEntity> result) {
//查询圈舍内的牲畜
if (result != null && result.size() > 0) {
Snowflake snowflake = IdUtil.createSnowflake(3, 1);
for (CattleResumeEntity cre : result) {
ImmuneBatchDetailEntity immuneBatchDetailEntity = new ImmuneBatchDetailEntity();
immuneBatchDetailEntity.setUnid(IdUtil.createSnowflake(3, 1).nextId());
immuneBatchDetailEntity.setUnid(snowflake.nextId());
immuneBatchDetailEntity.setCattleresumeUnid(cre.getUnid());
immuneBatchDetailEntity.setImmunebatchUnid(immuneBatchEntity.getUnid());
immuneBatchDetailEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
immuneBatchDetailEntity.setUploadStatus("0");
detailUploadData.add(immuneBatchDetailEntity);
}
......
......@@ -105,12 +105,16 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
private void initData(MedicalRecordEntity medicalRecordEntity) {
remarkParamEntity.setShowName(medicalRecordEntity.getRemark());
remarkParamEntity.setContent(medicalRecordEntity.getRemark());
String[] filedName = EntityUtils.getFiledName(medicalRecordEntity);
for (String name : filedName) {
......@@ -175,7 +179,7 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
public void onItemClick(GenTableColumn entity) {
if (Configs.tempUnid==null) {
if (Configs.tempUnid == null) {
ToastUtils.showShort("请扫描耳标或者输入耳标信息");
return;
}
......@@ -193,7 +197,7 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
public void click(int id) {
if (Configs.tempUnid==null) {
if (Configs.tempUnid == null) {
ToastUtils.showShort("请扫描耳标或者输入耳标信息");
return;
}
......@@ -213,6 +217,15 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
public BindingCommand onSaveClick = new BindingCommand(new BindingAction() {
@Override
public void call() {
//判断必填
for (GenTableColumn gtc : Configs.medicalrecords) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
saveMedicalRecord();
}
});
......@@ -221,6 +234,17 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.medicalrecords) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
......@@ -232,7 +256,7 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
uuid = IdUtil.createSnowflake(3, 1).nextId();
medicalRecordEntity.setUnid(uuid);
medicalRecordEntity.setCattleresumeId(Configs.tempUnid);
medicalRecordEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
medicalRecordEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
medicalRecordEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
medicalRecordEntity.setCreateTime(dateFormat.format(new Date()));
......@@ -244,6 +268,7 @@ public class MedicalRecordVM extends BaseViewModel<Repository> {
//清除选中unid
Configs.resumeId = null;
}
medicalRecordEntity.setRemark(remarkParamEntity.getContent());
medicalRecordEntity.setUploadStatus("0");
uploadData = new ArrayList<>();
......
......@@ -27,6 +27,7 @@ import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.entity.PerformanceEntity;
import com.phlx.anchorcollect.ui.fragment.list.CollectGridItem;
import com.phlx.anchorcollect.util.EntityUtils;
import com.phlx.anchorcollect.util.StringUtil;
import org.greenrobot.greendao.query.QueryBuilder;
......@@ -106,12 +107,16 @@ public class PerformanceVM extends BaseViewModel<Repository> {
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
private void initData(PerformanceEntity performanceEntity) {
remarkParamEntity.setShowName(performanceEntity.getRemark());
remarkParamEntity.setContent(performanceEntity.getRemark());
String[] filedName = EntityUtils.getFiledName(performanceEntity);
for (String name : filedName) {
......@@ -214,6 +219,15 @@ public class PerformanceVM extends BaseViewModel<Repository> {
public BindingCommand onSaveClick = new BindingCommand(new BindingAction() {
@Override
public void call() {
//判断必填
for (GenTableColumn gtc : Configs.performance) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
savePerformance();
}
});
......@@ -222,6 +236,17 @@ public class PerformanceVM extends BaseViewModel<Repository> {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.performance) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
......@@ -233,7 +258,7 @@ public class PerformanceVM extends BaseViewModel<Repository> {
uuid = IdUtil.createSnowflake(3, 1).nextId();
performanceEntity.setUnid(uuid);
performanceEntity.setCattleresumeId(Configs.tempUnid);
performanceEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
performanceEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
performanceEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
performanceEntity.setCreateTime(dateFormat.format(new Date()));
......@@ -246,6 +271,7 @@ public class PerformanceVM extends BaseViewModel<Repository> {
//清除选中unid
Configs.resumeId = null;
}
performanceEntity.setRemark(remarkParamEntity.getContent());
performanceEntity.setUploadStatus("0");
uploadData = new ArrayList<>();
......
......@@ -27,6 +27,8 @@ import com.phlx.anchorcollect.data.Repository;
import com.phlx.anchorcollect.db.DbUtil;
import com.phlx.anchorcollect.db.gen.CattleResumeEntityDao;
import com.phlx.anchorcollect.db.gen.DictEntityDao;
import com.phlx.anchorcollect.db.gen.MedicalRecordEntityDao;
import com.phlx.anchorcollect.db.gen.WeightManEntityDao;
import com.phlx.anchorcollect.db.interf.DbIDUCallBack;
import com.phlx.anchorcollect.db.interf.DbQueryCallBack;
import com.phlx.anchorcollect.entity.CattleResumeEntity;
......@@ -45,8 +47,11 @@ import com.uhf.structures.OnInventoryListener;
import org.greenrobot.greendao.query.QueryBuilder;
import java.io.File;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......@@ -85,9 +90,20 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public SingleLiveEvent<Boolean> onTagClickEvent = new SingleLiveEvent<>();
public SingleLiveEvent<Boolean> onNotifyAllEvent = new SingleLiveEvent<>();//true是清空页面
public SingleLiveEvent<String> onShowDialogEvent = new SingleLiveEvent<>();//弹窗提示
public SingleLiveEvent<WeightManEntity> onCoverRecordEvent = new SingleLiveEvent<>();//查询是否覆盖称重记录
public ObservableField<String> tag = new ObservableField<>("");
public ObservableField<String> rfid = new ObservableField<>("");
public ObservableField<Double> weight = new ObservableField<>(125.6);
public ObservableField<Double> weight = new ObservableField<>(325.6);
public ObservableField<Double> lastGainWeight = new ObservableField<>(0.0);//上次增重
public ObservableField<Double> adgGainWeight = new ObservableField<>(0.0);//日增重
public ObservableField<Double> totalGainWeight = new ObservableField<>(0.0);//总增重
public ObservableField<String> lastGainDate = new ObservableField<>("");//上次增重日期
public ObservableField<String> adgGainDate = new ObservableField<>("");//日增重日期
public ObservableField<String> totalGainDate = new ObservableField<>("");//总增重日期
private SimpleDateFormat dateFormat;
......@@ -166,6 +182,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
remarkParamEntity.setColumnComment("备注");
remarkParamEntity.setHtmlType("input");
remarkParamEntity.setJavaType("String");
remarkParamEntity.setColumnType("varchar(500)");
remarkParamEntity.setIsEdit("1");
}
......@@ -239,6 +256,70 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
// }
}
//查询 上次称重 日增重 总体增重
private void queryGainWeight() {
lastGainWeight.set(0.0);
adgGainWeight.set(0.0);
totalGainWeight.set(0.0);
QueryBuilder<WeightManEntity> builder3 =
DbUtil.getInstance().getQueryBuilder(WeightManEntity.class)
.where(WeightManEntityDao.Properties.CattleresumeId.eq(Configs.tempUnid))
.orderDesc(WeightManEntityDao.Properties.WTime);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<WeightManEntity>() {
@Override
public void onSuccess(List<WeightManEntity> result) {
if (result != null && result.size() > 0) {
//总增重
if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) {
totalGainWeight.set(result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy());
lastGainDate.set(result.get(0).getWTime());
adgGainDate.set(result.get(0).getWTime());
totalGainDate.set(result.get(0).getWTime());
// Log.e("weight", "totalGainWeight:" + totalGainWeight.get());
}
if (result.size() >= 1) {
lastGainWeight.set(result.get(0).getWeight());
// Log.e("weight", "lastGainWeight:" + lastGainWeight.get());
if (result.size() > 1) {//两条以上记录
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar frontCalendar = Calendar.getInstance();
Calendar laterCurcalendar = Calendar.getInstance();
try {
frontCalendar.setTime(dateFormat.parse(result.get(1).getWTime()));
laterCurcalendar.setTime(dateFormat.parse(result.get(0).getWTime()));
// Log.e("weight", "qian" + result.get(1).getWTime());
// Log.e("weight", "hou" + result.get(0).getWTime());
} catch (ParseException e) {
e.printStackTrace();
}
int days = 0; //定义一个变量来计算相隔天数
while (frontCalendar.before(laterCurcalendar)) {
frontCalendar.add(Calendar.DATE, 1);
days++;
}
double doubleADG = (result.get(0).getWeight() - result.get(1).getWeight()) / days;
adgGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doubleADG)));
// Log.e("weight", "days:" + days);
// Log.e("weight", "qian-weight:" + result.get(1).getWeight());
// Log.e("weight", "hou-weight:" + result.get(0).getWeight());
// Log.e("weight", "adgGainWeight:" + adgGainWeight.get());
}
}
}
}
@Override
public void onFailed() {
cn.wandersnail.commons.util.ToastUtils.showShort("查询称重记录失败!");
dismissDialog();
}
}).queryAsyncAll(WeightManEntity.class, builder3);
}
public void onItemClick(GenTableColumn entity) {
......@@ -287,7 +368,79 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public BindingCommand onSaveClick = new BindingCommand(new BindingAction() {
@Override
public void call() {
saveWeightMan();
//判断必填
for (GenTableColumn gtc : Configs.weightMan) {
if ("1".equals(gtc.getIsRequired()) && StringUtils.isEmpty(gtc.getContent())) {
onShowDialogEvent.setValue("请完成" + gtc.getColumnComment() + "的录入");
return;
}
}
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.weightMan) {
//防止转json类型错误
if ("".equals(gtc.getContent())) {
switch (gtc.getJavaType()) {
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
WeightManEntity weightManEntity = gson.fromJson(jsonObject, WeightManEntity.class);
//先看当天是否有称重记录
QueryBuilder<WeightManEntity> builder3 =
DbUtil.getInstance().getQueryBuilder(WeightManEntity.class)
.where(WeightManEntityDao.Properties.CattleresumeId.eq(Configs.tempUnid)
, WeightManEntityDao.Properties.WTime.eq(weightManEntity.getWTime())
);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<WeightManEntity>() {
@Override
public void onSuccess(List<WeightManEntity> result) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (result != null && result.size() > 0) {//本日有过称重记录
WeightManEntity newWeightManEntity = result.get(0);
newWeightManEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
newWeightManEntity.setUpdateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
newWeightManEntity.setUpdateTime(dateFormat.format(new Date()));
newWeightManEntity.setUploadStatus("0");
newWeightManEntity.setWeight(weight.get());
newWeightManEntity.setRemark(remarkParamEntity.getContent());
onCoverRecordEvent.setValue(newWeightManEntity);
} else {
uuid = IdUtil.createSnowflake(3, 1).nextId();
weightManEntity.setUnid(uuid);
weightManEntity.setCattleresumeId(Configs.tempUnid);
weightManEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
weightManEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
weightManEntity.setCreateTime(dateFormat.format(new Date()));
weightManEntity.setUploadStatus("0");
weightManEntity.setWeight(weight.get());
weightManEntity.setRemark(remarkParamEntity.getContent());
saveWeightMan(weightManEntity);
}
}
@Override
public void onFailed() {
cn.wandersnail.commons.util.ToastUtils.showShort("查询称重记录失败!");
dismissDialog();
}
}).queryAsyncAll(WeightManEntity.class, builder3);
}
});
......@@ -312,12 +465,15 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
+ "/anchorCiq" + result.get(0).getUnid() + ".jpg";
imgFile = new File(imgUrl);
Configs.tempCattleResume = result.get(0);
Configs.tempTag = result.get(0).getIndividualNo();
Configs.tempRfid = result.get(0).getRegistrationNo();
Configs.tempUnid = result.get(0).getUnid();
tag.set(Configs.tempTag);
rfid.set(Configs.tempRfid);
queryGainWeight();//刷新一下增重数据
String[] filedName = EntityUtils.getFiledName(result.get(0));
for (String name : filedName) {
......@@ -367,26 +523,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
}).queryAsyncAll(CattleResumeEntity.class, builder);
}
private void saveWeightMan() {
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.weightMan) {
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
WeightManEntity weightManEntity = gson.fromJson(jsonObject, WeightManEntity.class);
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
uuid = IdUtil.createSnowflake(3, 1).nextId();
weightManEntity.setUnid(uuid);
weightManEntity.setCattleresumeId(Configs.tempUnid);
weightManEntity.setDeptId(SPUtils.getInstance().getLong(Configs.SP_DEPT_ID));
weightManEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
weightManEntity.setCreateTime(dateFormat.format(new Date()));
weightManEntity.setUploadStatus("0");
weightManEntity.setWeight(weight.get());
public void saveWeightMan(WeightManEntity weightManEntity) {
uploadData = new ArrayList<>();
uploadData.add(weightManEntity);
......@@ -396,8 +533,13 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public void onNotification(boolean result) {
dismissDialog();
if (result) {
clearParamList();
for (GenTableColumn gtc : uiList) {
gtc.setContent("");
gtc.setShowName("");
gtc.notifyChange();
}
queryGainWeight();//刷新一下增重数据
ToastUtils.showShort("保存称重记录成功");
} else {
ToastUtils.showShort("保存称重记录失败");
......@@ -480,6 +622,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
Configs.tempTag = "";
Configs.tempUnid = null;
Configs.tempRfid = "";
Configs.tempCattleResume = null;
tag.set("");
rfid.set("");
rfidTag = "";
......@@ -494,7 +637,6 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
remarkParamEntity.setContent("");
remarkParamEntity.setShowName("");
currentParamEntity = new GenTableColumn();
uiList.get(0).setShowName("");
for (GenTableColumn gtc : Configs.weightMan) {
gtc.setShowName("");
gtc.setContent("");
......
......@@ -5,30 +5,38 @@ import android.view.View;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.phlx.anchorcollect.BR;
import com.phlx.anchorcollect.Configs;
import com.phlx.anchorcollect.R;
import com.phlx.anchorcollect.data.Repository;
import com.phlx.anchorcollect.db.DbUtil;
import com.phlx.anchorcollect.db.gen.BreedingRecordEntityDao;
import com.phlx.anchorcollect.db.gen.DictEntityDao;
import com.phlx.anchorcollect.db.gen.ImmuneBatchDetailEntityDao;
import com.phlx.anchorcollect.db.gen.ImmuneBatchEntityDao;
import com.phlx.anchorcollect.db.gen.MedicalRecordEntityDao;
import com.phlx.anchorcollect.db.gen.PerformanceEntityDao;
import com.phlx.anchorcollect.db.interf.DbQueryCallBack;
import com.phlx.anchorcollect.entity.BreedingRecordEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.entity.ImmuneBatchDetailEntity;
import com.phlx.anchorcollect.entity.ImmuneBatchEntity;
import com.phlx.anchorcollect.entity.MedicalRecordEntity;
import com.phlx.anchorcollect.entity.PerformanceEntity;
import com.phlx.anchorcollect.ui.base.BackBarVM;
import com.phlx.anchorcollect.util.EntityUtils;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
import me.tatarka.bindingcollectionadapter2.ItemBinding;
......@@ -183,19 +191,308 @@ public class CattleVM extends BackBarVM<Repository> {
}
public List<PerformanceEntity> getPerformanceEntityList() {
return performanceEntityList;
List<PerformanceEntity> resultList = new ArrayList<>();
if (performanceEntityList == null) {
return resultList;
}
for (PerformanceEntity pe : performanceEntityList) {
String[] filedName = EntityUtils.getFiledName(pe);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.performance) {
if (name.equals(gtc.getJavaField())) {
try {
// Log.e("key:", name);
Object fieldValueByName = EntityUtils.getFieldValueByName(name, pe);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("value:", value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
if (!StringUtils.isEmpty(gtc.getDictType())) {
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.where(DictEntityDao.Properties.DictType.eq(gtc.getDictType())
, DictEntityDao.Properties.DictValue.eq(value));
List<DictEntity> dictEntities = DbUtil.getInstance().queryAll(DictEntity.class, builder);
if (dictEntities != null && dictEntities.size() > 0) {
showName = dictEntities.get(0).getDictLabel();
}
}
gtc.setShowName(showName);
gtc.setContent(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
//再把格式bean里的数据转换为数据bean
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.performance) {
//防止转json类型错误
if("".equals(gtc.getContent())){
switch (gtc.getJavaType()){
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
Long unidTemp =pe.getUnid();
pe = gson.fromJson(jsonObject, PerformanceEntity.class);
pe.setUnid(unidTemp);
resultList.add(pe);
}
// resultList.clear();
// Arrays.copyOf()
// System.arraycopy(performanceEntityList, 0, resultList, 0 , performanceEntityList.size());
return resultList;
}
public List<MedicalRecordEntity> getMedicalRecordEntityList() {
return medicalRecordEntityList;
List<MedicalRecordEntity> resultList = new ArrayList<>();
if (medicalRecordEntityList == null) {
return resultList;
}
for (MedicalRecordEntity pe : medicalRecordEntityList) {
String[] filedName = EntityUtils.getFiledName(pe);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.medicalrecords) {
if (name.equals(gtc.getJavaField())) {
try {
// Log.e("key:", name);
Object fieldValueByName = EntityUtils.getFieldValueByName(name, pe);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("value:", value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
if (!StringUtils.isEmpty(gtc.getDictType())) {
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.where(DictEntityDao.Properties.DictType.eq(gtc.getDictType())
, DictEntityDao.Properties.DictValue.eq(value));
List<DictEntity> dictEntities = DbUtil.getInstance().queryAll(DictEntity.class, builder);
if (dictEntities != null && dictEntities.size() > 0) {
showName = dictEntities.get(0).getDictLabel();
}
}
gtc.setShowName(showName);
gtc.setContent(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
//再把格式bean里的数据转换为数据bean
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.medicalrecords) {
//防止转json类型错误
if("".equals(gtc.getContent())){
switch (gtc.getJavaType()){
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
Long unidTemp =pe.getUnid();
pe = gson.fromJson(jsonObject, MedicalRecordEntity.class);
pe.setUnid(unidTemp);
resultList.add(pe);
}
// resultList.clear();
// Arrays.copyOf()
// System.arraycopy(performanceEntityList, 0, resultList, 0 , performanceEntityList.size());
return resultList;
}
public List<ImmuneBatchEntity> getImmuneBatchEntityList() {
return immuneBatchEntityList;
List<ImmuneBatchEntity> resultList = new ArrayList<>();
if (immuneBatchEntityList == null) {
return resultList;
}
for (ImmuneBatchEntity pe : immuneBatchEntityList) {
String[] filedName = EntityUtils.getFiledName(pe);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.immunebatch) {
if (name.equals(gtc.getJavaField())) {
try {
// Log.e("key:", name);
Object fieldValueByName = EntityUtils.getFieldValueByName(name, pe);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("value:", value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
if (!StringUtils.isEmpty(gtc.getDictType())) {
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.where(DictEntityDao.Properties.DictType.eq(gtc.getDictType())
, DictEntityDao.Properties.DictValue.eq(value));
List<DictEntity> dictEntities = DbUtil.getInstance().queryAll(DictEntity.class, builder);
if (dictEntities != null && dictEntities.size() > 0) {
showName = dictEntities.get(0).getDictLabel();
}
}
gtc.setShowName(showName);
gtc.setContent(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
//再把格式bean里的数据转换为数据bean
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.immunebatch) {
//防止转json类型错误
if("".equals(gtc.getContent())){
switch (gtc.getJavaType()){
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
Long unidTemp =pe.getUnid();
pe = gson.fromJson(jsonObject, ImmuneBatchEntity.class);
pe.setUnid(unidTemp);
resultList.add(pe);
}
// resultList.clear();
// Arrays.copyOf()
// System.arraycopy(performanceEntityList, 0, resultList, 0 , performanceEntityList.size());
return resultList;
}
public List<BreedingRecordEntity> getBreedingRecordEntityList() {
return breedingRecordEntityList;
List<BreedingRecordEntity> resultList = new ArrayList<>();
if (breedingRecordEntityList == null) {
return resultList;
}
for (BreedingRecordEntity pe : breedingRecordEntityList) {
String[] filedName = EntityUtils.getFiledName(pe);
for (String name : filedName) {
for (GenTableColumn gtc : Configs.cattlematingMaster) {
if (name.equals(gtc.getJavaField())) {
try {
// Log.e("key:", name);
Object fieldValueByName = EntityUtils.getFieldValueByName(name, pe);
String value = fieldValueByName == null ? "" : fieldValueByName.toString();
// Log.e("value:", value);
gtc.setContent(value);
String showName = value;
// 如果是选择的,查字典项
if (!StringUtils.isEmpty(gtc.getDictType())) {
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.where(DictEntityDao.Properties.DictType.eq(gtc.getDictType())
, DictEntityDao.Properties.DictValue.eq(value));
List<DictEntity> dictEntities = DbUtil.getInstance().queryAll(DictEntity.class, builder);
if (dictEntities != null && dictEntities.size() > 0) {
showName = dictEntities.get(0).getDictLabel();
}
}
gtc.setShowName(showName);
gtc.setContent(showName);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
//再把格式bean里的数据转换为数据bean
JsonObject jsonObject = new JsonObject();
for (GenTableColumn gtc : Configs.cattlematingMaster) {
//防止转json类型错误
if("".equals(gtc.getContent())){
switch (gtc.getJavaType()){
case "Long":
case "Double":
case "Integer":
case "BigDecimal":
gtc.setContent("0");
break;
}
}
jsonObject.addProperty(gtc.getJavaField(), gtc.getContent());
}
Gson gson = new Gson();
Long unidTemp =pe.getUnid();
pe = gson.fromJson(jsonObject, BreedingRecordEntity.class);
pe.setUnid(unidTemp);
resultList.add(pe);
}
// resultList.clear();
// Arrays.copyOf()
// System.arraycopy(performanceEntityList, 0, resultList, 0 , performanceEntityList.size());
return resultList;
}
// private void refreshCard() {
......
......@@ -32,6 +32,8 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
private String path ;
private int loginType;//登录后是否跳转,0跳转main 1不跳转
@Override
public int initContentView(Bundle savedInstanceState) {
return R.layout.activity_login;
......@@ -45,6 +47,8 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
@Override
public void initParam() {
super.initParam();
loginType = getIntent().getIntExtra("loginType", 0);
}
@Override
......@@ -57,6 +61,8 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
public void initData() {
super.initData();
viewModel.loginType = loginType;
// downloadUrl = "http://"
// + SPUtils.getInstance().getString(Configs.SP_APP_IP, RetrofitClient.baseUrl)
// + ":" +
......
......@@ -2,6 +2,7 @@ package com.phlx.anchorcollect.ui.login;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
......@@ -60,6 +61,9 @@ public class LoginVM extends BaseViewModel<Repository> {
public SingleLiveEvent<Integer> appUpdateEvent = new SingleLiveEvent<>();
public int loginType;//登录后是否跳转, 0跳转main 1不跳转
public LoginVM(@NonNull Application application, Repository model) {
super(application, model);
......@@ -159,7 +163,9 @@ public class LoginVM extends BaseViewModel<Repository> {
// SPUtils.getInstance().put(Configs.SP_FREQUENCY, response.getData().getUser().getFrequencyConfig());
}
VMFactory.getInstance(getApplication()).refreshRepository();
startActivity(SplashActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("loginType", loginType);
startActivity(SplashActivity.class, bundle);
finish();
} else {
ToastUtils.showShort("服务器:" + response.getMsg());
......
......@@ -86,12 +86,6 @@ import okhttp3.RequestBody;
public class SettingVM extends BaseViewModel<Repository> implements DiscoveryListener {
private SoundPool soundPool;//盘点到标签时的提示音
private SparseIntArray musicId;
private static Map<String, Integer> map;//去重
private ArrayList<BluetoothEntity> mList;
private boolean isInventory = false;
//给RecyclerView添加ObservableList
public ObservableList<BLEItem> observableList = new ObservableArrayList<>();
......@@ -224,14 +218,7 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
public BindingCommand OnConnectionClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
mList.clear();
map.clear();
observableList.clear();
if (isInventory)
App.getInstance().getLinkage().stopInventory();
else
App.getInstance().getLinkage().startInventory(1, 0);
isInventory = !isInventory;
}
});
......
package com.phlx.anchorcollect.ui.setting;
import android.app.Application;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
......@@ -22,6 +23,7 @@ import com.phlx.anchorcollect.db.interf.DbQueryCallBack;
import com.phlx.anchorcollect.entity.BreedingRecordDetailEntity;
import com.phlx.anchorcollect.entity.BreedingRecordEntity;
import com.phlx.anchorcollect.entity.CattleResumeEntity;
import com.phlx.anchorcollect.entity.ErrorEntity;
import com.phlx.anchorcollect.entity.ImmuneBatchDetailEntity;
import com.phlx.anchorcollect.entity.ImmuneBatchEntity;
import com.phlx.anchorcollect.entity.MedicalRecordEntity;
......@@ -29,6 +31,7 @@ import com.phlx.anchorcollect.entity.PerformanceEntity;
import com.phlx.anchorcollect.entity.WeightManEntity;
import com.phlx.anchorcollect.params.CollectResponse;
import com.phlx.anchorcollect.params.ListResponse;
import com.phlx.anchorcollect.ui.login.LoginActivity;
import com.phlx.anchorcollect.util.BaseImageUtils;
import org.greenrobot.greendao.query.QueryBuilder;
......@@ -56,6 +59,10 @@ import okhttp3.RequestBody;
public class SyncVM extends BaseViewModel<Repository> {
final private static String UPLOAD_STATUS_HAVE_NOT = "0";
final private static String UPLOAD_STATUS_HAVE = "1";
final private static String UPLOAD_STATUS_ERROR = "2";
//错误提示
public SingleLiveEvent<String> errorEvent = new SingleLiveEvent<>();
......@@ -69,6 +76,15 @@ public class SyncVM extends BaseViewModel<Repository> {
public ObservableField<String> cattlematingMasterCount = new ObservableField<>("0");
public ObservableField<String> cattlematingDetaillCount = new ObservableField<>("0");
public ObservableField<String> cattleresumeErrorCount = new ObservableField<>("0");
public ObservableField<String> performanceErrorCount = new ObservableField<>("0");
public ObservableField<String> weightManErrorCount = new ObservableField<>("0");
public ObservableField<String> medicalrecordsErrorCount = new ObservableField<>("0");
public ObservableField<String> immunebatchErrorCount = new ObservableField<>("0");
public ObservableField<String> immunebatchDetailErrorCount = new ObservableField<>("0");
public ObservableField<String> cattlematingMasterErrorCount = new ObservableField<>("0");
public ObservableField<String> cattlematingDetaillErrorCount = new ObservableField<>("0");
public ObservableField<String> cattleresumeDate = new ObservableField<>("");
public ObservableField<String> performanceDate = new ObservableField<>("");
public ObservableField<String> weightManDate = new ObservableField<>("");
......@@ -156,6 +172,15 @@ public class SyncVM extends BaseViewModel<Repository> {
queryBreedingRecordDetail();
}
});
public BindingCommand OnErrorDataUploadClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
showDialog("正在上报错误数据...");
uploadErrorData();
}
});
/**===========================================基础数据================================================= */
/**
......@@ -216,10 +241,16 @@ public class SyncVM extends BaseViewModel<Repository> {
}).insertAsyncBatch(CattleResumeEntity.class, response.getData());
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步基础数据成功!");
queryCattleResumeUploadCount(false);
queryCattleResumeUploadCount(false, "0");
dismissDialog();
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
errorEvent.setValue("服务器 :" + response.getMsg());
......@@ -252,6 +283,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestBaseArchivesSync", response.toString());
if (response.getCode() == 0) {
requestBaseArchives();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -315,9 +352,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
ToastUtils.showShort("性能测定数据同步完成!");
queryPerformanceUploadCount(false);
queryPerformanceUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
dismissDialog();
......@@ -352,6 +395,12 @@ public class SyncVM extends BaseViewModel<Repository> {
if (response.getCode() == 0) {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步性能测定数据成功!");
requestSignMeasure();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
dismissDialog();
......@@ -403,14 +452,25 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在同步性能测定数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
dismissDialog();
KLog.e("requestSignMeasureSync", response.toString());
//先都设置成错误数据
for (PerformanceEntity pe : performanceEntities) {
pe.setUploadStatus("1");
pe.setUploadStatus("2");
}
if (response.getCode() == 0) {
if (response.getData() != null && response.getData().size() > 0) {
for (PerformanceEntity pe : performanceEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
......@@ -423,6 +483,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(PerformanceEntity.class, performanceEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
requestSignMeasure();
......@@ -487,9 +553,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步配种主表数据成功!");
queryBreedingRecordUploadCount(false);
queryBreedingRecordUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
......@@ -522,6 +594,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("downloadBreedingRecordListSync", response.toString());
if (response.getCode() == 0) {
requestBreedingRecord();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -573,12 +651,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-配种记录主表-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadBreedingRecord", response.toString());
for (BreedingRecordEntity pe : breedingRecordEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (BreedingRecordEntity pe : breedingRecordEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -591,6 +679,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(BreedingRecordEntity.class, breedingRecordEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -656,9 +750,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步配种记录子表数据成功!");
queryBreedingRecordDetailUploadCount(false);
queryBreedingRecordDetailUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
......@@ -691,6 +791,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestBreedingRecordDetailSync", response.toString());
if (response.getCode() == 0) {
queryBreedingRecordDetail();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -742,12 +848,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-配种记录子表-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadBreedingRecordDetail", response.toString());
for (BreedingRecordDetailEntity pe : breedingRecordDetailEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (BreedingRecordDetailEntity pe : breedingRecordDetailEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -760,6 +876,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(BreedingRecordDetailEntity.class, breedingRecordDetailEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -826,9 +948,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步称重管理数据成功!");
dismissDialog();
queryWeightManUploadCount(false);
queryWeightManUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
......@@ -861,6 +989,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestWeightManSync", response.toString());
if (response.getCode() == 0) {
queryWeightMan();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -912,12 +1046,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-称重管理-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadWeightMan", response.toString());
for (WeightManEntity pe : weightManEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (WeightManEntity pe : weightManEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -931,6 +1075,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(WeightManEntity.class, weightManEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
requestWeightMan();
......@@ -996,9 +1146,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步诊疗记录数据成功!");
queryMedicalRecordUploadCount(false);
queryMedicalRecordUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
......@@ -1031,6 +1187,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestMedicalRecordSync", response.toString());
if (response.getCode() == 0) {
queryMedicalRecord();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1082,12 +1244,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-诊疗记录-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadMedicalRecord", response.toString());
for (MedicalRecordEntity pe : medicalRecordEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (MedicalRecordEntity pe : medicalRecordEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -1101,6 +1273,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(MedicalRecordEntity.class, medicalRecordEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1167,9 +1345,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步免疫记录-主表数据成功!");
queryImmuneBatchUploadCount(false);
queryImmuneBatchUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
errorEvent.setValue("服务器 :" + response.getMsg());
......@@ -1204,6 +1388,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestImmuneBatchSync", response.toString());
if (response.getCode() == 0) {
queryImmuneBatch();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1255,12 +1445,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-免疫记录-主表-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadImmuneBatch", response.toString());
for (ImmuneBatchEntity pe : immuneBatchEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (ImmuneBatchEntity pe : immuneBatchEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -1274,6 +1474,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(ImmuneBatchEntity.class, immuneBatchEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1340,9 +1546,15 @@ public class SyncVM extends BaseViewModel<Repository> {
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("同步免疫记录-子表数据成功!");
queryImmuneBatchDetailUploadCount(false);
queryImmuneBatchDetailUploadCount(false, "0");
}
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
......@@ -1375,6 +1587,12 @@ public class SyncVM extends BaseViewModel<Repository> {
KLog.e("requestImmuneBatchDetailSync", response.toString());
if (response.getCode() == 0) {
queryImmuneBatchDetail();
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1426,12 +1644,22 @@ public class SyncVM extends BaseViewModel<Repository> {
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在同步-免疫记录-子表-数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
.subscribe((Consumer<ListResponse<Long>>) response -> {
if (response.getCode() == 0) {
KLog.e("uploadImmuneBatchDetail", response.toString());
for (ImmuneBatchDetailEntity pe : immuneBatchEntities) {
pe.setUploadStatus("2");
}
if (response.getData() != null && response.getData().size() > 0) {
for (ImmuneBatchDetailEntity pe : immuneBatchEntities) {
for (Long ids : response.getData()) {
if (pe.getUnid().equals(ids)) {
pe.setUploadStatus("1");
break;
}
}
}
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
......@@ -1445,6 +1673,12 @@ public class SyncVM extends BaseViewModel<Repository> {
}
}
}).updateAsyncBatch(ImmuneBatchDetailEntity.class, immuneBatchEntities);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
......@@ -1460,7 +1694,7 @@ public class SyncVM extends BaseViewModel<Repository> {
//刷新待上传数量
private void queryUploadCount(boolean isContinue) {
queryCattleResumeUploadCount(isContinue);
queryCattleResumeUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
}
//刷新数据更新时间
......@@ -1479,18 +1713,29 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 基础数据
*/
private void queryCattleResumeUploadCount(boolean isContinue) {
private void queryCattleResumeUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<CattleResumeEntity> builder0 =
DbUtil.getInstance().getQueryBuilder(CattleResumeEntity.class)
.where(CattleResumeEntityDao.Properties.UploadStatus.eq("0"));
.where(CattleResumeEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<CattleResumeEntity>() {
@Override
public void onSuccess(List<CattleResumeEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
cattleresumeCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
cattleresumeErrorCount.set(result.size() + "");
break;
}
if (isContinue)
queryPerformanceUploadCount(isContinue);
}
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryCattleResumeUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryPerformanceUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
}
@Override
......@@ -1505,19 +1750,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 性能测定
*/
private void queryPerformanceUploadCount(boolean isContinue) {
private void queryPerformanceUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<PerformanceEntity> builder1 =
DbUtil.getInstance().getQueryBuilder(PerformanceEntity.class)
.where(PerformanceEntityDao.Properties.UploadStatus.eq("0"));
.where(PerformanceEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<PerformanceEntity>() {
@Override
public void onSuccess(List<PerformanceEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
performanceCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
performanceErrorCount.set(result.size() + "");
break;
}
}
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryPerformanceUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryWeightManUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
if (isContinue)
queryWeightManUploadCount(isContinue);
}
@Override
......@@ -1532,19 +1788,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 称重管理
*/
private void queryWeightManUploadCount(boolean isContinue) {
private void queryWeightManUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<WeightManEntity> builder2 =
DbUtil.getInstance().getQueryBuilder(WeightManEntity.class)
.where(WeightManEntityDao.Properties.UploadStatus.eq("0"));
.where(WeightManEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<WeightManEntity>() {
@Override
public void onSuccess(List<WeightManEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
weightManCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
weightManErrorCount.set(result.size() + "");
break;
}
}
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryWeightManUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryMedicalRecordUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
if (isContinue)
queryMedicalRecordUploadCount(isContinue);
}
@Override
......@@ -1559,19 +1826,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 诊疗记录
*/
private void queryMedicalRecordUploadCount(boolean isContinue) {
private void queryMedicalRecordUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<MedicalRecordEntity> builder3 =
DbUtil.getInstance().getQueryBuilder(MedicalRecordEntity.class)
.where(MedicalRecordEntityDao.Properties.UploadStatus.eq("0"));
.where(MedicalRecordEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<MedicalRecordEntity>() {
@Override
public void onSuccess(List<MedicalRecordEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
medicalrecordsCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
medicalrecordsErrorCount.set(result.size() + "");
break;
}
}
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryMedicalRecordUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryImmuneBatchUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
if (isContinue)
queryImmuneBatchUploadCount(isContinue);
}
@Override
......@@ -1586,19 +1864,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 免疫记录-主表
*/
private void queryImmuneBatchUploadCount(boolean isContinue) {
private void queryImmuneBatchUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<ImmuneBatchEntity> builder4 =
DbUtil.getInstance().getQueryBuilder(ImmuneBatchEntity.class)
.where(ImmuneBatchEntityDao.Properties.UploadStatus.eq("0"));
.where(ImmuneBatchEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<ImmuneBatchEntity>() {
@Override
public void onSuccess(List<ImmuneBatchEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
immunebatchCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
immunebatchErrorCount.set(result.size() + "");
break;
}
}
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryImmuneBatchUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryImmuneBatchDetailUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
if (isContinue)
queryImmuneBatchDetailUploadCount(isContinue);
}
@Override
......@@ -1613,19 +1902,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 免疫记录-子表
*/
private void queryImmuneBatchDetailUploadCount(boolean isContinue) {
private void queryImmuneBatchDetailUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<ImmuneBatchDetailEntity> builder5 =
DbUtil.getInstance().getQueryBuilder(ImmuneBatchDetailEntity.class)
.where(ImmuneBatchDetailEntityDao.Properties.UploadStatus.eq("0"));
.where(ImmuneBatchDetailEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<ImmuneBatchDetailEntity>() {
@Override
public void onSuccess(List<ImmuneBatchDetailEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
immunebatchDetailCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
immunebatchDetailErrorCount.set(result.size() + "");
break;
}
}
if (isContinue)
queryBreedingRecordUploadCount(isContinue);
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryImmuneBatchDetailUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryBreedingRecordUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
}
@Override
......@@ -1640,19 +1940,30 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 配种记录-主表
*/
private void queryBreedingRecordUploadCount(boolean isContinue) {
private void queryBreedingRecordUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<BreedingRecordEntity> builder6 =
DbUtil.getInstance().getQueryBuilder(BreedingRecordEntity.class)
.where(BreedingRecordEntityDao.Properties.UploadStatus.eq("0"));
.where(BreedingRecordEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<BreedingRecordEntity>() {
@Override
public void onSuccess(List<BreedingRecordEntity> result) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
cattlematingMasterCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
cattlematingMasterErrorCount.set(result.size() + "");
break;
}
}
if (isContinue)
queryBreedingRecordDetailUploadCount(isContinue);
//如果是未上传就继续查错误数据,如果不是就看状态是否继续
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryBreedingRecordUploadCount(isContinue, UPLOAD_STATUS_ERROR);
} else if (isContinue)
queryBreedingRecordDetailUploadCount(isContinue, UPLOAD_STATUS_HAVE_NOT);
}
@Override
......@@ -1667,18 +1978,32 @@ public class SyncVM extends BaseViewModel<Repository> {
/**
* 配种记录-子表
*/
private void queryBreedingRecordDetailUploadCount(boolean isContinue) {
private void queryBreedingRecordDetailUploadCount(boolean isContinue, String uploadType) {
QueryBuilder<BreedingRecordDetailEntity> builder7 =
DbUtil.getInstance().getQueryBuilder(BreedingRecordDetailEntity.class)
.where(BreedingRecordDetailEntityDao.Properties.UploadStatus.eq("0"));
.where(BreedingRecordDetailEntityDao.Properties.UploadStatus.eq(uploadType));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<BreedingRecordDetailEntity>() {
@Override
public void onSuccess(List<BreedingRecordDetailEntity> result) {
if (result != null ) {
if (result != null) {
switch (uploadType) {
case UPLOAD_STATUS_HAVE_NOT:
cattlematingDetaillCount.set(result.size() + "");
break;
case UPLOAD_STATUS_ERROR:
cattlematingDetaillErrorCount.set(result.size() + "");
break;
}
}
//如果是未上传就继续查错误数据,如果不是就停止
if (UPLOAD_STATUS_HAVE_NOT.equals(uploadType)) {
queryBreedingRecordDetailUploadCount(isContinue, UPLOAD_STATUS_ERROR);
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询配种记录-子表数量失败!");
......@@ -1687,4 +2012,587 @@ public class SyncVM extends BaseViewModel<Repository> {
}).queryAsyncAll(BreedingRecordDetailEntity.class, builder7);
}
/**
* 错误数据上传
*/
private void uploadErrorData() {
uploadBaseArchivesError();
}
private void uploadBaseArchivesError() {
QueryBuilder<CattleResumeEntity> builder =
DbUtil.getInstance().getQueryBuilder(CattleResumeEntity.class)
.where(CattleResumeEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<CattleResumeEntity>() {
@Override
public void onSuccess(List<CattleResumeEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("cattle_resume_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadBaseArchivesError();
} else {
uploadPerformanceError();
}
}
}).deleteAsyncBatch(CattleResumeEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadPerformanceError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadPerformanceError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询基础数据错误数据失败!");
uploadPerformanceError();
}
}).queryAsyncAll(CattleResumeEntity.class, builder);
}
private void uploadPerformanceError() {
QueryBuilder<PerformanceEntity> builder =
DbUtil.getInstance().getQueryBuilder(PerformanceEntity.class)
.where(PerformanceEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<PerformanceEntity>() {
@Override
public void onSuccess(List<PerformanceEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("performance_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadPerformanceError();
} else {
uploadWeightManError();
}
}
}).deleteAsyncBatch(PerformanceEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadWeightManError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadWeightManError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询性能测定错误数据失败!");
uploadWeightManError();
}
}).queryAsyncAll(PerformanceEntity.class, builder);
}
private void uploadWeightManError() {
QueryBuilder<WeightManEntity> builder =
DbUtil.getInstance().getQueryBuilder(WeightManEntity.class)
.where(WeightManEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<WeightManEntity>() {
@Override
public void onSuccess(List<WeightManEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("weightman_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadWeightManError();
} else {
uploadMedicalRecordError();
}
}
}).deleteAsyncBatch(WeightManEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadMedicalRecordError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadMedicalRecordError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询称重错误数据失败!");
uploadMedicalRecordError();
}
}).queryAsyncAll(WeightManEntity.class, builder);
}
private void uploadMedicalRecordError() {
QueryBuilder<MedicalRecordEntity> builder =
DbUtil.getInstance().getQueryBuilder(MedicalRecordEntity.class)
.where(MedicalRecordEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<MedicalRecordEntity>() {
@Override
public void onSuccess(List<MedicalRecordEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("medical_record_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadMedicalRecordError();
} else {
uploadImmuneBatchError();
}
}
}).deleteAsyncBatch(MedicalRecordEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadImmuneBatchError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadImmuneBatchError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询诊疗记录错误数据失败!");
uploadImmuneBatchError();
}
}).queryAsyncAll(MedicalRecordEntity.class, builder);
}
private void uploadImmuneBatchError() {
QueryBuilder<ImmuneBatchEntity> builder =
DbUtil.getInstance().getQueryBuilder(ImmuneBatchEntity.class)
.where(ImmuneBatchEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<ImmuneBatchEntity>() {
@Override
public void onSuccess(List<ImmuneBatchEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("immune_batch_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadImmuneBatchError();
} else {
uploadImmuneBatchDetailError();
}
}
}).deleteAsyncBatch(ImmuneBatchEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadImmuneBatchDetailError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadImmuneBatchDetailError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询免疫记录错误数据失败!");
uploadImmuneBatchDetailError();
}
}).queryAsyncAll(ImmuneBatchEntity.class, builder);
}
private void uploadImmuneBatchDetailError() {
QueryBuilder<ImmuneBatchDetailEntity> builder =
DbUtil.getInstance().getQueryBuilder(ImmuneBatchDetailEntity.class)
.where(ImmuneBatchDetailEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<ImmuneBatchDetailEntity>() {
@Override
public void onSuccess(List<ImmuneBatchDetailEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("immune_batch_detail_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadImmuneBatchDetailError();
} else {
uploadBreedingRecordError();
}
}
}).deleteAsyncBatch(ImmuneBatchDetailEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadBreedingRecordError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadBreedingRecordError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询免疫记录-子表错误数据失败!");
uploadBreedingRecordError();
}
}).queryAsyncAll(ImmuneBatchDetailEntity.class, builder);
}
private void uploadBreedingRecordError() {
QueryBuilder<BreedingRecordEntity> builder =
DbUtil.getInstance().getQueryBuilder(BreedingRecordEntity.class)
.where(BreedingRecordEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<BreedingRecordEntity>() {
@Override
public void onSuccess(List<BreedingRecordEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("breeding_record_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadBreedingRecordError();
} else {
uploadBreedingRecordDetailError();
}
}
}).deleteAsyncBatch(BreedingRecordEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
uploadBreedingRecordDetailError();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
uploadBreedingRecordDetailError();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询配种记录错误数据失败!");
uploadBreedingRecordDetailError();
}
}).queryAsyncAll(BreedingRecordEntity.class, builder);
}
private void uploadBreedingRecordDetailError() {
QueryBuilder<BreedingRecordDetailEntity> builder =
DbUtil.getInstance().getQueryBuilder(BreedingRecordDetailEntity.class)
.where(BreedingRecordDetailEntityDao.Properties.UploadStatus.eq(UPLOAD_STATUS_ERROR)).limit(1);
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<BreedingRecordDetailEntity>() {
@Override
public void onSuccess(List<BreedingRecordDetailEntity> result) {
if (result != null && result.size() > 0) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ErrorEntity errorEntity = new ErrorEntity();
errorEntity.setDeptId(Long.parseLong(SPUtils.getInstance().getString(Configs.SP_DEPT_ID)));
errorEntity.setContent(new Gson().toJson(result.get(0)).toString());
errorEntity.setType("breeding_record_detail_error");
errorEntity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_LOGIN_NAME));
errorEntity.setCreateTime(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(errorEntity));
addSubscribe(model.uploadErrorData(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> showDialog("正在上传-错误数据..."))
.subscribe((Consumer<CollectResponse>) response -> {
if (response.getCode() == 0) {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
uploadBreedingRecordDetailError();
} else {
dismissDialog();
queryCattleResumeUploadCount(true, UPLOAD_STATUS_HAVE_NOT);
}
}
}).deleteAsyncBatch(BreedingRecordDetailEntity.class, result);
} else if (response.getCode() == 401) {
dismissDialog();
Bundle bundle = new Bundle();
bundle.putInt("loginType", 1);
startActivity(LoginActivity.class, bundle);
me.goldze.mvvmhabit.utils.ToastUtils.showShort("登录过期,请重新登录");
} else {
me.goldze.mvvmhabit.utils.ToastUtils.showShort("服务器:" + response.getMsg());
dismissDialog();
queryCattleResumeUploadCount(true, UPLOAD_STATUS_HAVE_NOT);
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
me.goldze.mvvmhabit.utils.ToastUtils.showShort(throwable.message);
})
);
} else {
dismissDialog();
queryCattleResumeUploadCount(true, UPLOAD_STATUS_HAVE_NOT);
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询配种记录-子表错误数据失败!");
dismissDialog();
queryCattleResumeUploadCount(true, UPLOAD_STATUS_HAVE_NOT);
}
}).queryAsyncAll(BreedingRecordDetailEntity.class, builder);
}
}
......@@ -21,6 +21,8 @@ import java.util.List;
public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashVM> {
private int loginType;//登录后是否跳转,0跳转main 1不跳转
@Override
public int initContentView(Bundle bundle) {
return R.layout.activity_splash;
......@@ -31,6 +33,13 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashVM
return BR.viewModel;
}
@Override
public void initParam() {
super.initParam();
loginType = getIntent().getIntExtra("loginType", 0);
}
@Override
public SplashVM initViewModel() {
VMFactory factory = VMFactory.getInstance(getApplication());
......@@ -41,6 +50,8 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashVM
public void initData() {
super.initData();
showDialog("正在同步基础数据,请稍后");
viewModel.loginType = loginType;
viewModel.requestDict();
}
......
......@@ -44,6 +44,8 @@ public class SplashVM extends MainBarVM<Repository> {
private int labelPageIndex = 1;
private int unitPageIndex = 0;
public int loginType;//登录后是否跳转, 0跳转main 1不跳转
public SplashVM(@NonNull Application application, Repository repository) {
super(application, repository);
......@@ -229,6 +231,7 @@ public class SplashVM extends MainBarVM<Repository> {
dismissDialog();
ToastUtils.showShort("页面配置详情数据更新完成!");
SPUtils.getInstance().put("isFirst", false);
if (loginType == 0)
startActivity(MainActivity.class);
finish();
}
......
......@@ -43,7 +43,7 @@ public class EntityUtils {
try {
method = user.getClass().getMethod(getter, new Class[]{});
value = method.invoke(user, new CattleResumeEntity[]{});
value = method.invoke(user, new Object[]{});
return value;
} catch (NoSuchMethodException e) {
......
......@@ -67,6 +67,7 @@
android:textColor="@color/textColor"
android:textColorHint="@color/textColorHint"
android:textSize="@dimen/edit_size"
android:imeOptions="actionNext"
binding:layout_constraintEnd_toStartOf="@+id/clear_et_img"
binding:layout_constraintStart_toEndOf="@+id/person_code_tip"
binding:layout_constraintTop_toTopOf="@+id/login_frame"
......@@ -113,6 +114,7 @@
android:textColor="@color/textColor"
android:textColorHint="@color/textColorHint"
android:textSize="@dimen/edit_size"
android:imeOptions="actionDone"
binding:layout_constraintEnd_toStartOf="@+id/iv_switch_pwd"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintStart_toEndOf="@+id/person_pwd_tip"
......
......@@ -34,6 +34,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
binding:layout_constraintLeft_toRightOf="@+id/guideline_vertical_left"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toTopOf="parent"
......@@ -77,6 +78,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_base_archives_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_base_archives_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.cattleresumeErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_base_archives_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_base_archives_time"
/>
<!-- sign_measure -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_sign_measure_sync"
......@@ -113,6 +126,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_sign_measure_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_sign_measure_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.performanceErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_sign_measure_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_sign_measure_time"
/>
<!-- weighting_manage -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_weighting_manage_sync"
......@@ -149,6 +174,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_weighting_manage_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_weighting_manage_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.weightManErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_weighting_manage_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_weighting_manage_time"
/>
<!-- treatment_record -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_treatment_record_sync"
......@@ -184,12 +221,26 @@
binding:layout_constraintLeft_toRightOf="@+id/tv_treatment_record_count"
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_treatment_record_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_treatment_record_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.medicalrecordsErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_treatment_record_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_treatment_record_time"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
binding:layout_constraintLeft_toRightOf="@+id/guideline_vertical_right"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toTopOf="parent"
......@@ -232,6 +283,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_immun_record_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_immun_record_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.immunebatchErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_immun_record_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_immun_record_time"
/>
<!-- immun_record_detail -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_immun_record_detail_sync"
......@@ -268,6 +331,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_immun_record_detail_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_immun_record_detail_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.immunebatchDetailErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_immun_record_detail_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_immun_record_detail_time"
/>
<!-- breeding_record -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_breeding_record_sync"
......@@ -304,6 +379,18 @@
binding:layout_constraintBaseline_toBaselineOf="@+id/btn_breeding_record_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_breeding_record_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.cattlematingMasterErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_breeding_record_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_breeding_record_time"
/>
<!-- breeding_record_detail -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_breeding_record_detail_sync"
......@@ -339,6 +426,31 @@
binding:layout_constraintLeft_toRightOf="@+id/tv_breeding_record_detail_count"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_breeding_record_detail_count"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_breeding_record_detail_error_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="@dimen/sp_18"
android:text="@{viewModel.cattlematingDetaillErrorCount}"
android:textColor="@color/orange"
binding:layout_constraintLeft_toRightOf="@+id/tv_breeding_record_detail_time"
binding:layout_constraintBaseline_toBaselineOf="@+id/tv_breeding_record_detail_time"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_error_data_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/error_data_upload"
android:layout_marginBottom="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_50"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintBottom_toBottomOf="parent"
binding:onClickCommand="@{viewModel.OnErrorDataUploadClickCommand}"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -183,7 +183,7 @@
android:id="@+id/tv_weigh_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.lastGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_last"
......@@ -204,7 +204,7 @@
android:id="@+id/tv_date_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.lastGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......@@ -238,7 +238,7 @@
android:id="@+id/tv_weigh_adg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.adgGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_adg"
......@@ -259,7 +259,7 @@
android:id="@+id/tv_date_adg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.adgGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......@@ -293,7 +293,7 @@
android:id="@+id/tv_weigh_bwg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.totalGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_bwg"
......@@ -314,7 +314,7 @@
android:id="@+id/tv_date_bwg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.totalGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......
......@@ -182,7 +182,7 @@
android:id="@+id/tv_weigh_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.lastGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_last"
......@@ -203,7 +203,7 @@
android:id="@+id/tv_date_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.lastGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......@@ -237,7 +237,7 @@
android:id="@+id/tv_weigh_adg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.adgGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_adg"
......@@ -258,7 +258,7 @@
android:id="@+id/tv_date_adg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.adgGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......@@ -292,7 +292,7 @@
android:id="@+id/tv_weigh_bwg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"
android:text="@{String.valueOf(viewModel.totalGainWeight)}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_18"
binding:layout_constraintBottom_toTopOf="@+id/tv_date_bwg"
......@@ -313,7 +313,7 @@
android:id="@+id/tv_date_bwg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-11-03"
android:text="@{viewModel.totalGainDate}"
android:textColor="@color/colorSecondary"
android:textSize="@dimen/sp_10"
binding:layout_constraintBottom_toBottomOf="parent"
......
......@@ -27,6 +27,9 @@
<string name="breeding_record_detail">配种详情</string>
<string name="error_data_upload">错误上报</string>
<string name="jobNum">工号:</string>
<string name="pleaseInputUserName">请输入用户名</string>
......
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