v0.1.17 進捗状況の表示
1 parent 81cd736 commit 1100f91befce0d825be804d872cc35aaa6feb4a1
@haya4 haya4 authored on 28 Nov 2023
Showing 10 changed files
View
2
■■■
pom.xml
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>osm.surveyor.plateau</groupId>
<artifactId>task-bldg</artifactId>
<version>0.1.16</version>
<version>0.1.17</version>
<packaging>war</packaging>
<name>task-bldg</name>
<description>TaskingManager for Plateau BLDG</description>
<properties>
View
97
src/main/java/osm/surveyor/task/city/CityService.java 0 → 100644
package osm.surveyor.task.city;
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import osm.surveyor.task.city.model.City;
import osm.surveyor.task.city.model.Citymesh;
import osm.surveyor.task.city.model.Status;
 
@Service
@Transactional // メソッド開始時にトランザクションを開始、終了時にコミットする
public class CityService {
 
@Autowired
CityRepository repository;
@Autowired
CitymeshRepository meshRepository;
 
public List<City> getAll() {
return repository.findAll(Sort.by(Sort.Direction.ASC, "citycode"));
}
/**
* ステータスを更新
* @param task
*/
public void updateStatus(String citycode) {
List<Citymesh> list = meshRepository.findByCitycode(citycode);
double cnt = 0;
double err = 0;
double edit = 0;
double resv = 0;
double total = list.size();
for (Citymesh mesh : list) {
Status status = mesh.getStatus();
switch (status) {
case OK:
cnt++;
break;
case NG:
err++;
break;
case EDITING:
edit++;
break;
case RESERVED:
resv++;
break;
case ACCEPTING:
resv++;
break;
default:
break;
}
}
City city = getCity(citycode);
if (err > 0) {
city.setStatus(Status.NG);
}
else if ((cnt / total) > 0.99d) {
city.setStatus(Status.OK);
}
else if ((cnt / total) > 0.9d) {
city.setStatus(Status.EDITING);
}
else if (edit > 0d) {
city.setStatus(Status.RESERVED);
}
else if (resv > 0d) {
city.setStatus(Status.ACCEPTING);
}
else {
city.setStatus(Status.PREPARATION);
}
repository.save(city);
}
 
public void store(City city) {
repository.save(city);
}
 
public City getCity(String citycode) {
return repository.findByCitycode(citycode);
}
 
public void deleteCity(String citycode) {
repository.deleteByCitycode(citycode);
}
 
}
View
2
■■■
src/main/java/osm/surveyor/task/city/DataLoader.java
public class DataLoader implements CommandLineRunner {
private final CityRepository cityRepository;
private final CitymeshRepository meshRepository;
private final TaskService taskService;
private final CityService cityService;
 
String url = "http://surveyor.mydns.jp/osm-data";
@Override
city.setLat(coordinates.getLat());
 
cityRepository.save(city);
storeTask(city);
cityService.updateStatus(city.getCitycode());
}
}
private String httpGet(String url) throws Exception {
View
6
src/main/java/osm/surveyor/task/city/TaskController.java
private final TaskRepository taskRepository;
@Autowired
private TaskService service;
@Autowired
private CityService cityService;
/**
* ログインユーザーが関係しているTASKリスト
* @param model
@RequestParam(name="meshcode") String meshcode)
{
String next = "task";
Operation operation = Operation.NOP;
Status nextStatus = Status.PREPARATION;
Status nextStatus = Status.ACCEPTING;
if (op.equals(Operation.RESERVE.toString())) {
model.addAttribute("command", "編集者登録");
operation = Operation.RESERVE;
nextStatus = Status.RESERVED;
// エラーがある場合
return nextPage(task);
}
service.add(task);
cityService.updateStatus(task.getCitycode());
return "redirect:/tasks?citycode="+ task.getCitycode() +"&meshcode="+ task.getMeshcode();
}
View
2
■■■
src/main/java/osm/surveyor/task/city/TaskService.java
if (task.getOperation() == Operation.RESERVE) {
task.setStatus(Status.RESERVED);
}
else if (task.getOperation() == Operation.CANCEL) {
task.setStatus(Status.ACCEPTING);
task.setStatus(Status.PREPARATION);
}
else if (task.getOperation() == Operation.NG) {
task.setStatus(Status.NG);
}
View
src/main/resources/static/img/EDITING.png 0 → 100644
View
src/main/resources/static/img/IMPORTED.png 100644 → 0
View
5
src/main/resources/templates/cities.html
<table class="table table-bordered">
<thead>
<tr>
<td colspan="5">
<img th:src="@{/img/NG.png}"></img>:エラーあり <img th:src="@{/img/OK.png}"></img>:完了 <img th:src="@{/img/EDITING.png}"></img>:あとちょっと <img th:src="@{/img/RESERVED.png}"></img>:編集中 <img th:src="@{/img/ACCEPTING.png}"></img>:着手 <img th:src="@{/img/PREPARATION.png}"></img>:未着手
</td>
</tr>
<tr>
<th th:text="#{status}"></th>
<th th:text="#{citycode}"></th>
<th th:text="#{cityname}"></th>
<th th:text="#{folder}"></th>
View
5
src/main/resources/templates/meshes.html
})
});
var status4 = new ol.style.Style({
image: new ol.style.Icon({
src: '/task-bldg/img/EDITING.png',
src: '/task-bldg/img/IMPORTED.png',
anchor: [0.5, 0.5],
scale: 1
})
});
<td>
<a th:text="#{return}" th:href="@{/}" class="btn btn-navy">
</a>
</td>
<td>
<img th:src="@{/img/NG.png}"></img>:エラー <img th:src="@{/img/OK.png}"></img>:完了 <img th:src="@{/img/EDITING.png}"></img>:編集中 <img th:src="@{/img/RESERVED.png}"></img>:予約済み <img th:src="@{/img/ACCEPTING.png}"></img>:受付中 <img th:src="@{/img/PREPARATION.png}"></img>:未着手
</td>
</tr>
</tbody>
</table>
 
View
2
■■■
src/main/resources/templates/tasks.html
})
});
var status4 = new ol.style.Style({
image: new ol.style.Icon({
src: './img/EDITING.png',
src: './img/IMPORTED.png',
anchor: [0.5, 0.5],
scale: 2
})
});