・重複時のダイアログに保護者の情報が表示されるように調整しました。 #50

Merged
Utahshi merged 2 commits from api into master 2024-07-10 07:31:26 +00:00
2 changed files with 37 additions and 14 deletions

View File

@ -42,13 +42,14 @@ public class CreateSchedule {
private final AppDatabase db;
private int arraySizeInt;
boolean notSecondDuplicatesBoolean = true;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
private boolean notSecondDuplicatesBoolean;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
String[] homeVisitDaysString;
public CreateSchedule(AppCompatActivity activity) {
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
this.notSecondDuplicatesBoolean = true; // 初期値をtrueに設定する
SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
String firstDay = sharedPreferences.getString("day1", null);
@ -57,7 +58,6 @@ public class CreateSchedule {
Log.d("createSchedule","day1"+firstDay+"day2"+secondDay+"thirdday"+thirdDay);
homeVisitDaysString = new String[]{firstDay, secondDay, thirdDay};
}
//MainActivityからデータを受け取る
@ -123,11 +123,12 @@ public class CreateSchedule {
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString);
outPutLogSchedule(myDataList);
return startPointLatLngString;
}
} else {
// 重複があるときは""を返す
Log.d("CreateSchedule", "重複によるエラー");
return "";
}
}
private void setData(List<MyDataClass> myDataList) {
@ -348,6 +349,7 @@ public class CreateSchedule {
}
}
for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認
return false;

View File

@ -20,6 +20,7 @@ import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -334,9 +335,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
final List<MyDataClass> finalMyDataList = myDataList;
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
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(() -> {
if (!startPointLatLngString.equals("")) {
if (finalNotDuplicatesBoolean) {
Log.d("MainActivity", "スケジュール作成成功");
saveMyDataList(finalMyDataList);
Intent toRoot = new Intent(MainActivity.this, Maps.class);
@ -374,12 +385,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
studentNumbers.add(data.getStudentNumber());
}
}
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。調整してください。\n出席番号: ");
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。保護者に連絡して調整してください。\n\n");
for (int i = 0; i < studentNumbers.size(); i++) {
message.append(studentNumbers.get(i));
if (i < studentNumbers.size() - 1) {
message.append(", ");
}
message.append("出席番号:" + studentNumbers.get(i));
message.append("\n保護者名:" + myDataList.get(i).getPatronName());
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)
.setTitle("警告")