How to use entryLoc method in stryker-parent

Best JavaScript code snippet using stryker-parent

mlClassify.js

Source:mlClassify.js Github

copy

Full Screen

1'use strict';2// var express = require('express');3// var fs = require('fs');4// var multer = require("multer");5// var exceljs = require('exceljs');6var appRoot = require('app-root-path').path;7// var request = require('request');8// var propertiesConfig = require(appRoot + '/config/propertiesConfig.js');9// var queryConfig = require(appRoot + '/config/queryConfig.js');10// var commonDB = require(appRoot + '/public/js/common.db.js');11// var commonUtil = require(appRoot + '/public/js/common.util.js');12// var pythonConfig = require(appRoot + '/config/pythonConfig');13// var PythonShell = require('python-shell')14var sync = require('../util/sync.js');15var oracle = require('../util/oracle.js');16// var execSync = require('sync-exec');17// var ocrUtil = require('../util/ocr.js');18// var Step = require('step');19// const xlsx = require('xlsx');20// const async = require("async");21var sync = require('../util/sync.js');22var difflib = require('difflib');23var predRegionConfig = require(appRoot + '/config/predRegionConfig');24var numeral = require('numeral');25//PKS 여기서부터 새로 시작26//module.exports = router;27module.exports = {28 classify: function (req, done) {29 sync.fiber(function () {30 try {31 //var retDataList =new Array();32 // mappingSid 추출33 var retReq = req;34 req = sync.await(getMappingSid(req, sync.defer()));35 if(req.docCategory.DOCTOPTYPE == 0)36 {37 var docTypes = sync.await(refindDocTopType(req, sync.defer()));38 if (docTypes[1] != 0) {39 // mappingSid 추출40 req = sync.await(getMappingSid(req, sync.defer()));41 // 가변영역추출42 req = sync.await(findEntry(req, docTypes[0], docTypes[1], sync.defer()));43 } else {44 req = retReq;45 }46 }47 else48 {49 // 가변영역추출50 req = sync.await(findEntry(req,req.docCategory.DOCTYPE,req.docCategory.DOCTOPTYPE, sync.defer()));51 }52 //retDataList.push(req);53 req = sync.await(editOcrTextTypos(req, sync.defer()));54 return done(null, req);55 } catch (e) {56 console.log(e);57 }58 });59 }60};61// ocrtext 오타수정62function editOcrTextTypos(req, done) {63 sync.fiber(function () {64 try {65 var symspellList = sync.await(oracle.selectIcrSymspell(req.docCategory.DOCTOPTYPE, sync.defer()));66 var symspellListLength = symspellList.length;67 var ocrData = req.data;68 var ocrDataLength = ocrData.length;69 //var reqDataLength = req.data.length;70 for(var i = 0; i < symspellListLength; i++) {71 var dbIcrWord = symspellList[i].ICRWORD;72 var dbKeyWord = symspellList[i].KEYWORD; 73 for(var j = 0; j < ocrDataLength; j++) {74 var ocrText = ocrData[j].text;75 // 전체 수정76 if(dbIcrWord == ocrText) {77 ocrData[j].text = dbKeyWord;78 }79 // 부분 수정80 // if(ocrText.indexOf(dbIcrWord)!==-1)81 // {82 // ocrText = ocrText.replace(dbIcrWord, dbKeyWord);83 // ocrData[j].text = ocrText;84 // }85 }86 }87 88 } catch (e) {89 console.log(e);90 } finally {91 return done(null, req);92 }93 });94}95function getMappingSid(req, done) {96 sync.fiber(function () {97 try {98 var retData = [];99 var docType = req.docCategory.DOCTYPE;100 101 retData["docCategory"]= req.docCategory;102 for (var i in req.data) {103 var item = req.data[i];104 // var sid = sync.await(oracle.selectSid(req.data[i], sync.defer()));105 var loc = req.data[i].location.split(',');106 var mappingSid = String(docType) + "," + String(loc[0]) + "," + String(loc[1]) + "," + String(parseInt(loc[0]) + parseInt(loc[2])) + ",0,0,0,0,0";107 //var mappingSid = String(docType) + "," + String(loc[0]) + "," + String(loc[1]) + "," + String(parseInt(loc[0]) + parseInt(loc[2])) + "," + String(req.data[i]["sid"]);108 req.data[i]["mappingSid"] = mappingSid;109 }110 retData["data"]= req.data;111 112 } catch (e) {113 console.log(e);114 } finally {115 return done(null, retData);116 }117 });118}119function refindDocTopType(req, done) {120 sync.fiber(function () {121 try {122 var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;123 var docTopType = 0;124 var docType = 0;125 var maxNum = 0;126 var text = [];127 var strText = "";128 let docTypeList = sync.await(oracle.selectRefindDocTopTypeList(req, sync.defer()));129 for(var j in req.data)130 {131 //console.log( req.data[j].text + " [ "+j+" ] " + req.data[j].text.replace(regExp,""));132 text += (req.data[j].text.replace(regExp,"")) + ",";133 if(j == 20){134 break;135 }136 }137 //console.log(text.length +" |||| "+text);138 if(text.length > 0)139 {140 strText = text.substring(0, text.length -1).toLowerCase();141 for(var i in docTypeList)142 {143 var ratio = similar(strText, docTypeList[i].DATA);144 if(ratio > maxNum)145 {146 maxNum = ratio;147 docType = docTypeList[i].DOCTYPE;148 docTopType = docTypeList[i].DOCTOPTYPE;149 }150 }151 }152 153 } catch (e) {154 console.log(e);155 } finally {156 if(maxNum > 0.2)157 {158 return done(null, [docTopType,docType]);159 }160 else161 {162 return done(null, [docTopType,docType]);163 }164 }165 });166}167function findEntry(req, docTypeVal, docTopTypeVal, done) {168 sync.fiber(function () {169 try 170 {171 var retData = {};172 var subLabel = [];173 var fixSingleLabel = [];174 var fixMultiLabel = [];175 var fixLabel = [];176 var variLabel = [];177 let docTopTypeParam = [docTopTypeVal];178 let docTypeParam = [docTypeVal];179 180 let labelRows = sync.await(oracle.selectDocIdLabelDefList(docTopTypeParam, sync.defer()));181 //label data 추출182 let labelTrainRows = sync.await(oracle.selectLabelTrainDataList(docTypeParam, sync.defer()));183 for(var j in req.data) {184 if(labelTrainRows.length > 0) {185 for (var k in labelTrainRows) {186 if (predictionColumn(req.docCategory, req.data[j], labelTrainRows[k], 'L')) {187 req.data[j]["colLbl"] = labelTrainRows[k].CLASS;188 break;189 }190 else {191 req.data[j]["colLbl"] = -1;192 }193 }194 }195 else {196 req.data[j]["colLbl"] = -1;197 }198 }199 retData["docCategory"] = req.docCategory;200 retData["data"] = req.data; 201 //entry data 추출202 let entryTrainRows = sync.await(oracle.selectTrainDataList(docTypeParam, sync.defer()));203 204 for(var j in req.data) {205 for (var k in entryTrainRows) {206 // if (entryTrainRows[k].CLASS != "760" && entryTrainRows[k].CLASS != "761" && entryTrainRows[k].CLASS != "502") {207 if (req.docCategory.DOCTYPE == "329" || req.docCategory.DOCTYPE == "319" || req.docCategory.DOCTYPE == "316" ){208 if (predictionColumn(req.docCategory, req.data[j], entryTrainRows[k], 'E') && isValid(labelRows, entryTrainRows[k].CLASS, req.data[j]["text"])) {209 if (!req.data[j]["entryLbls"]) {210 req.data[j]["entryLbls"] = [entryTrainRows[k]];211 } else {212 req.data[j]["entryLbls"].push(entryTrainRows[k]);213 }214 //req.data[j]["entryLbl"] = entryTrainRows[k].CLASS;215 //break;216 }217 }218 else219 {220 // if (entryTrainRows[k].CLASS != "760" && entryTrainRows[k].CLASS != "761" && entryTrainRows[k].CLASS != "502") {221 if (entryTrainRows[k].CLASS != "760" && entryTrainRows[k].CLASS != "761" && entryTrainRows[k].CLASS != "422") {222 if (predictionColumn(req.docCategory, req.data[j], entryTrainRows[k], 'E') && isValid(labelRows, entryTrainRows[k].CLASS, req.data[j]["text"])) {223 if (!req.data[j]["entryLbls"]) {224 req.data[j]["entryLbls"] = [entryTrainRows[k]];225 } else {226 req.data[j]["entryLbls"].push(entryTrainRows[k]);227 }228 //req.data[j]["entryLbl"] = entryTrainRows[k].CLASS;229 230 //break;231 }232 }233 }234 }235 var minDis = 10000;236 if (req.data[j]["entryLbls"]) {237 for (var k in req.data[j]["entryLbls"]) {238 var entryItem = req.data[j]["entryLbls"][k];239 var targetLoc = req.data[j].location.split(',');240 var entryLoc = [entryItem.OCR_TEXT_X.split(',')[0], entryItem.OCR_TEXT_Y.split(',')[0], entryItem.OCR_TEXT_X.split(',')[1], entryItem.OCR_TEXT_Y.split(',')[1]];241 var dx = Math.abs((targetLoc[0]) - (entryLoc[0]));242 var dy = Math.abs((targetLoc[1]) - (entryLoc[1]));243 var tragetDis = Math.sqrt((dx * dx) + (dy * dy));244 if (tragetDis < minDis) {245 minDis = tragetDis;246 req.data[j]["entryLbl"] = entryItem.CLASS;247 req.data[j]["amount"] = entryItem.AMOUNT;248 if (entryItem.AMOUNT == "multi") {249 req.data[j]["first"] = "Y";250 }251 delete req.data[j]["colLbl"];252 }253 }254 }255 256 // 예측 mlEntryLbl을 entryLbl로 넣기 257 if(req.docCategory.DOCSCORE < 0.3){258 if(typeof req.data[j]["mlEntryLbl"] != "undefined" && typeof req.data[j]["entryLbl"] == "undefined" ){259 // console.log("mlEntryLbl===>" + req.data[j]["mlEntryLbl"])260 req.data[j]["entryLbl"] = req.data[j]["mlEntryLbl"];261 delete req.data[j]["colLbl"];262 }263 } 264 265 } 266 267 //Multy entry search268 var diffHeight = 200;269 for (var j in req.data) {270 var amount = req.data[j]["amount"];271 if(typeof amount != "undefined" && amount == "multi" && typeof req.data[j]["first"] != "undefined" && req.data[j]["first"] == "Y") {272 //console.log(req.data[j]);273 var firstEntry = req.data[j];274 var preEntryHeight = req.data[j];275 // console.log("req.docCategory.DOCTYPE ==> " + req.docCategory.DOCTYPE);276 for (var k in req.data) {277 // if (req.docCategory.DOCTYPE == "422"){278 // var entryHeight = req.data[k]["location"].split(",");279 // if (multiEntryCheck(firstEntry, req.data[k] , req.docCategory.DOCTYPE) && parseInt(entryHeight[1]) < 1800) {280 // req.data[k]['entryLbl'] = firstEntry['entryLbl'];281 // req.data[k]["amount"] = firstEntry['amount'];282 // preEntryHeight = req.data[k];283 // }284 // } 285 // else 286 // if (multiEntryCheck(firstEntry, req.data[k] , req.docCategory.DOCTYPE) && entryHeightCheck(preEntryHeight, req.data[k], diffHeight)) {287 if (multiEntryCheck(firstEntry, req.data[k] , req.docCategory.DOCTYPE)) {288 req.data[k]['entryLbl'] = firstEntry['entryLbl'];289 req.data[k]["amount"] = firstEntry['amount'];290 preEntryHeight = req.data[k];291 }292 }293 }294 }295 296 // Add single entry text297 req.data = sync.await(addEntryTextOfLabel(req.data,req.docCategory.DOCTOPTYPE, sync.defer())); 298 var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;299 //예외처리 등록300 for(var j in req.data)301 {302 if(req.docCategory.DOCTOPTYPE == 58) {303 //761 사업자등록번호304 if(req.data[j]["entryLbl"] == 761)305 {306 if(req.data[j]["text"] == "615-81-45657산단5로100-235"){307 req.data[j]["text"] = "615-81-456575"308 }309 }310 else if(req.data[j]["entryLbl"] == 852)311 {312 313 req.data[j]["text"] = "대림산업(주)"314 315 }316 317 //납품용적318 if(req.data[j]["entryLbl"] == 767)319 {320 var regex= /[^0-9]/g;321 req.data[j]["text"] = req.data[j]["text"].replace(regex,"");322 if(req.data[j]["text"].indexOf(",") !== -1)323 {324 req.data[j]["text"] = req.data[j]["text"].replace(",","");325 }326 if(req.data[j]["text"].indexOf(".") == -1)327 {328 if(req.data[j]["text"].substring(req.data[j]["text"].length-3) == "000")329 {330 req.data[j]["text"] = req.data[j]["text"].substring(0, req.data[j]["text"].length-3) + "."+req.data[j]["text"].substring(req.data[j]["text"].length, req.data[j]["text"].length-3);331 }332 else if(req.data[j]["text"].substring(req.data[j]["text"].length-2) == "00")333 {334 req.data[j]["text"] = req.data[j]["text"].substring(0, req.data[j]["text"].length-2) + "."+req.data[j]["text"].substring(req.data[j]["text"].length, req.data[j]["text"].length-2);335 }336 }337 if(req.data[j]["text"].substring(req.data[j]["text"].length-1) == ".")338 {339 req.data[j]["text"] = req.data[j]["text"] +"00";340 }341 }342 //납품출발시간343 if(req.data[j]["entryLbl"] == 766)344 {345 if(req.data[j]["text"].indexOf("도") !== -1)346 {347 req.data[j]["text"] = req.data[j]["text"].replace("도","");348 }349 if(req.data[j]["text"].replace( /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/g,"").length == 4)350 {351 req.data[j]["text"] = req.data[j]["text"].replace( /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/g,"");352 req.data[j]["text"] = req.data[j]["text"].substring(0,2) + "시" + req.data[j]["text"].substring(2) + "분";353 }354 req.data[j]["text"] = req.data[j]["text"].replace("분분","분")355 req.data[j]["text"] = req.data[j]["text"].replace("시각","")356 357 }358 // 운반차순서359 if(req.data[j]["entryLbl"] == 792)360 {361 362 if(req.data[j]["text"].indexOf(".")!== -1)363 {364 req.data[j]["text"] = req.data[j]["text"].replace(".","");365 }366 if(req.data[j]["text"].indexOf("시")!== -1)367 {368 req.data[j]["text"] = req.data[j]["text"].replace("시","");369 }370 if(req.data[j]["text"].toLowerCase().indexOf("no") !== -1)371 {372 req.data[j]["text"] = req.data[j]["text"].toLowerCase().replace("no","");373 }374 375 }376 //누계377 if(req.data[j]["entryLbl"] == 768)378 {379 var regex= /[^0-9]/g;380 req.data[j]["text"] = req.data[j]["text"].replace(regex,"");381 if(req.data[j]["text"].indexOf(",") !== -1)382 {383 req.data[j]["text"] = req.data[j]["text"].replace(",","");384 }385 if(req.data[j]["text"].indexOf(".") == -1)386 {387 if(req.data[j]["text"].substring(req.data[j]["text"].length-3) == "000")388 {389 req.data[j]["text"] = req.data[j]["text"].substring(0, req.data[j]["text"].length-3) + "."+req.data[j]["text"].substring(req.data[j]["text"].length, req.data[j]["text"].length-3);390 }391 else if(req.data[j]["text"].substring(req.data[j]["text"].length-2) == "00")392 {393 req.data[j]["text"] = req.data[j]["text"].substring(0, req.data[j]["text"].length-2) + "."+req.data[j]["text"].substring(req.data[j]["text"].length, req.data[j]["text"].length-2);394 }395 }396 if(req.data[j]["text"].substring(req.data[j]["text"].length-1) == ".")397 {398 req.data[j]["text"] = req.data[j]["text"] +"00";399 }400 }401 //콘크리트402 if(req.data[j]["entryLbl"] == 769)403 {404 if(req.data[j]["text"] == "콘크리트따른구분" || req.data[j]["text"] == "콘크리트보통따른구분/" || req.data[j]["text"] == "따른구분/보통콘크리트" || req.data[j]["text"] == "따른구분콘크리트" || req.data[j]["text"] == "따른구분보통콘크리트" || req.data[j]["text"] == "방보콘크리트" || req.data[j]["text"] == "통콘크리트" || req.data[j]["text"] == "보콘크리트")405 {406 req.data[j]["text"] = "보통콘크리트";407 }408 409 }410 //굵은굴재411 if(req.data[j]["entryLbl"] == 770)412 {413 if((req.data[j]["text"].indexOf("시")!== -1) || (req.data[j]["text"].indexOf("시방")!== -1))414 {415 req.data[j]["text"] = req.data[j]["text"].replace( /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/g,"");416 }417 if(req.data[j]["text"].indexOf("mm") !== -1)418 {419 req.data[j]["text"] = req.data[j]["text"].replace("mm","");420 }421 if(req.data[j]["text"] == "125" || req.data[j]["text"] == "25방배합" || req.data[j]["text"] == "25.방" || req.data[j]["text"] == "25방배합" || req.data[j]["text"] == "방25배합" || req.data[j]["text"] == "125." || req.data[j]["text"] == "2" || req.data[j]["text"] == "255" || req.data[j]["text"] == "05")422 {423 req.data[j]["text"] = "25";424 }425 426 }427 //호칭강도428 if(req.data[j]["entryLbl"] == 771)429 {430 if(req.data[j]["text"] == "표18(g/" || req.data[j]["text"]=="표18(/" || req.data[j]["text"]=="118.표(g" || req.data[j]["text"]=="18(g")431 {432 req.data[j]["text"] = "18";433 }434 if(req.data[103]["text"].substring(req.data[103]["text"].length-1) == ".")435 {436 req.data[j]["text"] = req.data[j]["text"].substring(0,req.data[j]["text"].length-1 );437 }438 if(req.data[j]["text"] == "121" || req.data[j]["text"] == "21/" || req.data[j]["text"] == "1")439 {440 req.data[j]["text"] = "21";441 }442 443 }444 //슬럼프 150()445 if(req.data[j]["entryLbl"] == 772)446 {447 if(req.data[j]["text"].indexOf("mm") !== -1)448 {449 req.data[j]["text"] = req.data[j]["text"].replace("mm","");450 }451 if(req.data[j]["text"] == "1500" || req.data[j]["text"] == "1150" || req.data[j]["text"] == "1501" || req.data[j]["text"] == "15")452 {453 req.data[j]["text"] = "150";454 }455 }456 //시멘트457 if(req.data[j]["entryLbl"] == 773)458 {459 if(req.data[j]["text"] == "포틀랜드시멘트1종따른구분" || req.data[j]["text"] == "포들랜드시멘트1종따른구분" || req.data[j]["text"] == ")따른구분시멘트종류에포틀랜드시멘트1종" || req.data[j]["text"] == "시멘트종류에따른구분)포틀랜드시멘트1종" || req.data[j]["text"] == "따른구분포틀랜드시멘트종" || req.data[j]["text"] == "틀랜드시멘트1종")460 {461 req.data[j]["text"] = "포틀랜드시멘트1종";462 }463 if(req.data[j]["text"] == "포틀랜드시멘트1종O로슬래그시메트2")464 {465 req.data[j]["text"] = "포틀랜드시멘트1종";466 }467 if(req.data[j]["text"] == "랜드시멘트1종(70")468 {469 req.data[j]["text"] = "포틀랜드시멘트1종70";470 }471 if(req.data[j]["text"] == "보통포틀멘E" || req.data[j]["text"] == "보통포틀랜드시멘E1" || req.data[j]["text"] == "보통포틀랜시1" || req.data[j]["text"] == "보통틀랜드시멘E1" || req.data[j]["text"] == "보통포틀드시멘")472 {473 req.data[j]["text"] = "보통포틀랜드시멘트1종";474 }475 476 }477 }478 else if (req.docCategory.DOCTOPTYPE == 61) 479 {480 if(req.docCategory.DOCTYPE == 422 ){481 if(req.data[j]["entryLbl"] == "877"){482 var entry877 = "";483 entry877 = req.data[j].text.replace(regExp,"");484 if(entry877.substring(entry877.length-3, entry877.length) == "000"){485 // console.log(numeral(entry877.substring(0,entry877.length-3)).format('0,0')+".000");486 req.data[j].text = numeral(entry877.substring(0,entry877.length-3)).format('0,0')+".000";487 }488 }489 else if(req.data[j]["entryLbl"] == "873"){490 var entry873 = "";491 entry873 = req.data[j].text.replace(regExp,"");492 if(entry873.length == 14)493 {494 if(entry873.substring(entry873.length-6, entry873.length) == "000000"){495 entry873 = entry873.substring(0,entry873.length-6);496 console.log(entry873.substring(0,4) + "-" +entry873.substring(4,6)+ "-" +entry873.substring(6,8));497 req.data[j].text = entry873.substring(0,4) + "-" +entry873.substring(4,6)+ "-" +entry873.substring(6,8);498 }499 }500 else if(entry873.length == 8)501 {502 console.log(entry873.substring(0,4) + "-" +entry873.substring(4,6)+ "-" +entry873.substring(6,8));503 req.data[j].text = entry873.substring(0,4) + "-" +entry873.substring(4,6)+ "-" +entry873.substring(6,8);504 }505 }506 }507 508 }509 // else if (req.docCategory.DOCTOPTYPE == 51) {510 // //품목명 예외처리511 // if(req.data[j]["entryLbl"] == 504 || req.data[j]["entryLbl"] == 505 || req.data[j]["entryLbl"] == 506 ||req.data[j]["entryLbl"] == 543) {512 // if(req.data[j]["text"].indexOf("품명및") !== -1 || req.data[j]["text"].indexOf("이하여백") !== -1 || req.data[j]["text"].indexOf("***") !== -1 || req.data[j]["text"].indexOf("이여") !== -1 || req.data[j]["text"].indexOf("*하백") !== -1 || req.data[j]["text"].indexOf("**") !== -1)513 // {514 // delete req.data[j]["entryLbl"];515 // }516 // if(req.data[j]["text"].indexOf("비고:") !== -1 || req.data[j]["text"].indexOf("계좌:") !== -1 || req.data[j]["text"].indexOf("TEL:") !== -1 || req.data[j]["text"].indexOf("여백**") !== -1 || req.data[j]["text"].indexOf("***이하") !== -1 || req.data[j]["text"].indexOf("품명") !== -1)517 // {518 // delete req.data[j]["entryLbl"];519 // }520 // if(req.data[j]["text"].indexOf("품 명 및 규 격") !== -1 || req.data[j]["text"].indexOf("하백") !== -1)521 // {522 // delete req.data[j]["entryLbl"];523 // }524 // }525 // // 540 공급자 받는자526 // if(req.data[j]["entryLbl"] == 540)527 // {528 // if(req.data[j]["text"] == "호(주)통광")529 // {530 // req.data[j]["text"] = "(주)통광";531 // }532 // if(req.data[j]["text"] == "대림에스엠(주)성")533 // {534 // req.data[j]["text"] = "대림에스엠(주)";535 // }536 // if(req.data[j]["text"] == "호(주)대유스틸")537 // {538 // req.data[j]["text"] = "(주)대유스틸";539 // } 540 // if(req.data[j]["text"] == "호대림산업(주)" || req.data[j]["text"] == "상호대림산업(주)" || req.data[j]["text"] == "대림산업주)(" || req.data[j]["text"] == "독번역편한세상캐슬대림산업(주)" || req.data[j]["text"] == "호주)대림산업(")541 // {542 // req.data[j]["text"] = "대림산업(주)";543 // } 544 // }545 // // 541 현장명546 // if(req.data[j]["entryLbl"] == 541)547 // {548 // if(req.data[j]["text"] == "명녹번역e편한세상")549 // {550 // req.data[j]["text"] = "녹번역e편한세상";551 // }552 553 // if(req.data[j]["text"] == "독번") {554 // req.data[j]["text"] = "녹번";555 // }556 // if(req.data[j]["text"] == "독번역e-편한세상") {557 // req.data[j]["text"] = "녹번역e-편한세상";558 // } 559 // }560 // // 502 공급자561 // if(req.data[j]["entryLbl"] == 502)562 // {563 // if(req.data[j]["text"] == "호광일볼트")564 // {565 // req.data[j]["text"] = "광일볼트상사";566 // }567 // if(req.data[j]["text"] == "대림산업(주)녹번역편한세상캐슬" || req.data[j]["text"] == "Tot대림산업(주)" || req.data[j]["text"] == "호대림산업(주)")568 // {569 // req.data[j]["text"] = "대림산업(주)";570 // }571 // if(req.data[j]["text"] == ")백광도시개발군")572 // {573 // req.data[j]["text"] = "백광도시개발";574 // }575 // if(req.data[j]["text"] == "대치가설산업경기도여주시" || req.data[j]["text"] == "대치가설산업여주시경기도")576 // {577 // req.data[j]["text"] = "대치가설산업";578 // }579 // if(req.data[j]["text"] == "대림에스엠(주)성" || req.data[j]["text"] == "대림에스엠()주" || req.data[j]["text"] == "대림에스엠()성주" || req.data[j]["text"] == "대림(주)성에스엠" || req.data[j]["text"] == "대림에스엠)(주" || req.data[j]["text"] == "대림에스엠)성(주")580 // {581 // req.data[j]["text"] = "대림에스엠(주)";582 // }583 // if(req.data[j]["text"] == ")웍스코퍼레이성(" || req.data[j]["text"] == ")웍스코퍼레이성" || req.data[j]["text"] == ")웍스코퍼레이션퍼레이션성")584 // {585 // req.data[j]["text"] = "웍스코퍼레이션";586 // }587 // if(req.data[j]["text"] == "우신케이판미")588 // {589 // req.data[j]["text"] = "우신케이블판매";590 // }591 // if(req.data[j]["text"] == "(광지세이프티주)" || req.data[j]["text"] == "호)광지세이프티(주" || req.data[j]["text"] == "호(주)광지세이프티")592 // {593 // req.data[j]["text"] = "광지세이프티(주)";594 // }595 // req.data[j]["text"].replace("명독","녹");596 // }597 598 // }599 600 }601 retData["docCategory"] = req.docCategory;602 retData["data"] = req.data;603 //console.log(retData);604 605 } catch (e) {606 console.log(e);607 } finally {608 return done(null, retData);609 }610 });611}612function addEntryTextOfLabel(data, docTopType, done) {613 sync.fiber(function () {614 try { 615 for (var i = 0; i < data.length; i++) {616 for (var j = 0; j < data.length; j++) { 617 if (i != j && data[i]["entryLbl"] && data[j]["entryLbl"] && data[i]["entryLbl"] == data[j]["entryLbl"]) {618 var targetLoc = data[i]["location"].split(',');619 var compareLoc = data[j]["location"].split(',');620 if (data[i]["amount"] == "single" && data[j]["amount"] == "single") { // 싱글621 if ((data[i]["entryLbl"] == "769" || data[i]["entryLbl"] == "773") &&622 (Number(compareLoc[1]) - Number(targetLoc[1])) > 30) { // 콘크리트종류 or 시멘트 종류623 // 붙여진 text 정보를 확인하기 위한 용도 (텍스트가 붙여지면 entryLbls로는 확인이 어려움)624 if (data[i]["addItem"]) {625 data[i]["addItem"].push(JSON.parse(JSON.stringify(data[j])));626 } else {627 data[i]["addItem"] = [JSON.parse(JSON.stringify(data[i])), JSON.parse(JSON.stringify(data[j]))];628 delete data[i]["entryLbls"];629 }630 //예측값 출력 안되게631 if(typeof data[i]["mlEntryLbl"] != "undefined" && typeof data[i]["entryLbl"] != "undefined" && typeof data[j]["entryLbl"] != "undefined"){632 // console.log("no undefined" + data[i]["text"]);633 break;634 }635 // 텍스트와 위치 데이터 가공636 data[i]["text"] = data[i]["text"] + data[j]["text"];637 data[i]["location"] = targetLoc[0] + ',' + targetLoc[1]638 + ',' + (compareLoc[2])639 + ',' + (Number(targetLoc[3]) + Number(compareLoc[3]) + (Number(compareLoc[1]) - (Number(targetLoc[1]) + Number(targetLoc[3]))))640 // 붙여진 text row 제거하고 배열 인덱스 한단계 전으로 돌아가서 현재 row 기준으로 다시 실행 641 data.splice(j, 1);642 i--;643 break;644 } else {645 if (data[i]["addItem"]) {646 data[i]["addItem"].push(JSON.parse(JSON.stringify(data[j])));647 } else {648 data[i]["addItem"] = [JSON.parse(JSON.stringify(data[i])), JSON.parse(JSON.stringify(data[j]))];649 delete data[i]["entryLbls"];650 }651 if (Number(targetLoc[0]) < Number(compareLoc[0])) {652 //예측값 출력 안되게 653 if(typeof data[j]["mlEntryLbl"] != "undefined" && typeof data[j]["entryLbl"] != "undefined" && typeof data[i]["entryLbl"] != "undefined"){654 // console.log("no undefined" + data[i]["text"]);655 delete data[i]["entryLbls"];656 break;657 } else {658 data[i]["text"] += data[j]["text"];659 data[i]["location"] = targetLoc[0] + ',' + targetLoc[1]660 + ',' + (Number(compareLoc[0]) + Number(compareLoc[2]) - Number(targetLoc[0]))661 + ',' + ((Number(targetLoc[3]) > Number(compareLoc[3])) ? targetLoc[3] : compareLoc[3])662 }663 664 } else {665 data[i]["text"] = data[j]["text"] + data[i]["text"];666 data[i]["location"] = compareLoc[0] + ',' + compareLoc[1]667 + ',' + (Number(targetLoc[0]) + Number(targetLoc[2]) - Number(compareLoc[0]))668 + ',' + ((Number(targetLoc[3]) > Number(compareLoc[3])) ? targetLoc[3] : compareLoc[3])669 } 670 data.splice(j, 1);671 i--;672 break;673 }674 } 675 // else if (data[i]["amount"] == "multi" && data[j]["amount"] == "multi") { // 멀티676 // var yGap = ((Number(targetLoc[1]) - Number(compareLoc[1])) > 0) ? (Number(targetLoc[1]) - Number(compareLoc[1])) : -(Number(targetLoc[1]) - Number(compareLoc[1]));677 // // 텍스트와 위치 데이터 가공 678 // if (Number(targetLoc[0]) < Number(compareLoc[0]) && yGap < 7) { 679 // // 붙여진 text 정보를 확인하기 위한 용도 (텍스트가 붙여지면 entryLbls로는 확인이 어려움)680 // if (data[i]["addItem"]) {681 // data[i]["addItem"].push(JSON.parse(JSON.stringify(data[j])));682 // } else {683 // data[i]["addItem"] = [JSON.parse(JSON.stringify(data[i])), JSON.parse(JSON.stringify(data[j]))];684 // delete data[i]["entryLbls"];685 // }686 687 // data[i]["text"] += data[j]["text"];688 // data[i]["location"] = targetLoc[0] + ',' + targetLoc[1]689 // + ',' + (Number(compareLoc[0]) + Number(compareLoc[2]) - Number(targetLoc[0]))690 // + ',' + ((Number(targetLoc[3]) > Number(compareLoc[3])) ? targetLoc[3] : compareLoc[3])691 // data.splice(j, 1);692 // i--;693 // break;694 // }695 // } 696 else if (data[i]["entryLbl"] == "760" || data[i]["entryLbl"] == "761" || data[i]["entryLbl"] == "502" || data[i]["entryLbl"] == "422") {697 } else {698 if(docTopType == "58")699 {700 if (data[i]["addItem"]) {701 data[i]["addItem"].push(JSON.parse(JSON.stringify(data[j])));702 } else {703 data[i]["addItem"] = [JSON.parse(JSON.stringify(data[i])), JSON.parse(JSON.stringify(data[j]))];704 delete data[i]["entryLbls"];705 }706 707 if (Number(targetLoc[0]) < Number(compareLoc[0])) {708 data[i]["text"] += data[j]["text"];709 data[i]["location"] = targetLoc[0] + ',' + targetLoc[1]710 + ',' + (Number(compareLoc[0]) + Number(compareLoc[2]) - Number(targetLoc[0]))711 + ',' + ((Number(targetLoc[3]) > Number(compareLoc[3])) ? targetLoc[3] : compareLoc[3])712 } else {713 data[i]["text"] = data[j]["text"] + data[i]["text"];714 data[i]["location"] = compareLoc[0] + ',' + compareLoc[1]715 + ',' + (Number(targetLoc[0]) + Number(targetLoc[2]) - Number(compareLoc[0]))716 + ',' + ((Number(targetLoc[3]) > Number(compareLoc[3])) ? targetLoc[3] : compareLoc[3])717 }718 data.splice(j, 1);719 i--;720 break;721 }722 723 } 724 }725 }726 }727 } catch (e) {728 console.log(e);729 } finally {730 return done(null, data);731 }732 });733}734function entryHeightCheck(data1, data2, diffHeight) {735 var check = false;736 data1 = data1['location'].split(',');737 data2 = data2['location'].split(',');738 var res = parseInt(data2[1]) - parseInt(data1[1]);739 // if(docType == 422)740 // {741 // if (res < 600) {742 // check = true;743 // }744 // }745 // else746 // {747 // if (res < diffHeight) {748 // check = true;749 // }750 // }751 if (res < diffHeight) {752 check = true;753 }754 755 return check;756}757function multiEntryCheck(firstEntry, entry, doctype) {758 var check = false;759 var firstLoc = firstEntry['location'].split(',');760 var entryLoc = entry['location'].split(',');761 // console.log("multiEntryCheck doctype===>" + doctype);762 // console.log("multiEntryCheck firstEntry===>" + firstEntry['entryLbl']);763 764 // if(doctype == 340) {765 // // 504 품목명766 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 50, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){767 // check = true;768 // } else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {769 // check = true;770 // }771 // } else if(doctype == 341) {772 // // 504 품목명773 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 80, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){774 // check = true;775 // } else if (firstEntry['entryLbl'] == 505 && verticalCheck(firstLoc, entryLoc, 10, -10) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {776 // check = true;777 // } else if (firstEntry['entryLbl'] == 543 && verticalCheck(firstLoc, entryLoc, 80, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {778 // check = true;779 // } else if (firstEntry['entryLbl'] == 506 && verticalCheck(firstLoc, entryLoc, 50, -50) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {780 // check = true;781 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {782 // check = true;783 // }784 // // 일반송자_광일볼트상사785 // }else if(doctype == 348){786 // // 504 품목명787 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 100, -300) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){788 // check = true;789 // }else if(firstEntry['entryLbl'] == 506 && verticalCheck(firstLoc, entryLoc, 100, -50) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){790 // check = true;791 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {792 // check = true;793 // }794 795 // // 355 일반송장_남양씨피엠796 // }else if(doctype == 355){797 // // 504 품목명798 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 150, -300) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){799 // check = true;800 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {801 // check = true;802 // }803 // // 358 대림에스엠804 // }else if(doctype == 358){ 805 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 10, -10) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){806 // check = true;807 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {808 // check = true;809 // }810 // }else if(doctype == 363) {811 // // 504 품목명812 // if(firstEntry['entryLbl'] == 505 && verticalCheck(firstLoc, entryLoc, 20, -20) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){813 // check = true;814 // }815 // // 364 대유스틸816 // }else if(doctype == 364){ 817 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){818 // check = true;819 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {820 // check = true;821 // }822 // // 367 대치가설산업823 // }else if(doctype == 367){ 824 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 10, -10) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){825 // check = true;826 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {827 // check = true;828 // } 829 // // 355 삼성에스앤에이치830 // }else if(doctype == 355){ 831 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 10, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){832 // check = true;833 // }else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {834 // check = true;835 // }836 // // 380 광지세이프티02837 // }else if(doctype == 380){ 838 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 10, -150) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){839 // check = true;840 // }else if(firstEntry['entryLbl'] == 505 && verticalCheck(firstLoc, entryLoc, 100, -50) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){841 // check = true;842 // }843 // else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {844 // check = true;845 // }846 847 // // 380 광지세이프티02848 // }else if(doctype == 383){ 849 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 200, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){850 // check = true;851 // }else if(firstEntry['entryLbl'] == 505 && verticalCheck(firstLoc, entryLoc, 100, -50) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){852 // check = true;853 // }854 // else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {855 // check = true;856 // }857 858 // // 387 미래테크859 // }else if(doctype == 387){ 860 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 100, -150) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){861 // check = true;862 // }else if(firstEntry['entryLbl'] == 505 && verticalCheck(firstLoc, entryLoc, 100, -50) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){863 // check = true;864 // }865 // // 343 대림씨엔에스866 // }else if(doctype == 343){ 867 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 100, -150) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){868 // check = true;869 // }else if(firstEntry['entryLbl'] == 541 && verticalCheck(firstLoc, entryLoc, 100, -150) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){870 // check = true;871 // }872 // // 343 광지세이프티01873 // }else if(doctype == 344){ 874 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){875 // check = true;876 // }else if(firstEntry['entryLbl'] == 541 && verticalCheck(firstLoc, entryLoc, 100, -150) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){877 // check = true;878 // } 879 880 // // 336 대림에스엠881 // }else if(doctype == 336){ 882 // if(firstEntry['entryLbl'] == 504 && verticalCheck(firstLoc, entryLoc, 50, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)){883 // check = true;884 // } else if(verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {885 // check = true;886 // } 887 // }888 if(doctype == 422) {889 // var deleteY =0;890 // if(entry["text"] == "TOTAL" && Number(entryLoc[1]) > 2000)891 // {892 // console.log(entry["text"]);893 // console.log(entryLoc[1]);894 // deleteY = Number(entryLoc[1]);895 // }896 // else897 // {898 // deleteY = 5000899 // }900 if(entry["text"] != "TOTAL" && entry["text"] != "인수확인자" && entry["text"] != "제품의포장" && entry["text"] != "(인)")901 // if(Number(entryLoc[1]) < deleteY)902 {903 if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {904 check = true;905 }906 }907 }908 else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {909 check = true;910 }911 return check;912}913function multiDeleteEntryCheck(deleteEntry, entry, doctype) {914 var check = false;915 var firstLoc = firstEntry['location'].split(',');916 var entryLoc = entry['location'].split(',');917 if(doctype == 422) {918 console.log(entry["text"]);919 if(entry["text"] != "TOTAL" && entry["text"] != "인수확인자" && entry["text"] != "제품의포장" && entry["text"] != "(인)")920 {921 console.log("11111111");922 if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {923 check = true;924 }925 }926 // else927 // {928 // console.log("2222222");929 // check = false;930 // }931 }932 else if (verticalCheck(firstLoc, entryLoc, 100, -100) && locationCheck(firstLoc[1], entryLoc[1], 0, -2000)) {933 check = true;934 }935 return check;936}937// function verticalCheck(data1, data2, plus, minus) {938// var check = false;939// var dataWidthLoc2 = (parseInt(data2[0]) + parseInt(data2[0]) + parseInt(data2[2])) / 2;940// var leftRange = parseInt(data1[0]) + minus;941// var rigthRange = parseInt(data1[0]) + parseInt(data1[0]) + parseInt(data1[2]) + plus;942// if (leftRange < dataWidthLoc2 && dataWidthLoc2 < rigthRange) {943// check = true;944// }945// return check;946// }947function verticalCheck(data1, data2, plus, minus) {948 var check = false;949 var dataWidthLoc1 = (parseInt(data1[0]) + parseInt(data1[0]) + parseInt(data1[2])) / 2;950 var dataWidthLoc2 = (parseInt(data2[0]) + parseInt(data2[0]) + parseInt(data2[2])) / 2;951 var res = dataWidthLoc1 - dataWidthLoc2;952 if (res < plus && res > minus) {953 check = true;954 }955 return check;956}957function locationCheck(data1, data2, plus, minus) {958 var res = parseInt(data1) - parseInt(data2);959 var check = false;960 if (res < plus && res > minus) {961 check = true;962 }963 return check;964}965// db 컬럼 정규식과 현재 타겟 text 비교966function isValid(list, cls, text) {967 for (var i in list) {968 if (list[i].SEQNUM == cls) {969 var reg = new RegExp(list[i].VALID);970 return reg.test(text);971 }972 }973 return false;974}975function similar(str, data) {976 return new difflib.SequenceMatcher(null,str, data).ratio();977}978// label, entry 예측 범위 지정 (기준점 : 좌상단, 우하단)979function predictionColumn(docCategory, targetData, dbRowData, type) {980 var mapJson = predRegionConfig;981 var loc = targetData.location.split(","); 982 // 좌상단 좌표를 기준으로 영역 계산983 var tgXLoc = Number(loc[0]), tgYLoc = Number(loc[1]);984 var dbXLoc = (type == 'L') ? Number(dbRowData.LOCATION_X.split(",")[0]) : Number(dbRowData.OCR_TEXT_X.split(",")[0]);985 var dbYLoc = (type == 'L') ? Number(dbRowData.LOCATION_Y.split(",")[0]) : Number(dbRowData.OCR_TEXT_Y.split(",")[0]);986 var upYLoc = dbYLoc, rightXLoc = dbXLoc, downYLoc = dbYLoc, leftXLoc = dbXLoc;987 // if (mapJson[docCategory.DOCTYPE] && mapJson[docCategory.DOCTYPE][dbRowData.CLASS] && mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU']988 // && mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU'][type]) {989 // upYLoc -= mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU'][type].up,990 // rightXLoc += mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU'][type].right,991 // downYLoc += mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU'][type].down,992 // leftXLoc -= mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['LU'][type].left;993 // } else {994 // upYLoc -= mapJson['default']['LU'][type].up,995 // rightXLoc += mapJson['default']['LU'][type].right,996 // downYLoc += mapJson['default']['LU'][type].down,997 // leftXLoc -= mapJson['default']['LU'][type].left;998 // }999 // DOCTOPTYP별로 config 호출1000 if (mapJson[docCategory.DOCTOPTYPE] != "") { 1001 upYLoc -= mapJson[docCategory.DOCTOPTYPE]['LU'][type].up,1002 rightXLoc += mapJson[docCategory.DOCTOPTYPE]['LU'][type].right,1003 downYLoc += mapJson[docCategory.DOCTOPTYPE]['LU'][type].down,1004 leftXLoc -= mapJson[docCategory.DOCTOPTYPE]['LU'][type].left;1005 } else {1006 upYLoc -= mapJson['default']['LU'][type].up,1007 rightXLoc += mapJson['default']['LU'][type].right,1008 downYLoc += mapJson['default']['LU'][type].down,1009 leftXLoc -= mapJson['default']['LU'][type].left;1010 }1011 var isLUCheck = (leftXLoc <= tgXLoc && tgXLoc <= rightXLoc) && (upYLoc <= tgYLoc && tgYLoc <= downYLoc);1012 // 우하단 좌표를 기준으로 영역 계산1013 var tgXLoc = Number(loc[0]) + Number(loc[2]), tgYLoc = Number(loc[1]) + Number(loc[3]);1014 var dbXLoc = (type == 'L') ? Number(dbRowData.LOCATION_X.split(",")[0]) + Number(dbRowData.LOCATION_X.split(",")[1]) : Number(dbRowData.OCR_TEXT_X.split(",")[0]) + Number(dbRowData.OCR_TEXT_X.split(",")[1]);1015 var dbYLoc = (type == 'L') ? Number(dbRowData.LOCATION_Y.split(",")[0]) + Number(dbRowData.LOCATION_Y.split(",")[1]) : Number(dbRowData.OCR_TEXT_Y.split(",")[0]) + Number(dbRowData.OCR_TEXT_Y.split(",")[1]);1016 var upYLoc = dbYLoc, rightXLoc = dbXLoc, downYLoc = dbYLoc, leftXLoc = dbXLoc;1017 if (mapJson[docCategory.DOCTYPE] && mapJson[docCategory.DOCTYPE][dbRowData.CLASS] && mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD']1018 && mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD'][type]) {1019 upYLoc -= mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD'][type].up,1020 rightXLoc += mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD'][type].right,1021 downYLoc += mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD'][type].down,1022 leftXLoc -= mapJson[docCategory.DOCTYPE][dbRowData.CLASS]['RD'][type].left;1023 } else {1024 upYLoc -= mapJson['default']['RD'][type].up,1025 rightXLoc += mapJson['default']['RD'][type].right,1026 downYLoc += mapJson['default']['RD'][type].down,1027 leftXLoc -= mapJson['default']['RD'][type].left;1028 }1029 var isRDCheck = (leftXLoc <= tgXLoc && tgXLoc <= rightXLoc) && (upYLoc <= tgYLoc && tgYLoc <= downYLoc);1030 return (isLUCheck || isRDCheck) ? true : false;1031}1032// function predictionColumn(docCategory, targetData, dbRowData, type) {1033// var loc = targetData.location.split(","); 1034// var dbXLoc = (type == 'L') ? Number(dbRowData.LOCATION_X.split(",")[0]) : Number(dbRowData.OCR_TEXT_X.split(",")[0]);1035// var dbYLoc = (type == 'L') ? Number(dbRowData.LOCATION_Y.split(",")[0]) : Number(dbRowData.OCR_TEXT_Y.split(",")[0]);1036// return (loc[0] == dbXLoc && loc[1] == dbYLoc);...

