Commit 3c04d802 authored by hywang's avatar hywang

1.增加绒毛购买、绒毛测量功能;

2.数据上传、下载功能添加绒毛购买、测量功能;
3.修改数据上传、数据下载、清楚数据的逻辑。
parent 84ed9743
......@@ -65,4 +65,7 @@ dependencies {
implementation project(':mvvmhabit')
implementation project(':appupdateX')
implementation files('libs/uhf.jar')
//生成主键
implementation 'cn.hutool:hutool-all:4.5.6'
}
......@@ -75,6 +75,14 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity android:name=".ui.villus.VillusBuyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity android:name=".ui.villus.VillusGaugeActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
</application>
</manifest>
\ No newline at end of file
......@@ -35,6 +35,7 @@ public class Configs {
public static final String SP_APP_PORT = "sp_app_port";
//用户信息
public static final String SP_USER_NAME = "sp_user_name";
public static final String SP_ID = "sp_id";
public static final String SP_NAME = "sp_name";
public static final String SP_USER_PASSWORD = "sp_user_password";
public static final String SP_USER_EMAIL = "sp_user_email";
......
......@@ -6,6 +6,9 @@ import androidx.annotation.NonNull;
import com.phlx.wool.data.http.HttpDataSource;
import com.phlx.wool.data.local.LocalDataSource;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.DivisionEntityDao;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
......@@ -15,9 +18,15 @@ import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.User;
import com.phlx.wool.entity.Variety;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VeterinaryDao;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusBuyEntityDao;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.List;
import io.reactivex.Observable;
......@@ -91,11 +100,31 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
return mHttpDataSource.getVeterinaryList(body);
}
@Override
public Observable<CattleResponse<List<VillusBuyEntity>>> getVillusBuyList(RequestBody body) {
return mHttpDataSource.getVillusBuyList(body);
}
@Override
public Observable<CattleResponse<List<DivisionEntity>>> getDivisionList(RequestBody body) {
return mHttpDataSource.getDivisionList(body);
}
@Override
public Observable<CattleResponse<List<Marking>>> submitMarking(RequestBody body) {
return mHttpDataSource.submitMarking(body);
}
@Override
public Observable<CattleResponse<List<VillusBuyEntity>>> submitVillusBuy(RequestBody body) {
return mHttpDataSource.submitVillusBuy(body);
}
@Override
public Observable<CattleResponse<List<VillusGaugeEntity>>> submitVillusGauge(RequestBody body) {
return mHttpDataSource.submitVillusGauge(body);
}
@Override
public Observable<CattleResponse<List<Quarantine>>> submitQuarantine(RequestBody body) {
return mHttpDataSource.submitQuarantine(body);
......@@ -194,6 +223,23 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
return mLocalDataSource.getVariety();
}
@Override
public List<DivisionEntity> getPertain(String parentId) {
QueryBuilder<DivisionEntity> builder =
DbUtil.getInstance().getQueryBuilder(DivisionEntity.class)
.where(DivisionEntityDao.Properties.ParentCode.eq(parentId));
return DbUtil.getInstance().queryAll(DivisionEntity.class, builder);
}
@Override
public List<VillusBuyEntity> getVillusBuy() {
QueryBuilder<VillusBuyEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusBuyEntity.class)
.orderDesc(VillusBuyEntityDao.Properties.CreateTime)
;
return DbUtil.getInstance().queryAll(VillusBuyEntity.class);
}
@Override
public List<TreatmentMethod> getTreatmentMethod() {
return mLocalDataSource.getTreatmentMethod();
......
......@@ -15,6 +15,8 @@ import com.phlx.wool.ui.splash.SplashVM;
import com.phlx.wool.ui.sync.vm.ClearVM;
import com.phlx.wool.ui.sync.vm.DownloadVM;
import com.phlx.wool.ui.sync.vm.UploadVM;
import com.phlx.wool.ui.villus.VillusBuyVM;
import com.phlx.wool.ui.villus.VillusGaugeVM;
import com.phlx.wool.ui.work.harmless.HarmlessVM;
import com.phlx.wool.ui.work.mark.MarkingVM;
import com.phlx.wool.ui.work.quarantine.QuarantineVM;
......@@ -85,6 +87,10 @@ public class VMFactory extends ViewModelProvider.NewInstanceFactory {
return (T) new UploadVM(mApplication, repository);
}else if (modelClass.isAssignableFrom(DownloadVM.class)) {
return (T) new DownloadVM(mApplication, repository);
}else if (modelClass.isAssignableFrom(VillusBuyVM.class)) {
return (T) new VillusBuyVM(mApplication, repository);
}else if (modelClass.isAssignableFrom(VillusGaugeVM.class)) {
return (T) new VillusGaugeVM(mApplication, repository);
}
throw new IllegalArgumentException("Unknown ViewModel class: " + modelClass.getName());
}
......
......@@ -2,6 +2,7 @@ package com.phlx.wool.data.http;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
......@@ -9,6 +10,8 @@ import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.User;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
......@@ -74,6 +77,19 @@ public interface ApiService {
@POST("/app/basicsInfo/findVeterinaryList")
Observable<CattleResponse<List<Veterinary>>> getVeterinaryList(@Body RequestBody body);
/**
* 获取绒毛购买
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/app/villus/findVillusBuy")
Observable<CattleResponse<List<VillusBuyEntity>>> getVillusBuyList(@Body RequestBody body);
/**
* 获取行政区划
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/app/basicsInfo/findDivisionsList")
Observable<CattleResponse<List<DivisionEntity>>> getDivisionList(@Body RequestBody body);
/**
* 上传打标信息
......@@ -82,6 +98,20 @@ public interface ApiService {
@POST("/app/resumeInfo/saveList")
Observable<CattleResponse<List<Marking>>> submitMarking(@Body RequestBody body);
/**
* 上传绒毛购买信息
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/app/villus/saveListVillusBuy")
Observable<CattleResponse<List<VillusBuyEntity>>> submitVillusBuy(@Body RequestBody body);
/**
* 上传绒毛测量信息
*/
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("/app/villus/saveListVillusGauge")
Observable<CattleResponse<List<VillusGaugeEntity>>> submitVillusGauge(@Body RequestBody body);
/**
* 上传产地检疫
*/
......
......@@ -2,6 +2,7 @@ package com.phlx.wool.data.http;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
......@@ -9,6 +10,8 @@ import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.User;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
......@@ -60,11 +63,32 @@ public interface HttpDataSource {
Observable<CattleResponse<List<Veterinary>>> getVeterinaryList(@Body RequestBody body);
/**
* 获取绒毛购买
*/
Observable<CattleResponse<List<VillusBuyEntity>>> getVillusBuyList(@Body RequestBody body);
/**
* 获取行政区划
*/
Observable<CattleResponse<List<DivisionEntity>>> getDivisionList(@Body RequestBody body);
/**
* 上传打标信息
*/
Observable<CattleResponse<List<Marking>>> submitMarking(@Body RequestBody body);
/**
* 上传绒毛购买信息
*/
Observable<CattleResponse<List<VillusBuyEntity>>> submitVillusBuy(@Body RequestBody body);
/**
* 上传绒毛测量信息
*/
Observable<CattleResponse<List<VillusGaugeEntity>>> submitVillusGauge(@Body RequestBody body);
/**
* 上传产地检疫
*/
......
......@@ -2,6 +2,7 @@ package com.phlx.wool.data.http;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
......@@ -9,6 +10,8 @@ import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.User;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
......@@ -78,11 +81,31 @@ public class HttpDataSourceImpl implements HttpDataSource {
return apiService.getVeterinaryList(body);
}
@Override
public Observable<CattleResponse<List<VillusBuyEntity>>> getVillusBuyList(RequestBody body) {
return apiService.getVillusBuyList(body);
}
@Override
public Observable<CattleResponse<List<DivisionEntity>>> getDivisionList(RequestBody body) {
return apiService.getDivisionList(body);
}
@Override
public Observable<CattleResponse<List<Marking>>> submitMarking(RequestBody body) {
return apiService.submitMarking(body);
}
@Override
public Observable<CattleResponse<List<VillusBuyEntity>>> submitVillusBuy(RequestBody body) {
return apiService.submitVillusBuy(body);
}
@Override
public Observable<CattleResponse<List<VillusGaugeEntity>>> submitVillusGauge(RequestBody body) {
return apiService.submitVillusGauge(body);
}
@Override
public Observable<CattleResponse<List<Quarantine>>> submitQuarantine(RequestBody body) {
return apiService.submitQuarantine(body);
......
......@@ -2,8 +2,10 @@ package com.phlx.wool.data.local;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.TreatmentMethod;
import com.phlx.wool.entity.Variety;
import com.phlx.wool.entity.VillusBuyEntity;
import java.util.List;
......@@ -95,15 +97,21 @@ public interface LocalDataSource {
*/
void saveTreatmentMethod(List<TreatmentMethod> treatmentMethods) throws Exception;
/**
* 获取品种
*/
List<Variety> getVariety();
/**
* 获取行政区划
*/
List<DivisionEntity> getPertain(String parentId);
/**
* 获取绒毛购买列表
*/
List<VillusBuyEntity> getVillusBuy();
/**
* 获取无害化处理方式
*/
......
......@@ -4,8 +4,10 @@ package com.phlx.wool.data.local;
import com.phlx.wool.Configs;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.TreatmentMethod;
import com.phlx.wool.entity.Variety;
import com.phlx.wool.entity.VillusBuyEntity;
import java.util.List;
......@@ -116,6 +118,16 @@ public class LocalDataSourceImpl implements LocalDataSource {
return DbUtil.getInstance().queryAll(Variety.class);
}
@Override
public List<DivisionEntity> getPertain(String parentId) {
return DbUtil.getInstance().queryAll(DivisionEntity.class);
}
@Override
public List<VillusBuyEntity> getVillusBuy() {
return DbUtil.getInstance().queryAll(VillusBuyEntity.class);
}
@Override
public List<TreatmentMethod> getTreatmentMethod() {
return DbUtil.getInstance().queryAll(TreatmentMethod.class);
......
package com.phlx.wool.entity;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.databinding.BaseObservable;
import com.google.gson.annotations.SerializedName;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Generated;
/**
* 行政区划对象 zs_divisions
*
* @author phlx
* @date 2019-12-24
*/
@Entity
public class DivisionEntity extends BaseObservable implements Parcelable {
/**
* $column.columnComment
*/
@Id(autoincrement = false)
private Long id;
/**
* 代码
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 父级
*/
private String parentCode;
/**
* 排序号
*/
private String sortcode;
/**
* 时间戳
*/
private String inputTime;
/**
* 0正常 1更新 2删除
*/
private String status;
/**
* 打标牧户数
*/
private String PasCount;
/**
* 各旗打标牧户数
*/
private String CityCount;
/**
* 各镇打标牧户数
*/
private String TownsCount;
/**
* 各村打标牧户数
*/
private String PasVillageCount;
/**
* 时间
*/
private String year;
public DivisionEntity() {
}
protected DivisionEntity(Parcel in) {
if (in.readByte() == 0) {
id = null;
} else {
id = in.readLong();
}
code = in.readString();
name = in.readString();
parentCode = in.readString();
sortcode = in.readString();
inputTime = in.readString();
status = in.readString();
PasCount = in.readString();
CityCount = in.readString();
TownsCount = in.readString();
PasVillageCount = in.readString();
year = in.readString();
}
@Generated(hash = 1743104085)
public DivisionEntity(Long id, String code, String name, String parentCode,
String sortcode, String inputTime, String status, String PasCount,
String CityCount, String TownsCount, String PasVillageCount, String year) {
this.id = id;
this.code = code;
this.name = name;
this.parentCode = parentCode;
this.sortcode = sortcode;
this.inputTime = inputTime;
this.status = status;
this.PasCount = PasCount;
this.CityCount = CityCount;
this.TownsCount = TownsCount;
this.PasVillageCount = PasVillageCount;
this.year = year;
}
@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(code);
dest.writeString(name);
dest.writeString(parentCode);
dest.writeString(sortcode);
dest.writeString(inputTime);
dest.writeString(status);
dest.writeString(PasCount);
dest.writeString(CityCount);
dest.writeString(TownsCount);
dest.writeString(PasVillageCount);
dest.writeString(year);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<DivisionEntity> CREATOR = new Creator<DivisionEntity>() {
@Override
public DivisionEntity createFromParcel(Parcel in) {
return new DivisionEntity(in);
}
@Override
public DivisionEntity[] newArray(int size) {
return new DivisionEntity[size];
}
};
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getSortcode() {
return sortcode;
}
public void setSortcode(String sortcode) {
this.sortcode = sortcode;
}
public String getInputTime() {
return inputTime;
}
public void setInputTime(String inputTime) {
this.inputTime = inputTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getPasCount() {
return PasCount;
}
public void setPasCount(String pasCount) {
PasCount = pasCount;
}
public String getCityCount() {
return CityCount;
}
public void setCityCount(String cityCount) {
CityCount = cityCount;
}
public String getTownsCount() {
return TownsCount;
}
public void setTownsCount(String townsCount) {
TownsCount = townsCount;
}
public String getPasVillageCount() {
return PasVillageCount;
}
public void setPasVillageCount(String pasVillageCount) {
PasVillageCount = pasVillageCount;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
@Override
public String toString() {
return "DivisionEntity{" +
"id=" + id +
", code='" + code + '\'' +
", name='" + name + '\'' +
", parentCode='" + parentCode + '\'' +
", sortcode='" + sortcode + '\'' +
", inputTime='" + inputTime + '\'' +
", status='" + status + '\'' +
", PasCount='" + PasCount + '\'' +
", CityCount='" + CityCount + '\'' +
", TownsCount='" + TownsCount + '\'' +
", PasVillageCount='" + PasVillageCount + '\'' +
", year='" + year + '\'' +
'}';
}
}
package com.phlx.wool.entity;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.databinding.BaseObservable;
import com.google.gson.annotations.SerializedName;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;
/**
* 绒毛收购 对象 zs_villus_buy
*
* @author phlx
* @date 2021-01-14
*/
@Entity
public class VillusBuyEntity extends BaseObservable implements Parcelable {
/**
* 主键
*/
@Id(autoincrement = false)
private Long id;
/**
* 收购批次
*/
private String buyBatch;
/**
* 所属苏木
*/
private String revision;
/**
* 收购重量
*/
private String buyWeight;
/**
* 收购厂家
*/
private String buyFactory;
/**
* 收购日期
*/
private String buyDate;
/**
* 负责人
*/
private String personInCharge;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/**
* 数据状态 0--上传成功,1----未上传或上传失败
*/
private int status;
public VillusBuyEntity() {
}
protected VillusBuyEntity(Parcel in) {
if (in.readByte() == 0) {
id = null;
} else {
id = in.readLong();
}
buyBatch = in.readString();
revision = in.readString();
buyWeight = in.readString();
buyFactory = in.readString();
buyDate = in.readString();
personInCharge = in.readString();
createBy = in.readString();
createTime = in.readString();
status = in.readInt();
}
@Generated(hash = 73546827)
public VillusBuyEntity(Long id, String buyBatch, String revision, String buyWeight,
String buyFactory, String buyDate, String personInCharge, String createBy,
String createTime, int status) {
this.id = id;
this.buyBatch = buyBatch;
this.revision = revision;
this.buyWeight = buyWeight;
this.buyFactory = buyFactory;
this.buyDate = buyDate;
this.personInCharge = personInCharge;
this.createBy = createBy;
this.createTime = createTime;
this.status = status;
}
@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(buyBatch);
dest.writeString(revision);
dest.writeString(buyWeight);
dest.writeString(buyFactory);
dest.writeString(buyDate);
dest.writeString(personInCharge);
dest.writeString(createBy);
dest.writeString(createTime);
dest.writeInt(status);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<VillusBuyEntity> CREATOR = new Creator<VillusBuyEntity>() {
@Override
public VillusBuyEntity createFromParcel(Parcel in) {
return new VillusBuyEntity(in);
}
@Override
public VillusBuyEntity[] newArray(int size) {
return new VillusBuyEntity[size];
}
};
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBuyBatch() {
return buyBatch;
}
public void setBuyBatch(String buyBatch) {
this.buyBatch = buyBatch;
}
public String getRevision() {
return revision;
}
public void setRevision(String revision) {
this.revision = revision;
}
public String getBuyWeight() {
return buyWeight;
}
public void setBuyWeight(String buyWeight) {
this.buyWeight = buyWeight;
}
public String getBuyFactory() {
return buyFactory;
}
public void setBuyFactory(String buyFactory) {
this.buyFactory = buyFactory;
}
public String getBuyDate() {
return buyDate;
}
public void setBuyDate(String buyDate) {
this.buyDate = buyDate;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
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;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public String toString() {
return "VillusBuyEntity{" +
"id=" + id +
", buyBatch='" + buyBatch + '\'' +
", revision='" + revision + '\'' +
", buyWeight='" + buyWeight + '\'' +
", buyFactory='" + buyFactory + '\'' +
", buyDate='" + buyDate + '\'' +
", personInCharge='" + personInCharge + '\'' +
", createBy='" + createBy + '\'' +
", createTime='" + createTime + '\'' +
", status='" + status + '\'' +
'}';
}
}
package com.phlx.wool.entity;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.databinding.BaseObservable;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;
/**
* 绒毛测量 对象 zs_villus_gauge
*
* @author phlx
* @date 2021-01-18
*/
@Entity
public class VillusGaugeEntity extends BaseObservable implements Parcelable {
/**
* 主键
*/
@Id(autoincrement = false)
private Long id;
/**
* 收购批次
*/
private String buyBatch;
/**
* 测量日期
*/
private String measuringTime;
/**
* 直径μm
*/
private String diameter;
/**
* 长度cm
*/
private String length;
/**
* 长度变异系数
*/
private String lenghtRsd;
/**
* 绒伸直长cm
*/
private String villusStraightLong;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/**
* 数据状态 0--上传成功,1----未上传或上传失败
*/
private int status;
public VillusGaugeEntity() {
}
@Generated(hash = 1062554218)
public VillusGaugeEntity(Long id, String buyBatch, String measuringTime,
String diameter, String length, String lenghtRsd,
String villusStraightLong, String createBy, String createTime,
int status) {
this.id = id;
this.buyBatch = buyBatch;
this.measuringTime = measuringTime;
this.diameter = diameter;
this.length = length;
this.lenghtRsd = lenghtRsd;
this.villusStraightLong = villusStraightLong;
this.createBy = createBy;
this.createTime = createTime;
this.status = status;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBuyBatch() {
return buyBatch;
}
public void setBuyBatch(String buyBatch) {
this.buyBatch = buyBatch;
}
public String getMeasuringTime() {
return measuringTime;
}
public void setMeasuringTime(String measuringTime) {
this.measuringTime = measuringTime;
}
public String getDiameter() {
return diameter;
}
public void setDiameter(String diameter) {
this.diameter = diameter;
}
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getLenghtRsd() {
return lenghtRsd;
}
public void setLenghtRsd(String lenghtRsd) {
this.lenghtRsd = lenghtRsd;
}
public String getVillusStraightLong() {
return villusStraightLong;
}
public void setVillusStraightLong(String villusStraightLong) {
this.villusStraightLong = villusStraightLong;
}
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;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public String toString() {
return "VillusGaugeEntity{" +
"id=" + id +
", buyBatch='" + buyBatch + '\'' +
", measuringTime='" + measuringTime + '\'' +
", diameter='" + diameter + '\'' +
", length='" + length + '\'' +
", lenghtRsd='" + lenghtRsd + '\'' +
", villusStraightLong='" + villusStraightLong + '\'' +
", createBy='" + createBy + '\'' +
", createTime='" + createTime + '\'' +
", status='" + status + '\'' +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
}
}
......@@ -47,7 +47,7 @@ public class RetrofitClient {
//缓存时间
private static final int CACHE_TIMEOUT = 10 * 1024 * 1024;
//服务端根路径
public static String baseUrl = "192.168.8.182";
public static String baseUrl = "192.168.8.189";
public static String port = "80";
private static Context mContext = Utils.getContext();
......@@ -121,6 +121,7 @@ public class RetrofitClient {
.addInterceptor(new LoggingInterceptor
.Builder()//构建者模式
.loggable(BuildConfig.DEBUG) //是否开启日志打印
// .loggable(true) //是否开启日志打印
.setLevel(Level.BASIC) //打印的等级
.log(Platform.INFO) // 打印类型
.request("Request") // request的Tag
......
......@@ -54,6 +54,7 @@ import me.goldze.mvvmhabit.http.ResponseThrowable;
import me.goldze.mvvmhabit.utils.KLog;
import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.SPUtils;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
import me.tatarka.bindingcollectionadapter2.ItemBinding;
......@@ -186,10 +187,23 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
public BindingCommand onFixedClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
//如果是低频
if("1".equals(Configs.FREQUENCY_CONFIG)){
mList.clear();
String epcStr = tipDesc.get();
if(!StringUtils.isEmpty(epcStr)) {
Label label = new Label();
label.setEpc(epcStr);
label.setTid(epcStr);
mList.add(label);
}
}
if (mList != null && mList.size() > 0) {
addSubscribe(Observable.create((ObservableOnSubscribe<List<Label>>) emitter -> {
try {
checkList = new ArrayList<>();
legalCount = 0;
KLog.e(mList.toString());
......@@ -217,7 +231,7 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
.doOnSubscribe(disposable -> {
})
.subscribe((Consumer<List<Label>>) response -> {
if (response != null && response.size() > 0) {
if (legalCount > 0) {
labelCheckEvent.setValue("" + legalCount);
} else {
jumpToActivity();
......@@ -225,6 +239,8 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
}, (Consumer<ResponseThrowable>) throwable -> {
ToastUtils.showShort(throwable.message);
}));
} else {
ToastUtils.showShort("请扫描耳标");
}
}
});
......@@ -257,6 +273,7 @@ public class InventoryVM extends BackBarVM<Repository> implements OnInventoryLis
mList.clear();
labelNum.set("");
map.clear();
tipDesc.set("");
}
});
......
......@@ -139,6 +139,7 @@ public class LoginVM extends BackBarVM<Repository> {
model.saveFrequencyConfig(response.getData().getUser().getFrequencyConfig());
Configs.FREQUENCY_CONFIG = response.getData().getUser().getFrequencyConfig();
model.saveBreed(response.getData().getUser().getDept().getDeptName());
SPUtils.getInstance().put(Configs.SP_ID, response.getData().getUser().getUserId());
SPUtils.getInstance().put(Configs.SP_NAME, response.getData().getUser().getUserName());
}
VMFactory.getInstance(getApplication()).refreshRepository();
......
......@@ -13,6 +13,8 @@ import com.phlx.wool.ui.inventory.InventoryActivity;
import com.phlx.wool.ui.sync.activity.ClearActivity;
import com.phlx.wool.ui.sync.activity.DownloadActivity;
import com.phlx.wool.ui.sync.activity.UploadActivity;
import com.phlx.wool.ui.villus.VillusBuyActivity;
import com.phlx.wool.ui.villus.VillusGaugeActivity;
import com.phlx.wool.ui.work.unit.UnitActivity;
import me.goldze.mvvmhabit.binding.command.BindingAction;
......@@ -85,6 +87,20 @@ public class MainVM extends MainBarVM<Repository> {
});
public BindingCommand OnVillusBuyClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
startActivity(VillusBuyActivity.class);
}
});
public BindingCommand OnVillusGaugeClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
startActivity(VillusGaugeActivity.class);
}
});
public BindingCommand OnDownloadClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
......
......@@ -9,6 +9,7 @@ import com.phlx.wool.data.Repository;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.db.interf.DbIDUCallBack;
import com.phlx.wool.db.interf.DbQueryCallBack;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.Veterinary;
......@@ -20,6 +21,8 @@ import com.phlx.wool.ui.main.MainActivity;
import org.greenrobot.greendao.query.WhereCondition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import io.reactivex.functions.Consumer;
......@@ -51,7 +54,8 @@ public class SplashVM extends MainBarVM<Repository> {
postParams.setInputTime(inputTime);
postParams.setPageNum(index);
postParams.setPageSize(count);
postParams.setYears("2018");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
postParams.setYears(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
KLog.e("label", postParams.toString());
......@@ -190,7 +194,7 @@ public class SplashVM extends MainBarVM<Repository> {
if (result) {
dismissDialog();
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestBasicInfo();
requestDivisionInfo();
}
}
}).insertAsyncBatch(Veterinary.class, response.getData());
......@@ -211,14 +215,52 @@ public class SplashVM extends MainBarVM<Repository> {
);
}
private void requestDivisionInfo(){
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),"");
addSubscribe(model.getDivisionList(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> {
})
.subscribe((Consumer<CattleResponse<List<DivisionEntity>>>) response -> {
if (response.getCode() == 0) {
if (response.getData() != null && response.getData().size() > 0) {
KLog.e(response.getData().size());
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
showDialog("正在下载行政区划数据,请稍后!");
requestBasicInfo();
}
}
}).insertAsyncBatch(DivisionEntity.class, response.getData());
} else {
dismissDialog();
errorEvent.setValue("缺少行政区划数据,请联系管理员");
}
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
})
);
}
private void requestBasicInfo() {
PostParams postParams = new PostParams();
postParams.setInputTime(0);
postParams.setPageNum(1);
postParams.setPageSize(200);
postParams.setYears("2018");
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(postParams));
addSubscribe(model.getBasicInfo(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
......
......@@ -17,6 +17,8 @@ import com.phlx.wool.entity.HarmlessDetail;
import com.phlx.wool.entity.Marking;
import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.QuarantineDetail;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.ui.base.BackBarVM;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
......@@ -37,14 +39,18 @@ public class ClearVM extends BackBarVM<Repository> {
public ObservableField<Boolean> isClearMarking = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isClearHarmless = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isClearQuarantine = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isClearVillusBuy = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isClearVillusGauge = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isClearAll = new ObservableField<Boolean>(false);
public ObservableInt clearDataVisibility = new ObservableInt();
private boolean isMarkingClear, isHarmlessClear, isQuarantineClear, isVillusBuyClear, isVillusGaugeClear;
public ClearVM(@NonNull Application application, Repository repository) {
super(application, repository);
if (Configs.isOnLine) {
clearDataVisibility.set(View.VISIBLE);
}else {
} else {
clearDataVisibility.set(View.GONE);
}
}
......@@ -78,6 +84,22 @@ public class ClearVM extends BackBarVM<Repository> {
}
});
public BindingCommand<Boolean> onVillusBuyCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isClearVillusBuy.set(isChecked);
}
});
public BindingCommand<Boolean> onVillusGaugeCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isClearVillusGauge.set(isChecked);
}
});
public BindingCommand<Boolean> onClearAllCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
......@@ -91,38 +113,44 @@ public class ClearVM extends BackBarVM<Repository> {
isClearMarking.set(isSelected);
isClearHarmless.set(isSelected);
isClearQuarantine.set(isSelected);
isClearVillusBuy.set(isSelected);
isClearVillusGauge.set(isSelected);
}
public BindingCommand onClearClickCommand = new BindingCommand(() -> {
isMarkingClear = false;
isHarmlessClear = false;
isQuarantineClear = false;
isVillusBuyClear = false;
isVillusGaugeClear = false;
clearNext();
});
if (isClearMarking.get()) {
private void clearNext() {
if (isClearMarking.get() && !isMarkingClear) {
deleteAllMarking();
} else if (isClearQuarantine.get()) {
} else if (isClearQuarantine.get() && !isHarmlessClear) {
deleteAllQuarantine();
} else if (isClearHarmless.get()) {
} else if (isClearHarmless.get() && !isQuarantineClear) {
deleteAllHarmless();
} else {
ToastUtils.showShort("请选择清空的项目");
} else if (isClearVillusBuy.get() && !isVillusBuyClear) {
deleteAllVillusBuy();
} else if (isClearVillusGauge.get() && !isVillusGaugeClear) {
deleteAllVillusGauge();
}
}
});
private void deleteAllMarking() {
showDialog("正在清除数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isMarkingClear = true;
if (result) {
dismissDialog();
if (isClearQuarantine.get()) {
deleteAllQuarantine();
} else if (isClearHarmless.get()) {
deleteAllHarmless();
}
}
clearNext();
}
}).deleteAsyncAll(Marking.class);
}
......@@ -132,13 +160,12 @@ public class ClearVM extends BackBarVM<Repository> {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isQuarantineClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(QuarantineDetail.class);
if (isClearHarmless.get()) {
deleteAllHarmless();
}
}
clearNext();
}
}).deleteAsyncAll(Quarantine.class);
}
......@@ -148,13 +175,45 @@ public class ClearVM extends BackBarVM<Repository> {
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isHarmlessClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(HarmlessDetail.class);
}
clearNext();
}
}).deleteAsyncAll(Harmless.class);
}
private void deleteAllVillusBuy() {
showDialog("正在清除绒毛购买数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isVillusBuyClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(VillusBuyEntity.class);
}
clearNext();
}
}).deleteAsyncAll(VillusBuyEntity.class);
}
private void deleteAllVillusGauge() {
showDialog("正在清除绒毛测量数据,请勿关闭屏幕或退出程序");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
isVillusGaugeClear = true;
if (result) {
dismissDialog();
DbUtil.getInstance().deleteAsyncAll(VillusGaugeEntity.class);
}
clearNext();
}
}).deleteAsyncAll(VillusGaugeEntity.class);
}
}
......@@ -16,6 +16,7 @@ import com.phlx.wool.db.interf.DbQueryCallBack;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;
import com.phlx.wool.params.PostParams;
......@@ -24,6 +25,9 @@ import com.phlx.wool.ui.main.MainActivity;
import org.greenrobot.greendao.query.WhereCondition;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import io.reactivex.functions.Consumer;
......@@ -48,6 +52,10 @@ import okhttp3.RequestBody;
* </pre>
*/
public class DownloadVM extends BackBarVM<Repository> {
private SimpleDateFormat dateFormat;
public SingleLiveEvent<String> errorEvent = new SingleLiveEvent<>();
private int labelPageIndex = 0;
......@@ -56,14 +64,19 @@ public class DownloadVM extends BackBarVM<Repository> {
public ObservableField<Boolean> isDownloadBasic = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isDownloadUnit = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isDownloadVeterinary = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isDownloadVillusBuy = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isDownloadAll = new ObservableField<Boolean>(false);
public ObservableInt downloadDataVisibility = new ObservableInt();
private boolean isLabelDownload, isBasicDownload, isUnitDownload, isVeterinaryDownload, isVillusBuyDownload;
public DownloadVM(@NonNull Application application, Repository repository) {
super(application, repository);
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (Configs.isOnLine) {
downloadDataVisibility.set(View.VISIBLE);
}else {
} else {
downloadDataVisibility.set(View.GONE);
}
}
......@@ -88,6 +101,7 @@ public class DownloadVM extends BackBarVM<Repository> {
isDownloadBasic.set(isChecked);
}
});
public BindingCommand<Boolean> onDownloadUnitCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
......@@ -96,7 +110,6 @@ public class DownloadVM extends BackBarVM<Repository> {
}
});
public BindingCommand<Boolean> onDownloadVeterinaryCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
......@@ -105,6 +118,14 @@ public class DownloadVM extends BackBarVM<Repository> {
}
});
public BindingCommand<Boolean> onDownloadVillusBuyCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isDownloadVeterinary.set(isChecked);
}
});
public BindingCommand<Boolean> onDownloadAllCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
......@@ -119,11 +140,41 @@ public class DownloadVM extends BackBarVM<Repository> {
isDownloadBasic.set(isSelected);
isDownloadUnit.set(isSelected);
isDownloadVeterinary.set(isSelected);
isDownloadVillusBuy.set(isSelected);
}
public BindingCommand onDownloadClickCommand = new BindingCommand(() -> {
if (isDownloadLabel.get()) {
isLabelDownload = false;
isBasicDownload = false;
isUnitDownload = false;
isVeterinaryDownload = false;
isVillusBuyDownload = false;
downloadNext();
});
private void downloadNext() {
if (isDownloadLabel.get() && !isLabelDownload) {
baseDateUpload();
} else if (isDownloadBasic.get() && !isBasicDownload) {
requestBasicInfo();
} else if (isDownloadUnit.get() && !isUnitDownload) {
queryUnitInputTime(unitPageIndex, 100000);
} else if (isDownloadVeterinary.get() && !isVeterinaryDownload) {
requestVeterinary();
} else if (isDownloadVillusBuy.get() && !isVillusBuyDownload) {
requestVillusBuy();
} else {
startActivity(MainActivity.class);
finish();
}
}
private void baseDateUpload() {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
String sql = "TIMESTAMP IN " + "(SELECT MAX(TIMESTAMP) FROM LABEL)";
WhereCondition.StringCondition stringCondition =
......@@ -140,36 +191,26 @@ public class DownloadVM extends BackBarVM<Repository> {
@Override
public void onFailed() {
downloadNext();
}
}).queryAsync(Label.class, stringCondition);
} else if (isDownloadUnit.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
queryUnitInputTime(unitPageIndex, 100000);
} else if (isDownloadVeterinary.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestVeterinary();
}else if (isDownloadBasic.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestBasicInfo();
} else {
ToastUtils.showShort("请选择下载的项目");
}
});
/**
* 获取标签数据
*/
public void requestLabel(int index, long inputTime, int count) {
isLabelDownload = true;
PostParams postParams = new PostParams();
postParams.setInputTime(inputTime);
postParams.setPageNum(index);
postParams.setPageSize(count);
postParams.setYears("2018");
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
postParams.setYears(dateFormat.format(new Date()));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(postParams));
KLog.e("label", postParams.toString());
addSubscribe(model.getLabelList(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
......@@ -188,30 +229,24 @@ public class DownloadVM extends BackBarVM<Repository> {
if (result) {
labelPageIndex++;
requestLabel(labelPageIndex, inputTime, count);
} else {
downloadNext();
}
}
}).insertAsyncBatch(Label.class, response.getData());
} else {
dismissDialog();
if (isDownloadUnit.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
queryUnitInputTime(unitPageIndex, 100000);
} else if (isDownloadVeterinary.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestVeterinary();
} else if (isDownloadBasic.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestBasicInfo();
}
downloadNext();
}
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
errorEvent.setValue("标签数据-服务器 :" + response.getMsg());
downloadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
errorEvent.setValue("同步标签数据失败");
downloadNext();
})
);
......@@ -245,29 +280,25 @@ public class DownloadVM extends BackBarVM<Repository> {
if (result) {
unitPageIndex++;
requestUnit(unitPageIndex, inputTime, count);
}else{
downloadNext();
}
}
}).insertAsyncBatch(Unit.class, response.getData());
} else {
dismissDialog();
if (isDownloadVeterinary.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestVeterinary();
} else if (isDownloadBasic.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestBasicInfo();
}
downloadNext();
}
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
downloadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
downloadNext();
})
);
......@@ -290,7 +321,7 @@ public class DownloadVM extends BackBarVM<Repository> {
@Override
public void onFailed() {
downloadNext();
}
}).queryAsync(Unit.class, stringCondition);
}
......@@ -320,8 +351,8 @@ public class DownloadVM extends BackBarVM<Repository> {
dismissDialog();
if (isDownloadBasic.get()) {
showDialog("正在同步数据,请勿关闭屏幕或退出程序!");
requestBasicInfo();
}
downloadNext();
}
}
}).insertAsyncBatch(Veterinary.class, response.getData());
......@@ -329,15 +360,75 @@ public class DownloadVM extends BackBarVM<Repository> {
} else {
dismissDialog();
errorEvent.setValue("缺少兽医基础数据,请联系管理员");
downloadNext();
}
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
downloadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
downloadNext();
})
);
}
private void requestVillusBuy() {
List<VillusBuyEntity> villusBuy = model.getVillusBuy();
PostParams postParams = new PostParams();
Date _date = null;
try {
if (villusBuy != null && villusBuy.size() > 0) {
_date = dateFormat.parse(villusBuy.get(0).getCreateTime());
postParams.setInputTime(_date.getTime());
}
} catch (ParseException e) {
e.printStackTrace();
}
postParams.setPageNum(1);
postParams.setPageSize(200);
// postParams.setYears("2018");
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(postParams));
addSubscribe(model.getVillusBuyList(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> {
})
.subscribe((Consumer<CattleResponse<List<VillusBuyEntity>>>) response -> {
if (response.getCode() == 0) {
if (response.getData() != null && response.getData().size() > 0) {
KLog.e(response.getData().size());
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
if (isDownloadBasic.get()) {
showDialog("正在同步绒毛购买数据,请勿关闭屏幕或退出程序!");
}
downloadNext();
}
}
}).insertAsyncBatch(VillusBuyEntity.class, response.getData());
} else {
dismissDialog();
downloadNext();
}
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
downloadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
downloadNext();
})
);
}
......@@ -366,15 +457,16 @@ public class DownloadVM extends BackBarVM<Repository> {
model.saveTreatmentMethod(response.getData().getInnocuitymanagewayinfoList());
}
SPUtils.getInstance().put("isFirst", false);
startActivity(MainActivity.class);
finish();
downloadNext();
} else {
errorEvent.setValue("服务器 :" + response.getMsg());
downloadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
KLog.e(throwable.message);
errorEvent.setValue("同步数据失败");
downloadNext();
})
);
}
......
......@@ -23,6 +23,10 @@ import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.QuarantineDao;
import com.phlx.wool.entity.QuarantineDetail;
import com.phlx.wool.entity.QuarantineDetailDao;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusBuyEntityDao;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.entity.VillusGaugeEntityDao;
import com.phlx.wool.params.CattleResponse;
import com.phlx.wool.params.UploadParams;
import com.phlx.wool.ui.base.BackBarVM;
......@@ -55,14 +59,18 @@ public class UploadVM extends BackBarVM<Repository> {
public ObservableField<Boolean> isUploadMarking = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isUploadHarmless = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isUploadQuarantine = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isUploadVillusBuy = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isUploadVillusGauge = new ObservableField<Boolean>(false);
public ObservableField<Boolean> isUploadAll = new ObservableField<Boolean>(false);
public ObservableInt uploadDataVisibility = new ObservableInt();
private boolean isMarkingUpload, isHarmlessUpload, isQuarantineUpload, isVillusBuyUpload, isVillusGaugeUpload;
public UploadVM(@NonNull Application application, Repository repository) {
super(application, repository);
if (Configs.isOnLine) {
uploadDataVisibility.set(View.VISIBLE);
}else {
} else {
uploadDataVisibility.set(View.GONE);
}
}
......@@ -96,6 +104,22 @@ public class UploadVM extends BackBarVM<Repository> {
}
});
public BindingCommand<Boolean> onUploadVillusBuyCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isUploadVillusBuy.set(isChecked);
}
});
public BindingCommand<Boolean> onUploadVillusGaugeCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
public void call(Boolean isChecked) {
isUploadVillusGauge.set(isChecked);
}
});
public BindingCommand<Boolean> onUploadAllCommand =
new BindingCommand<>(new BindingConsumer<Boolean>() {
@Override
......@@ -109,73 +133,102 @@ public class UploadVM extends BackBarVM<Repository> {
isUploadMarking.set(isSelected);
isUploadHarmless.set(isSelected);
isUploadQuarantine.set(isSelected);
isUploadVillusBuy.set(isSelected);
isUploadVillusGauge.set(isSelected);
}
private void uploadNext() {
if (isUploadMarking.get() && !isMarkingUpload) {
uploadMarking();
} else if (isUploadHarmless.get() && !isHarmlessUpload) {
uploadHarmless();
} else if (isUploadQuarantine.get() && !isQuarantineUpload) {
uploadQuarantine();
} else if (isUploadMarking.get() && !isVillusBuyUpload) {
uploadVillusBuy();
} else if (isUploadMarking.get() && !isVillusGaugeUpload) {
uploadVillusGauge();
} else {
ToastUtils.showShort("请选择上传的项目");
}
}
public BindingCommand onUploadClickCommand = new BindingCommand(() -> {
if (isUploadMarking.get()) {
isMarkingUpload = false;
isHarmlessUpload = false;
isQuarantineUpload = false;
isVillusBuyUpload = false;
isVillusGaugeUpload = false;
uploadNext();
});
private void uploadMarking() {
QueryBuilder<Marking> builder =
DbUtil.getInstance().getQueryBuilder(Marking.class).
where(MarkingDao.Properties.Status.eq("1"));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Marking>() {
@Override
public void onSuccess(List<Marking> result) {
if (result != null && result.size() > 0) {
uploadMarking(result);
}
}
@Override
public void onFailed() {
}
}).queryAsyncAll(Marking.class, builder);
} else if (isUploadQuarantine.get()) {
uploadQuarantine();
} else if (isUploadHarmless.get()){
uploadHarmless();
}else {
ToastUtils.showShort("请选择上传的项目");
}
});
private void uploadMarking(List<Marking> markingList) {
isMarkingUpload = true;
if (result != null && result.size() > 0) {
String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<List<Marking>>(markingList));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
postInfoStr);
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<Marking>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitMarking(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传数据..."))
.doOnSubscribe(disposable -> showDialog("正在上传marking数据..."))
.subscribe((Consumer<CattleResponse<List<Marking>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
if (response.getCode() == 0) {
for (int i = 0; i < markingList.size(); i++) {
markingList.get(i).setStatus(0);
for (int i = 0; i < result.size(); i++) {
result.get(i).setStatus(0);
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
if (isUploadQuarantine.get()) {
uploadQuarantine();
} else if (isUploadHarmless.get()) {
}
} else {
ToastUtils.showShort("删除marking数据失败");
}
uploadNext();
}
}).deleteAsyncBatch(Marking.class, markingList);
}).deleteAsyncBatch(Marking.class, result);
} else {
dismissDialog();
ToastUtils.showShort("上传失败");
ToastUtils.showShort("marking上传失败");
uploadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
uploadNext();
})
);
} else {
uploadNext();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("marking数据库查询失败");
}
}).queryAsyncAll(Marking.class, builder);
}
......@@ -189,6 +242,7 @@ public class UploadVM extends BackBarVM<Repository> {
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Quarantine>() {
@Override
public void onSuccess(List<Quarantine> result) {
isQuarantineUpload = true;
if (result != null && result.size() > 0) {
KLog.e(result.toString());
for (Quarantine quarantine : result) {
......@@ -204,10 +258,10 @@ public class UploadVM extends BackBarVM<Repository> {
}
KLog.e(result.toString());
String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<List<Quarantine>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; " +
"charset=utf-8"),
postInfoStr);
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<Quarantine>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitQuarantine(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
......@@ -223,28 +277,30 @@ public class UploadVM extends BackBarVM<Repository> {
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(QuarantineDetail.class);
if (isUploadHarmless.get()) {
uploadHarmless();
}
} else {
ToastUtils.showShort("删除检疫数据失败");
}
uploadNext();
}
}).deleteAsyncBatch(Quarantine.class, result);
} else {
ToastUtils.showShort("上传失败");
ToastUtils.showShort("上传检疫数据失败");
uploadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
uploadNext();
})
);
} else {
uploadNext();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("检疫数据库查询失败");
}
}).queryAsyncAll(Quarantine.class, builder);
}
......@@ -260,6 +316,7 @@ public class UploadVM extends BackBarVM<Repository> {
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<Harmless>() {
@Override
public void onSuccess(List<Harmless> result) {
isHarmlessUpload = true;
if (result != null && result.size() > 0) {
KLog.e(result.toString());
for (Harmless harmless : result) {
......@@ -275,16 +332,16 @@ public class UploadVM extends BackBarVM<Repository> {
}
KLog.e(result.toString());
String postInfoStr =
new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create().toJson(new UploadParams<List<Harmless>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; " +
"charset=utf-8"),
postInfoStr);
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<Harmless>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitHarmless(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传检疫数据..."))
.doOnSubscribe(disposable -> showDialog("正在上传无害化数据..."))
.subscribe((Consumer<CattleResponse<List<Harmless>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
dismissDialog();
......@@ -294,27 +351,160 @@ public class UploadVM extends BackBarVM<Repository> {
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(HarmlessDetail.class);
} else {
ToastUtils.showShort("删除无害化数据失败");
}
uploadNext();
}
}).deleteAsyncBatch(Harmless.class, result);
} else {
ToastUtils.showShort("上传无害化失败");
uploadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
uploadNext();
})
);
} else {
uploadNext();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("无害化数据库查询失败");
}
}).queryAsyncAll(Harmless.class, builder);
}
/**
* 上传绒毛购买数据
*/
private void uploadVillusBuy() {
QueryBuilder<VillusBuyEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusBuyEntity.class).
where(VillusBuyEntityDao.Properties.Status.eq("1"));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusBuyEntity>() {
@Override
public void onSuccess(List<VillusBuyEntity> result) {
isVillusBuyUpload = true;
if (result != null && result.size() > 0) {
KLog.e(result.toString());
String postInfoStr =
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<VillusBuyEntity>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitVillusBuy(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传绒毛购买数据..."))
.subscribe((Consumer<CattleResponse<List<VillusBuyEntity>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
dismissDialog();
if (response.getCode() == 0) {
for (VillusBuyEntity villusBuyEntity : result) {
villusBuyEntity.setStatus(0);
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
} else {
ToastUtils.showShort("更新绒毛购买数据失败");
}
uploadNext();
}
}).updateAsyncBatch(VillusBuyEntity.class, result);
} else {
ToastUtils.showShort("上传失败");
ToastUtils.showShort("上传绒毛购买数据失败");
uploadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
uploadNext();
})
);
} else {
uploadNext();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询绒毛购买数据失败");
}
}).queryAsyncAll(VillusBuyEntity.class, builder);
}
/**
* 上传绒毛测量数据
*/
private void uploadVillusGauge() {
QueryBuilder<VillusGaugeEntity> builder =
DbUtil.getInstance().getQueryBuilder(VillusGaugeEntity.class).
where(VillusGaugeEntityDao.Properties.Status.eq("1"));
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<VillusGaugeEntity>() {
@Override
public void onSuccess(List<VillusGaugeEntity> result) {
isVillusGaugeUpload = true;
if (result != null && result.size() > 0) {
KLog.e(result.toString());
String postInfoStr =
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<VillusGaugeEntity>>(result));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitVillusGauge(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传绒毛测量数据..."))
.subscribe((Consumer<CattleResponse<List<VillusGaugeEntity>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
dismissDialog();
if (response.getCode() == 0) {
for (VillusGaugeEntity villusGaugeEntity : result) {
villusGaugeEntity.setStatus(0);
}
}).queryAsyncAll(Harmless.class, builder);
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
DbUtil.getInstance().deleteAll(VillusGaugeEntity.class);
} else {
ToastUtils.showShort("删除绒毛测量数据失败");
}
uploadNext();
}
}).updateAsyncBatch(VillusGaugeEntity.class, result);
} else {
ToastUtils.showShort("上传绒毛测量数据失败");
uploadNext();
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
uploadNext();
})
);
} else {
uploadNext();
}
}
@Override
public void onFailed() {
ToastUtils.showShort("查询绒毛测量数据失败");
}
}).queryAsyncAll(VillusGaugeEntity.class, builder);
}
}
package com.phlx.wool.ui.villus;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.SpinnerAdapter;
import androidx.lifecycle.ViewModelProviders;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.phlx.wool.R;
import com.phlx.wool.data.VMFactory;
import com.phlx.wool.databinding.ActivityVillusBuyBinding;
import com.phlx.wool.ui.base.BaseActivity;
import java.util.Date;
import me.tatarka.bindingcollectionadapter2.BR;
public class VillusBuyActivity extends BaseActivity<ActivityVillusBuyBinding, VillusBuyVM> {
private TimePickerView pvTime;
@Override
public int initContentView(Bundle savedInstanceState) {
return R.layout.activity_villus_buy;
}
@Override
public int initVariableId() {
return BR.viewModel;
}
@Override
public void initParam() {
super.initParam();
}
@Override
public VillusBuyVM initViewModel() {
VMFactory factory = VMFactory.getInstance(getApplication());
return ViewModelProviders.of(this, factory).get(VillusBuyVM.class);
}
@Override
public void initData() {
super.initData();
viewModel.initToolbar();
initTimePicker();
}
@Override
public void initViewObservable() {
super.initViewObservable();
viewModel.buyDay.observe(this, aBoolean -> {
pvTime.show(binding.birthDayTv);
});
viewModel.changeDivision.observe(this, aBoolean -> {
SpinnerAdapter spa = binding.divisionSp.getAdapter();
if (spa != null)
spa.notify();
});
}
private void initTimePicker() {//Dialog 模式下,在底部弹出
pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date, View v) {
viewModel.setBuyDate(date);
}
})
.setTimeSelectChangeListener(new OnTimeSelectChangeListener() {
@Override
public void onTimeSelectChanged(Date date) {
}
})
.setType(new boolean[]{true, true, true, true, true, true})
.isDialog(true) //默认设置false ,内部实现将DecorView 作为它的父控件。
.addOnCancelClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i("pvTime", "onCancelClickListener");
}
})
.setItemVisibleCount(5) //若设置偶数,实际值会加1(比如设置6,则最大可见条目为7)
.setLineSpacingMultiplier(2.0f)
.isAlphaGradient(true)
.build();
Dialog mDialog = pvTime.getDialog();
if (mDialog != null) {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
params.leftMargin = 0;
params.rightMargin = 0;
pvTime.getDialogContainerLayout().setLayoutParams(params);
Window dialogWindow = mDialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setWindowAnimations(com.bigkoo.pickerview.R.style.picker_view_slide_anim);//修改动画样式
dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
dialogWindow.setDimAmount(0.3f);
}
}
}
}
package com.phlx.wool.ui.villus;
import android.app.Application;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.phlx.wool.Configs;
import com.phlx.wool.data.Repository;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.db.interf.DbIDUCallBack;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Marking;
import com.phlx.wool.entity.Variety;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.event.EventMsg;
import com.phlx.wool.event.EventTag;
import com.phlx.wool.params.CattleResponse;
import com.phlx.wool.params.UploadParams;
import com.phlx.wool.ui.base.BackBarVM;
import com.phlx.wool.widget.ItemData;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.binding.command.BindingConsumer;
import me.goldze.mvvmhabit.binding.viewadapter.spinner.IKeyAndValue;
import me.goldze.mvvmhabit.bus.RxBus;
import me.goldze.mvvmhabit.bus.RxSubscriptions;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import me.goldze.mvvmhabit.http.ResponseThrowable;
import me.goldze.mvvmhabit.utils.KLog;
import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.SPUtils;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class VillusBuyVM extends BackBarVM<Repository> {
public VillusBuyEntity entity;
public List<IKeyAndValue> superiorPertainItemData;
public List<IKeyAndValue> pertainItemData;
private List<VillusBuyEntity> uploadData;
public SingleLiveEvent<Boolean> buyDay = new SingleLiveEvent<>();
public SingleLiveEvent<Boolean> changeDivision = new SingleLiveEvent<>();
private SimpleDateFormat dateFormat;
private Disposable inventoryBus;
public VillusBuyVM(@NonNull Application application, Repository model) {
super(application, model);
if (entity == null) {
entity = new VillusBuyEntity();
}
dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date _date = new Date();
entity.setBuyBatch(dateFormat.format(_date) + "-" + SPUtils.getInstance().getString(Configs.SP_ID));
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
superiorPertainItemData = new ArrayList<>();
List<DivisionEntity> superiorDivisionEntities = model.getPertain("152900");
if (superiorDivisionEntities != null && superiorDivisionEntities.size() > 0) {
for (DivisionEntity divisionEntity : superiorDivisionEntities) {
superiorPertainItemData.add(new ItemData(divisionEntity.getName(), divisionEntity.getCode()));
}
}
pertainItemData = new ArrayList<>();
if (superiorDivisionEntities != null && superiorDivisionEntities.size() > 0) {
List<DivisionEntity> divisionEntities = model.getPertain(superiorDivisionEntities.get(0).getCode());
if (divisionEntities != null && divisionEntities.size() > 0) {
for (DivisionEntity divisionEntity : divisionEntities) {
pertainItemData.add(new ItemData(divisionEntity.getName(), divisionEntity.getCode()));
}
}
}
}
//初始化ToolBar
public void initToolbar() {
setBackTitleText("绒毛购买");
setSettingVisibleObservable(View.GONE);
setBackRightTextVisible(View.VISIBLE);
setBackRightText("保存");
}
//出生日期
public BindingCommand onBuyDateClick = new BindingCommand(() -> buyDay.call());
public void setBuyDate(Date date) {
entity.setBuyDate(dateFormat.format(date));
entity.notifyChange();
}
public BindingCommand<IKeyAndValue> onSuperiorPertainSelectorCommand =
new BindingCommand<>(new BindingConsumer<IKeyAndValue>() {
@Override
public void call(IKeyAndValue iKeyAndValue) {
pertainItemData = new ArrayList<>();
List<DivisionEntity> divisionEntities = model.getPertain(iKeyAndValue.getValue());
pertainItemData.clear();
if (divisionEntities != null && divisionEntities.size() > 0) {
for (DivisionEntity divisionEntity : divisionEntities) {
pertainItemData.add(new ItemData(divisionEntity.getName(), divisionEntity.getCode()));
}
}
// changeDivision.call();
// pertainItemData.notifyAll();
}
});
public BindingCommand<IKeyAndValue> onPertainSelectorCommand =
new BindingCommand<>(new BindingConsumer<IKeyAndValue>() {
@Override
public void call(IKeyAndValue iKeyAndValue) {
entity.setRevision(iKeyAndValue.getValue());
}
});
/**
* 离线保存本地,在线先上传,后保存本地
*/
@Override
protected void backRightTextOnClick() {
if (StringUtils.isEmpty(entity.getBuyDate())) {
ToastUtils.showShort("请选择收购日期");
return;
}
if (StringUtils.isEmpty(entity.getRevision())) {
ToastUtils.showShort("请选择所属苏木");
return;
}
if (StringUtils.isEmpty(entity.getBuyFactory())) {
ToastUtils.showShort("请填写收购厂家");
return;
}
if (StringUtils.isEmpty(entity.getBuyWeight())) {
ToastUtils.showShort("请填写收购重量");
return;
}
if (StringUtils.isEmpty(entity.getPersonInCharge())) {
ToastUtils.showShort("请填写负责人");
return;
}
uploadData = new ArrayList<>();
entity.setId(IdUtil.createSnowflake(3, 1).nextId());
entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME));
entity.setCreateTime(dateFormat.format(new Date()));
entity.setStatus(1);
uploadData.add(entity);
KLog.e(uploadData.size() + uploadData.toString());
/**
* 存储数据库
*/
showDialog("正在保存本地...");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
if (Configs.isOnLine) {
uploadVillusBuy();
} else {
backMain();
}
}
}
}).insertAsyncBatch(VillusBuyEntity.class, uploadData);
}
private void uploadVillusBuy() {
String postInfoStr =
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<VillusBuyEntity>>(uploadData));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitVillusBuy(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传绒毛购买数据..."))
.subscribe((Consumer<CattleResponse<List<VillusBuyEntity>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
if (response.getCode() == 0) {
for (int i = 0; i < uploadData.size(); i++) {
uploadData.get(i).setStatus(0);
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
backMain();
}
}
}).deleteAsyncBatch(VillusBuyEntity.class, uploadData);
} else {
dismissDialog();
ToastUtils.showShort("上传失败");
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
})
);
}
private void backMain() {
finish();
}
@Override
public void registerRxBus() {
super.registerRxBus();
inventoryBus =
RxBus.getDefault().toObservable(EventMsg.class).subscribe(eventType -> {
if (eventType.getAction().equals(EventTag.EVENT_INVENTORY_DATA)) {
}
});
RxSubscriptions.add(inventoryBus);
}
@Override
public void removeRxBus() {
super.removeRxBus();
RxSubscriptions.remove(inventoryBus);
}
}
package com.phlx.wool.ui.villus;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import androidx.lifecycle.ViewModelProviders;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.phlx.wool.R;
import com.phlx.wool.data.VMFactory;
import com.phlx.wool.databinding.ActivityVillusGaugeBinding;
import com.phlx.wool.ui.base.BaseActivity;
import java.util.Date;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.tatarka.bindingcollectionadapter2.BR;
public class VillusGaugeActivity extends BaseActivity<ActivityVillusGaugeBinding, VillusGaugeVM> {
private TimePickerView pvTime;
@Override
public int initContentView(Bundle savedInstanceState) {
return R.layout.activity_villus_gauge;
}
@Override
public int initVariableId() {
return BR.viewModel;
}
@Override
public void initParam() {
super.initParam();
}
@Override
public VillusGaugeVM initViewModel() {
VMFactory factory = VMFactory.getInstance(getApplication());
return ViewModelProviders.of(this, factory).get(VillusGaugeVM.class);
}
@Override
public void initData() {
super.initData();
viewModel.initToolbar();
initTimePicker();
}
@Override
public void initViewObservable() {
super.initViewObservable();
viewModel.gaugeDay.observe(this, aBoolean -> {
pvTime.show(binding.gaugeDayTv);
});
}
private void initTimePicker() {//Dialog 模式下,在底部弹出
pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date, View v) {
viewModel.setGaugeDate(date);
}
})
.setTimeSelectChangeListener(new OnTimeSelectChangeListener() {
@Override
public void onTimeSelectChanged(Date date) {
}
})
.setType(new boolean[]{true, true, true, true, true, true})
.isDialog(true) //默认设置false ,内部实现将DecorView 作为它的父控件。
.addOnCancelClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i("pvTime", "onCancelClickListener");
}
})
.setItemVisibleCount(5) //若设置偶数,实际值会加1(比如设置6,则最大可见条目为7)
.setLineSpacingMultiplier(2.0f)
.isAlphaGradient(true)
.build();
Dialog mDialog = pvTime.getDialog();
if (mDialog != null) {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
params.leftMargin = 0;
params.rightMargin = 0;
pvTime.getDialogContainerLayout().setLayoutParams(params);
Window dialogWindow = mDialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setWindowAnimations(com.bigkoo.pickerview.R.style.picker_view_slide_anim);//修改动画样式
dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
dialogWindow.setDimAmount(0.3f);
}
}
}
}
package com.phlx.wool.ui.villus;
import android.app.Application;
import android.view.View;
import androidx.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.phlx.wool.Configs;
import com.phlx.wool.data.Repository;
import com.phlx.wool.db.DbUtil;
import com.phlx.wool.db.interf.DbIDUCallBack;
import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.CattleResponse;
import com.phlx.wool.params.UploadParams;
import com.phlx.wool.ui.base.BackBarVM;
import com.phlx.wool.widget.ItemData;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import io.reactivex.functions.Consumer;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.binding.command.BindingConsumer;
import me.goldze.mvvmhabit.binding.viewadapter.spinner.IKeyAndValue;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import me.goldze.mvvmhabit.http.ResponseThrowable;
import me.goldze.mvvmhabit.utils.KLog;
import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.SPUtils;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class VillusGaugeVM extends BackBarVM<Repository> {
public VillusGaugeEntity entity;
public List<IKeyAndValue> batchItemData;
public SingleLiveEvent<Boolean> gaugeDay = new SingleLiveEvent<>();
private SimpleDateFormat dateFormat;
private List<VillusGaugeEntity> uploadData;
public VillusGaugeVM(@NonNull Application application, Repository model) {
super(application, model);
if (entity == null) {
entity = new VillusGaugeEntity();
}
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
batchItemData = new ArrayList<>();
List<VillusBuyEntity> villusBuyEntities = model.getVillusBuy();
if (villusBuyEntities != null && villusBuyEntities.size() > 0) {
for (VillusBuyEntity villusBuyEntity : villusBuyEntities) {
batchItemData.add(new ItemData(villusBuyEntity.getBuyBatch(), villusBuyEntity.getBuyBatch()));
}
}
}
//初始化ToolBar
public void initToolbar() {
setBackTitleText("绒毛测量");
setSettingVisibleObservable(View.GONE);
setBackRightTextVisible(View.VISIBLE);
setBackRightText("保存");
}
//出生日期
public BindingCommand onGaugeDateClick = new BindingCommand(() -> gaugeDay.call());
public void setGaugeDate(Date date) {
entity.setMeasuringTime(dateFormat.format(date));
entity.notifyChange();
}
public BindingCommand<IKeyAndValue> onGaugeSelectorCommand =
new BindingCommand<>(new BindingConsumer<IKeyAndValue>() {
@Override
public void call(IKeyAndValue iKeyAndValue) {
entity.setBuyBatch(iKeyAndValue.getValue());
}
});
/**
* 离线保存本地,在线先上传,后保存本地
*/
@Override
protected void backRightTextOnClick() {
if (StringUtils.isEmpty(entity.getBuyBatch())) {
ToastUtils.showShort("请选择收购批次");
return;
}
if (StringUtils.isEmpty(entity.getMeasuringTime())) {
ToastUtils.showShort("请选择测量日期");
return;
}
if (StringUtils.isEmpty(entity.getDiameter())) {
ToastUtils.showShort("请填写直径");
return;
}
if (StringUtils.isEmpty(entity.getLength())) {
ToastUtils.showShort("请填写长度");
return;
}
if (StringUtils.isEmpty(entity.getLenghtRsd())) {
ToastUtils.showShort("请填写长度变异系数");
return;
}
if (StringUtils.isEmpty(entity.getVillusStraightLong())) {
ToastUtils.showShort("请填写绒伸直长");
return;
}
uploadData = new ArrayList<>();
entity.setId(IdUtil.createSnowflake(3, 1).nextId());
entity.setCreateBy(SPUtils.getInstance().getString(Configs.SP_NAME));
entity.setCreateTime(dateFormat.format(new Date()));
entity.setStatus(1);
uploadData.add(entity);
KLog.e(uploadData.size() + uploadData.toString());
/**
* 存储数据库
*/
showDialog("正在保存本地...");
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
if (Configs.isOnLine) {
uploadVillusGauge();
} else {
backMain();
}
}
}
}).insertAsyncBatch(VillusGaugeEntity.class, uploadData);
}
private void uploadVillusGauge() {
String postInfoStr =
new GsonBuilder().serializeNulls()
// .excludeFieldsWithoutExposeAnnotation()
.create().toJson(new UploadParams<List<VillusGaugeEntity>>(uploadData));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postInfoStr);
KLog.e(postInfoStr);
addSubscribe(model.submitVillusGauge(body)
.compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.doOnSubscribe(disposable -> showDialog("正在上传绒毛测量数据..."))
.subscribe((Consumer<CattleResponse<List<VillusBuyEntity>>>) response -> {
KLog.e(response.getCode() + response.getMsg());
if (response.getCode() == 0) {
for (int i = 0; i < uploadData.size(); i++) {
uploadData.get(i).setStatus(0);
}
DbUtil.getInstance().setDbIDUCallBack(new DbIDUCallBack() {
@Override
public void onNotification(boolean result) {
if (result) {
dismissDialog();
backMain();
}
}
}).deleteAsyncBatch(VillusGaugeEntity.class, uploadData);
} else {
dismissDialog();
ToastUtils.showShort("上传失败");
}
}, (Consumer<ResponseThrowable>) throwable -> {
dismissDialog();
ToastUtils.showShort(throwable.message);
})
);
}
private void backMain() {
finish();
}
}
......@@ -21,7 +21,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_200"
android:layout_height="@dimen/dp_250"
android:layout_marginStart="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginEnd="@dimen/dp_15"
......@@ -68,6 +68,32 @@
binding:layout_constraintTop_toBottomOf="@+id/marking_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onClearQuarantineCommand}" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_buy_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearVillusBuy}"
android:text="绒毛购买"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/harmless_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/harmless_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onVillusBuyCommand}" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_gauge_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isClearVillusGauge}"
android:text="绒毛测量"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/quarantine_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/quarantine_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onVillusGaugeCommand}" />
<View
android:id="@+id/clear_line"
......@@ -78,7 +104,7 @@
android:layout_marginEnd="@dimen/dp_10"
android:background="@color/setting_bg"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/quarantine_info_desc" />
binding:layout_constraintTop_toBottomOf="@+id/villus_gauge_desc" />
<androidx.appcompat.widget.AppCompatCheckBox
......
......@@ -82,8 +82,33 @@
binding:layout_constraintStart_toStartOf="@+id/breed_unit_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/breed_unit_info_desc" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_buy_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:text="绒毛购买"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
android:checked="@{viewModel.isDownloadVillusBuy}"
binding:onCheckedChangedCommand="@{viewModel.onDownloadVillusBuyCommand}"
binding:layout_constraintStart_toStartOf="@+id/basic_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/basic_info_desc" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_gauge_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:text="绒毛测量"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
android:checked="@{viewModel.isDownloadVillusGauge}"
binding:onCheckedChangedCommand="@{viewModel.onDownloadVillusGaugeCommand}"
binding:layout_constraintStart_toStartOf="@+id/veterinary_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/veterinary_info_desc" />
<View
android:id="@+id/clear_line"
......@@ -94,8 +119,7 @@
android:layout_marginEnd="@dimen/dp_10"
android:background="@color/setting_bg"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/basic_info_desc" />
binding:layout_constraintTop_toBottomOf="@+id/villus_buy_desc" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/all_selected_desc"
......
......@@ -120,6 +120,8 @@
android:id="@+id/et_inv_desc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/input_frame_bg"
android:gravity="center_vertical"
binding:layout_constraintLeft_toRightOf="@+id/inventory_epc_tip_desc"
binding:layout_constraintRight_toLeftOf="@+id/progress_bar"
binding:layout_constraintTop_toTopOf="@+id/inventory_epc_tip_desc"
......
......@@ -156,6 +156,33 @@
binding:layout_constraintTop_toBottomOf="@+id/data_line"
binding:onClickCommand="@{viewModel.OnHarmlessClickCommand}" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/villus_buy_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:drawableTop="@mipmap/ic_harmless"
android:drawablePadding="@dimen/dp_10"
android:text="@string/villus_buy"
android:textSize="@dimen/main_btn_size"
binding:layout_constraintStart_toStartOf="@+id/select_unit_btn"
binding:layout_constraintTop_toBottomOf="@+id/marking_btn"
binding:onClickCommand="@{viewModel.OnVillusBuyClickCommand}" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/villus_gauge_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_10"
android:drawableTop="@mipmap/ic_harmless"
android:drawablePadding="@dimen/dp_10"
android:text="@string/villus_gauge"
android:textSize="@dimen/main_btn_size"
binding:layout_constraintStart_toEndOf="@+id/villus_buy_btn"
binding:layout_constraintTop_toBottomOf="@+id/marking_btn"
binding:onClickCommand="@{viewModel.OnVillusGaugeClickCommand}" />
<View
android:id="@+id/sync_tip_line"
......@@ -165,7 +192,7 @@
android:layout_marginTop="@dimen/dp_15"
android:background="#ff3c3c"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/marking_btn" />
binding:layout_constraintTop_toBottomOf="@+id/villus_buy_btn" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/sync_tip_desc"
......@@ -177,7 +204,7 @@
android:textColor="@color/black"
android:textSize="@dimen/sp_14"
binding:layout_constraintStart_toEndOf="@id/sync_tip_line"
binding:layout_constraintTop_toBottomOf="@+id/marking_btn" />
binding:layout_constraintTop_toBottomOf="@+id/villus_buy_btn" />
<View
android:id="@+id/sync_line"
......
......@@ -21,7 +21,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_200"
android:layout_height="@dimen/dp_250"
android:layout_marginStart="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginEnd="@dimen/dp_15"
......@@ -68,6 +68,33 @@
binding:layout_constraintTop_toBottomOf="@+id/marking_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onUploadQuarantineCommand}" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_buy_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_20"
android:checked="@{viewModel.isUploadVillusBuy}"
android:text="绒毛购买"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/harmless_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/harmless_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onUploadVillusBuyCommand}" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/villus_gauge_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:checked="@{viewModel.isUploadVillusGauge}"
android:text="绒毛测量"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintStart_toStartOf="@id/marking_info_desc"
binding:layout_constraintTop_toBottomOf="@+id/quarantine_info_desc"
binding:onCheckedChangedCommand="@{viewModel.onUploadVillusGaugeCommand}" />
<View
android:id="@+id/clear_line"
......@@ -78,7 +105,7 @@
android:layout_marginEnd="@dimen/dp_10"
android:background="@color/setting_bg"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/quarantine_info_desc" />
binding:layout_constraintTop_toBottomOf="@+id/villus_gauge_desc" />
<androidx.appcompat.widget.AppCompatCheckBox
......
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:binding="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.phlx.wool.ui.villus.VillusBuyVM" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include"
layout="@layout/layout_back_bar"
binding:backBarVM="@{viewModel.backBarVM}" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0"
binding:layout_constraintBottom_toBottomOf="parent"
binding:layout_constraintEnd_toEndOf="parent"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/include">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_30">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/marking_guideline_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
binding:layout_constraintGuide_begin="69dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/veterinary_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buy_batch"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/veterinary_edit"
binding:layout_constraintBottom_toTopOf="@+id/birth_day_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/birth_day_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buy_day"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/birth_day_tv"
binding:layout_constraintBottom_toTopOf="@+id/l_variety_selected_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/veterinary_selected_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/l_variety_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/superior_pertain"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBottom_toTopOf="@+id/variety_selected_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_day_desc" />
<Spinner
android:id="@+id/superior_division_sp"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:minHeight="@dimen/dp_40"
android:spinnerMode="dialog"
binding:itemDatas="@{viewModel.superiorPertainItemData}"
binding:layout_constraintBottom_toTopOf="@+id/variety_sp"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_day_tv"
binding:onItemSelectedCommand="@{viewModel.onSuperiorPertainSelectorCommand}"
binding:valueReply="@{viewModel.entity.revision}" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/variety_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pertain"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBottom_toTopOf="@+id/birth_place_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/l_variety_selected_desc" />
<Spinner
android:id="@+id/division_sp"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:minHeight="@dimen/dp_40"
android:spinnerMode="dialog"
binding:itemDatas="@{viewModel.pertainItemData}"
binding:layout_constraintBottom_toTopOf="@+id/birth_place_edit"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/superior_division_sp"
binding:onItemSelectedCommand="@{viewModel.onPertainSelectorCommand}"
binding:valueReply="@{viewModel.entity.revision}" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/birth_place_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buy_factory"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/birth_place_edit"
binding:layout_constraintBottom_toTopOf="@+id/weight_selected_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/variety_selected_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/weight_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buy_weight"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/weight_edit"
binding:layout_constraintBottom_toTopOf="@+id/breed_sheep_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_place_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/parity_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/person_in_charge"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/parity_edit"
binding:layout_constraintBottom_toTopOf="@+id/twin_sheep_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/weight_selected_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/veterinary_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:gravity="center_vertical"
android:hint="请输入收购批次"
android:text="@={viewModel.entity.buyBatch}"
android:textSize="@dimen/edit_size"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/birth_day_tv"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:drawableEnd="@mipmap/ic_date_btn"
android:drawablePadding="@dimen/dp_3"
android:gravity="center_vertical"
android:hint="请选择收购日期"
android:text="@={viewModel.entity.buyDate}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/superior_division_sp"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/veterinary_edit"
binding:onClickCommand="@{viewModel.onBuyDateClick}" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/birth_place_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入收购厂家"
android:maxLines="1"
android:text="@={viewModel.entity.buyFactory}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/weight_edit"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/division_sp" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/weight_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入重量"
android:inputType="numberDecimal"
android:maxLines="1"
android:text="@={viewModel.entity.buyWeight}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/breed_sheep_cb"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_place_edit" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/parity_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入负责人"
android:maxLines="1"
android:text="@={viewModel.entity.personInCharge}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/twin_sheep_cb"
binding:layout_constraintHorizontal_bias="0.0"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/weight_edit" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:binding="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.phlx.wool.ui.villus.VillusGaugeVM" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include"
layout="@layout/layout_back_bar"
binding:backBarVM="@{viewModel.backBarVM}" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0"
binding:layout_constraintBottom_toBottomOf="parent"
binding:layout_constraintEnd_toEndOf="parent"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/include">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_30">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/marking_guideline_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
binding:layout_constraintGuide_percent="0.33029154" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/veterinary_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buy_batch"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBottom_toTopOf="@+id/birth_day_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/birth_day_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gauge_day"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/gauge_day_tv"
binding:layout_constraintBottom_toTopOf="@+id/l_variety_selected_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/veterinary_selected_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/birth_place_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/diameter"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/birth_place_edit"
binding:layout_constraintBottom_toTopOf="@+id/weight_selected_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_day_desc" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/weight_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/length"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/weight_edit"
binding:layout_constraintBottom_toTopOf="@+id/breed_sheep_desc"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_place_desc" />
<Spinner
android:id="@+id/buy_batch_sp"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:minHeight="@dimen/dp_40"
android:spinnerMode="dialog"
binding:itemDatas="@{viewModel.batchItemData}"
binding:layout_constraintHorizontal_bias="0.0"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toTopOf="parent"
binding:onItemSelectedCommand="@{viewModel.onGaugeSelectorCommand}"
binding:valueReply="@{viewModel.entity.buyBatch}" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gauge_day_tv"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:drawableEnd="@mipmap/ic_date_btn"
android:drawablePadding="@dimen/dp_3"
android:gravity="center_vertical"
android:hint="请选择测量日期"
android:text="@={viewModel.entity.measuringTime}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/superior_division_sp"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/buy_batch_sp"
binding:onClickCommand="@{viewModel.onGaugeDateClick}" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/birth_place_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入直径"
android:inputType="numberDecimal"
android:maxLines="1"
android:text="@={viewModel.entity.diameter}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/weight_edit"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/gauge_day_tv" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/weight_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入长度"
android:inputType="numberDecimal"
android:maxLines="1"
android:text="@={viewModel.entity.length}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/breed_sheep_cb"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/birth_place_edit" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/parity_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/variation_length"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/parity_edit"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/weight_selected_desc" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/parity_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入变异系数"
android:inputType="numberDecimal"
android:maxLines="1"
android:text="@={viewModel.entity.lenghtRsd}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/twin_sheep_cb"
binding:layout_constraintHorizontal_bias="0.0"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/weight_edit" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/l_parity_selected_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/villus_length"
android:textColor="@color/black"
android:textSize="@dimen/desc_text_size"
binding:layout_constraintBaseline_toBaselineOf="@id/l_parity_edit"
binding:layout_constraintStart_toStartOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/parity_selected_desc" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/l_parity_edit"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/input_frame_bg"
android:hint="请输入绒伸直长度"
android:inputType="numberDecimal"
android:maxLines="1"
android:text="@={viewModel.entity.villusStraightLong}"
android:textSize="@dimen/edit_size"
binding:layout_constraintBottom_toTopOf="@+id/twin_sheep_cb"
binding:layout_constraintHorizontal_bias="0.0"
binding:layout_constraintLeft_toLeftOf="@+id/marking_guideline_vertical"
binding:layout_constraintRight_toRightOf="parent"
binding:layout_constraintTop_toBottomOf="@+id/parity_edit" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -12,12 +12,26 @@
<string name="marking">打标记录</string>
<string name="quarantine">检疫记录</string>
<string name="harmless">无害化处理</string>
<string name="villus_buy">绒毛收购</string>
<string name="villus_gauge">绒毛测量</string>
<string name="download">下载数据</string>
<string name="upload">上传数据</string>
<string name="re_login">重新登录</string>
<string name="clear_data">清空数据</string>
<string name="select_unit">养殖单位</string>
<string name="veterinary">兽医</string>
<string name="buy_batch">收购批次</string>
<string name="superior_pertain">所属旗</string>
<string name="pertain">所属苏木</string>
<string name="buy_day">收购日期</string>
<string name="buy_weight">收购重量</string>
<string name="buy_factory">收购厂家</string>
<string name="person_in_charge">负责人</string>
<string name="gauge_day">测量日期</string>
<string name="diameter">直径μm</string>
<string name="length">长度cm</string>
<string name="variation_length">长度变异系数</string>
<string name="villus_length">绒伸直长cm</string>
<string name="birth_day">出生日期</string>
<string name="variety">品种</string>
<string name="birth_place">出生地</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