Skip to content

Commit

Permalink
extract section and city 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 5c8f457 commit a925afb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
18 changes: 16 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,22 @@ 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.name(),
"city" -> section.getCityBase().recommend(decoder.getString("OPPLACE")).name(),
)))

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

/**
* 住所から郵便番号と残りの文字列を抽出します。
*
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
18 changes: 12 additions & 6 deletions app/views/comps/file.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ <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);
}
$('#@{form(s"entries[$idx].city").id}').selectpicker('val', json.city);
}
}
});
});
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.294",
"org.jruby" % "jruby-core" % "9.+",
"com.h2database" % "h2" % "1.4.+",
"com.typesafe.play" %% "play-mailer" % "7.0.+",
Expand Down

0 comments on commit a925afb

Please sign in to comment.