Full Screen

Full Screen

CreateEntryLocPage.js

Source:CreateEntryLocPage.js Github

copy

Full Screen

1import React from 'react';2import ReactMixin from 'react-mixin';3var Reflux = require('reflux');4import { Form, Modal, Button, Input, Select, Row, Col} from 'antd';5const FormItem = Form.Item;6const Option = Select.Option;7import ServiceMsg from '../../../../lib/Components/ServiceMsg';8import ModalForm from '../../../../lib/Components/ModalForm';9var Common = require('../../../../public/script/common');10var Utils = require('../../../../public/script/utils');11var EntryLocStore = require('../data/EntryLocStore.js');12var EntryLocActions = require('../action/EntryLocActions');13var CreateEntryLocPage = React.createClass({14 getInitialState : function() {15 return {16 entryLocSet: {},17 loading: false,18 modal: false,19 entryLoc: {},20 hints: {},21 validRules: []22 }23 },24 mixins: [Reflux.listenTo(EntryLocStore, "onServiceComplete"), ModalForm('entryLoc')],25 onServiceComplete: function(data) {26 if(this.state.modal && data.operation === 'create'){27 if( data.errMsg === ''){28 // 成功,关闭窗口29 this.setState({30 modal: false31 });32 }33 else{34 // 失败35 this.setState({36 loading: false,37 entryLocSet: data38 });39 }40 }41 },42 // 第一次加载43 componentDidMount : function(){44 this.state.validRules = [45 { id: 'locName', desc: '入职地址', required: true, max: 128,},46 { id: 'corpName', desc: '公司名称', required: true, max: 128,},47 { id: 'corpPhone', desc: '电话', max: 64,},48 { id: 'cityName', desc: '城市', max: 32,},49 { id: 'workTime', desc: '工作时间', max: 64,},50 { id: 'corpHome', desc: '公司网址', max: 64,},51 ];52 },53 clear : function(filter){54 // FIXME 输入参数,对象初始化55 this.state.hints = {};56 this.state.entryLoc.uuid='';57 this.state.entryLoc.filter = filter;58 this.state.entryLoc.locName='';59 this.state.entryLoc.corpName='';60 this.state.entryLoc.corpPhone='';61 this.state.entryLoc.cityName='';62 this.state.entryLoc.workTime='9:00-12:00,13:00-18:00';63 this.state.entryLoc.corpHome='';64 this.state.loading = false;65 if( !this.state.modal && typeof(this.refs.mxgBox) != 'undefined' ){66 this.refs.mxgBox.clear();67 }68 },69 onClickSave : function(){70 if(Common.formValidator(this, this.state.entryLoc)){71 this.setState({loading: true});72 this.state.entryLoc.corpUuid = window.loginData.compUser.corpUuid;73 EntryLocActions.createEntryLoc( this.state.entryLoc );74 }75 },76 render : function(){77 var layout='horizontal';78 var layoutItem='form-item-'+layout;79 const formItemLayout = {80 labelCol: ((layout=='vertical') ? null : {span: 4}),81 wrapperCol: ((layout=='vertical') ? null : {span: 20}),82 };83 const formItemLayout2 = {84 labelCol: ((layout == 'vertical') ? null : { span: 8 }),85 wrapperCol: ((layout == 'vertical') ? null : { span: 16 }),86 };87 var hints=this.state.hints;88 return (89 <Modal visible={this.state.modal} width='540px' title="增加入职地址信息" maskClosable={false} onOk={this.onClickSave} onCancel={this.toggle}90 footer={[91 <div key="footerDiv" style={{display:'block', textAlign:'right'}}>92 <ServiceMsg ref='mxgBox' svcList={['entry-loc/create']}/>93 <Button key="btnOK" type="primary" size="large" onClick={this.onClickSave} loading={this.state.loading}>保存</Button>{' '}94 <Button key="btnClose" size="large" onClick={this.toggle}>取消</Button>95 </div>96 ]}97 >98 <Form layout={layout}>99 <FormItem {...formItemLayout} className={layoutItem} label='入职地址' required={true} colon={true} help={hints.locNameHint} validateStatus={hints.locNameStatus}>100 <Input type='text' name='locName' id='locName' value={this.state.entryLoc.locName} onChange={this.handleOnChange} />101 </FormItem>102 <FormItem {...formItemLayout} className={layoutItem} label='公司名称' required={true} colon={true} help={hints.corpNameHint} validateStatus={hints.corpNameStatus}>103 <Input type='text' name='corpName' id='corpName' value={this.state.entryLoc.corpName} onChange={this.handleOnChange} />104 </FormItem>105 <Row type="flex">106 <Col span="12">107 <FormItem {...formItemLayout2} className={layoutItem} label='城市' colon={true} help={hints.cityNameHint} validateStatus={hints.cityNameStatus}>108 <Input type='text' name='cityName' id='cityName' value={this.state.entryLoc.cityName} onChange={this.handleOnChange} />109 </FormItem>110 </Col>111 <Col span="12">112 <FormItem {...formItemLayout2} className={layoutItem} label='电话' colon={true} help={hints.corpPhoneHint} validateStatus={hints.corpPhoneStatus}>113 <Input type='text' name='corpPhone' id='corpPhone' value={this.state.entryLoc.corpPhone} onChange={this.handleOnChange} />114 </FormItem>115 </Col>116 </Row>117 <Row type="flex">118 <Col span="12">119 <FormItem {...formItemLayout2} className={layoutItem} label='工作时间' colon={true} help={hints.workTimeHint} validateStatus={hints.workTimeStatus}>120 <Input type='text' name='workTime' id='workTime' value={this.state.entryLoc.workTime} onChange={this.handleOnChange} />121 </FormItem>122 </Col>123 <Col span="12">124 <FormItem {...formItemLayout2} className={layoutItem} label='公司网址' colon={true} help={hints.corpHomeHint} validateStatus={hints.corpHomeStatus}>125 <Input type='text' name='corpHome' id='corpHome' value={this.state.entryLoc.corpHome} onChange={this.handleOnChange} />126 </FormItem>127 </Col>128 </Row>129 </Form>130 </Modal>131 );132 }133});...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import resolve from "try-resolve";2import path from "path";3import fs from "fs";4import _ from "lodash";5function humanize(val, noext) {6 if (noext) val = path.basename(val, path.extname(val));7 return val.replace(/-/g, " ");8}9type TestFile = {10 loc: string;11 code: string;12 filename: string;13};14type Test = {15 title: string;16 disabled: boolean;17 options: Object;18 exec: TestFile;19 actual: TestFile;20 expected: TestFile;21};22type Suite = {23 options: Object;24 tests: Array<Test>;25 title: string;26 filename: string;27};28function assertDirectory(loc) {29 if (!fs.statSync(loc).isDirectory()) {30 throw new Error(`Expected ${loc} to be a directory.`);31 }32}33function shouldIgnore(name, blacklist?: Array<string>) {34 if (blacklist && blacklist.indexOf(name) >= 0) {35 return true;36 }37 let ext = path.extname(name);38 let base = path.basename(name, ext);39 return name[0] === "." || ext === ".md" || base === "LICENSE" || base === "options";40}41export default function get(entryLoc): Array<Suite> {42 let suites = [];43 let rootOpts = {};44 let rootOptsLoc = resolve(entryLoc + "/options");45 if (rootOptsLoc) rootOpts = require(rootOptsLoc);46 for (let suiteName of fs.readdirSync(entryLoc)) {47 if (shouldIgnore(suiteName)) continue;48 let suite = {49 options: _.clone(rootOpts),50 tests: [],51 title: humanize(suiteName),52 filename: entryLoc + "/" + suiteName53 };54 assertDirectory(suite.filename);55 suites.push(suite);56 let suiteOptsLoc = resolve(suite.filename + "/options");57 if (suiteOptsLoc) suite.options = require(suiteOptsLoc);58 for (let taskName of fs.readdirSync(suite.filename)) {59 push(taskName, suite.filename + "/" + taskName);60 }61 function push(taskName, taskDir) {62 let actualLocAlias = suiteName + "/" + taskName + "/actual.js";63 let expectLocAlias = suiteName + "/" + taskName + "/expected.js";64 let execLocAlias = suiteName + "/" + taskName + "/exec.js";65 let actualLoc = taskDir + "/actual.js";66 let expectLoc = taskDir + "/expected.js";67 let execLoc = taskDir + "/exec.js";68 if (fs.statSync(taskDir).isFile()) {69 let ext = path.extname(taskDir);70 if (ext !== ".js" && ext !== ".module.js") return;71 execLoc = taskDir;72 }73 if (resolve.relative(expectLoc + "on")) {74 expectLoc += "on";75 expectLocAlias += "on";76 }77 let taskOpts = _.cloneDeep(suite.options);78 let taskOptsLoc = resolve(taskDir + "/options");79 if (taskOptsLoc) _.merge(taskOpts, require(taskOptsLoc));80 let test = {81 optionsDir: taskOptsLoc ? path.dirname(taskOptsLoc) : null,82 title: humanize(taskName, true),83 disabled: taskName[0] === ".",84 options: taskOpts,85 exec: {86 loc: execLoc,87 code: readFile(execLoc),88 filename: execLocAlias,89 },90 actual: {91 loc: actualLoc,92 code: readFile(actualLoc),93 filename: actualLocAlias,94 },95 expect: {96 loc: expectLoc,97 code: readFile(expectLoc),98 filename: expectLocAlias99 }100 };101 // traceur checks102 if (test.exec.code.indexOf("// Async.") >= 0) {103 return;104 }105 suite.tests.push(test);106 let sourceMappingsLoc = taskDir + "/source-mappings.json";107 if (fs.existsSync(sourceMappingsLoc)) {108 test.sourceMappings = JSON.parse(readFile(sourceMappingsLoc));109 }110 let sourceMapLoc = taskDir + "/source-map.json";111 if (fs.existsSync(sourceMapLoc)) {112 test.sourceMap = JSON.parse(readFile(sourceMapLoc));113 }114 }115 }116 return suites;117}118export function multiple(entryLoc, ignore?: Array<string>) {119 let categories = {};120 for (let name of fs.readdirSync(entryLoc)) {121 if (shouldIgnore(name, ignore)) continue;122 let loc = path.join(entryLoc, name);123 assertDirectory(loc);124 categories[name] = get(loc);125 }126 return categories;127}128export function readFile(filename) {129 if (fs.existsSync(filename)) {130 let file = _.trimEnd(fs.readFileSync(filename, "utf8"));131 file = file.replace(/\r\n/g, "\n");132 return file;133 } else {134 return "";135 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const entryLoc = require('stryker-parent').entryLoc;2console.log(entryLoc());3const entryLoc = require('stryker-parent').entryLoc;4console.log(entryLoc());5const entryLoc = require('stryker-parent').entryLoc;6console.log(entryLoc());7const entryLoc = require('stryker-parent').entryLoc;8console.log(entryLoc());9const entryLoc = require('stryker-parent').entryLoc;10console.log(entryLoc());11const entryLoc = require('stryker-parent').entryLoc;12console.log(entryLoc());13const entryLoc = require('stryker-parent').entryLoc;14console.log(entryLoc());15const entryLoc = require('stryker-parent').entryLoc;16console.log(entryLoc());17const entryLoc = require('stryker-parent').entryLoc;18console.log(entryLoc());19const entryLoc = require('stryker-parent').entryLoc;20console.log(entryLoc());21const entryLoc = require('stryker-parent').entryLoc;22console.log(entryLoc());23const entryLoc = require('stryker-parent').entryLoc;24console.log(entryLoc());25const entryLoc = require('stryker-parent').entryLoc;26console.log(entryLoc());

Full Screen

Using AI Code Generation

copy

Full Screen

1import { entryLoc } from 'stryker-parent';2import { entryLoc } from 'stryker';3import { entryLoc } from 'stryker-parent';4import { entryLoc } from 'stryker';5import { entryLoc } from 'stryker-parent';6import { entryLoc } from 'stryker';7import { entryLoc } from 'stryker-parent';8import { entryLoc } from 'stryker';9import { entryLoc } from 'stryker-parent';10import { entryLoc } from 'stryker';11import { entryLoc } from 'stryker-parent';12import { entryLoc } from 'stryker';13import { entryLoc } from 'stryker-parent';14import { entryLoc } from 'stryker';15import { entryLoc } from 'stryker-parent';16import { entryLoc } from 'stryker';17import { entryLoc } from 'stryker-parent';18import { entryLoc } from 'stryker';19import { entryLoc } from 'stryker-parent';20import { entryLoc } from 'stryker';21import { entryLoc } from 'stryker-parent';22import { entryLoc } from 'stryker';

Full Screen

Using AI Code Generation

copy

Full Screen

1const entryLoc = require('stryker-parent').entryLoc;2const entryLocResult = entryLoc('test.js');3console.log(entryLocResult);4const entryLoc = require('stryker-parent').entryLoc;5const entryLocResult = entryLoc('test.js');6console.log(entryLocResult);7const entryLoc = require('stryker-parent').entryLoc;8const entryLocResult = entryLoc('test.js');9console.log(entryLocResult);10const entryLoc = require('stryker-parent').entryLoc;11const entryLocResult = entryLoc('test.js');12console.log(entryLocResult);13const entryLoc = require('stryker-parent').entryLoc;14const entryLocResult = entryLoc('test.js');15console.log(entryLocResult);16const entryLoc = require('stryker-parent').entryLoc;17const entryLocResult = entryLoc('test.js');18console.log(entryLocResult);19const entryLoc = require('stryker-parent').entryLoc;20const entryLocResult = entryLoc('test.js');21console.log(entryLocResult);22const entryLoc = require('stryker-parent').entryLoc;23const entryLocResult = entryLoc('test.js');24console.log(entryLocResult);25const entryLoc = require('stryker-parent').entryLoc;26const entryLocResult = entryLoc('test.js');27console.log(entryLocResult);28const entryLoc = require('stryker-parent').entryLoc;29const entryLocResult = entryLoc('test.js');30console.log(entryLocResult);31const entryLoc = require('stryker-parent').entryLoc;

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var child = require('child_process');3var path = require('path');4var childProcess = child.fork(path.join(__dirname, './child.js'), [], {5 '--require', require.resolve('source-map-support/register'),6 '--require', require.resolve('stryker-parent/entryLoc')7});8childProcess.on('message', function (message) {9 console.log(message);10});11var strykerParent = require('stryker-parent');12var child = require('child_process');13var path = require('path');14var childProcess = child.fork(path.join(__dirname, './grandChild.js'), [], {15 '--require', require.resolve('source-map-support/register'),16 '--require', require.resolve('stryker-parent/entryLoc')17});18childProcess.on('message', function (message) {19 console.log(message);20});21var strykerParent = require('stryker-parent');22var child = require('child_process');23var path = require('path');24var childProcess = child.fork(path.join(__dirname, './greatGrandChild.js'), [], {25 '--require', require.resolve('source-map-support/register'),26 '--require', require.resolve('stryker-parent/entryLoc')27});28childProcess.on('message', function (message) {29 console.log(message);30});31var strykerParent = require('stryker-parent');32console.log('greatGrandChild: ' + strykerParent.entryLoc());

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const entryLoc = require('stryker-parent').entryLoc;3const childProcess = require('child_process');4const child = childProcess.fork(entryLoc('stryker'), ['run', '--files', path.resolve(__dirname, 'index.js')], { stdio: 'inherit' });5child.on('exit', function (code) {6 process.exit(code);7});8const a = 1;9const b = 2;10const c = a + b;11console.log(c);12module.exports = function (config) {13 config.set({14 commandRunner: {15 }16 });17};18I have tried with the default test runner (jest) and it worked fine. But I

Full Screen

Using AI Code Generation

copy

Full Screen

1const entryLoc = require('stryker-parent').entryLoc;2const entry = entryLoc('path/to/entry.js');3const entryLoc = require('stryker-parent').entryLoc;4const entry = entryLoc('path/to/entry.js');5const entryLoc = require('stryker-parent').entryLoc;6const entry = entryLoc('path/to/entry.js');7const entryLoc = require('stryker-parent').entryLoc;8const entry = entryLoc('path/to/entry.js');9const entryLoc = require('stryker-parent').entryLoc;10const entry = entryLoc('path/to/entry.js');11const entryLoc = require('stryker-parent').entryLoc;12const entry = entryLoc('path/to/entry.js');13const entryLoc = require('stryker-parent').entryLoc;14const entry = entryLoc('path/to/entry.js');15const entryLoc = require('stryker-parent').entryLoc;16const entry = entryLoc('path/to/entry.js');17const entryLoc = require('stryker-parent').entryLoc;18const entry = entryLoc('path/to/entry.js');19const entryLoc = require('stryker-parent').entryLoc;20const entry = entryLoc('path/to/

Full Screen

Using AI Code Generation

copy

Full Screen

1import { entryLoc } from 'stryker-parent';2const loc = entryLoc('test.js');3import { entryLoc } from 'stryker-parent';4const loc = entryLoc('test2.js');5import { entryLoc } from 'stryker-parent';6const loc = entryLoc('test2.js');7import { entryLoc } from 'stryker-parent';8const loc = entryLoc('test2.js');9import { entryLoc } from 'stryker-parent';10const loc = entryLoc('test2.js');11import { entryLoc } from 'stryker-parent';12const loc = entryLoc('test2.js');13import { entryLoc } from 'stryker-parent';14const loc = entryLoc('test2.js');15import { entryLoc } from 'stryker-parent';16const loc = entryLoc('test2.js');17import { entryLoc } from 'stryker-parent';18const loc = entryLoc('test2.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var entryLoc = require('stryker-parent').entryLoc;2var loc = entryLoc('test.js');3console.log(loc);4var entryLoc = require('stryker-parent').entryLoc;5var loc = entryLoc('/Users/username/stryker-parent/test.js');6console.log(loc);7var entryLoc = require('stryker-parent').entryLoc;8var loc = entryLoc('/Users/username/stryker-parent/test.js', true);9console.log(loc);10var entryLoc = require('stryker-parent').entryLoc;11var loc = entryLoc('/Users/username/stryker-parent/test.js', false);12console.log(loc);13var entryLoc = require('stryker-parent').entryLoc;14var loc = entryLoc('/Users/username/stryker-parent/test.js', 'true');15console.log(loc);16var entryLoc = require('stryker-parent').entryLoc;17var loc = entryLoc('/Users/username/stryker-parent/test.js', 'false');18console.log(loc);

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require("stryker-parent");2var loc = strykerParent.entryLoc(__dirname);3console.log("entryLoc: " + loc);4var strykerParent = require("stryker-parent");5var loc = strykerParent.entryLoc(__dirname);6console.log("entryLoc: " + loc);7var strykerParent = require("stryker-parent");8var loc = strykerParent.entryLoc(__dirname);9console.log("entryLoc: " + loc);10var strykerParent = require("stryker-parent");11var loc = strykerParent.entryLoc(__dirname);12console.log("entryLoc: " + loc);13var strykerParent = require("stryker-parent");14var loc = strykerParent.entryLoc(__dirname);15console.log("entryLoc: " + loc);16var strykerParent = require("stryker-parent");17var loc = strykerParent.entryLoc(__dirname);18console.log("entryLoc: " + loc);19var strykerParent = require("stryker-parent");20var loc = strykerParent.entryLoc(__dirname);21console.log("entryLoc: " + loc);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful