Mercurial > mercurial > hgweb_golang.cgi
comparison src/kaigo/Perori/bk.go @ 42:c58172a59534
bug fix.
| author | pyon@macmini |
|---|---|
| date | Tue, 10 Mar 2020 21:12:29 +0900 |
| parents | 34a474fb83c3 |
| children | 4877160411cc |
comparison
equal
deleted
inserted
replaced
| 41:34a474fb83c3 | 42:c58172a59534 |
|---|---|
| 1 /* | 1 /* |
| 2 bk.go: Insert Biko & Hatsuban | 2 bk.go: Insert Biko & Hatsuban |
| 3 | 3 |
| 4 Last Change: 2020-03-04 水 16:48:05. | 4 Last Change: 2020-03-10 火 15:13:54. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 package main | 7 package main |
| 8 | 8 |
| 9 /* | 9 /* |
| 74 if (api_result < 0) return api_result; | 74 if (api_result < 0) return api_result; |
| 75 | 75 |
| 76 XDW_DOCUMENT_INFO info = {sizeof(XDW_DOCUMENT_INFO), 0, 0, 0}; | 76 XDW_DOCUMENT_INFO info = {sizeof(XDW_DOCUMENT_INFO), 0, 0, 0}; |
| 77 XDW_GetDocumentInformation(h, &info); | 77 XDW_GetDocumentInformation(h, &info); |
| 78 | 78 |
| 79 int color = XDW_COLOR_NONE; | |
| 79 XDW_FOUND_HANDLE pFoundHandle = NULL; | 80 XDW_FOUND_HANDLE pFoundHandle = NULL; |
| 80 for (int i = 0; i < info.nPages; i++) { | 81 for (int i = 0; i < info.nPages; i++) { |
| 81 api_result = XDW_FindTextInPage(h, i + 1, stxt, NULL, &pFoundHandle, NULL); | 82 api_result = XDW_FindTextInPage(h, i + 1, stxt, NULL, &pFoundHandle, NULL); |
| 82 if (pFoundHandle == NULL) continue; | 83 if (pFoundHandle == NULL) continue; |
| 83 | 84 |
| 85 int api_result = XDW_AddAnnotation(h, XDW_AID_TEXT, i + 1, x, y, NULL, &annoation, NULL); | 86 int api_result = XDW_AddAnnotation(h, XDW_AID_TEXT, i + 1, x, y, NULL, &annoation, NULL); |
| 86 if (api_result < 0) return api_result; | 87 if (api_result < 0) return api_result; |
| 87 | 88 |
| 88 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_Text, XDW_ATYPE_STRING, hb, 0, NULL); | 89 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_Text, XDW_ATYPE_STRING, hb, 0, NULL); |
| 89 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_FontSize, XDW_ATYPE_INT, (char*)&sz, 0, NULL); | 90 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_FontSize, XDW_ATYPE_INT, (char*)&sz, 0, NULL); |
| 90 | |
| 91 int color = XDW_COLOR_NONE; | |
| 92 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); | 91 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); |
| 93 } | 92 } |
| 94 | 93 |
| 95 XDW_SaveDocument(h, NULL); | 94 XDW_SaveDocument(h, NULL); |
| 96 XDW_CloseDocumentHandle(h, NULL); | 95 XDW_CloseDocumentHandle(h, NULL); |
| 131 api_result = XDW_SetAnnotationAttribute(h, annoation1, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); | 130 api_result = XDW_SetAnnotationAttribute(h, annoation1, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); |
| 132 | 131 |
| 133 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_Text, XDW_ATYPE_STRING, kubun, 0, NULL); | 132 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_Text, XDW_ATYPE_STRING, kubun, 0, NULL); |
| 134 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_FontSize, XDW_ATYPE_INT, (char*)&sz, 0, NULL); | 133 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_FontSize, XDW_ATYPE_INT, (char*)&sz, 0, NULL); |
| 135 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); | 134 api_result = XDW_SetAnnotationAttribute(h, annoation2, XDW_ATN_BackColor, XDW_ATYPE_INT, (char*)&color, 0, NULL); |
| 135 | |
| 136 XDW_SaveDocument(h, NULL); | |
| 137 XDW_CloseDocumentHandle(h, NULL); | |
| 138 | |
| 139 return 0; | |
| 140 } | |
| 141 | |
| 142 int xdweraren(const char* in_file, const char* stxt) | |
| 143 { | |
| 144 int x = 1870; | |
| 145 int y = 4680; | |
| 146 int yoff = 2825; | |
| 147 int sz = 90; | |
| 148 | |
| 149 char in_path[_MAX_PATH]; | |
| 150 _fullpath(in_path, in_file, _MAX_PATH); | |
| 151 | |
| 152 XDW_DOCUMENT_HANDLE h = NULL; | |
| 153 XDW_OPEN_MODE_EX mode = {sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_UPDATE, XDW_AUTH_NODIALOGUE}; | |
| 154 | |
| 155 int api_result = XDW_OpenDocumentHandle(in_path, &h, (XDW_OPEN_MODE*)&mode); | |
| 156 if (api_result < 0) return api_result; | |
| 157 | |
| 158 XDW_DOCUMENT_INFO info = {sizeof(XDW_DOCUMENT_INFO), 0, 0, 0}; | |
| 159 XDW_GetDocumentInformation(h, &info); | |
| 160 | |
| 161 XDW_FOUND_HANDLE pFoundHandle = NULL; | |
| 162 for (int i = 0; i < info.nPages; i++) { | |
| 163 api_result = XDW_FindTextInPage(h, i + 1, stxt, NULL, &pFoundHandle, NULL); | |
| 164 if (pFoundHandle != NULL) continue; | |
| 165 | |
| 166 for (int r = 0; r < 9; r++) { | |
| 167 XDW_ANNOTATION_HANDLE annoation; | |
| 168 int api_result = XDW_AddAnnotation(h, XDW_AID_TEXT, i + 1, x, y + r * yoff, NULL, &annoation, NULL); | |
| 169 if (api_result < 0) return api_result; | |
| 170 | |
| 171 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_Text, XDW_ATYPE_STRING, " ", 0, NULL); | |
| 172 api_result = XDW_SetAnnotationAttribute(h, annoation, XDW_ATN_FontSize, XDW_ATYPE_INT, (char*)&sz, 0, NULL); | |
| 173 } | |
| 174 } | |
| 136 | 175 |
| 137 XDW_SaveDocument(h, NULL); | 176 XDW_SaveDocument(h, NULL); |
| 138 XDW_CloseDocumentHandle(h, NULL); | 177 XDW_CloseDocumentHandle(h, NULL); |
| 139 | 178 |
| 140 return 0; | 179 return 0; |
| 160 "golang.org/x/text/transform" | 199 "golang.org/x/text/transform" |
| 161 ) | 200 ) |
| 162 | 201 |
| 163 // Constants | 202 // Constants |
| 164 const ( | 203 const ( |
| 165 version = "0.3" | 204 version = "0.4" |
| 166 default_ccsvfile = "chosairai.csv" | 205 default_ccsvfile = "chosairai.csv" |
| 167 default_icsvfile = "ikenshoirai.csv" | 206 default_icsvfile = "ikenshoirai.csv" |
| 168 default_cxdwfile = "KBPC116G.xdw" | 207 default_cxdwfile = "KBPC116G.xdw" |
| 169 default_ixdwfile = "KBPB116G.xdw" | 208 default_ixdwfile = "KBPB116G.xdw" |
| 170 default_tmpxdw = "tmp.xdw" | 209 default_tmpxdw = "tmp.xdw" |
| 228 /* READ BIKO FROM CSV */ | 267 /* READ BIKO FROM CSV */ |
| 229 bhash, err := getBiko_fromCSV(default_ccsvfile, today) | 268 bhash, err := getBiko_fromCSV(default_ccsvfile, today) |
| 230 if err != nil { | 269 if err != nil { |
| 231 log.Fatal(err) | 270 log.Fatal(err) |
| 232 } | 271 } |
| 233 fmt.Println(" 備考データ読込") | 272 fmt.Println(" 備考データ読込 ... done") |
| 234 step_start := print_time(start) | 273 step_start := print_time(start) |
| 235 | 274 |
| 236 /* READ KUBUN FROM CSV */ | 275 /* READ KUBUN FROM CSV */ |
| 237 khash, err := getKubun_fromCSV(default_icsvfile, bhash) | 276 khash, err := getKubun_fromCSV(default_icsvfile, bhash) |
| 238 if err != nil { | 277 if err != nil { |
| 239 log.Fatal(err) | 278 log.Fatal(err) |
| 240 } | 279 } |
| 241 fmt.Println(" 申請区分データ読込") | 280 fmt.Println(" 申請区分データ読込 ... done") |
| 242 step_start = print_time(start) | 281 step_start = print_time(start) |
| 243 | 282 |
| 244 /* INSERT BIKO */ | 283 /* INSERT BIKO */ |
| 245 var ctxt []string | 284 var ctxt []string |
| 246 copy_tmp(default_cxdwfile) | 285 copy_tmp(default_cxdwfile) |
| 250 C.xdwbiko(C.CString(default_tmpxdw), C.int(p + 1), C.int(r), C.CString(bk), C.CString(khash[hno])) | 289 C.xdwbiko(C.CString(default_tmpxdw), C.int(p + 1), C.int(r), C.CString(bk), C.CString(khash[hno])) |
| 251 } | 290 } |
| 252 } | 291 } |
| 253 ctxt = append(ctxt, t) | 292 ctxt = append(ctxt, t) |
| 254 } | 293 } |
| 255 fmt.Println(" 備考と申請区分を追加") | 294 fmt.Println(" 備考と申請区分を追加 ... done") |
| 295 step_start = print_time(step_start) | |
| 256 | 296 |
| 257 /* INSERT HATSU-BAN & OPTIMIZE */ | 297 /* INSERT HATSU-BAN & OPTIMIZE */ |
| 258 stxt, _, _ := transform.String(japanese.ShiftJIS.NewEncoder(), "大仙広介") | 298 stxt, _, _ := transform.String(japanese.ShiftJIS.NewEncoder(), "大仙広介") |
| 259 C.xdwhb(C.CString(default_tmpxdw), C.CString(default_cout), C.CString(hbi), C.CString(stxt)) | 299 C.xdwhb(C.CString(default_tmpxdw), C.CString(default_cout), C.CString(hbc), C.CString(stxt)) |
| 260 fmt.Println(" 発番追加(調査依頼ファイル)") | 300 fmt.Println(" 発番追加(調査依頼ファイル)... done") |
| 261 step_start = print_time(step_start) | 301 step_start = print_time(step_start) |
| 262 | 302 |
| 303 /* ERASE RENRAKUSAKI */ | |
| 263 copy_tmp(default_ixdwfile) | 304 copy_tmp(default_ixdwfile) |
| 264 C.xdwhb(C.CString(default_tmpxdw), C.CString(default_iout), C.CString(hbc), C.CString(stxt)) | 305 C.xdweraren(C.CString(default_tmpxdw), C.CString(stxt)) |
| 265 fmt.Println(" 発番追加( 意見書依頼ファイル)") | 306 fmt.Println(" 連絡先消去 ... done") |
| 307 step_start = print_time(step_start) | |
| 308 | |
| 309 /* INSERT HATSU-BAN & OPTIMIZE */ | |
| 310 C.xdwhb(C.CString(default_tmpxdw), C.CString(default_iout), C.CString(hbi), C.CString(stxt)) | |
| 311 fmt.Println(" 発番追加( 意見書依頼ファイル)... done") | |
| 266 step_start = print_time(step_start) | 312 step_start = print_time(step_start) |
| 267 | 313 |
| 268 /* CHOSA IRAI LIST */ | 314 /* CHOSA IRAI LIST */ |
| 269 f, err := os.Create(default_lout) | 315 f, err := os.Create(default_lout) |
| 270 if err != nil { | 316 if err != nil { |
| 317 } | 363 } |
| 318 } | 364 } |
| 319 } | 365 } |
| 320 w.Flush() | 366 w.Flush() |
| 321 | 367 |
| 322 fmt.Println(" 調査依頼リスト作成") | 368 fmt.Println(" 調査依頼リスト作成 ... done") |
| 323 step_start = print_time(step_start) | 369 step_start = print_time(step_start) |
| 324 | 370 |
| 325 /* CLEAN */ | 371 /* CLEAN */ |
| 326 os.Remove(default_tmpxdw) | 372 os.Remove(default_tmpxdw) |
| 327 fmt.Println(" 終了") | 373 fmt.Println(" 終了 ... end") |
| 328 step_start = print_time(step_start) | 374 step_start = print_time(step_start) |
| 329 } | 375 } |
| 330 | 376 |
| 331 func getBiko_fromCSV(file, date string) (bikohash map[string]string, err error) { | 377 func getBiko_fromCSV(file, date string) (bikohash map[string]string, err error) { |
| 332 bikohash = make(map[string]string) | 378 bikohash = make(map[string]string) |
