変数名とコメントの調整(済) #33

Merged
Utahshi merged 1 commits from test into master 2024-07-03 07:18:16 +00:00
3 changed files with 96 additions and 87 deletions
Showing only changes of commit 0f8ee6283a - Show all commits

View File

@ -98,7 +98,7 @@ public class CreateRoot {
notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt); notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt);
} }
}); });
if(notSecondDuplicatesBoolean){ if (notSecondDuplicatesBoolean) {
sortSchedule(myDataList); sortSchedule(myDataList);
geocodeAddress(myDataList, context); geocodeAddress(myDataList, context);
outPutLogSchedule(myDataList); outPutLogSchedule(myDataList);
@ -114,12 +114,12 @@ public class CreateRoot {
// 希望時間帯の終了時刻から開始時刻を引いて希望時間帯の長さ(timezone)に入れる // 希望時間帯の終了時刻から開始時刻を引いて希望時間帯の長さ(timezone)に入れる
data = myDataList.get(i); data = myDataList.get(i);
//保護者の第一希望日 //保護者の第一希望日
List<Timestamp> firstDay = data.getFirstDay(); List<Timestamp> firstDayList = data.getFirstDay();
//保護者の第一希望日の開始時間 //保護者の第一希望日の開始時間
Timestamp parentStartTimestamp = firstDay.get(0); Timestamp parentStartTimestamp = firstDayList.get(0);
//保護者の第一希望日の終了時間 //保護者の第一希望日の終了時間
Timestamp parentEndTimestamp = firstDay.get(1); Timestamp parentEndTimestamp = firstDayList.get(1);
//保護者の第一希望日の希望時間帯の長さ //保護者の第一希望日の希望時間帯の長さ
Long timezoneLong = parentEndTimestamp.getSeconds() - parentStartTimestamp.getSeconds(); Long timezoneLong = parentEndTimestamp.getSeconds() - parentStartTimestamp.getSeconds();
data.setTimezone(timezoneLong); data.setTimezone(timezoneLong);
@ -158,11 +158,11 @@ public class CreateRoot {
data = myDataList.get(i); data = myDataList.get(i);
if (myDataList.get(i).getSecondDay() != null) { if (myDataList.get(i).getSecondDay() != null) {
//保護者の第二希望日 //保護者の第二希望日
List<Timestamp> secondDay = data.getSecondDay(); List<Timestamp> secondDayList = data.getSecondDay();
//保護者の第二希望日の開始時間 //保護者の第二希望日の開始時間
Timestamp parentStartTimestamp = secondDay.get(0); Timestamp parentStartTimestamp = secondDayList.get(0);
//保護者の第二希望日の終了時間 //保護者の第二希望日の終了時間
Timestamp parentEndTimestamp = secondDay.get(1); Timestamp parentEndTimestamp = secondDayList.get(1);
//保護者の第二希望日の希望時間帯の長さ //保護者の第二希望日の希望時間帯の長さ
Long secondDayTimezoneLong = parentEndTimestamp.getSeconds() - parentStartTimestamp.getSeconds(); Long secondDayTimezoneLong = parentEndTimestamp.getSeconds() - parentStartTimestamp.getSeconds();
data.setTimezone(secondDayTimezoneLong); data.setTimezone(secondDayTimezoneLong);
@ -264,17 +264,18 @@ public class CreateRoot {
if (intervalMinutesInt % 100 >= 60) { if (intervalMinutesInt % 100 >= 60) {
intervalMinutesInt += 40; // 下2桁が60以上の場合は繰り上げる intervalMinutesInt += 40; // 下2桁が60以上の場合は繰り上げる
} }
//教師の休憩時間を除く処理
if (intervalMinutesInt < startBreakTimeMinutesInt || intervalMinutesInt >= endBreakTimeMinutesInt) { if (intervalMinutesInt < startBreakTimeMinutesInt || intervalMinutesInt >= endBreakTimeMinutesInt) {
intervalList.add(intervalMinutesInt); intervalList.add(intervalMinutesInt);
} }
} }
//[3]は家庭訪問の日目
int[][][] intervalArrayInt = new int[3][intervalList.size()][2]; int[][][] intervalArrayInt = new int[3][intervalList.size()][2];
for (int i = 0; i < intervalList.size(); i++) { for (int i = 0; i < intervalList.size(); i++) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
intervalArrayInt[j][i][0] = intervalList.get(i); intervalArrayInt[j][i][0] = intervalList.get(i);//家庭訪問のスケジュール区切りの時間を要素に入れる
intervalArrayInt[j][i][1] = 0;//割り当てされていないことを表す intervalArrayInt[j][i][1] = 0;//家庭訪問のスケジュールにまだ保護者が割り当てられていないことを表す
} }
} }
@ -293,6 +294,8 @@ public class CreateRoot {
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
for (int j = 0; j < intervalArrayInt[0].length - 1; j++) { for (int j = 0; j < intervalArrayInt[0].length - 1; j++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
//家庭訪問の日目が保護者の第一希望日かを判定する
//まだスケジュールを割り当てていない保護者かを判定する
if (testdata[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) { if (testdata[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) {
checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getStartDateString()); checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getStartDateString());
break; break;
@ -303,7 +306,7 @@ public class CreateRoot {
} }
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;
} }
} }
@ -314,6 +317,8 @@ public class CreateRoot {
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
for (int j = 0; j < intervalArrayInt[0].length - 1; j++) { for (int j = 0; j < intervalArrayInt[0].length - 1; j++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
//家庭訪問の日目が保護者の第一希望日かを判定する
//まだスケジュールを割り当てていない保護者かを判定する
if (testdata[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) { if (testdata[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) {
checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getSecondDayStartDateString()); checkSchedule(myDataList, intervalArrayInt, i, j, x, myDataList.get(i).getSecondDayStartDateString());
} }
@ -322,23 +327,24 @@ public class CreateRoot {
} }
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;
} }
} }
return true; return true;
} }
private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArrayInt, int i, int j, int x, String desiredDateString) { private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArrayInt, int i, int j, int x, String desiredDateString) {
//保護者の希望時間の開始と終了の間にまだ保護者の割り当てがされていないスケジュールの空き時間があるかの判定
if (intervalArrayInt[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArrayInt[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArrayInt[x][j][1] == 0) { if (intervalArrayInt[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArrayInt[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArrayInt[x][j][1] == 0) {
intervalArrayInt[x][j][1] += 1;//割り当て済みを表す intervalArrayInt[x][j][1] += 1;//その時間が割り当て済みでありこと
myDataList.get(i).setSchedule(Integer.parseInt(desiredDateString.substring(4, 8) + intervalArrayInt[x][j][0])); myDataList.get(i).setSchedule(Integer.parseInt(desiredDateString.substring(4, 8) + intervalArrayInt[x][j][0]));//スケジュールをmyDataListに入れる(:6041240(6月4日12時40分))
} }
} }
private void sortSchedule(List<MyDataClass> myDataList) { private void sortSchedule(List<MyDataClass> myDataList) {
Comparator<MyDataClass> comparator = Comparator.comparing(MyDataClass::getSchedule); Comparator<MyDataClass> comparator = Comparator.comparing(MyDataClass::getSchedule);
//スケジュールを元にmyDataListをソートする
myDataList.sort(comparator); myDataList.sort(comparator);
} }
@ -347,11 +353,13 @@ public class CreateRoot {
try { try {
Geocoder geocoder = new Geocoder(context, Locale.getDefault()); Geocoder geocoder = new Geocoder(context, Locale.getDefault());
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
List<Address> addresses = geocoder.getFromLocationName(myDataList.get(i).getAddress().toString(), 1); List<Address> addressesList = geocoder.getFromLocationName(myDataList.get(i).getAddress().toString(), 1);
if (addresses != null && !addresses.isEmpty()) { if (addressesList != null && !addressesList.isEmpty()) {
Address addressResult = addresses.get(0); Address addressResult = addressesList.get(0);
//保護者の住所を緯度経度に変換する
double latitudeDouble = addressResult.getLatitude(); double latitudeDouble = addressResult.getLatitude();
double longitudeDouble = addressResult.getLongitude(); double longitudeDouble = addressResult.getLongitude();
//保護者の住所の緯度経度をmyDataListに追加する
myDataList.get(i).setLatLng(new LatLng(latitudeDouble, longitudeDouble)); myDataList.get(i).setLatLng(new LatLng(latitudeDouble, longitudeDouble));
} }
} }

View File

@ -241,6 +241,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}); });
new Thread(() -> { new Thread(() -> {
List<MyDataClass> myDataList = firestoreReception.getMyDataList();
try { try {
latch.await(); // Both tasks must call countDown() before this returns latch.await(); // Both tasks must call countDown() before this returns
runOnUiThread(() -> { runOnUiThread(() -> {

View File

@ -7,129 +7,129 @@ import java.util.List;
public class MyDataClass { public class MyDataClass {
String patronName; private String patronNameString;
int classId; private int classIdInt;
List<String> address; private List<String> addressList;
List<Timestamp> firstDay; private List<Timestamp> firstDayList;
int studentNumber; private int studentNumberInt;
String childName; private String childNameString;
List<Timestamp> thirdDay; private List<Timestamp> thirdDayList;
List<Timestamp> secondDay; private List<Timestamp> secondDayList;
double latitude; private double latitudeDouble;
private Long Timezone; private Long timezoneLong;
private String startDateString; private String startDateString;
private String endDateString; private String endDateString;
private String AssignedStartTime; private String assignedStartTimeString;
private int AssignedIndex; private int assignedIndexInt;
private boolean linking; private boolean linkingBoolean;
private String parentStartTimeString; private String parentStartTimeString;
private String parentEndTimeString; private String parentEndTimeString;
private int schedule; private int scheduleInt;
private String secondDayStartDateString; private String secondDayStartDateString;
private String secondDayEndDateString; private String secondDayEndDateString;
private Long secondDayTimezone; private Long secondDayTimezoneLong;
private String secondDayParentStartTimeString; private String secondDayParentStartTimeString;
private String secondDayParentEndTimeString; private String secondDayParentEndTimeString;
private LatLng latLng; private LatLng latLng;
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) { public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
this.patronName = patronName; this.patronNameString = patronName;
this.classId = classId; this.classIdInt = classId;
this.address = address; this.addressList = address;
this.firstDay = firstDay; this.firstDayList = firstDay;
this.studentNumber = studentNumber; this.studentNumberInt = studentNumber;
this.childName = childName; this.childNameString = childName;
this.thirdDay = thirdDay; this.thirdDayList = thirdDay;
this.secondDay = secondDay; this.secondDayList = secondDay;
} }
@Override @Override
public String toString() { public String toString() {
return "MyDataClass{" + return "MyDataClass{" +
"patronName='" + patronName + '\'' + "patronName='" + patronNameString + '\'' +
", classId=" + classId + ", classId=" + classIdInt +
", address=" + address + ", address=" + addressList +
", firstDay=" + firstDay + ", firstDay=" + firstDayList +
", studentNumber=" + studentNumber + ", studentNumber=" + studentNumberInt +
", childName='" + childName + '\'' + ", childName='" + childNameString + '\'' +
", thirdDay=" + thirdDay + ", thirdDay=" + thirdDayList +
", secondDay=" + secondDay + ", secondDay=" + secondDayList +
'}'; '}';
} }
//getter //getter
public String getPatronName() { public String getPatronName() {
return patronName; return patronNameString;
} }
//setter //setter
public void setPatronName(String patronName) { public void setPatronName(String patronNameString) {
this.patronName = patronName; this.patronNameString = patronNameString;
} }
public int getClassId() { public int getClassId() {
return classId; return classIdInt;
} }
public void setClassId(int classId) { public void setClassId(int classId) {
this.classId = classId; this.classIdInt = classId;
} }
public List<String> getAddress() { public List<String> getAddress() {
return address; return addressList;
} }
public void setAddress(List<String> address) { public void setAddress(List<String> address) {
this.address = address; this.addressList = address;
} }
public List<Timestamp> getFirstDay() { public List<Timestamp> getFirstDay() {
return firstDay; return firstDayList;
} }
public void setFirstDay(List<Timestamp> firstDay) { public void setFirstDay(List<Timestamp> firstDay) {
this.firstDay = firstDay; this.firstDayList = firstDay;
} }
public int getStudentNumber() { public int getStudentNumber() {
return studentNumber; return studentNumberInt;
} }
public void setStudentNumber(int studentNumber) { public void setStudentNumber(int studentNumber) {
this.studentNumber = studentNumber; this.studentNumberInt = studentNumber;
} }
public String getChildName() { public String getChildName() {
return childName; return childNameString;
} }
public void setChildName(String childName) { public void setChildName(String childName) {
this.childName = childName; this.childNameString = childName;
} }
public List<Timestamp> getThirdDay() { public List<Timestamp> getThirdDay() {
return thirdDay; return thirdDayList;
} }
public void setThirdDay(List<Timestamp> thirdDay) { public void setThirdDay(List<Timestamp> thirdDay) {
this.thirdDay = thirdDay; this.thirdDayList = thirdDay;
} }
public List<Timestamp> getSecondDay() { public List<Timestamp> getSecondDay() {
return secondDay; return secondDayList;
} }
public void setSecondDay(List<Timestamp> secondDay) { public void setSecondDay(List<Timestamp> secondDay) {
this.secondDay = secondDay; this.secondDayList = secondDay;
} }
public double getLatitude() { public double getLatitude() {
return latitude; return latitudeDouble;
} }
public void setLatitude(double latitude) { public void setLatitude(double latitudeDouble) {
this.latitude = latitude; this.latitudeDouble = latitudeDouble;
} }
public void setEndDateString(String endDateString) { public void setEndDateString(String endDateString) {
@ -137,11 +137,11 @@ public class MyDataClass {
} }
public Long getTimezone() { public Long getTimezone() {
return Timezone; return timezoneLong;
} }
public void setTimezone(Long Timezone) { public void setTimezone(Long timezoneLong) {
this.Timezone = Timezone; this.timezoneLong = timezoneLong;
} }
public String getStartDateString() { public String getStartDateString() {
@ -153,29 +153,29 @@ public class MyDataClass {
} }
public void setAssignedStartTime(String AssignedStartTime) { public void setAssignedStartTime(String assignedStartTime) {
this.AssignedStartTime = AssignedStartTime; this.assignedStartTimeString = assignedStartTime;
} }
public String setAssignedEndTime(String s) { public String getAssignedEndTime() {
return AssignedStartTime; return assignedStartTimeString;
} }
public void setAssignedIndex(int AssignedIndex) { public void setAssignedIndex(int assignedIndexInt) {
this.AssignedIndex = AssignedIndex; this.assignedIndexInt = assignedIndexInt;
} }
public int getAssignedIndex() { public int getAssignedIndex() {
return AssignedIndex; return assignedIndexInt;
} }
public void setLinking(boolean linking) { public void setLinking(boolean linking) {
this.linking = linking; this.linkingBoolean = linking;
} }
public boolean getLinking() { public boolean getLinking() {
return linking; return linkingBoolean;
} }
public void setParentStartTimeString(String parentStartTimeString) { public void setParentStartTimeString(String parentStartTimeString) {
@ -194,12 +194,12 @@ public class MyDataClass {
return parentEndTimeString; return parentEndTimeString;
} }
public void setSchedule(int schedule) { public void setSchedule(int scheduleInt) {
this.schedule = schedule; this.scheduleInt = scheduleInt;
} }
public int getSchedule() { public int getSchedule() {
return schedule; return scheduleInt;
} }
public void setSecondDayStartDateString(String secondDayStartDateString) { public void setSecondDayStartDateString(String secondDayStartDateString) {
@ -211,11 +211,11 @@ public class MyDataClass {
} }
public void setSecondDayTimezone(Long secondDayTimezone) { public void setSecondDayTimezone(Long secondDayTimezone) {
this.secondDayTimezone = secondDayTimezone; this.secondDayTimezoneLong = secondDayTimezone;
} }
public Long getSecondDayTimezone() { public Long getSecondDayTimezone() {
return secondDayTimezone; return secondDayTimezoneLong;
} }