修复问题
This commit is contained in:
parent
9c7bb9e568
commit
c2f2e44c42
|
@ -81,7 +81,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
||||||
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
||||||
+ COLUMN_TURBINE_NAME + " TEXT,"
|
+ COLUMN_TURBINE_NAME + " TEXT,"
|
||||||
+ COLUMN_PROJECT_NAME + " TEXT,"
|
+ COLUMN_PROJECT_ID + " TEXT,"
|
||||||
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
||||||
db.execSQL(CREATE_TURBINE_TABLE);
|
db.execSQL(CREATE_TURBINE_TABLE);
|
||||||
String CREATE_PARTS_TABLE = "CREATE TABLE " + TABLE_PARTS + "("
|
String CREATE_PARTS_TABLE = "CREATE TABLE " + TABLE_PARTS + "("
|
||||||
|
@ -169,7 +169,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
||||||
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
||||||
+ COLUMN_TURBINE_NAME + " TEXT,"
|
+ COLUMN_TURBINE_NAME + " TEXT,"
|
||||||
+ COLUMN_PROJECT_NAME + " TEXT,"
|
+ COLUMN_PROJECT_ID + " TEXT,"
|
||||||
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
||||||
db.execSQL(CREATE_TURBINE_TABLE);
|
db.execSQL(CREATE_TURBINE_TABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,8 +315,8 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
private static final String PREF_REMEMBER = "remember";
|
private static final String PREF_REMEMBER = "remember";
|
||||||
private final String AUTH_TOKEN_KEY = "auth_token";
|
private final String AUTH_TOKEN_KEY = "auth_token";
|
||||||
private String authToken = "";
|
private String authToken = "";
|
||||||
private final String BASE_URL = "http://10.2.1.20:8888";
|
// private final String BASE_URL = "http://10.2.1.20:8888";
|
||||||
// private final String BASE_URL = "http://pms.dtyx.net:9158";
|
private final String BASE_URL = "http://pms.dtyx.net:9158";
|
||||||
|
|
||||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||||
@Override
|
@Override
|
||||||
|
@ -469,6 +469,10 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearProject() {
|
private void clearProject() {
|
||||||
|
projectId = "";
|
||||||
|
projectName = "";
|
||||||
|
sharedPreferences.edit().putString(PREF_PROJECT, "").apply();
|
||||||
|
dataManager.setProjectId("");
|
||||||
actvProject.setText("");
|
actvProject.setText("");
|
||||||
loadProjects();
|
loadProjects();
|
||||||
projectAdapter.getFilter().filter("");
|
projectAdapter.getFilter().filter("");
|
||||||
|
@ -477,6 +481,11 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearTurbine() {
|
private void clearTurbine() {
|
||||||
|
turbineId = "";
|
||||||
|
turbineName = "";
|
||||||
|
sharedPreferences.edit().putString(PREF_TURBINE, "").apply();
|
||||||
|
dataManager.setTurbineId("");
|
||||||
|
dataManager.setTurbineName("");
|
||||||
actvTurbine.setText("");
|
actvTurbine.setText("");
|
||||||
loadTurbines();
|
loadTurbines();
|
||||||
turbineAdapter.getFilter().filter("");
|
turbineAdapter.getFilter().filter("");
|
||||||
|
@ -484,6 +493,11 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearPart() {
|
private void clearPart() {
|
||||||
|
partId = "";
|
||||||
|
partName = "";
|
||||||
|
sharedPreferences.edit().putString(PREF_PART, "").apply();
|
||||||
|
dataManager.setPartId("");
|
||||||
|
dataManager.setPartName("");
|
||||||
actvPart.setText("");
|
actvPart.setText("");
|
||||||
loadParts();
|
loadParts();
|
||||||
partAdapter.getFilter().filter("");
|
partAdapter.getFilter().filter("");
|
||||||
|
@ -552,21 +566,10 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Retrofit initRetrofit() {
|
|
||||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
|
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(30, TimeUnit.SECONDS);
|
|
||||||
okHttpClientBuilder.addInterceptor(new AuthInterceptor(authToken));
|
|
||||||
// 2. 初始化Retrofit
|
|
||||||
|
|
||||||
return RetrofitClient.getClient(authToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadProjects() {
|
private void loadProjects() {
|
||||||
try {
|
try {
|
||||||
// 2. 初始化Retrofit
|
// 2. 初始化Retrofit
|
||||||
Retrofit retrofit = initRetrofit();
|
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||||
// 3. 创建API服务
|
// 3. 创建API服务
|
||||||
ProjectApi projectApi = retrofit.create(ProjectApi.class);
|
ProjectApi projectApi = retrofit.create(ProjectApi.class);
|
||||||
// 4. 执行网络请求
|
// 4. 执行网络请求
|
||||||
|
@ -584,7 +587,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 2. 初始化Retrofit
|
// 2. 初始化Retrofit
|
||||||
Retrofit retrofit = initRetrofit();
|
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||||
// 3. 创建API服务
|
// 3. 创建API服务
|
||||||
TurbineApiService turbine = retrofit.create(TurbineApiService.class);
|
TurbineApiService turbine = retrofit.create(TurbineApiService.class);
|
||||||
// 4. 执行网络请求
|
// 4. 执行网络请求
|
||||||
|
@ -602,7 +605,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 2. 初始化Retrofit
|
// 2. 初始化Retrofit
|
||||||
Retrofit retrofit = initRetrofit();
|
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||||
// 3. 创建API服务
|
// 3. 创建API服务
|
||||||
PartService part = retrofit.create(PartService.class);
|
PartService part = retrofit.create(PartService.class);
|
||||||
// 4. 执行网络请求
|
// 4. 执行网络请求
|
||||||
|
@ -892,7 +895,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executePartRequest(PartService partApi) {
|
private void executePartRequest(PartService partApi) {
|
||||||
retrofit2.Call<ApiResponse<List<PartResponse>>> call = partApi.getPartList(projectId, null, null, null, null);
|
retrofit2.Call<ApiResponse<List<PartResponse>>> call = partApi.getPartList(projectId, turbineId, null, null, null, null);
|
||||||
|
|
||||||
call.enqueue(new retrofit2.Callback<>() {
|
call.enqueue(new retrofit2.Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -122,8 +122,7 @@ public class PartListFetcher {
|
||||||
}
|
}
|
||||||
private List<PartResponse> fetchFromServer() throws IOException, ApiException {
|
private List<PartResponse> fetchFromServer() throws IOException, ApiException {
|
||||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||||
projectId,
|
projectId, null,
|
||||||
|
|
||||||
null, null, null, null
|
null, null, null, null
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -143,7 +142,7 @@ public class PartListFetcher {
|
||||||
}
|
}
|
||||||
private void fetchFromServerAsync(final PartListCallback callback) {
|
private void fetchFromServerAsync(final PartListCallback callback) {
|
||||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||||
projectId,
|
projectId, null,
|
||||||
|
|
||||||
null, null, null, null
|
null, null, null, null
|
||||||
|
|
||||||
|
@ -194,7 +193,7 @@ public class PartListFetcher {
|
||||||
PartListCallback callback) {
|
PartListCallback callback) {
|
||||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||||
projectId,
|
projectId,
|
||||||
|
null,
|
||||||
keyword,
|
keyword,
|
||||||
manufacturer,
|
manufacturer,
|
||||||
model,
|
model,
|
||||||
|
|
|
@ -13,6 +13,7 @@ public interface PartService {
|
||||||
@GET("/part/list")
|
@GET("/part/list")
|
||||||
Call<ApiResponse<List<PartResponse>>> getPartList(
|
Call<ApiResponse<List<PartResponse>>> getPartList(
|
||||||
@Query("projectId") String projectId,
|
@Query("projectId") String projectId,
|
||||||
|
@Query("turbineId") String turbineId,
|
||||||
@Query("keyword") String keyword,
|
@Query("keyword") String keyword,
|
||||||
@Query("partManufacturer") String partManufacturer,
|
@Query("partManufacturer") String partManufacturer,
|
||||||
@Query("partModel") String partModel,
|
@Query("partModel") String partModel,
|
||||||
|
|
|
@ -17,8 +17,8 @@ dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
maven("https://maven.aliyun.com/repository/google")
|
||||||
maven { url = uri("https://chaquo.com/maven") }
|
maven("https://maven.aliyun.com/repository/central")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue