Skip to content

Commit

Permalink
extract section name from JARL summary sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
JG1VPP committed Jul 14, 2024
1 parent ffab790 commit 1f5c5b1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
17 changes: 15 additions & 2 deletions app/models/models.scala
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,9 @@ class RankingTableToJson(implicit in: Injections) {
*
*
* @param decoder 対象のサマリーシート
* @param in 依存性注入
*/
class SheetDecoderToJson(decoder: SheetDecoder) {
class SheetDecoderToJson(decoder: SheetDecoder)(implicit in: Injections) {
val postal = "[\\u3012\\u3020]\\s*?\\d{3}-?\\d{4}".r

/**
Expand All @@ -416,9 +417,21 @@ class SheetDecoderToJson(decoder: SheetDecoder) {
"post" -> post(decoder.getString("ADDRESS"))._1.trim,
"addr" -> post(decoder.getString("ADDRESS"))._2.trim,
"mail" -> decoder.getString("EMAIL"),
"note" -> decoder.getString("COMMENTS")
"note" -> decoder.getString("COMMENTS"),
"sect" -> section,
)))

/**
* 指定された名前に適合する部門を検索して返します。
*
* @return 部門
*/
def section: String = {
val name = decoder.getString("CATEGORYNAME")
val code = decoder.getString("CATEGORYCODE")
in.rule.similar(Option(name).getOrElse(code)).name()
}

/**
* 住所から郵便番号と残りの文字列を抽出します。
*
Expand Down
3 changes: 2 additions & 1 deletion app/tasks/tasks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ class VerifyTask(implicit req: Request[AnyContent], in: Injections) {
*
*
* @param req サマリーシートを含むリクエスト
* @param in 依存性注入
*/
class FillInTask(implicit req: Request[AnyContent]) {
class FillInTask(implicit req: Request[AnyContent], in: Injections) {
/**
* サマリーシートを読み取るデコーダです。
*/
Expand Down
17 changes: 11 additions & 6 deletions app/views/comps/file.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ <h3 class='card-header'>
}).done((data) => {
if(data) {
const json = JSON.parse(data);
if(!$('#@{form("station.call").id}').val()) $('#@{form("station.call").id}').val(json.call);
if(!$('#@{form("station.name").id}').val()) $('#@{form("station.name").id}').val(json.name);
if(!$('#@{form("station.post").id}').val()) $('#@{form("station.post").id}').val(json.post);
if(!$('#@{form("station.addr").id}').val()) $('#@{form("station.addr").id}').val(json.addr);
if(!$('#@{form("station.mail").id}').val()) $('#@{form("station.mail").id}').val(json.mail);
if(!$('#@{form("station.note").id}').val()) $('#@{form("station.note").id}').val(json.note);
$('#@{form("station.call").id}').val(json.call);
$('#@{form("station.name").id}').val(json.name);
$('#@{form("station.post").id}').val(json.post);
$('#@{form("station.addr").id}').val(json.addr);
$('#@{form("station.mail").id}').val(json.mail);
$('#@{form("station.note").id}').val(json.note);
@for(idx <- in.rule.getSectionCodes().asScala.indices) {
if($(`#@{form(s"entries[$idx].sect").id} option[value=${json.sect}]`).length) {
$('#@{form(s"entries[$idx].sect").id}').selectpicker('val', json.sect);
}
}
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libraryDependencies ++= Seq(
filters,
guice,
jdbc,
"qxsl" % "qxsl" % "0.1.292",
"qxsl" % "qxsl" % "0.1.293",
"org.jruby" % "jruby-core" % "9.+",
"com.h2database" % "h2" % "1.4.+",
"com.typesafe.play" %% "play-mailer" % "7.0.+",
Expand Down

0 comments on commit 1f5c5b1

Please sign in to comment.