・重複時のダイアログに保護者の情報が表示されるように調整しました。 #50
|
@ -42,13 +42,14 @@ public class CreateSchedule {
|
||||||
private final AppDatabase db;
|
private final AppDatabase db;
|
||||||
private int arraySizeInt;
|
private int arraySizeInt;
|
||||||
|
|
||||||
boolean notSecondDuplicatesBoolean = true;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
|
private boolean notSecondDuplicatesBoolean;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
|
||||||
|
|
||||||
String[] homeVisitDaysString;
|
String[] homeVisitDaysString;
|
||||||
|
|
||||||
|
|
||||||
public CreateSchedule(AppCompatActivity activity) {
|
public CreateSchedule(AppCompatActivity activity) {
|
||||||
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
|
this.notSecondDuplicatesBoolean = true; // 初期値をtrueに設定する
|
||||||
SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
|
||||||
|
|
||||||
String firstDay = sharedPreferences.getString("day1", null);
|
String firstDay = sharedPreferences.getString("day1", null);
|
||||||
|
@ -57,7 +58,6 @@ public class CreateSchedule {
|
||||||
|
|
||||||
Log.d("createSchedule","day1"+firstDay+"day2"+secondDay+"thirdday"+thirdDay);
|
Log.d("createSchedule","day1"+firstDay+"day2"+secondDay+"thirdday"+thirdDay);
|
||||||
homeVisitDaysString = new String[]{firstDay, secondDay, thirdDay};
|
homeVisitDaysString = new String[]{firstDay, secondDay, thirdDay};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MainActivityからデータを受け取る
|
//MainActivityからデータを受け取る
|
||||||
|
@ -116,17 +116,18 @@ public class CreateSchedule {
|
||||||
sortSchedule(myDataList);
|
sortSchedule(myDataList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//重複がなければ開始地点の緯度経度を返す
|
// 重複がなければ開始地点の緯度経度を返す
|
||||||
if (notSecondDuplicatesBoolean) {
|
if (notSecondDuplicatesBoolean) {
|
||||||
//保護者の住所を緯度経度に変換する
|
// 保護者の住所を緯度経度に変換する
|
||||||
String startPointLatLngString = geocodeAddress(myDataList, context);
|
String startPointLatLngString = geocodeAddress(myDataList, context);
|
||||||
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString);
|
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString);
|
||||||
outPutLogSchedule(myDataList);
|
outPutLogSchedule(myDataList);
|
||||||
return startPointLatLngString;
|
return startPointLatLngString;
|
||||||
|
} else {
|
||||||
|
// 重複があるときは""を返す
|
||||||
|
Log.d("CreateSchedule", "重複によるエラー");
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
//重複があるときは""を返す
|
|
||||||
Log.d("CreateSchedule", "重複によるエラー");
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -348,6 +349,7 @@ public class CreateSchedule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < myDataList.size(); i++) {
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認
|
if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class FirestoreReception {
|
||||||
//ClassIdを引数にデータの作成を行う
|
//ClassIdを引数にデータの作成を行う
|
||||||
public void getDocumentsByClassId(int classId) {
|
public void getDocumentsByClassId(int classId) {
|
||||||
myDataList.clear();
|
myDataList.clear();
|
||||||
CollectionReference collectionRef = db.collection("testAddressArray");
|
CollectionReference collectionRef = db.collection("testDistinct");
|
||||||
|
|
||||||
// classIdが引数のものを取得する
|
// classIdが引数のものを取得する
|
||||||
collectionRef.whereEqualTo("classId", classId).get()
|
collectionRef.whereEqualTo("classId", classId).get()
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
// firestoreの受信関連
|
// firestoreの受信関連
|
||||||
db = FirebaseFirestore.getInstance();
|
db = FirebaseFirestore.getInstance();
|
||||||
firestoreReception = new FirestoreReception();
|
firestoreReception = new FirestoreReception();
|
||||||
Log.d("MainActivity","geocodeAddress");
|
Log.d("MainActivity", "geocodeAddress");
|
||||||
|
|
||||||
|
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
@ -105,7 +105,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// クリック処理
|
// クリック処理
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -194,7 +193,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
AppDatabase db = getDatabaseInstance(); SetUpTableDao setUpTableDao = db.setUpTableDao();
|
AppDatabase db = getDatabaseInstance();
|
||||||
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
int totalStudentInt = setUpTableDao.getTotalStudent();
|
int totalStudentInt = setUpTableDao.getTotalStudent();
|
||||||
int myDataListSizeInt = firestoreReception.getMyDataListSize();
|
int myDataListSizeInt = firestoreReception.getMyDataListSize();
|
||||||
|
|
||||||
|
@ -245,10 +245,20 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
//final宣言することによって、スレッドセーフになる(ラムダ式内で使えるようにする)
|
//final宣言することによって、スレッドセーフになる(ラムダ式内で使えるようにする)
|
||||||
final List<MyDataClass> finalMyDataList = myDataList;
|
final List<MyDataClass> finalMyDataList = myDataList;
|
||||||
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
|
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
|
||||||
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
|
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
|
||||||
|
Boolean notDuplicatesBoolean = null;
|
||||||
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
|
if (myDataList.get(i).getSchedule() == 0) {
|
||||||
|
notDuplicatesBoolean = false;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
notDuplicatesBoolean = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean;
|
||||||
|
Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean));
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if ( !startPointLatLngString.equals("")) {
|
if (finalNotDuplicatesBoolean) {
|
||||||
Log.d("MainActivity", "スケジュール作成成功");
|
Log.d("MainActivity", "スケジュール作成成功");
|
||||||
saveMyDataList(finalMyDataList);
|
saveMyDataList(finalMyDataList);
|
||||||
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
||||||
|
@ -264,6 +274,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveMyDataList(List<MyDataClass> myDataList) {
|
private void saveMyDataList(List<MyDataClass> myDataList) {
|
||||||
// 共有プリファレンスのインスタンスを取得
|
// 共有プリファレンスのインスタンスを取得
|
||||||
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||||
|
@ -285,12 +296,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
studentNumbers.add(data.getStudentNumber());
|
studentNumbers.add(data.getStudentNumber());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。調整してください。\n出席番号: ");
|
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。保護者に連絡して調整してください。\n\n");
|
||||||
for (int i = 0; i < studentNumbers.size(); i++) {
|
for (int i = 0; i < studentNumbers.size(); i++) {
|
||||||
message.append(studentNumbers.get(i));
|
message.append("出席番号:" + studentNumbers.get(i));
|
||||||
if (i < studentNumbers.size() - 1) {
|
message.append("\n保護者名:" + myDataList.get(i).getPatronName());
|
||||||
message.append(", ");
|
message.append("\n第一希望 " + myDataList.get(i).getStartDateString().substring(4,6)+"月");
|
||||||
}
|
message.append(myDataList.get(i).getStartDateString().substring(6,8)+"日");
|
||||||
|
message.append(" " + myDataList.get(i).getParentStartTimeString().substring(0, 2));
|
||||||
|
message.append(":" + myDataList.get(i).getParentStartTimeString().substring(2, 4));
|
||||||
|
message.append("~" + myDataList.get(i).getParentEndTimeString().substring(0, 2));
|
||||||
|
message.append(":" + myDataList.get(i).getParentEndTimeString().substring(2, 4));
|
||||||
|
message.append("\n第二希望 " + myDataList.get(i).getSecondDayStartDateString().substring(4,6)+"月");
|
||||||
|
message.append(myDataList.get(i).getSecondDayStartDateString().substring(6,8)+"日");
|
||||||
|
message.append(" " + myDataList.get(i).getSecondDayParentStartTimeString().substring(0, 2));
|
||||||
|
message.append(":" + myDataList.get(i).getSecondDayParentStartTimeString().substring(2, 4));
|
||||||
|
message.append("~" + myDataList.get(i).getSecondDayParentEndTimeString().substring(0, 2));
|
||||||
|
message.append(":" + myDataList.get(i).getSecondDayParentEndTimeString().substring(2, 4) + "\n\n");
|
||||||
}
|
}
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
new AlertDialog.Builder(MainActivity.this)
|
||||||
.setTitle("警告")
|
.setTitle("警告")
|
||||||
|
@ -307,7 +328,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//提出状況の取得
|
//提出状況の取得
|
||||||
private ArrayList<SubmissionStudent> getSubmissionStudents() {
|
private ArrayList<SubmissionStudent> getSubmissionStudents() {
|
||||||
ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>();
|
ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user