| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:ReportModuleLogic.cs
- * 2.功能描述:生产线报表分析
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 宋扬 2014/11/08 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using Oracle.DataAccess.Client;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DataAccess;
- using Dongke.IBOSS.PRD.Service.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels.ReportModule;
- using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
- using Dongke.WinForm.Utilities;
- namespace Dongke.IBOSS.PRD.Service.ReportModuleLogic
- {
- /// <summary>
- /// 生产线报表分析
- /// </summary>
- public class ReportModuleLogic
- {
- #region 综合报表
- #region 跟踪统计表
- #region 生产管理
- /// <summary>
- /// 产品跟踪明细查询
- /// </summary>
- /// <param name="searchGoodsFollowingEntity">产品跟踪统计实体类</param>
- /// <param name="sUserInfo">用户基本信息</param>
- /// <returns>DataSet</returns>
- public static DataSet GetSearchGoodsFollowingDetailModule(SearchGoodsFollowingEntity searchGoodsFollowingEntity, SUserInfo sUserInfo)
- {
- IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- con.Open();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
- new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetRPTDetailData", paras);
- return dsSearchReport;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (con.ConnState == ConnectionState.Open)
- {
- con.Close();
- }
- }
- }
- #endregion
- #endregion
- #endregion
- #region 统一使用ServiceResultEntity类模式
- #region 跟踪报表
- /// <summary>
- /// 取得RPT020101_1画面(产品跟踪)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT020101SData(SUserInfo user, RPT020101_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_barCode",OracleDbType.Varchar2,se.Barcode,ParameterDirection.Input),
- new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- new OracleParameter("out_result1",OracleDbType.RefCursor,ParameterDirection.Output),
- };
- //DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetGoodsFollowingData", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- #endregion
- #region 明细报表
- /// <summary>
- /// 取得RPT010101_1画面(注浆明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010101SData(SUserInfo user, RPT010101_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010101SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- // 成型线类型ids
- if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
- {
- sql.Append("AND instr(','||:GMouldTypeIDS||',',','||TP_MST_GMouldType.gMouldTypeId||',')>0 ");
- parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
- }
- // 成型线IDS
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append("AND instr(','||:GroutingLineIDS||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append("AND instr(','||:GoodsIDS||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- // 产品类别IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- // sql.Append("AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ");
- sql.Append("AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- // 模具号
- if (!string.IsNullOrEmpty(se.GroutingMouldCode))
- {
- sql.Append("AND instr(TP_PM_GroutingDailyDetail.GroutingMouldCode,:GroutingMouldCode)>0 ");
- parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
- }
- // 注浆时间-开始
- if (se.GroutingDateStart.HasValue)
- {
- sql.Append("AND TP_PM_GroutingDailyDetail.GroutingDate >= :GroutingDateStart ");
- parameters.Add(new OracleParameter(":GroutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
- }
- // 模具类型IDS
- if (se.GroutingDateEnd.HasValue)
- {
- sql.Append("AND TP_PM_GroutingDailyDetail.GroutingDate <= :GroutingDateEnd ");
- parameters.Add(new OracleParameter(":GroutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
- }
- if (se.GroutingBatchNo.HasValue)
- {
- //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingBatchNo = :GroutingBatchNo");
- sql.Append(" AND instr(TP_PM_GroutingDailyDetail.GroutingBatchNo,:GroutingBatchNo)>0");
- parameters.Add(new OracleParameter(":GroutingBatchNo", OracleDbType.Int32, se.GroutingBatchNo, ParameterDirection.Input));
- }
- // 成型工号IDS
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- sql.Append("and instr(',' || :GroutingUserIDS || ',' ,','||TP_PM_GroutingDailyDetail.UserID||',' )>0 ");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.Clob, se.GroutingUserIDS, ParameterDirection.Input));
- }
- // 未注浆原因
- if (!string.IsNullOrEmpty(se.NoGroutingRreason))
- {
- sql.Append("AND instr(b.dictionaryvalue,:NoGroutingRreason)>0 ");
- parameters.Add(new OracleParameter(":NoGroutingRreason", OracleDbType.NVarchar2, se.NoGroutingRreason, ParameterDirection.Input));
- }
- // 生产工号IDS
- if (!string.IsNullOrEmpty(se.CreateUserIDS))
- {
- sql.Append("and instr(',' || :CreateUserIDS || ',' ,','||TP_PM_GroutingDailyDetail.CreateUserID||',' )>0 ");
- parameters.Add(new OracleParameter(":CreateUserIDS", OracleDbType.NVarchar2, se.CreateUserIDS, ParameterDirection.Input));
- }
- // 备注
- if (!string.IsNullOrEmpty(se.Remarks))
- {
- sql.Append(" AND INSTR(TP_PM_GroutingDailyDetail.Remarks, :Remarks) > 0");
- parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
- }
- // 注浆标识
- if (!string.IsNullOrEmpty(se.GroutingFlag))
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingFlag = :GroutingFlag");
- parameters.Add(new OracleParameter(":GroutingFlag", OracleDbType.Char, se.GroutingFlag, ParameterDirection.Input));
- }
- // 损坯标识
- if (!string.IsNullOrEmpty(se.ScrapFlag))
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapFlag = :ScrapFlag");
- parameters.Add(new OracleParameter(":ScrapFlag", OracleDbType.Char, se.ScrapFlag, ParameterDirection.Input));
- }
- // 绑定条码
- if (!string.IsNullOrEmpty(se.BarCodeFlag))
- {
- if ("1" == se.BarCodeFlag)
- {
- sql.Append(" AND LENGTH(TP_PM_GroutingDailyDetail.BarCode) > 0");
- }
- else
- {
- sql.Append(" AND (TP_PM_GroutingDailyDetail.BarCode IS NULL OR LENGTH(TP_PM_GroutingDailyDetail.BarCode) = 0)");
- }
- }
- // 交坯日期-开始
- if (se.DeliverTimeBegin.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverTime >= :DeliverTimeBegin");
- parameters.Add(new OracleParameter(":DeliverTimeBegin", OracleDbType.Date, se.DeliverTimeBegin.Value, ParameterDirection.Input));
- }
- // 交坯日期-结束
- if (se.DeliverTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverTime <= :DeliverTimeEnd");
- parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.DeliverTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯标识
- if (!string.IsNullOrEmpty(se.DeliverFlag))
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverFlag = :DeliverFlag");
- parameters.Add(new OracleParameter(":DeliverFlag", OracleDbType.Char, se.DeliverFlag, ParameterDirection.Input));
- }
- // 损坯日期-开始
- if (se.ScrapTimeBegin.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapTime >= :ScrapTimeBegin");
- parameters.Add(new OracleParameter(":ScrapTimeBegin", OracleDbType.Date, se.ScrapTimeBegin.Value, ParameterDirection.Input));
- }
- // 损坯日期-结束
- if (se.ScrapTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapTime <= :ScrapTimeEnd");
- parameters.Add(new OracleParameter(":ScrapTimeEnd", OracleDbType.Date, se.ScrapTimeEnd.Value, ParameterDirection.Input));
- }
- // 注浆操作时间-开始
- if (se.GCTimeBegin.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.CreateTime >= :GCTimeBegin");
- parameters.Add(new OracleParameter(":GCTimeBegin", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
- }
- // 注浆操作时间-结束
- if (se.GCTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.CreateTime <= :GCTimeEnd");
- parameters.Add(new OracleParameter(":GCTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
- }
- //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingLineID in(Select PurviewID from TP_MST_UserPurview where PurviewType= 5 and UserID = :UserID) ");
- sql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 5 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= TP_PM_GroutingDailyDetail.GroutingLineID))");
- parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- }
- sql.Append(" order by TP_PM_GroutingDailyDetail.GroutingDate desc, ");
- sql.Append(" TP_PM_GroutingDailyDetail.GroutingLineCode, ");
- sql.Append(" TP_PM_GroutingDailyDetail.GroutingBatchNo, ");
- sql.Append(" TP_PM_GroutingDailyDetail.GroutingMouldCode");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010101_1画面(注浆明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010101SSQL()
- {
- string selSql =
- "select " +
- " TP_PM_GroutingDailyDetail.GroutingDate, " +
- " TP_PM_GroutingDailyDetail.GroutingBatchNo, " +
- " TP_PM_GroutingDailyDetail.GroutingLineCode, " +
- " TP_MST_GMouldType.Gmouldtypename, " +
- " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
- " TP_PM_GroutingDailyDetail.GoodsCode, " +
- " TP_MST_GOODS.GOODSSPECIFICATION, " +
- " TP_PM_GroutingDailyDetail.GroutingMouldCode, " +
- " TP_MST_DataDictionary.DICTIONARYVALUE, " +
- " TP_PM_GroutingDailyDetail.Groutingcount, " +
- " TP_PM_GroutingDailyDetail.Barcode, " +
- " tp_mst_user.UserCode CreateUserCode, " +
- " tp_mst_user.username CreateUserName, " +
- " TP_PM_GroutingDailyDetail.UserCode, " +
- " TP_PM_GroutingDailyDetail.SCRAPFLAG, " +
- " TP_PM_GroutingDailyDetail.GoodsName, " +
- " TP_PM_GroutingDailyDetail.GROUTINGFLAG, " +
- " TP_PM_GroutingDailyDetail.GMOULDSTATUS, " +
- " TP_PM_GroutingDailyDetail.DeliverTime, " +
- " TP_PM_GroutingDailyDetail.DeliverFlag, " +
- " tp_sys_gmouldstatus.gmouldstatusname, " +
- " b.dictionaryvalue AS NoGroutingRreason, " +
- " TP_PM_GroutingDailyDetail.SCRAPTIME, " +
- " TP_PM_GroutingDailyDetail.CreateTime GCTime, " +
- " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
- "from TP_PM_GroutingDailyDetail " +
- "inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID " +
- "inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID " +
- "inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_GroutingDailyDetail.GoodsID " +
- "inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.Glazetypeid " +
- "inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
- "inner join tp_sys_gmouldstatus on TP_PM_GroutingDailyDetail.gmouldstatus = tp_sys_gmouldstatus.gmouldstatusid " +
- "left join tp_mst_user on TP_PM_GroutingDailyDetail.CreateUserID=tp_mst_user.userid " +
- "left join TP_MST_DataDictionary b on TP_PM_GroutingDailyDetail.NoGroutingRreason=b.DictionaryID " +
- "left join TP_MST_logo on TP_PM_GroutingDailyDetail.logoid=TP_MST_logo.logoid " +
- "Where 1=1 " +
- "and TP_PM_GroutingDailyDetail.Valueflag=1 " +
- "and TP_PM_GroutingDailyDetail.AccountID=:AccountID ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010102_1画面(半检明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010102SData(SUserInfo user, RPT010102_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_goodsID",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
- new OracleParameter("in_testUserID",OracleDbType.Varchar2,se.TestUserIDS,ParameterDirection.Input),
- new OracleParameter("in_groutingUserID",OracleDbType.Varchar2,se.GroutingUserIDS,ParameterDirection.Input),
- new OracleParameter("in_goodsTypeID",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
- new OracleParameter("in_semiTestTypeID",OracleDbType.Varchar2,se.semiTestTypeID,ParameterDirection.Input),
- new OracleParameter("in_remarks",OracleDbType.Varchar2,se.Remarks,ParameterDirection.Input),
- new OracleParameter("in_semiTestDateStart",OracleDbType.Varchar2,se.SemiTestDateStart,ParameterDirection.Input),
- new OracleParameter("in_semiTestDateEnd",OracleDbType.Varchar2,se.SemiTestDateEnd,ParameterDirection.Input),
- new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetSemiTestDetail", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT010103画面(交坯明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010103SData(SUserInfo user, RPT010103_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010103SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- // parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- if (se != null)
- {
- //成型线IDS
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append(" and instr(','||:GroutingLineIDS||',',','||pd.GroutingLineID||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 成型线类别
- if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
- {
- sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||gt.GMouldTypeID||',')>0 ");
- parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
- }
- // 交坯日期-开始
- if (se.CreateTimeBegin.HasValue)
- {
- sql.Append(" AND pd.CreateTime >= :CreateTimeBegin ");
- parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.CreateTimeBegin.Value, ParameterDirection.Input));
- }
- // 交坯日期-结束
- if (se.CreateTimeEnd.HasValue)
- {
- sql.Append(" AND pd.CreateTime <= :CreateTimeEnd ");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 注浆模具编号
- if (!string.IsNullOrEmpty(se.GroutingMouldCode))
- {
- //sql.Append(" AND INSTR(','||:GroutingMouldCode||',',','||pd.GroutingMouldCode||',') > 0 ");
- sql.Append(" AND INSTR(pd.GroutingMouldCode,:GroutingMouldCode) > 0 ");
- parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
- }
- //产品IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- // sql.Append(" and instr(','||:GoodsTypeIDS||',',','||gdt.GoodsTypeCode||',')=1");
- sql.Append("AND instr(gdt.GoodsTypeCode,:GoodsTypeIDS)=1 ");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- //产品类别IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append(" and instr(','||:GoodsIDS||',',','||pd.goodsid||',')>0");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- // 备注
- if (!string.IsNullOrEmpty(se.Remarks))
- {
- sql.Append(" AND INSTR(pd.Remarks, :Remarks) > 0");
- parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
- }
- // 注浆工号
- if (!string.IsNullOrEmpty(se.GroutingUserCode))
- {
- sql.Append(" AND INSTR( ','||:GroutingUserCode||',',','||pd.GroutingUserCode||',') > 0");
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 条码
- if (!string.IsNullOrEmpty(se.BarCode))
- {
- //sql.Append(" AND INSTR(','||:BarCode||',',','||pd.BarCode||',') > 0");
- sql.Append(" AND INSTR(pd.BarCode,:BarCode) > 0");
- parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
- }
- // 生产工号和注浆工号不同
- if (se.ProdUserIsGroutingUserFlag == 1)
- {
- sql.Append(" and pd.usercode<>pd.GroutingUserCode");
- }
- }
- sql.Append(" ORDER BY pd.CreateTime, pd.GroutingLineCode, pd.GroutingMouldCode");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010103画面(交坯明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010103SSQL()
- {
- string selSql =
- "select "
- //---产品条码
- + "pd.barcode, "
- //注浆时间
- + "pd.groutingdate,"
- //交坯时间
- + "pd.CreateTime,"
- //---产品类别
- + "g.GoodsTypeID,"
- //---产品类别编码
- + "gdt.GoodsTypeCode,"
- //---产品类别名称
- + "gdt.GoodsTypeName,"
- //----产品ID
- + "pd.goodsid,"
- //----产品编码
- + "pd.goodscode,"
- //----产品名称
- + "pd.goodsname,"
- //----规格
- + "g.GoodsSpecification,"
- //----釉色类别ID
- + "g.GlazeTypeID,"
- //----釉色类别描述
- + "dd.dictionaryvalue as GlazeTypeName,"
- //----注浆模具
- + "pd.GroutingMouldCode,"
- //---生产线号
- + "pd.ProductionLineID,"
- //---成型线编码
- + "pd.ProductionLineCode,"
- //---成型线名称
- + "pd.ProductionLineName,"
- //---成型线号Id
- + " pd.GroutingLineID,"
- //---成型线号
- + " pd.GroutingLineCode,"
- //---成型线类型ID
- + "gt.GMouldTypeID,"
- //---成型线类型
- + "gt.GMouldTypeName,"
- //---生产工号
- + "pd.UserID,"
- //---生产工号用户编号
- + "u.usercode,"
- //----注浆工号
- + "pd.GroutingUserID,"
- //---注浆工号用户编号
- + "pd.GroutingUserCode, "
- //--公坯标识
- + " pd.ISPUBLICBODY, "
- //--注浆次数
- + " gdd.GROUTINGCOUNT, "
- + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
- //--查油工号
- + " , uc.usercode check1 "
- //生产数据
- + "from TP_PM_PRODUCTIONDATA pd "
- //注浆明细
- + " inner join TP_PM_GROUTINGDAILYDETAIL gdd on pd.GROUTINGDAILYDETAILID=gdd.GROUTINGDAILYDETAILID "
- //模具类型
- + "inner join TP_MST_GMouldType gt "
- + "on pd.GMOULDTYPEID=gt.GMouldTypeID "
- //产品档案
- + "inner join TP_MST_Goods g "
- + "on pd.goodsid=g.goodsid "
- //数据字典,TPC002为釉色类别
- + "inner join TP_MST_DataDictionary dd "
- //
- + "on dd.DictionaryType = 'TPC002' "
- //
- + "and dd.dictionaryid= g.GlazeTypeID "
- //用户信息
- + "inner join tp_mst_user u "
- + "on pd.userid=u.userid "
- + "inner join tp_mst_user uc "
- + "on pd.createuserid=uc.userid "
- //
- + "inner join TP_MST_GoodsType gdt "
- + "on g.GoodsTypeID=gdt.GoodsTypeID "
- + "inner join TP_MST_logo "
- + "on gdd.logoid=TP_MST_logo.logoid "
- // 交坯
- + " WHERE pd.modeltype=5 "
- // 账套
- + " and pd.AccountID=:AccountID"
- + " and pd.ValueFlag='" + (int)Constant.ValueFlag.Effective + "'";
- //成型线查看权限
- //+ " and exists (select up.PurviewID "
- //+ " from TP_MST_UserPurview up where up.PurviewType='"
- //+ (int)Constant.PurviewType.ViewGroutingLine
- //+ "' and up.PurviewID=pd.GroutingLineID "
- //+ " and up.UserId=:UPUserId)";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010105画面(成型线模具使用明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010105SData(SUserInfo user, RPT010105_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlString =
- "SELECT t.groutinglinecode\n" +
- " ,gl.BuildingNo\n" +
- " ,gl.FloorNo\n" +
- " ,gl.GroutingLineNo\n" +
- " ,t.usercode\n" +
- " ,t.goodscode\n" +
- " ,t.GOODSSPECIFICATION\n" +
- " ,t.goodstypename\n" +
- " ,t.MouldQuantity\n" +
- " ,gld.groutingmouldcode\n" +
- " ,gms.gmouldstatusname\n" +
- " ,gld.beginuseddate\n" +
- " ,(SELECT MIN(ggg.groutingdate)\n" +
- " FROM tp_pm_groutingdailydetail ggg\n" +
- " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
- " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
- " ,SUM(t.groutingflag) sumgroutingcount\n" +
- " ,MAX(t.GroutingCount) maxGroutingCount\n" +
- " ,gld.groutingcount\n" +
- " FROM (SELECT gd.groutinglinecode\n" +
- " ,gd.usercode\n" +
- " ,gdd.goodsid\n" +
- " ,gd.MouldQuantity\n" +
- " ,gdd.groutinglinedetailid\n" +
- " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
- " ,gdd.GroutingCount\n" +
- " ,gt.goodstypename\n" +
- " ,g.goodscode\n" +
- " ,g.GOODSSPECIFICATION\n" +
- " FROM TP_PM_GroutingDaily gd\n" +
- " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
- " INNER JOIN TP_MST_Goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN TP_MST_GOODSTYPE gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " WHERE gd.accountid = :AccountID\n" +
- " AND gd.groutingdate >= :GDateBegin\n" +
- " AND gd.groutingdate <= :GDateEnd\n" +
- " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
- " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
- " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
- " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- " ) t\n" +
- " INNER JOIN tp_pc_groutinglinedetail gld\n" +
- " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
- " INNER JOIN tp_pc_groutingline gl\n" +
- " ON gld.groutinglineid = gl.groutinglineid\n" +
- " INNER JOIN TP_SYS_GMouldStatus gms\n" +
- " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
- " GROUP BY t.groutinglinecode\n" +
- " ,gl.BuildingNo\n" +
- " ,gl.FloorNo\n" +
- " ,gl.GroutingLineNo\n" +
- " ,t.usercode\n" +
- " ,t.goodscode\n" +
- " ,t.GOODSSPECIFICATION\n" +
- " ,t.goodstypename\n" +
- " ,t.MouldQuantity\n" +
- " ,gld.groutingmouldcode\n" +
- " ,gms.gmouldstatusname\n" +
- " ,gld.beginuseddate\n" +
- " ,gld.groutingcount\n" +
- " ,t.groutinglinedetailid\n" +
- " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlString =
- "SELECT gl.buildingno\n" +
- " ,gl.floorno\n" +
- " ,gl.groutinglineno\n" +
- " ,gl.groutinglinecode\n" +
- " ,gl.Remarks\n" +
- " ,decode(UserCount,\n" +
- " 1,\n" +
- " mu.usercode,\n" +
- " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
- " FROM tp_pc_groutinguser gu\n" +
- " INNER JOIN tp_mst_user gmu\n" +
- " ON gmu.userid = gu.userid\n" +
- " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
- " ,g.goodscode\n" +
- " ,g.goodsspecification\n" +
- " ,gt.goodstypename\n" +
- " --,gl.mouldquantity\n" +
- " ,gldd.mouldquantity\n" +
- " ,gmt.gmouldtypename\n" +
- " ,gms.gmouldstatusname\n" +
- " ,gldd.beginuseddate -- 上模日期\n" +
- " ,gldd.groutingdate -- 首次注浆日期\n" +
- " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
- " ,gldd.groutingcount -- 最大注浆次数\n" +
- " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
- " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
- " ,gldd.sumgroutingcount -- 总注浆次数\n" +
- " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
- " ,round(decode(gl.mouldquantity,\n" +
- " 0,\n" +
- " 0,\n" +
- " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
- " gl.mouldquantity),\n" +
- " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
- " FROM tp_pc_groutingline gl\n" +
- " INNER JOIN (SELECT gld.groutinglineid\n" +
- " ,gld.goodsid\n" +
- " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
- " ,MIN(gld.beginuseddate) beginuseddate\n" +
- " ,MIN(gddd.groutingdate) groutingdate\n" +
- " /* ,(SELECT MIN(gdd.groutingdate)\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
- " AND gdd.groutingflag = '1') groutingdate*/\n" +
- " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
- " ,MAX(gld.groutingcount) groutingcount\n" +
- " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
- " ,SUM(gld.groutingcount) sumgroutingcount\n" +
- " FROM tp_pc_groutinglinedetail gld\n" +
- " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
- " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
- " -- AND gdd.groutingflag = '1'\n" +
- " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
- " ,gdd.mouldcode\n" +
- " ,MIN(gdd.groutingdate) groutingdate\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " WHERE gdd.accountid = :AccountID\n" +
- " AND gdd.groutingflag = '1'\n" +
- " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
- " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
- " AND gddd.mouldcode = gld.mouldcode\n" +
- " WHERE gld.valueflag = '1'\n" +
- " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
- " ON gldd.groutinglineid = gl.groutinglineid\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gldd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " INNER JOIN tp_mst_gmouldtype gmt\n" +
- " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
- " INNER JOIN tp_sys_gmouldstatus gms\n" +
- " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
- " INNER JOIN tp_mst_user mu\n" +
- " ON mu.userid = gl.userid\n" +
- " WHERE gl.accountid = :AccountID\n" +
- " AND gl.valueflag = '1'\n" +
- " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
- " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
- " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
- " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- " ORDER BY gl.groutinglinecode, g.goodscode";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- // 校验时间--开始
- if (se.beginCreateTime.HasValue)
- {
- parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- // 校验时间--结束
- if (se.endCreateTime.HasValue)
- {
- parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
- }
- conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
- parameters.Clear();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- #region
- /*
- selSql = selSql +
- "select * from (" +
- "select " +
- "MissProcedureID, " +
- "MissProcedureCode, " +
- "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
- "MissProcedureName, " +
- "MissID, " +
- "BarCode, " +
- "OrganizationID, " +
- "OrganizationName, " +
- "OrganizationCode, " +
- "OrganizationFullName, " +
- "CompleteProcedureID, " +
- "CompleteProcedureCode, " +
- "CompleteProcedureName, " +
- "ProcedureID, " +
- "ProcedureCode, " +
- "ProcedureName, " +
- "GoodsID, " +
- "GoodsCode, " +
- "GoodsName, " +
- "result.GoodsTypeID, " +
- "result.CreateTime, " +
- "result.GoodsTypeName, " +
- "UserName, " +
- "MissUserCode, " +
- "barcodecount, seqno " +
- "from " +
- " ( " +
- " select " +
- " MissProcedureID, " +
- " MissProcedureCode, " +
- " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
- " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
- " MissID, " +
- " BarCode, " +
- " OrganizationID, " +
- " OrganizationName, " +
- " OrganizationCode, " +
- " OrganizationFullName, " +
- " CompleteProcedureID, " +
- " CompleteProcedureCode, " +
- " CompleteProcedureName, " +
- " ProcedureID, " +
- " ProcedureCode, " +
- " ProcedureName, " +
- " GoodsID, " +
- " GoodsCode, " +
- " GoodsName, " +
- " GoodsTypeID, " +
- " CreateTime, " +
- " GoodsTypeName, " +
- " UserName, " +
- " MissUserCode, " +
- " barcodecount,rownum seqno " +
- " from " +
- " ( " +
- " select " +
- " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
- " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
- " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
- " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
- " decode(grouping(MissID),1,'--',MissID) MissID, " +
- " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
- " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
- " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
- " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
- " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
- " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
- " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
- " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
- " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
- " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
- " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
- " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
- " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
- " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
- " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
- " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
- " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
- " decode(grouping(UserName),1,'--',UserName) UserName, " +
- " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
- " count(barcode) barcodecount " +
- " from " +
- " ( " +
- " select TP_PM_BarCodeMissing.MissProcedureID, " +
- " TP_PM_BarCodeMissing.MissProcedureCode, " +
- " TP_PM_BarCodeMissing.MissProcedureName, " +
- " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
- " TP_PM_BarCodeMissing.MissID, " +
- " TP_PM_BarCodeMissing.BarCode, " +
- " TP_PM_BarCodeMissing.OrganizationID, " +
- " TP_PM_BarCodeMissing.OrganizationName, " +
- " TP_PM_BarCodeMissing.OrganizationCode, " +
- " TP_PM_BarCodeMissing.OrganizationFullName, " +
- " TP_PM_BarCodeMissing.CompleteProcedureID, " +
- " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
- " TP_PM_BarCodeMissing.CompleteProcedureName, " +
- " TP_PM_BarCodeMissing.ProcedureID, " +
- " TP_PM_BarCodeMissing.ProcedureCode, " +
- " TP_PM_BarCodeMissing.ProcedureName, " +
- " TP_PM_BarCodeMissing.GoodsID, " +
- " TP_PM_BarCodeMissing.GoodsCode, " +
- " TP_PM_BarCodeMissing.GoodsName, " +
- " TP_PM_BarCodeMissing.GoodsTypeID, " +
- " TP_PM_BarCodeMissing.MissUserCode, " +
- " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
- " TP_MST_GoodsType.GoodsTypeName, " +
- " TP_MST_USER.UserName " +
- " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
- " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
- " left join TP_MST_USER " +
- " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
- " where TP_PM_BarCodeMissing.valueflag=1 " +
- " and TP_PM_BarCodeMissing.accountid=:AccountID ";
- // 产品条码
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
- parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- // 组织结构
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- // 完成工序
- if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
- }
- // 校验工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- // 漏扫工序
- if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- // 校验时间--开始
- if (se.beginCreateTime.HasValue)
- {
- selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- // 校验时间--结束
- if (se.endCreateTime.HasValue)
- {
- selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- // " order by missprocedureid,username " +
- " ) " +
- " group by rollup( " +
- " GoodsType, " +
- " MissProcedureID, " +
- " MissProcedureCode, " +
- " MissProcedureName, " +
- " MissID, " +
- " BarCode, " +
- " OrganizationID, " +
- " OrganizationName, " +
- " OrganizationCode, " +
- " OrganizationFullName, " +
- " CompleteProcedureID, " +
- " CompleteProcedureCode, " +
- " CompleteProcedureName, " +
- " ProcedureID, " +
- " ProcedureCode, " +
- " ProcedureName, " +
- " GoodsID, " +
- " GoodsCode, " +
- " GoodsName, " +
- " GoodsTypeID, " +
- " CreateTime, " +
- " GoodsTypeName,MissUserCode, " +
- " UserName ) " +
- " ) " +
- " where UserName!='--' or " +
- " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
- " or " +
- " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
- " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
- + " ) order by seqno";
- */
- #endregion
- string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
- " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
- " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
- " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
- " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
- " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
- " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
- " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
- " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
- " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
- " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
- " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
- " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
- " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
- " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
- " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
- " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
- " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
- " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
- " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
- " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
- " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
- " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
- " decode(tt.gid, 0, tt.username, '--') username,\n" +
- " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
- " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
- " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
- " tt.barcodecount, --数量\n" +
- " tt.LogoCodeName\n" +
- " from (select grouping_id(t.goodstypename2, --产品大类\n" +
- " --t.MissProcedureCode,\n" +
- " t.MissProcedureName,\n" +
- " t.MissID) gid,\n" +
- " t.MissID, --漏扫ID\n" +
- " t.BarCode, --产品条码\n" +
- " --t.OrganizationID,\n" +
- " --t.OrganizationCode,\n" +
- " t.OrganizationName, --漏扫部门\n" +
- " --t.OrganizationFullName,\n" +
- " --t.CompleteProcedureID,\n" +
- " --t.CompleteProcedureCode,\n" +
- " t.CompleteProcedureName, --完成工序\n" +
- " --t.ProcedureID,\n" +
- " --t.ProcedureCode,\n" +
- " t.ProcedureName, --校验工序\n" +
- " --t.MissProcedureID,\n" +
- " --t.MissProcedureCode,\n" +
- " t.MissProcedureName, --漏扫工序\n" +
- " t.GoodsID,\n" +
- " t.GoodsCode, --产品编码\n" +
- " t.GoodsName, --产品名称\n" +
- " t.GoodsTypeID,\n" +
- " t.MissUserID,\n" +
- " t.MissUserCode, --漏扫工号\n" +
- " t.CreateTime, --校验漏扫时间\n" +
- " t.CreateUserID,\n" +
- " t.username, --校验者\n" +
- " t.repaircode, --补扫操作工号\n" +
- " t.prepaircode, --补扫生产工号\n" +
- " t.goodstypename2, --产品大类\n" +
- " count(t.barcodecount) barcodecount, --数量\n" +
- " t.LogoCodeName\n" +
- " from (select bcm.MissID, --漏扫ID\n" +
- " bcm.BarCode, --产品条码\n" +
- " --bcm.OrganizationID,\n" +
- " --bcm.OrganizationCode,\n" +
- " bcm.OrganizationName, --漏扫部门\n" +
- " --bcm.OrganizationFullName,\n" +
- " --bcm.CompleteProcedureID,\n" +
- " --bcm.CompleteProcedureCode,\n" +
- " --bcm.CompleteProcedureName, --完成工序\n" +
- " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
- " --bcm.ProcedureID,\n" +
- " --bcm.ProcedureCode,\n" +
- " --bcm.ProcedureName, --校验工序\n" +
- " cp.ProcedureName, --校验工序\n" +
- " --bcm.MissProcedureID,\n" +
- " --bcm.MissProcedureCode,\n" +
- " --bcm.MissProcedureName, --漏扫工序\n" +
- " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
- " bcm.GoodsID,\n" +
- " bcm.GoodsCode, --产品编码\n" +
- " bcm.GoodsName, --产品名称\n" +
- " bcm.GoodsTypeID,\n" +
- " bcm.MissUserID,\n" +
- " bcm.MissUserCode, --漏扫工号\n" +
- " bcm.CreateTime, --校验漏扫时间\n" +
- " bcm.CreateUserID,\n" +
- " u.username, --校验者\n" +
- //" MU.usercode repaircode, --补扫操作工号\n" +
- //" MU.pusercode prepaircode, --补扫生产工号\n" +
- " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
- " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
- " gt2.goodstypename goodstypename2, --产品大类\n" +
- " 1 barcodecount, --数量\n" +
- " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
- " from TP_PM_BarCodeMissing bcm\n" +
- " left join TP_MST_User u\n" +
- " on bcm.CreateUserID = u.userid\n" +
- " left join TP_MST_GoodsType gt\n" +
- " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
- " left join TP_MST_GoodsType gt2\n" +
- " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
- " and gt.accountid = gt2.accountid\n" +
- /*
- //" left join TP_PM_ProductionData PD\n" +
- //" on PD.BarCode = bcm.BarCode\n" +
- //" and PD.ProcedureID = bcm.MissProcedureID\n" +
- //" left join TP_MST_User MU\n" +
- //" on MU.UserID = PD.CreateUserID\n" +
- " left join (select pd.barcode,\n" +
- " pd.procedureid,\n" +
- " pd.usercode pusercode,\n" +
- " mu.usercode,\n" +
- //" pd.usercode,\n" +
- " max(bm.missid) missid\n" +
- //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_pm_barcodemissing bm\n" +
- " on bm.barcode = pd.barcode\n" +
- " and bm.missprocedureid = pd.procedureid\n" +
- " and bm.createtime < pd.createtime\n" +
- " and bm.valueflag ='1'\n" +
- " inner join tp_mst_user mu\n" +
- " on mu.userid = pd.createuserid\n" +
- " where pd.valueflag = '1'\n" +
- " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
- " ) MU\n" +
- " on MU.barcode = bcm.barcode\n" +
- " and MU.procedureid = bcm.missprocedureid\n" +
- " and MU.missid = bcm.missid" +
- //" and MU.rnum = 1" +
- */
- " left join tp_pc_procedure cedp \n" +
- " on cedp.procedureid = bcm.CompleteProcedureID\n" +
- " left join tp_pc_procedure cp \n" +
- " on cp.procedureid = bcm.ProcedureID\n" +
- " left join tp_pc_procedure mp \n" +
- " on mp.procedureid = bcm.MissProcedureID\n" +
- " left join TP_PM_GroutingDailyDetail \n" +
- " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
- " left join tp_mst_logo \n" +
- " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
- " where bcm.valueflag='1' \n" +
- " and bcm.accountid=:AccountID \n";
- // 产品条码
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- selSql = selSql + " and bcm.barcode=:Barcode ";
- parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- // 组织结构
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- // 完成工序
- if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
- }
- // 校验工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- // 漏扫工序
- if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
- {
- selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
- parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
- selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- // 校验时间--开始
- if (se.beginCreateTime.HasValue)
- {
- selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- // 校验时间--结束
- if (se.endCreateTime.HasValue)
- {
- selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
- }
- selSql += "\n" +
- //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
- //" --bcm.GoodsCode,\n" +
- //" bcm.BarCode,\n" +
- //" bcm.ProcedureCode,\n" +
- //" bcm.CompleteProcedureCode\n" +
- //" ) t\n" +
- " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
- " --bcm.GoodsCode,\n" +
- " bcm.BarCode,\n" +
- " cp.ProcedureName,\n" +
- " cedp.ProcedureName\n" +
- " ) t\n" +
- " group by grouping sets((t.MissID, --漏扫ID\n" +
- " t.BarCode, --产品条码\n" +
- " t.goodstypename2, --产品大类\n" +
- " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
- " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
- " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
- " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
- " t.GoodsID, t.GoodsCode, --产品编码\n" +
- " t.GoodsName, --产品名称\n" +
- " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
- " t.CreateTime, --校验漏扫时间\n" +
- " t.CreateUserID, t.username, --校验者\n" +
- " t.repaircode, --补扫工号\n" +
- " t.prepaircode, --补扫工号\n" +
- " t.LogoCodeName --商标\n" +
- " ),(t.goodstypename2, --产品大类\n" +
- " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
- " ),(t.goodstypename2 --产品大类\n" +
- " ),())) tt";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010301_1画面(条码变更明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- // 更换条码时间-开始
- if (se.createTimeBegin.HasValue)
- {
- sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
- parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
- }
- // 更换条码时间-结束
- if (se.createTimeEnd.HasValue)
- {
- sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
- }
- //成型线IDS
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- // sql.Append(" and (TP_PM_BarCodeRecord.BARCODE=:Barcode or TP_PM_BarCodeRecord.NEWBARCODE=:Barcode or TP_PM_BarCodeRecord.FIRSTBARCODE=:Barcode or TP_PM_BarCodeRecord.FINALBARCODE=:Barcode )");
- sql.Append(" and (instr(TP_PM_BarCodeRecord.BARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.NEWBARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.FIRSTBARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.FINALBARCODE,:Barcode)>0 )");
- parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- }
- sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010301_1画面(条码变更明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010301SSQL()
- {
- string selSql =
- " SELECT "
- + " TP_PM_BarCodeRecord.BarCode, "
- + " TP_PM_BarCodeRecord.NewBarCode, "
- + " TP_PM_BarCodeRecord.FirstBarCode, "
- + " TP_PM_BarCodeRecord.FinalBarCode, "
- + " TP_PM_BarCodeRecord.Createtime, "
- + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
- + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
- + " TP_MST_GMouldType.Gmouldtypename, "
- + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
- + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
- + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
- + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
- + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
- + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
- + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
- + " TP_PC_PROCEDURE.PROCEDURECODE, "
- + " TP_PC_PROCEDURE.PROCEDURENAME, "
- + " TP_MST_USER.USERNAME, "
- + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
- + " from TP_PM_BarCodeRecord "
- + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
- + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
- + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
- + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
- + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
- + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
- + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010401画面(在产品明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- // 条码
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
- sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
- parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- //生产线IDS
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- //完成工序IDS
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- //生产工号IDS
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- // 成型线IDS
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 成型线类型IDS
- if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
- {
- sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
- parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
- }
- // 交坯时间--开始
- if (se.CreateTimeStart.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- // 交坯时间--结束
- if (se.CreateTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 完成时间--开始
- if (se.UpdateTimeStart.HasValue)
- {
- sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
- parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成时间--结束
- if (se.UpdateTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
- parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.inscrapflag != 2)
- {
- sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
- parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
- }
- if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
- {
- sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- }
- sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010401画面(在产品明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010401SSQL()
- {
- string selSql =
- "SELECT " +
- " TP_PM_InProduction.BarCode, " +
- " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
- " TP_PM_InProduction.GoodsName, gt.goodstypename," +
- " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
- " TP_PM_InProduction.ProductionLineID, " +
- " TP_PM_InProduction.ProductionLineCode, " +
- " TP_PM_InProduction.ProductionLineName, " +
- " TP_PM_InProduction.ModelType, " +
- " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
- //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
- " TP_PM_InProduction.IsPublicBody, " +
- //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
- " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
- " TP_PM_InProduction.IsReworkFlag, " +
- " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
- " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
- " TP_PM_InProduction.GroutingDailyID, " +
- " TP_PM_InProduction.GroutingDailyDetailID, " +
- " TP_PM_InProduction.GroutingDate, " +
- " TP_PM_InProduction.GroutingLineID, " +
- " TP_PM_InProduction.GroutingLineCode, " +
- " TP_PM_InProduction.GroutingLineName, " +
- " TP_PM_InProduction.KILNCODE, " +
- " TP_PM_InProduction.KILNCARCODE, " +
- " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
- " D.ProcedureName as CompleteProcedureName, " +
- " TP_PM_InProduction.GMouldTypeID, " +
- " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
- " TP_PM_InProduction.GroutingLineDetailID, " +
- " TP_PM_InProduction.GroutingMouldCode, " +
- " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
- " TP_PM_InProduction.GROUTINGUSERCODE, " +
- " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
- " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
- " TP_PM_GroutingDailyDetail.delivertime, " +
- " TP_PM_InProduction.proceduretime, " +
- " TP_PM_InProduction.Remarks, " +
- " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
- " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
- " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
- " TP_PM_GroutingDailyDetail.glazingroom," +
- " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
- " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
- " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
- //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
- " nvl(TP_PM_GroutingDailyDetail.outlabelcode, TP_PM_GroutingDailyDetail.MaterialCode || (select a.workcode from tp_mst_account a where a.accountid = TP_PM_GroutingDailyDetail.accountid) || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
- "FROM TP_PM_InProduction " +
- " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
- " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
- " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
- " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
- " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
- " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
- " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
- " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
- " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
- " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
- " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
- " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
- " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
- " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
- " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
- " Where TP_PM_InProduction.ValueFlag = 1 " +
- " and TP_PM_InProduction.AccountID=:AccountID ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010402画面(产成品明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- // 条码
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
- sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
- parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- // 产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- // 生产线IDS
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- // 成型线ids
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 成型线类型ids
- if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
- {
- sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
- parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
- }
- // 财务日期--开始
- if (se.AccountDateStart.HasValue)
- {
- //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
- sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
- parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
- }
- // 财务日期--结束
- if (se.AccountDateEnd.HasValue)
- {
- //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
- sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
- parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
- }
- // 注浆时间--开始
- if (se.CreateTimeStart.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- // 注浆时间--结束
- if (se.CreateTimeEnd.HasValue)
- {
- sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- }
- sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010402画面(产成品明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010402SSQL()
- {
- string selSql =
- "SELECT " +
- " TP_PM_FinishedProduct.BarCode, " +
- " TP_PM_FinishedProduct.GoodsID, " +
- " TP_PM_FinishedProduct.GoodsCode, " +
- " TP_PM_FinishedProduct.GoodsName, " +
- " TP_PM_FinishedProduct.ProductionLineID, " +
- " TP_PM_FinishedProduct.ProductionLineCode, " +
- " TP_PM_FinishedProduct.ProductionLineName, " +
- //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
- //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
- " TP_PM_FinishedProduct.IsPublicBody, " +
- " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
- " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
- " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
- " TP_PM_FinishedProduct.GroutingDailyID, " +
- " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
- " TP_PM_FinishedProduct.GroutingDate, " +
- " TP_PM_FinishedProduct.GroutingLineID, " +
- " TP_PM_FinishedProduct.GroutingLineCode," +
- " TP_PM_FinishedProduct.GroutingLineName, " +
- " TP_PM_FinishedProduct.GMouldTypeID, " +
- " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
- " TP_PM_FinishedProduct.GroutingLineDetailID, " +
- " TP_PM_FinishedProduct.GroutingMouldCode," +
- " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
- " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
- " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
- " TP_PM_FinishedProduct.KILNID," +
- " TP_PM_FinishedProduct.KILNCODE," +
- " TP_PM_FinishedProduct.KILNNAME," +
- " TP_PM_FinishedProduct.KILNCARID," +
- " TP_PM_FinishedProduct.KILNCARCODE," +
- " TP_PM_FinishedProduct.KILNCARNAME," +
- " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
- " TP_PM_FinishedProduct.MouldCode, " +
- " TP_PM_FinishedProduct.Remarks, " +
- " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
- " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
- " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
- " TP_PM_FinishedProduct.FHUSERCODE, " +
- " TP_PM_FinishedProduct.FHTIME, " +
- " odr.ORDERNO, " +
- " TP_PM_FinishedProduct.AccountID, " +
- " TP_PM_FinishedProduct.ValueFlag, " +
- " TP_PM_FinishedProduct.AccountDate, " +
- " TP_PM_FinishedProduct.CreateTime, " +
- " TP_PM_FinishedProduct.CreateUserID, " +
- " B.USERNAME as CreateUserName, " +
- " TP_PM_FinishedProduct.UpdateTime, " +
- " TP_PM_FinishedProduct.UpdateUserID, " +
- " C.USERNAME as UpdateUserName, " +
- " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
- " TP_PM_GroutingDailyDetail.Materialcode," +
- //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
- " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
- " FROM TP_PM_FinishedProduct " +
- " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
- " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
- " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
- " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
- " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
- " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
- " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
- " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
- " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
- " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
- " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
- " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
- " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
- " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
- " and TP_PM_FinishedProduct.AccountID=:AccountID ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT010403画面(生产数据明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sqlString =
- "SELECT *\n" +
- " FROM (SELECT pd.barcode\n" +
- " ,gt2.goodstypename as goodstypename2\n" +
- " ,gt.goodstypename\n" +
- " ,g.goodscode\n" +
- " ,PD.ProductionLineName\n" +
- " ,to_char(p.ProcedureName) AS ProcedureName\n" +
- " ,op.organizationfullname AS porgname\n" +
- " ,pd.CreateTime\n" +
- " ,PD.UserCode\n" +
- " ,cu.Usercode AS CreateUsercode\n" +
- " ,cu.Username AS CreateUserName\n" +
- " ,co.organizationfullname corgname\n" +
- " , CASE\n" +
- " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
- " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
- " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
- " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
- " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
- " ELSE\n" +
- " to_char(GL.GOODSLEVELNAME)\n" +
- " END || CASE\n" +
- " WHEN pd.modeltype = 1 THEN\n" +
- " '[' || to_char(pd.kilncarcode) || ']'\n" +
- " ELSE\n" +
- " ''\n" +
- " END GOODSLEVELNAME\n" +
- " ,gdd.glazingroom" +
- " FROM TP_PM_ProductionData PD\n" +
- " INNER JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = pd.procedureid\n" +
- " LEFT JOIN tp_mst_goods g\n" +
- " ON g.goodsid = pd.goodsid\n" +
- " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.AccountID = :AccountID\n" +
- " INNER JOIN tp_mst_organization op\n" +
- " ON op.organizationid = p.organizationid\n" +
- " INNER JOIN tp_mst_user cu\n" +
- " ON cu.userid = PD.Createuserid\n" +
- " INNER JOIN tp_mst_organization co\n" +
- " ON co.organizationid = cu.organizationid\n" +
- " LEFT JOIN tp_mst_user bu\n" +
- " ON bu.userid = PD.Backoutuserid\n" +
- " LEFT JOIN tp_mst_goodslevel GL\n" +
- " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
- " AND gl.AccountID = :AccountID\n" +
- " WHERE PD.AccountID = :AccountID\n" +
- " AND PD.Createtime >= :CreatetimeBegin\n" +
- " AND PD.Createtime <= :CreatetimeEnd\n" +
- " AND (:ProductionLineID IS NULL OR\n" +
- " pd.productionlineid = :ProductionLineID)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
- " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
- " UNION ALL\n" +
- " -- 报损\n" +
- " SELECT sp.barcode\n" +
- " ,gt2.goodstypename as goodstypename2\n" +
- " ,gt.goodstypename\n" +
- " ,g.goodscode\n" +
- " ,sp.productionlinename\n" +
- //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
- //" to_char(p.procedurename) || '】' AS procedurename\n" +
- " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
- " WHEN rpp.procedureid IS NOT NULL THEN\n" +
- " to_char(rpp.procedurename)\n" +
- " ELSE\n" +
- " '无'\n" +
- " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
- " to_char(sruser.Username) || '】-原因【' ||\n" +
- " to_char(sp.rreason) || '】' AS procedurename" +
- " ,NULL AS porgname\n" +
- " ,sp.Createtime\n" +
- " ,NULL AS Usercode\n" +
- " ,u.Usercode AS CreateUsercode\n" +
- " ,U.Username AS CreateUserName\n" +
- " ,co.organizationfullname corgname\n" +
- " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
- " WHEN Length(AU.usercode) > 0 THEN\n" +
- " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
- " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
- " ELSE\n" +
- " ''\n" +
- " END || CASE\n" +
- " WHEN sp.valueflag = '0' THEN\n" +
- " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
- " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
- " ELSE\n" +
- " ''\n" +
- " END AS GOODSLEVELNAME\n" +
- " ,null glazingroom\n" +
- " FROM tp_pm_scrapproduct sp\n" +
- " LEFT JOIN tp_mst_goods g\n" +
- " ON g.goodsid = sp.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.AccountID = :AccountID\n" +
- " INNER JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = sp.procedureid\n" +
- " --inner join tp_mst_organization op\n" +
- " -- on op.organizationid = p.organizationid\n" +
- " INNER JOIN tp_mst_user U\n" +
- " ON U.userid = sp.CREATEUSERID\n" +
- " INNER JOIN tp_mst_organization co\n" +
- " ON co.organizationid = u.organizationid\n" +
- " INNER JOIN tp_mst_user uu\n" +
- " ON uu.userid = sp.Updateuserid\n" +
- " INNER JOIN tp_sys_AuditStatus A\n" +
- " ON A.AuditStatusid = sp.AuditStatus\n" +
- " LEFT JOIN tp_mst_goodslevel gl\n" +
- " ON gl.goodsleveltypeid = 8\n" +
- " AND gl.accountid = 1\n" +
- " LEFT JOIN tp_mst_user AU\n" +
- " ON au.userid = sp.auditor\n" +
- " LEFT JOIN TP_PM_ResponProcedure rp\n" +
- " ON rp.scrapproductid = sp.scrapproductid\n" +
- " LEFT JOIN tp_pc_procedure rpp\n" +
- " ON rpp.procedureid = rp.procedureid\n" +
- " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
- " FROM TP_PM_ScrapResponsible sr\n" +
- " WHERE sr.AccountID = :AccountID\n" +
- " -- 编辑后 时间不一致\n" +
- " --AND sr.Createtime >= :CreatetimeBegin\n" +
- " --AND sr.Createtime <= :CreatetimeEnd\n" +
- " ) sru\n" +
- " ON sru.scrapproductid = sp.scrapproductid\n" +
- " LEFT JOIN tp_mst_user sruser\n" +
- " ON sruser.userid = sru.userid" +
- " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
- " AND sp.scraptype = '0'\n" +
- " AND sp.AccountID = :AccountID\n" +
- " AND sp.Createtime >= :CreatetimeBegin\n" +
- " AND sp.Createtime <= :CreatetimeEnd\n" +
- " AND (:ProductionLineID IS NULL OR\n" +
- " sp.productionlineid = :ProductionLineID)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
- " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
- " ORDER BY t.barcode, t.Createtime";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT010302画面(商标变更明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- // 更换条码时间-开始
- if (se.createTimeBegin.HasValue)
- {
- sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
- parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
- }
- // 更换条码时间-结束
- if (se.createTimeEnd.HasValue)
- {
- sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
- }
- //成型线IDS
- if (!string.IsNullOrEmpty(se.Barcode))
- {
- // sql.Append(" and (TP_PM_BarCodeRecord.BARCODE=:Barcode or TP_PM_BarCodeRecord.NEWBARCODE=:Barcode or TP_PM_BarCodeRecord.FIRSTBARCODE=:Barcode or TP_PM_BarCodeRecord.FINALBARCODE=:Barcode )");
- sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
- parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
- }
- }
- sql.Append(" ORDER BY lcr.CREATETIME ");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010302画面(商标变更明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT010302SSQL()
- {
- string selSql =
- "SELECT lcr.BarCode\n" +
- " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
- " '[]',\n" +
- " '') AS oldLogoCodeName\n" +
- " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
- " '[]',\n" +
- " '') AS newLogoCodeName\n" +
- " ,lcr.Createtime\n" +
- " ,gdd.GroutingLineCode\n" +
- " ,gdd.GroutingLineName\n" +
- " ,gdd.GroutingDate\n" +
- " ,gdd.GroutingMouldCode\n" +
- " ,gdd.MouldCode\n" +
- " ,gdd.UserCode GroutingUserCode\n" +
- " ,gdd.GroutingCount\n" +
- " ,gdd.GoodsCode\n" +
- " ,gdd.GoodsName\n" +
- " ,p.PROCEDURECODE\n" +
- " ,p.PROCEDURENAME\n" +
- " ,u.USERCode\n" +
- " ,u.USERNAME\n" +
- " FROM TP_PM_LogoChangedRecord lcr\n" +
- " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
- " ON lcr.barcode = gdd.Barcode\n" +
- " LEFT JOIN TP_PC_PROCEDURE p\n" +
- " ON lcr.Procedureid = p.PROCEDUREID\n" +
- " LEFT JOIN TP_MST_USER u\n" +
- " ON lcr.CreateUserID = u.USERID\n" +
- " LEFT JOIN TP_MST_logo oldlogo\n" +
- " ON lcr.oldlogoid = oldlogo.logoid\n" +
- " LEFT JOIN TP_MST_logo newlogo\n" +
- " ON lcr.newlogoid = newlogo.logoid\n" +
- " WHERE lcr.ACCOUNTID = :AccountID";
- return selSql;
- }
- #endregion 明细报表
- #region 分析报表
- /// <summary>
- /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- #region
- /*
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
- if (se != null)
- {
- // 成型线IDS
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 成型工IDS
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- //产品类型IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- //产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- }
- sql.Append(" group by ");
- sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
- sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
- sql.Append(" line.GroutinglineCode, ");
- sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
- sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
- sql.Append(" TP_MST_Goods.Goodsspecification, ");
- sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
- sql.Append(" MouldQuantity ");
- sql.Append(" ) temp ");
- sql.Append(" ) a ");
- sql.Append(" group by rollup( ");
- sql.Append(" UserCode, ");
- sql.Append(" Groutinglinecode, ");
- sql.Append(" GoodsTypeName, ");
- sql.Append(" GoodsCode, ");
- sql.Append(" Goodsspecification, ");
- sql.Append(" DICTIONARYVALUE, ");
- sql.Append(" MouldQuantity, ");
- sql.Append(" 注浆量, ");
- sql.Append(" 交坯量 ");
- sql.Append(" ) ");
- sql.Append(") Temp where 交坯量 is not null");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- */
- #endregion
- List<OracleParameter> parameters = new List<OracleParameter>();
- //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
- string sqlGroutingdate = null;
- StringBuilder sql = new StringBuilder();
- if (se != null)
- {
- // 成型线IDS
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 成型工IDS
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- //产品类型IDS
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
- sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- //产品IDS
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.GroutingDateStart.HasValue)
- {
- //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
- //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
- sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
- + " and gdd.groutingdate <= :groutingDateEnd \n";
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
- }
- else if (se.GCTimeBegin.HasValue)
- {
- //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
- //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
- sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
- + " and gdd.createtime <= :groutingDateEnd \n";
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
- }
- }
- string sqlString =
- "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
- " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
- " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
- " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
- " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
- " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
- " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
- //" select gddata.usercode,\n" +
- //" gddata.goodscode,\n" +
- //" gddata.goodstypename,\n" +
- //" gddata.goodsspecification,\n" +
- //" gddata.GlazeType,\n" +
- //" gddata.groutinglinecode,\n" +
- //" gddata.MouldQuantity,\n" +
- " gddata.GroutingNum,\n" +
- " gddata.StrippingNum,\n" +
- " gddata.DeliverNum,\n" +
- " decode(gddata.GroutingNum,\n" +
- " 0,\n" +
- " '0.00%',\n" +
- " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
- " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
- " decode(gddata.GroutingNum,\n" +
- " 0,\n" +
- " '0.00%',\n" +
- " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
- " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
- " decode(gddata.StrippingNum,\n" +
- " 0,\n" +
- " '0.00%',\n" +
- " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
- " '9,990.00') || '%') SDPercent -- 成交比,\n" +
- " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
- //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
- " gdd.usercode,\n" +
- " gdd.goodscode,\n" +
- " gdd.goodstypename,\n" +
- " gdd.goodsspecification,\n" +
- " gdd.GlazeType,\n" +
- " gdd.groutinglinecode,\n" +
- " gdd.MouldQuantity,\n" +
- " sum(gdd.GroutingNum) GroutingNum,\n" +
- " sum(gdd.StrippingNum) StrippingNum,\n" +
- " sum(gdd.DeliverNum) DeliverNum\n" +
- " from (select 1 flag,\n" +
- //" select 1 flag,\n" +
- " gddgroup.usercode,\n" +
- " gddgroup.goodscode,\n" +
- " gddgroup.goodstypename,\n" +
- " gddgroup.goodsspecification,\n" +
- " gddgroup.GlazeType,\n" +
- " gddgroup.groutinglinecode,\n" +
- " gddgroup.MouldQuantity,\n" +
- " sum(gddgroup.GroutingNum) GroutingNum,\n" +
- " sum(gddgroup.StrippingNum) StrippingNum,\n" +
- " sum(gddgroup.DeliverNum) DeliverNum\n" +
- " from (select --gdd.groutingdailydetailid,\n" +
- " gd.groutinglinecode,\n" +
- " gt.goodstypename,\n" +
- " g.goodscode,\n" +
- " g.goodsspecification,\n" +
- " dd.dictionaryvalue GlazeType,\n" +
- //" gdd.usercode,\n" +
- (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
- " gd.MouldQuantity,\n" +
- " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
- " case\n" +
- " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end StrippingNum,\n" +
- " 0 DeliverNum\n" +
- " from tp_pm_groutingdaily gd\n" +
- " inner join tp_pm_groutingdailydetail gdd\n" +
- " on gd.groutingdailyid = gdd.groutingdailyid\n" +
- " left join tp_mst_user mu\n" +
- " on mu.userid = gd.MonitorID\n" +
- " inner join tp_mst_goods g\n" +
- " on gdd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on g.goodstypeid = gt.goodstypeid\n" +
- " inner join tp_mst_datadictionary dd\n" +
- " on dd.dictionaryid = g.GlazeTypeID\n" +
- " where gd.valueflag = '1'\n" +
- " and gd.accountid = :AccountID\n"
- + sqlGroutingdate +
- //" and gdd.groutingdate >= :groutingDateStart \n" +
- //" and gdd.groutingdate <= :groutingDateEnd \n" +
- sql +
- " union all\n" +
- " select --gdd.groutingdailydetailid,\n" +
- " gd.groutinglinecode,\n" +
- " gt.goodstypename,\n" +
- " g.goodscode,\n" +
- " g.goodsspecification,\n" +
- " dd.dictionaryvalue GlazeType,\n" +
- //" gdd.usercode,\n" +
- (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
- " gd.MouldQuantity,\n" +
- " 0 GroutingNum,\n" +
- " 0 StrippingNum,\n" +
- " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
- " from tp_pm_groutingdaily gd\n" +
- " inner join tp_pm_groutingdailydetail gdd\n" +
- " on gd.groutingdailyid = gdd.groutingdailyid\n" +
- " left join tp_mst_user mu\n" +
- " on mu.userid = gd.MonitorID\n" +
- " inner join tp_mst_goods g\n" +
- " on gdd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on g.goodstypeid = gt.goodstypeid\n" +
- " inner join tp_mst_datadictionary dd\n" +
- " on dd.dictionaryid = g.GlazeTypeID\n" +
- " where gd.valueflag = '1'\n" +
- " and gd.accountid = :AccountID\n" +
- " and gdd.DeliverTime >= :DeliverTimeStart \n" +
- " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
- " ) gddgroup\n" +
- " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
- " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
- " ) gdd\n" +
- " group by grouping sets((gdd.flag,gdd.usercode, gdd.goodscode, gdd.goodstypename, gdd.goodsspecification, gdd.GlazeType, gdd.groutinglinecode, gdd.MouldQuantity),(gdd.flag,gdd.usercode, gdd.goodscode),(gdd.flag,gdd.usercode),gdd.flag)\n" +
- //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
- ") gddata";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040101SSQL()
- {
- string selSql =
- "select " +
- "UserCode, " +
- "Groutinglinename, " +
- "GoodsTypeName, " +
- "GoodsCode, " +
- "Goodsspecification, " +
- "DICTIONARYVALUE, " +
- "MouldQuantity, " +
- "注浆量, " +
- "交坯量, " +
- "交坯率 " +
- "from " +
- "( " +
- " select " +
- " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
- " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
- " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
- " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
- " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
- " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
- " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
- " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
- " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
- " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
- " from " +
- " ( " +
- " select " +
- " UserCode, " +
- " Groutinglinecode, " +
- " GoodsTypeName, " +
- " GoodsCode, " +
- " Goodsspecification, " +
- " DICTIONARYVALUE, " +
- " MouldQuantity, " +
- " 注浆量, " +
- " ( " +
- " select count(TP_PM_ProductionData.Productiondataid) " +
- " from TP_PM_ProductionData " +
- " where " +
- " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
- " and TP_PM_ProductionData.Usercode=temp.UserCode " +
- " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
- //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
- //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
- //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
- //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
- //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
- //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
- //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
- //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
- //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
- //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
- " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
- " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
- " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
- " ) as 交坯量 " +
- " from " +
- " ( " +
- " select " +
- " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
- " TP_PM_GroutingDailyDetail.Groutinglineid, " +
- " line.GroutinglineCode, " +
- " TP_MST_GOODSTYPE.GoodsTypeName, " +
- " TP_PM_GroutingDailyDetail.GoodsCode, " +
- " TP_MST_Goods.Goodsspecification, " +
- " TP_MST_DataDictionary.DICTIONARYVALUE, " +
- " line.MouldQuantity, " +
- " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
- " from " +
- " TP_PM_GroutingDailyDetail " +
- " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
- " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
- " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
- " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
- " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
- " where " +
- " TP_PM_GroutingDailyDetail.Valueflag=1 " +
- " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
- " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
- " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
- " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT040102_1画面(工序产量分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- //OracleParameter[] paras = new OracleParameter[]{
- // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
- // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
- // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
- // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
- // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
- // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- //};
- /*
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
- new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
- new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
- new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
- new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
- new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
- new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- };
-
- //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- return sre;
- */
- ServiceResultEntity sre = new ServiceResultEntity();
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- string sqlString =
- "select p.procedureid, p.procedurecode, p.procedurename\n" +
- " from tp_pc_procedure p\n" +
- " where p.valueflag = '1'\n" +
- " and p.AccountID = :AccountID" +
- " and p.productionlineid = :productionlineid\n";
- if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
- {
- sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
- }
- sqlString += "order by p.Displayno";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- parameters.Clear();
- StringBuilder sql1 = new StringBuilder();
- StringBuilder sql2 = new StringBuilder();
- StringBuilder sql3 = new StringBuilder();
- foreach (DataRow item in data.Rows)
- {
- //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
- //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
- //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
- sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
- sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
- sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
- }
- sqlString =
- "select --pdg.gid,\n" +
- " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
- " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
- " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
- " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
- " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
- " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
- sql3 +
- " from ( select " +
- " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
- " pdata.productionlineid,\n" +
- " pdata.goodstypename2,\n" +
- " pdata.goodstypename,\n" +
- " pdata.goodscode,\n" +
- " pdata.goodsspecification,\n" +
- " pdata.GOODSMODEL,\n" +
- " pdata.GLAZETYPE\n" +
- sql2 +
- " from (" +
- " select\n" +
- " pd.productionlineid,\n" +
- " gt2.goodstypename goodstypename2,\n" +
- " gt.goodstypename,\n" +
- " g.goodscode,\n" +
- " g.goodsspecification,\n" +
- " g.GOODSMODEL,\n" +
- " dd.dictionaryvalue GLAZETYPE\n" +
- sql1 +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_mst_goods g\n" +
- " on g.goodsid = pd.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
- " and gt2.accountid = gt.accountid\n" +
- " inner join tp_mst_datadictionary dd\n" +
- " on dd.dictionaryid = g.GLAZETYPEID\n" +
- " where pd.valueflag = '1'\n" +
- // 公坯、干补不算交坯工序的产量。
- //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
- // modify wangx 2015-12-3
- (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
- " and pd.accountid = :accountid\n" +
- " and pd.productionlineid = :productionlineid\n" +
- " and pd.createtime >= :createtimeStart\n" +
- " and pd.createtime <= :createtimeEnd\n";
- StringBuilder sql = new StringBuilder(sqlString);
- if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
- {
- sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
- parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
- {
- //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
- sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
- parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
- {
- sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
- }
- sql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= pd.ProductionLineId))");
- parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- sqlString =
- " group by \n" +
- " pd.productionlineid,\n" +
- " gt2.goodstypename,\n" +
- " gt.goodstypename,\n" +
- " g.goodscode,\n" +
- " g.goodsspecification,\n" +
- " g.GOODSMODEL,\n" +
- " dd.dictionaryvalue\n" +
- " order by gt2.goodstypename, g.goodscode" +
- " ) pdata\n" +
- " group by grouping sets((pdata.productionlineid,\n" +
- " pdata.goodstypename2,\n" +
- " pdata.goodstypename,\n" +
- " pdata.goodsspecification,\n" +
- " pdata.GOODSMODEL,\n" +
- " pdata.GLAZETYPE,\n" +
- " pdata.goodscode),\n" +
- " (pdata.productionlineid,pdata.goodstypename2),\n" +
- " pdata.productionlineid)\n" +
- " ) pdg";
- sql.Append(sqlString);
- parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
- DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- if (data1 == null || data1.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data1);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT040103画面(工序质量分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
- string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT040103画面(工序质量分析表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- // 2015-06-16 modify by chenxy
- string sqlString = "\n" +
- "select qdgroup.gid,\n" +
- " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
- " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
- " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
- " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
- " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
- " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
- " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
- " qdgroup.OutKilnCount,\n" +
- " qdgroup.GoodCount,\n" +
- " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
- " qdgroup.SubstandardCount,\n" +
- " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' SubstandardPercent,\n" +
- " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
- " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' QualifiedPercent,\n" +
- " qdgroup.BadCount,\n" +
- " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
- " qdgroup.ReFireCount,\n" +
- " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " qd.usercode,\n" +
- " --mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode) gid,\n" +
- " pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " --qd.kilnid,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename goodstypename2,\n" +
- " qd.usercode,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode,\n" +
- " sum(qd.OutKilnCount) OutKilnCount,\n" +
- " sum(qd.GoodCount) GoodCount,\n" +
- " sum(qd.SubstandardCount) SubstandardCount,\n" +
- " sum(qd.BadCount) BadCount,\n" +
- " sum(qd.ReFireCount) ReFireCount\n" +
- " from (select --pdbc.barcode,\n" +
- " pdbc.productionlineid,\n" +
- " pdata.procedureid,\n" +
- " pdata.usercode,\n" +
- " pdbc.goodsid,\n" +
- " pdbc.kilnid,\n" +
- " --pdbc.kilncarid,\n" +
- " --pdbc.kilncarbatchno,\n" +
- " 1 OutKilnCount,\n" +
- " case\n" +
- " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
- " 0\n" +
- " else\n" +
- " 1\n" +
- " end GoodCount,\n" +
- " case\n" +
- " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end SubstandardCount,\n" +
- " case\n" +
- " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end ReFireCount,\n" +
- " case\n" +
- " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end BadCount\n" +
- " from (select distinct pd.barcode,\n" +
- " pd.productionlineid,\n" +
- " pd.goodsid,\n" +
- " pd.kilnid,\n" +
- " --pd.kilncarid,\n" +
- " pd.kilncarbatchno\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.procedureid = :in_rptSprocedureId \n" +
- " and pd.AccountID = :AccountID\n ";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= pd.ProductionLineId))");
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " ) pdbc\n" + // 成检交接工序
- " inner join (select distinct pd.barcode,\n" +
- " pd.userid,\n" +
- " pd.usercode,\n" +
- " pd.procedureid\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.AccountID = :AccountID\n" +
- // 公坯、干补不算交坯工序的质量。
- //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
- // 干补不算交坯工序的质量。
- " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
- " and exists\n" +
- " (select 1\n" +
- " from tp_mst_rpttprocedure rptt\n" +
- " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
- {
- selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
- parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
- }
- //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))");
- selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
- parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- sqlString =
- " ) pdata\n" + // 生产工序
- " on pdata.barcode = pdbc.barcode\n" +
- " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
- " from (select pd.barcode,\n" +
- " pd.kilncarbatchno,\n" +
- " pd.goodsleveltypeid,\n" +
- " pd.productiondataid,\n" +
- " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.AccountID = :AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n" +
- " AND pd.createtime >= :CreateTimeStart\n" +
- " and pd.modeltype = -1) kcbc\n" +
- " where kcbc.dataid = 1) glt\n" +
- " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
- " and pdbc.barcode = glt.barcode\n" +
- " left join (select distinct productiondataid, defectprocedureid" +
- " from tp_pm_defect def " +
- " where def.valueflag='1'" +
- " and def.AccountID = :AccountID\n" +
- " AND def.createtime >= :CreateTimeStart) defect\n" +
- " on defect.productiondataid = glt.productiondataid\n" +
- " and pdata.procedureid = defect.defectprocedureid\n" +
- " ) qd\n" +
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = qd.productionlineid\n" +
- " inner join tp_pc_procedure pcp\n" +
- " on pcp.procedureid = qd.procedureid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = qd.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = qd.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " and mstgoodstype.accountid = mstgoods.accountid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
- " where 1=1\n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
- selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " qd.usercode,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode),\n" +
- " (pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename),\n" +
- " (pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " mstkiln.kilncode),\n" +
- " (pcpl.productionlinename, pcp.procedurename))\n" +
- " order by pcpl.productionlinename,\n" +
- " pcp.procedurename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " qd.usercode,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode\n" +
- " ) qdgroup\n";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- string sqlString = "select qdgroup.gid\n" +
- " ,qdgroup.productionlinename\n" +
- " ,decode(qdgroup.gid\n" +
- " ,15\n" +
- " ,'总计[' || qdgroup.procedurename || ']'\n" +
- " ,qdgroup.procedurename) procedurename\n" +
- " ,decode(qdgroup.gid\n" +
- " ,7\n" +
- " ,'合计[' || qdgroup.kilncode || ']'\n" +
- " ,15\n" +
- " ,'--'\n" +
- " ,qdgroup.kilncode) kilncode\n" +
- " ,decode(qdgroup.gid\n" +
- " ,3\n" +
- " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
- " ,15\n" +
- " ,'--'\n" +
- " ,7\n" +
- " ,'--'\n" +
- " ,qdgroup.goodstypename2) goodstypename2\n" +
- " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
- " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
- " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
- " ,qdgroup.OutKilnCount\n" +
- " ,qdgroup.GoodCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
- " ,qdgroup.SubstandardCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
- " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
- " qdgroup.OutKilnCount\n" +
- " ,4)) QualifiedPercent\n" +
- " ,qdgroup.BadCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
- " ,qdgroup.ReFireCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename\n" +
- " ,pcp.procedurename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode\n" +
- " ,pdata.usercode\n" +
- " ,mstgoods.goodscode) gid\n" +
- " ,pcpl.productionlinename\n" +
- " ,pcp.procedurename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypename goodstypename2\n" +
- " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
- " ,pdata.usercode\n" +
- " ,mstgoodstype.goodstypename\n" +
- " ,mstgoods.goodscode\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
- " from (select 0 goodsleveltypeid -- 出窑数量\n" +
- " ,pd.barcode\n" +
- " ,pd.productionlineid\n" +
- " ,pd.goodsid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " ,0 procedureid\n" +
- " ,1 cc\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.procedureid = :in_rptSprocedureId\n" +
- " and pd.accountid = :in_AccountID\n";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " union all\n" +
- " select distinct ppd.goodsleveltypeid\n" +
- " ,dd.barcode\n" +
- " ,dd.productionlineid\n" +
- " ,dd.goodsid\n" +
- " ,ppd.kilnid\n" +
- " ,ppd.kilncarbatchno\n" +
- " ,dd.defectprocedureid procedureid\n" +
- " ,1 cc\n" +
- " from (select pd.productiondataid\n" +
- " ,pd.goodsleveltypeid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.AccountID = :in_AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n" +
- " and pd.modeltype = -1\n";
- selSql.Append(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.checktime >= :checktimeStart\n");
- parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.checktime < :checktimeEnd\n");
- parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " and exists\n" +
- " (select 1\n" +
- " from tp_pm_productiondata outpd\n" +
- " where outpd.barcode = pd.barcode\n" +
- " and outpd.procedureid = :in_rptSprocedureId\n" +
- " and outpd.valueflag = '1'\n" +
- " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
- " inner join tp_pm_defect dd\n" +
- " on dd.productiondataid = ppd.productiondataid\n" +
- //" --and dd.checktime >= in_DateBegin\n" +
- //" --and dd.checktime <= in_DateEnd\n" +
- " ) ppcc\n" +
- " inner join tp_pm_productiondata pdata\n" +
- " on pdata.barcode = ppcc.barcode\n" +
- // 干补不算交坯工序的质量。
- " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
- " and exists\n" +
- " (select 1\n" +
- " from tp_mst_rpttprocedure rptt\n" +
- " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
- {
- selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
- parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
- }
- sqlString =
- " and rptt.procedureid = pdata.procedureid)\n" +
- " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
- parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- sqlString =
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = pdata.productionlineid\n" +
- " inner join tp_pc_procedure pcp\n" +
- " on pcp.procedureid = pdata.procedureid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = ppcc.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = pdata.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " and mstgoodstype.accountid = mstgoods.accountid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
- // 产品类别
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename, pdata.usercode, mstgoodstype.goodstypecode, mstgoodstype.goodstypename, mstgoods.goodscode),(pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename),(pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode),(pcpl.productionlinename, pcp.displayno, pcp.procedurename))\n" +
- " order by pcpl.productionlinename\n" +
- " ,pcp.displayno\n" +
- " ,pcp.procedurename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode\n" +
- " ,pdata.usercode\n" +
- " ,mstgoodstype.goodstypecode\n" +
- " ,mstgoods.goodscode) qdgroup";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 取得RPT040104画面(产成品质量分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
- string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT040104画面(产成品质量分析表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- // 2015-06-16 modify by chenxy
- string sqlString = "\n" +
- "select qdgroup.gid,\n" +
- " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
- " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
- " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
- " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
- " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
- " qdgroup.OutKilnCount,\n" +
- " qdgroup.GoodCount,\n" +
- " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
- " qdgroup.SubstandardCount,\n" +
- " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' SubstandardPercent,\n" +
- " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
- " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' QualifiedPercent,\n" +
- " qdgroup.BadCount,\n" +
- " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
- " qdgroup.ReFireCount,\n" +
- " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " --mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode) gid,\n" +
- " pcpl.productionlinename,\n" +
- " --qd.kilnid,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename goodstypename2,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode,\n" +
- " sum(qd.OutKilnCount) OutKilnCount,\n" +
- " sum(qd.GoodCount) GoodCount,\n" +
- " sum(qd.SubstandardCount) SubstandardCount,\n" +
- " sum(qd.BadCount) BadCount,\n" +
- " sum(qd.ReFireCount) ReFireCount\n" +
- " from (select --pdbc.barcode,\n" +
- " pdbc.productionlineid,\n" +
- " pdbc.goodsid,\n" +
- " pdbc.kilnid,\n" +
- " --pdbc.kilncarid,\n" +
- " --pdbc.kilncarbatchno,\n" +
- " 1 OutKilnCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
- " 0\n" +
- " else\n" +
- " 1\n" +
- " end GoodCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 7 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end SubstandardCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 6 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end ReFireCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 5 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end BadCount\n" +
- " from (select distinct pd.barcode,\n" +
- " pd.productionlineid,\n" +
- " pd.goodsid,\n" +
- " pd.kilnid,\n" +
- " --pd.kilncarid,\n" +
- " pd.kilncarbatchno\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.procedureid = :in_rptSprocedureId \n" +
- " and pd.AccountID = :AccountID\n";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID= pd.ProductionLineId))");
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " ) pdbc\n" +
- " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
- " from (select pd.barcode,\n" +
- " pd.kilncarbatchno,\n" +
- " pd.goodsleveltypeid,\n" +
- " pd.productiondataid,\n" +
- " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.AccountID = :AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n" +
- " AND pd.createtime >= :CreateTimeStart\n" +
- " and pd.modeltype = -1) kcbc\n" +
- " where kcbc.dataid = 1) glt\n" +
- " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
- " and pdbc.barcode = glt.barcode) qd\n" +
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = qd.productionlineid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = qd.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = qd.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " and mstgoodstype.accountid = mstgoods.accountid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
- " where 1=1\n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
- selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode),\n" +
- " (pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename),\n" +
- " (pcpl.productionlinename,\n" +
- " mstkiln.kilncode),\n" +
- " pcpl.productionlinename)\n" +
- " order by pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename,\n" +
- " mstgoodstype.goodstypename,\n" +
- " mstgoods.goodscode\n" +
- " ) qdgroup\n";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- string sqlString = "select qdgroup.gid\n" +
- " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
- " ,decode(qdgroup.gid\n" +
- " ,3\n" +
- " ,'合计[' || qdgroup.kilncode || ']'\n" +
- " ,7\n" +
- " ,'--'\n" +
- " ,qdgroup.kilncode) kilncode\n" +
- " ,decode(qdgroup.gid\n" +
- " ,1\n" +
- " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
- " ,0\n" +
- " ,qdgroup.goodstypename2\n" +
- " ,'--') goodstypename2\n" +
- " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
- " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
- " ,qdgroup.OutKilnCount\n" +
- " ,qdgroup.GoodCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
- " ,qdgroup.SubstandardCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
- " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
- " qdgroup.OutKilnCount\n" +
- " ,4)) QualifiedPercent\n" +
- " ,qdgroup.BadCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
- " ,qdgroup.ReFireCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode\n" +
- " ,mstgoods.goodscode) gid\n" +
- " ,pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypename goodstypename2\n" +
- " ,mstgoodstype.goodstypename\n" +
- " ,mstgoods.goodscode\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
- " from (select 0 goodsleveltypeid -- 出窑数量\n" +
- " ,pd.barcode\n" +
- " ,pd.productionlineid\n" +
- " ,pd.goodsid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " ,1 cc\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.procedureid = :in_rptSprocedureId\n" +
- " and pd.accountid = :in_AccountID\n";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " union all\n" +
- " select distinct pd.goodsleveltypeid\n" +
- " ,pd.barcode\n" +
- " ,pd.productionlineid\n" +
- " ,pd.goodsid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " ,1 cc\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.modeltype = -1\n" +
- " and pd.AccountID = :in_AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n";
- selSql.Append(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.checktime >= :checktimeStart\n");
- parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.checktime < :checktimeEnd\n");
- parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " and exists\n" +
- " (select 1\n" +
- " from tp_pm_productiondata outpd\n" +
- " where outpd.barcode = pd.barcode\n" +
- " and outpd.procedureid = :in_rptSprocedureId\n" +
- " and outpd.valueflag = '1'\n" +
- " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = ppcc.productionlineid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = ppcc.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = ppcc.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " and mstgoodstype.accountid = mstgoods.accountid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
- // 产品类别
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename, mstgoodstype.goodstypecode, mstgoodstype.goodstypename, mstgoods.goodscode),(pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename),(pcpl.productionlinename, mstkiln.kilncode),(pcpl.productionlinename))\n" +
- " order by pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode\n" +
- " ,mstgoodstype.goodstypecode\n" +
- " ,mstgoods.goodscode) qdgroup\n";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 取得RPT040105画面(质量报表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sqlString =
- "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingdate >= :datebegin\n" +
- " AND gdd.groutingdate <= :dateend\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
- parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
- DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- parameters.Clear();
- //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
- string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- data.Columns.Add("GCount", typeof(int));
- //data.Columns.Add("OutGCount", typeof(string));
- //data.Columns.Add("GoodGCount", typeof(string));
- data.Columns.Add("OutGCount", typeof(decimal));
- data.Columns.Add("GoodGCount", typeof(decimal));
- foreach (DataRow item in data.Rows)
- {
- int gid = Convert.ToInt32(item["gid"]);
- if (gid < 2)
- {
- continue;
- }
- int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
- int goodCount = Convert.ToInt32(item["Qualified"]);
- DataRow[] drs = null;
- if (gid == 2)
- {
- drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
- }
- else if (gid == 3)
- {
- drs = dataCount.Select("goodstypecode2 is null");
- }
- if (drs != null && drs.Length > 0)
- {
- int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
- item["GCount"] = barcodecount;
- //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
- //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
- item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
- item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
- }
- else
- {
- item["GCount"] = 0;
- //item["OutGCount"] = "#DIV/0!";
- //item["GoodGCount"] = "#DIV/0!";
- item["OutGCount"] = DBNull.Value;
- item["GoodGCount"] = DBNull.Value;
- }
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT040105画面(质量报表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- // 2015-06-16 modify by chenxy
- string sqlString = "\n" +
- "select qdgroup.gid,\n" +
- " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
- " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
- " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
- " qdgroup.goodstypecode2,\n" +
- " qdgroup.OutKilnCount,\n" +
- " qdgroup.GoodCount,\n" +
- " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
- " qdgroup.SubstandardCount,\n" +
- " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' SubstandardPercent,\n" +
- " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
- " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' QualifiedPercent,\n" +
- " qdgroup.BadCount,\n" +
- " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
- " qdgroup.ReFireCount,\n" +
- " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
- " '990.00') || '%' ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypecode) gid,\n" +
- " pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypecode goodstypecode2,\n" +
- " mstgoodstype2.goodstypename goodstypename2,\n" +
- " sum(qd.OutKilnCount) OutKilnCount,\n" +
- " sum(qd.GoodCount) GoodCount,\n" +
- " sum(qd.SubstandardCount) SubstandardCount,\n" +
- " sum(qd.BadCount) BadCount,\n" +
- " sum(qd.ReFireCount) ReFireCount\n" +
- " from (select --pdbc.barcode,\n" +
- " pdbc.productionlineid,\n" +
- " pdbc.goodsid,\n" +
- " pdbc.kilnid,\n" +
- " 1 OutKilnCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
- " 0\n" +
- " else\n" +
- " 1\n" +
- " end GoodCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 7 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end SubstandardCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 6 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end ReFireCount,\n" +
- " case\n" +
- " when glt.goodsleveltypeid = 5 then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end BadCount\n" +
- " from (select distinct pd.barcode,\n" +
- " pd.productionlineid,\n" +
- " pd.goodsid,\n" +
- " pd.kilnid,\n" +
- " pd.kilncarbatchno\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
- " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
- " and pd.AccountID = :AccountID\n";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- // 不控制权限
- //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID= pd.ProductionLineId))");
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " ) pdbc\n" +
- " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
- " from (select pd.barcode,\n" +
- " pd.kilncarbatchno,\n" +
- " pd.goodsleveltypeid,\n" +
- " pd.productiondataid,\n" +
- " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.AccountID = :AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n" +
- " AND pd.createtime >= :CreateTimeStart\n" +
- " and pd.modeltype = -1) kcbc\n" +
- " where kcbc.dataid = 1) glt\n" +
- " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
- " and pdbc.barcode = glt.barcode) qd\n" +
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = qd.productionlineid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = qd.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = qd.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
- " where 1=1\n";
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypecode,\n" +
- " mstgoodstype2.goodstypename),\n" +
- " (pcpl.productionlinename,\n" +
- " mstgoodstype2.goodstypecode,\n" +
- " mstgoodstype2.goodstypename),\n" +
- " (pcpl.productionlinename,\n" +
- " mstkiln.kilncode),\n" +
- " pcpl.productionlinename)\n" +
- " order by pcpl.productionlinename,\n" +
- " mstkiln.kilncode,\n" +
- " mstgoodstype2.goodstypename\n" +
- " ) qdgroup\n";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- string sqlString = "select qdgroup.gid\n" +
- " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
- " ,decode(qdgroup.gid\n" +
- " ,1\n" +
- " ,'合计[' || qdgroup.kilncode || ']'\n" +
- " ,0\n" +
- " ,qdgroup.kilncode\n" +
- " ,'--') kilncode\n" +
- " ,decode(qdgroup.gid\n" +
- " ,2\n" +
- " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
- " ,0\n" +
- " ,qdgroup.goodstypename2\n" +
- " ,'--') goodstypename2\n" +
- " ,qdgroup.goodstypecode2\n" +
- //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
- //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
- " ,qdgroup.OutKilnCount\n" +
- " ,qdgroup.GoodCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
- " ,qdgroup.SubstandardCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
- " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
- " qdgroup.OutKilnCount\n" +
- " ,4)) QualifiedPercent\n" +
- " ,qdgroup.BadCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
- " ,qdgroup.ReFireCount\n" +
- " ,decode(qdgroup.OutKilnCount\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
- " from (select grouping_id(pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode) gid\n" +
- " ,pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypename goodstypename2\n" +
- " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
- //" ,mstgoodstype.goodstypename\n" +
- //" ,mstgoods.goodscode\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
- " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
- " from (select 0 goodsleveltypeid -- 出窑数量\n" +
- " ,pd.barcode\n" +
- " ,pd.productionlineid\n" +
- " ,pd.goodsid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " ,1 cc\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
- " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
- " and pd.accountid = :in_AccountID\n";
- StringBuilder selSql = new StringBuilder(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " union all\n" +
- " select distinct pd.goodsleveltypeid\n" +
- " ,pd.barcode\n" +
- " ,pd.productionlineid\n" +
- " ,pd.goodsid\n" +
- " ,pd.kilnid\n" +
- " ,pd.kilncarbatchno\n" +
- " ,1 cc\n" +
- " from tp_pm_productiondata pd\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.modeltype = -1\n" +
- " and pd.AccountID = :in_AccountID\n" +
- " and length(pd.kilncarbatchno) > 0\n";
- selSql.Append(sqlString);
- if (se.CreateTimeStart.HasValue)
- {
- selSql.Append(" AND pd.checktime >= :checktimeStart\n");
- parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql.Append(" AND pd.checktime < :checktimeEnd\n");
- parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingUserIDS))
- {
- selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GroutingLineIDS))
- {
- selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
- parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql.Append(" AND pd.KilnID = :KilnID\n");
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- sqlString =
- " and exists\n" +
- " (select 1\n" +
- " from tp_pm_productiondata outpd\n" +
- " where outpd.barcode = pd.barcode\n" +
- //" and outpd.procedureid = :in_rptSprocedureId\n" +
- " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
- " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
- " and outpd.valueflag = '1'\n" +
- " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
- " inner join tp_pc_productionline pcpl\n" +
- " on pcpl.productionlineid = ppcc.productionlineid\n" +
- " inner join tp_mst_kiln mstkiln\n" +
- " on mstkiln.kilnid = ppcc.kilnid\n" +
- " inner join tp_mst_goods mstgoods\n" +
- " on mstgoods.goodsid = ppcc.goodsid\n" +
- " inner join tp_mst_goodstype mstgoodstype\n" +
- " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
- " and mstgoodstype.accountid = mstgoods.accountid\n" +
- " inner join tp_mst_goodstype mstgoodstype2\n" +
- " on mstgoodstype2.goodstypecode =\n" +
- " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
- " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
- // 产品类别
- selSql.Append(sqlString);
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- sqlString =
- " group by grouping sets((pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypename,mstgoodstype2.goodstypecode),(pcpl.productionlinename, mstgoodstype2.goodstypename,mstgoodstype2.goodstypecode),(pcpl.productionlinename, mstkiln.kilncode),(pcpl.productionlinename))\n" +
- " order by pcpl.productionlinename\n" +
- " ,mstkiln.kilncode\n" +
- " ,mstgoodstype2.goodstypecode\n" +
- " ) qdgroup\n";
- selSql.Append(sqlString);
- return selSql.ToString();
- }
- /// <summary>
- /// 取得RPT040106画面(缺陷报表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlString = null;
- OracleParameter[] parameters = null;
- if (se.OutKilnNumByGoodsType)
- {
- sqlString = "SELECT Defect.productionlinename\n" +
- " ,Defect.procedurename\n" +
- " ,Defect.Defectcode\n" +
- " ,Defect.Defectname\n" +
- " ,Defect.goodstypename2\n" +
- " ,Defect.DefectCount\n" +
- " ,OUT.outNum OutKilnCount\n" +
- " ,decode(OUT.outNum,\n" +
- " 0,\n" +
- " to_number(NULL),\n" +
- " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
- " FROM (SELECT tp_pc_productionline.productionlinename\n" +
- " ,tp_pc_procedure.procedurename\n" +
- " ,TP_MST_DefectType.Defecttypename\n" +
- " ,TP_MST_Defect.Defectcode\n" +
- " ,TP_MST_Defect.Defectname\n" +
- " ,goodstype2.goodstypename goodstypename2\n" +
- " ,goodstype2.goodstypecode goodstypecode2\n" +
- " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
- " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
- " FROM TP_PM_Defect\n" +
- " LEFT JOIN tp_pc_procedure\n" +
- " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
- " LEFT JOIN tp_pc_productionline\n" +
- " ON TP_PM_Defect.Productionlineid =\n" +
- " tp_pc_productionline.Productionlineid\n" +
- " LEFT JOIN TP_MST_Goods\n" +
- " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType\n" +
- " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
- " ON goodstype2.goodstypecode =\n" +
- " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
- " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
- " LEFT JOIN TP_MST_Defect\n" +
- " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
- " LEFT JOIN TP_MST_DefectType\n" +
- " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
- " --LEFT JOIN TP_PM_ProductionData\n" +
- " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
- " -- TP_PM_Defect.ProductionDataID\n" +
- " WHERE TP_PM_Defect.valueflag = '1'\n" +
- " --AND tp_pc_procedure.ModelType = -1\n" +
- " AND TP_PM_Defect.AccountID = :AccountID\n" +
- " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
- " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
- " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
- " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
- " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
- " GROUP BY tp_pc_productionline.productionlinename\n" +
- " ,tp_pc_procedure.procedurename\n" +
- " ,TP_MST_DefectType.Defecttypename\n" +
- " ,TP_MST_Defect.Defectcode\n" +
- " ,TP_MST_Defect.Defectname\n" +
- " ,goodstype2.goodstypecode\n" +
- " ,goodstype2.goodstypename) Defect\n" +
- " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND pd.procedureid = :procedureid\n" +
- " AND pd.AccountID = :AccountID\n" +
- " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
- " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
- " GROUP BY gt2.goodstypecode) OUT \n" +
- " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
- parameters = new OracleParameter[]
- {
- new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
- new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
- new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
- new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
- new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
- //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
- new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
- };
- }
- else
- {
- sqlString = "SELECT COUNT(pd.barcode) \n" +
- " FROM tp_pm_productiondata pd\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND pd.procedureid = :procedureid\n" +
- " AND pd.AccountID = :AccountID\n" +
- " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
- " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
- parameters = new OracleParameter[]
- {
- new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
- new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
- new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
- };
- int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
- sqlString = "SELECT Defect.productionlinename\n" +
- " ,Defect.procedurename\n" +
- " ,Defect.Defectcode\n" +
- " ,Defect.Defectname\n" +
- " ,Defect.goodstypename2\n" +
- " ,Defect.DefectCount\n" +
- " ,:OutKilnCount OutKilnCount\n" +
- " ,decode(:OutKilnCount,\n" +
- " 0,\n" +
- " to_number(NULL),\n" +
- " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
- " FROM (SELECT tp_pc_productionline.productionlinename\n" +
- " ,tp_pc_procedure.procedurename\n" +
- " ,TP_MST_DefectType.Defecttypename\n" +
- " ,TP_MST_Defect.Defectcode\n" +
- " ,TP_MST_Defect.Defectname\n" +
- " ,goodstype2.goodstypename goodstypename2\n" +
- " ,:OutKilnCount OutKilnCount\n" +
- " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
- " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
- " FROM TP_PM_Defect\n" +
- " LEFT JOIN tp_pc_procedure\n" +
- " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
- " LEFT JOIN tp_pc_productionline\n" +
- " ON TP_PM_Defect.Productionlineid =\n" +
- " tp_pc_productionline.Productionlineid\n" +
- " LEFT JOIN TP_MST_Goods\n" +
- " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType\n" +
- " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
- " ON goodstype2.goodstypecode =\n" +
- " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
- " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
- " LEFT JOIN TP_MST_Defect\n" +
- " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
- " LEFT JOIN TP_MST_DefectType\n" +
- " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
- " --LEFT JOIN TP_PM_ProductionData\n" +
- " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
- " -- TP_PM_Defect.ProductionDataID\n" +
- " WHERE TP_PM_Defect.valueflag = '1'\n" +
- " --AND tp_pc_procedure.ModelType = -1\n" +
- " AND TP_PM_Defect.AccountID = :AccountID\n" +
- " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
- " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
- " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
- " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
- " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
- " GROUP BY tp_pc_productionline.productionlinename\n" +
- " ,tp_pc_procedure.procedurename\n" +
- " ,TP_MST_DefectType.Defecttypename\n" +
- " ,TP_MST_Defect.Defectcode\n" +
- " ,TP_MST_Defect.Defectname\n" +
- " ,goodstype2.goodstypename) Defect";
- parameters = new OracleParameter[]
- {
- new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
- new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
- new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
- new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
- new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
- new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
- };
- }
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
- " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
- " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
- " p.procedurename || '\"',\n" +
- " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
- " FROM (SELECT to_char(p.procedureid) procedureid\n" +
- " ,to_char(p.procedurename) procedurename\n" +
- " ,p.displayno\n" +
- " ,p.productionlineid plid\n" +
- " ,p.procedureid pid\n" +
- " FROM tp_pc_procedure p\n" +
- " WHERE p.valueflag = '1'\n" +
- " AND p.modeltype <> -1\n" +
- " AND p.accountid = :AccountID\n" +
- " UNION ALL\n" +
- " SELECT to_char(p.procedureid) || 'S'\n" +
- " ,to_char(p.procedurename) || '(不合格)'\n" +
- " ,p.displayno\n" +
- " ,p.productionlineid plid\n" +
- " ,p.procedureid pid\n" +
- " FROM tp_pc_procedure p\n" +
- " WHERE p.valueflag = '1'\n" +
- " AND p.modeltype = -1\n" +
- " AND p.accountid = :AccountID) p" +
- " WHERE exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=p.plid)) \n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=p.pid)) \n";
- // 生产线
- if (se.ProductionLineID.HasValue)
- {
- sqlString = sqlString + " AND p.plid = :ProductionLineID ";
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
- }
- // 生产工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (cols == null || cols.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- string pivotcol = cols.Rows[0]["pivotcol"].ToString();
- string groupsum = cols.Rows[0]["groupsum"].ToString();
- if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- parameters.Clear();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- sqlString =
- "WITH pd_data AS\n" +
- " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
- " ,pd.groutingdailydetailid\n" +
- " ,decode(pd.MODELTYPE,\n" +
- " -1,\n" +
- " to_char(pd.procedureid) || 'S',\n" +
- " to_char(pd.procedureid)) procedureid\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = goods.goodstypeid\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
- " AND pd.accountid = :AccountID\n" +
- (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineID)) \n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.procedureid)) \n";
- // 生产线
- if (se.ProductionLineID.HasValue)
- {
- sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
- }
- // 生产工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 注浆时间
- if (se.GTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
- }
- if (se.GTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
- }
- sqlString +=
- " ),\n" +
- "pivot_data AS\n" +
- " (SELECT *\n" +
- " FROM pd_data\n" +
- " PIVOT(COUNT(groutingdailydetailid) bc\n" +
- " FOR procedureid IN(" + pivotcol + ")))\n" +
- "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
- " 3,\n" +
- " '合计',\n" +
- " 1,\n" +
- " '小计【' || groutdetail.goodstypename2 || '】',\n" +
- " groutdetail.goodstypename2) \"产量类别\"\n" +
- " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
- " 0,\n" +
- " groutdetail.goodscode,\n" +
- " '--') \"产品编码\"\n" +
- " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
- " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
- " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
- " ," + groupsum + "\n" +
- " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
- " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
- " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
- " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = gdd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = goods.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " WHERE gdd.valueflag = '1'\n" +
- " AND gdd.accountid = :AccountID\n";
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
- }
- // 注浆时间
- if (se.GTimeStart.HasValue)
- {
- sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
- }
- if (se.GTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
- }
- sqlString +=
- " AND gdd.groutingflag = '1'\n" +
- " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
- " LEFT JOIN pivot_data pd\n" +
- " ON pd.pdgoodsid = groutdetail.goodsid\n" +
- " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
- " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT040108画面(成型线产量分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- //string sqlString =
- // "SELECT t.groutinglinecode\n" +
- // " ,t.BuildingNo\n" +
- // " ,t.FloorNo\n" +
- // " ,t.GroutingLineNo\n" +
- // " ,t.usercode\n" +
- // " ,t.goodscode\n" +
- // " ,t.GOODSSPECIFICATION\n" +
- // " ,t.goodstypename\n" +
- // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
- // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
- // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
- // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
- // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
- // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
- // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
- // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
- // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
- // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
- // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
- // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
- // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
- // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
- // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
- // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
- // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
- // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
- // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
- // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
- // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
- // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
- // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
- // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
- // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
- // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
- // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
- // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
- // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
- // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
- // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
- // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
- // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
- // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
- // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
- // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
- // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
- // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
- // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
- // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
- // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
- // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
- // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
- // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
- // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
- // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
- // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
- // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
- // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
- // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
- // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
- // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
- // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
- // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
- // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
- // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
- // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
- // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
- // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
- // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
- // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
- // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
- // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
- // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
- // " FROM (SELECT gd.groutinglinecode\n" +
- // " ,gl.BuildingNo\n" +
- // " ,gl.FloorNo\n" +
- // " ,gl.GroutingLineNo\n" +
- // " ,gd.usercode\n" +
- // " ,gdd.goodscode\n" +
- // " ,g.GOODSSPECIFICATION\n" +
- // " ,gt.goodstypename\n" +
- // //" ,gd.MouldQuantity\n" +
- // " ,gl.MouldQuantity\n" +
- // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
- // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
- // " , CASE\n" +
- // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
- // " gd.groutingdate <= :GDateEnd AND\n" +
- // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
- // " 1\n" +
- // " ELSE\n" +
- // " 0\n" +
- // " END c -- 成坯量\n" +
- // " , CASE\n" +
- // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
- // " gdd.delivertime <= :GDateEnd AND\n" +
- // " gdd.deliverflag = '1' THEN\n" +
- // " 1\n" +
- // " ELSE\n" +
- // " 0\n" +
- // " END d -- 交坯量\n" +
- // " FROM TP_PM_GroutingDaily gd\n" +
- // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
- // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
- // " INNER JOIN TP_PC_GroutingLine gl \n" +
- // " ON gl.groutinglineid = gd.groutinglineid\n" +
- // " INNER JOIN TP_MST_Goods g\n" +
- // " ON g.goodsid = gdd.goodsid\n" +
- // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
- // " ON gt.goodstypeid = g.goodstypeid\n" +
- // " WHERE gd.accountid = :AccountID\n" +
- // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
- // " gd.groutingdate <= :GDateEnd) OR\n" +
- // " (gdd.delivertime >= :GDateBegin AND\n" +
- // " gdd.delivertime <= :GDateEnd))\n" +
- // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
- // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
- // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
- // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- // " ) t\n" +
- // " GROUP BY t.groutinglinecode\n" +
- // " ,t.BuildingNo\n" +
- // " ,t.FloorNo\n" +
- // " ,t.GroutingLineNo\n" +
- // " ,t.usercode\n" +
- // " ,t.goodscode\n" +
- // " ,t.GOODSSPECIFICATION\n" +
- // " ,t.goodstypename\n" +
- // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
- string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
- " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
- " ,nvl(t.FloorNo, '--') FloorNo\n" +
- " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
- " ,nvl(t.usercode, '--') usercode\n" +
- " ,nvl2(t.groutinglinecode\n" +
- " ,t.goodscode\n" +
- " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
- " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
- " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
- " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
- " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
- " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
- " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
- " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
- " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
- " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
- " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
- " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
- " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
- " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
- " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
- " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
- " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
- " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
- " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
- " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
- " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
- " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
- " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
- " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
- " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
- " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
- " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
- " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
- " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
- " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
- " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
- " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
- " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
- " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
- " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
- " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
- " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
- " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
- " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
- " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
- " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
- " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
- " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
- " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
- " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
- " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
- " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
- " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
- " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
- " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
- " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
- " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
- " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
- " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
- " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
- " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
- " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
- " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
- " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
- " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
- " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
- " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
- " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
- " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
- " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
- " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
- " from (select gd.groutinglinecode\n" +
- " ,gl.BuildingNo\n" +
- " ,gl.FloorNo\n" +
- " ,gl.GroutingLineNo\n" +
- " ,gd.usercode\n" +
- " ,gdd.goodscode\n" +
- " ,g.GOODSSPECIFICATION\n" +
- " ,gt.goodstypename\n" +
- " ,gl.MouldQuantity\n" +
- " ,to_char(gd.groutingdate, 'dd') as gday\n" +
- " ,to_char(gdd.delivertime, 'dd') as dday\n" +
- " ,case\n" +
- " when gd.groutingdate >= :GDateBegin and\n" +
- " gd.groutingdate <= :GDateEnd and\n" +
- " gdd.GroutingFlag = '1' and\n" +
- " gdd.ScrapFlag = '0' then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end c -- 成坯量\n" +
- " ,case\n" +
- " when gdd.delivertime >= :GDateBegin and\n" +
- " gdd.delivertime <= :GDateEnd and\n" +
- " gdd.deliverflag = '1' then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end d -- 交坯量\n" +
- " from TP_PM_GroutingDaily gd\n" +
- " inner join TP_PM_GroutingDailyDetail gdd\n" +
- " on gdd.groutingdailyid = gd.groutingdailyid\n" +
- " inner join TP_PC_GroutingLine gl\n" +
- " on gl.groutinglineid = gd.groutinglineid\n" +
- " inner join TP_MST_Goods g\n" +
- " on g.goodsid = gdd.goodsid\n" +
- " inner join TP_MST_GOODSTYPE gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " where gd.accountid = :AccountID\n" +
- " and ((gd.groutingdate >= :GDateBegin and\n" +
- " gd.groutingdate <= :GDateEnd) or\n" +
- " (gdd.delivertime >= :GDateBegin and\n" +
- " gdd.delivertime <= :GDateEnd))\n" +
- " and (:groutinglinecode is null or\n" +
- " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
- " and (:groutingusercode is null or\n" +
- " instr(gdd.usercode, :groutingusercode) > 0)\n" +
- " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
- " and (:goodstypecode is null or\n" +
- " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
- " group by grouping sets((t.groutinglinecode, t.BuildingNo, t.FloorNo, t.GroutingLineNo, t.usercode, t.goodscode, t.GOODSSPECIFICATION, t.goodstypename),(t.goodscode, t.GOODSSPECIFICATION, t.goodstypename),())\n" +
- " order by t.goodscode, t.groutinglinecode, t.usercode";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT040109画面(整体质量分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] parameters = new OracleParameter[]
- {
- new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
- new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
- new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
- new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
- new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
- new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
- new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- //out_data1 -- 质量整体情况
- //out_data2 -- 各缺陷类型成品率
- //out_data3 -- 各缺陷类型缺陷率
- //out_data4 -- 产品质量排行榜
- //out_data21 -- 各缺陷类型成品率-总成品率
- //out_data31 -- 各缺陷类型缺陷率-总缺陷率
- //out_data32 -- 各缺陷类型缺陷率-分缺陷率
- //out_table1 -- 缺陷类别
- //out_table2 -- 工号分组
- //out_table3 -- 缺陷扣罚
- //out_table4 -- 缺陷
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- data.Tables[0].TableName = "TQ";
- data.Tables[1].TableName = "FR";
- data.Tables[2].TableName = "DR";
- data.Tables[3].TableName = "DL";
- data.Tables[4].TableName = "FR1";
- data.Tables[5].TableName = "DR1";
- data.Tables[6].TableName = "DR2";
- data.Tables[7].TableName = "DT";
- data.Tables[8].TableName = "WG";
- data.Tables[9].TableName = "DF";
- data.Tables[10].TableName = "D";
- DataTable dtFR = data.Tables["FR"];
- DataTable dtFRClone = dtFR.Clone();
- for (int i = 0; i < dtFR.Columns.Count; i++)
- {
- dtFRClone.Columns[i].DataType = typeof(string);
- }
- foreach (DataRow item in dtFR.Rows)
- {
- item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
- dtFRClone.Rows.Add(item.ItemArray);
- }
- // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
- //DataRow drFR = dtFRClone.NewRow();
- //drFR["goodstypename2"] = "成品率(%)";
- //foreach (DataRow row in data.Tables["FR1"].Rows)
- //{
- // string tid = row["tid"].ToString();
- // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
- // foreach (DataColumn col in dtFRClone.Columns)
- // {
- // if (col.ColumnName.StartsWith(tid))
- // {
- // drFR[col.ColumnName] = overRate;
- // }
- // }
- //}
- //dtFRClone.Rows.Add(drFR);
- Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
- foreach (DataRow row in data.Tables["FR1"].Rows)
- {
- string tcode = row["goodstypecode2"].ToString();
- DataRow drFR = null;
- if (drFRs.ContainsKey(tcode))
- {
- drFR = drFRs[tcode];
- }
- else
- {
- drFR = dtFRClone.NewRow();
- drFRs.Add(tcode, drFR);
- drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
- }
- string tid = row["tid"].ToString();
- string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
- foreach (DataColumn col in dtFRClone.Columns)
- {
- if (col.ColumnName.StartsWith(tid))
- {
- drFR[col.ColumnName] = overRate;
- }
- }
- }
- foreach (DataRow item in drFRs.Values)
- {
- dtFRClone.Rows.Add(item);
- }
- // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
- data.Tables.Remove(dtFR);
- data.Tables.Remove(data.Tables["FR1"]);
- data.Tables.Add(dtFRClone);
- DataTable dtDR = data.Tables["DR"];
- DataTable dtDRClone = dtDR.Clone();
- for (int i = 0; i < dtDR.Columns.Count; i++)
- {
- dtDRClone.Columns[i].DataType = typeof(string);
- }
- foreach (DataRow item in dtDR.Rows)
- {
- item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
- dtDRClone.Rows.Add(item.ItemArray);
- }
- // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
- //DataRow drDR = dtDRClone.NewRow();
- //drDR["goodstypename2"] = "缺陷率(%)";
- //foreach (DataRow row in data.Tables["DR2"].Rows)
- //{
- // string tid = row["tdfid"].ToString();
- // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
- // drDR[tid] = defectRate;
- //}
- //dtDRClone.Rows.Add(drDR);
- Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
- foreach (DataRow row in data.Tables["DR2"].Rows)
- {
- string tcode = row["goodstypecode2"].ToString();
- DataRow drDR = null;
- if (drDRs.ContainsKey(tcode))
- {
- drDR = drDRs[tcode];
- }
- else
- {
- drDR = dtDRClone.NewRow();
- drDRs.Add(tcode, drDR);
- drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
- }
- string tid = row["tdfid"].ToString();
- string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
- drDR[tid] = defectRate;
- }
- foreach (DataRow item in drDRs.Values)
- {
- dtDRClone.Rows.Add(item);
- }
- // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
- data.Tables.Remove(dtDR);
- data.Tables.Remove(data.Tables["DR2"]);
- data.Tables.Add(dtDRClone);
- conn.Commit();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- /// <summary>
- /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] parameters = new OracleParameter[]
- {
- new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
- new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
- new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
- new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
- new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
- };
- DataSet data = null;
- if (se.IsShowG)
- {
- data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
- }
- else
- {
- data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
- }
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- conn.Commit();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- #endregion 分析报表
- #region 汇总报表
- /// <summary>
- /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
- {
- //string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- /*
- selSql = selSql +
- "select " +
- " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
- " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
- " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
- " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
- " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
- " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
- " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
- " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
- " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
- " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
- " t.产量 " +
- "from " +
- "( " +
- " select " +
- " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
- " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
- " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
- " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
- " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
- " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
- " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
- " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
- " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
- " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
- " count(BarCode) as 产量 " +
- " from TP_PM_ProductionData " +
- " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
- " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
- " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
- " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
- " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
- // 公坯、干补不算交坯工序的质量。
- (se.ProductionFlag == "1" ? " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and (TP_PM_ProductionData.IsPublicBody = '0' or TP_PM_ProductionData.SpecialRepairFlag = '0'))) \n" : "") +
- " and TP_PM_ProductionData.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- if (se.AccountDateStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
- parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
- }
- if (se.AccountDateEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
- parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- "group by " +
- " rollup(TP_MST_Organization.OrganizationName, " +
- " TP_PM_ProductionData.ProductionLineName, " +
- " TP_PM_ProductionData.Procedureid, " +
- " TP_PM_ProductionData.ProcedureName, " +
- " TP_MST_GOODSTYPE.GoodsTypeName, " +
- " TP_PM_ProductionData.GoodsCode, " +
- " TP_PM_ProductionData.GoodsId, " +
- " TP_MST_Goods.GOODSSPECIFICATION, " +
- " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
- " order by " +
- " TP_MST_Organization.OrganizationName, " +
- " TP_PM_ProductionData.ProductionLineName, " +
- " TP_PM_ProductionData.Procedureid, " +
- " TP_PM_ProductionData.ProcedureName, " +
- " TP_MST_GOODSTYPE.GoodsTypeName " +
- ") t \n" +
- // 增加 产品型号
- "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
- "where 1=1 " +
- "and (t.DICTIONARYVALUE!='--' ) " +
- "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
- "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
- "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
- */
- string selSql =
- "select t.gid\n" +
- " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
- " ,t.OrganizationID\n" +
- " --,t.OrganizationCode\n" +
- " ,decode(t.gid\n" +
- " ,7\n" +
- " ,'合计[' || t.OrganizationName || ']'\n" +
- " ,15\n" +
- " ,'--'\n" +
- " ,t.OrganizationName) OrganizationName\n" +
- " ,t.Procedureid\n" +
- " ,decode(t.gid\n" +
- " ,3\n" +
- " ,'小计[' || t.ProcedureName || ']'\n" +
- " ,0\n" +
- " ,t.ProcedureName\n" +
- " ,1\n" +
- " ,t.ProcedureName\n" +
- " ,'--') ProcedureName\n" +
- " ,t.GoodsTypeID\n" +
- " ,decode(t.gid\n" +
- " ,1\n" +
- " ,'小计[' || t.GoodsTypeName || ']'\n" +
- " ,0\n" +
- " ,t.GoodsTypeName\n" +
- " ,'--') GoodsTypeName\n" +
- " --,t.GoodsId\n" +
- " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
- " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
- " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
- " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
- " ,t.pfcount as 产量\n" +
- " from (select grouping_id(org.OrganizationID\n" +
- " ,p.Procedureid\n" +
- " ,gt.goodstypeid\n" +
- " ,g.GoodsId) as gid\n" +
- " ,pd.ProductionLineName\n" +
- " ,org.OrganizationID\n" +
- " --,org.OrganizationCode\n" +
- " ,org.OrganizationName\n" +
- " ,p.Procedureid\n" +
- " ,p.ProcedureName\n" +
- " ,gt.GoodsTypeID\n" +
- " ,gt.GoodsTypeName\n" +
- " ,g.GoodsId\n" +
- " ,g.GoodsCode\n" +
- " ,g.GOODSSPECIFICATION\n" +
- " ,d.Dictionaryvalue\n" +
- " ,count(BarCode) as pfcount" +
- " from TP_PM_ProductionData pd\n" +
- " inner join tp_pc_Procedure p\n" +
- " on p.Procedureid = pd.Procedureid\n" +
- " inner join TP_MST_Goods g\n" +
- " on g.GoodsID = pd.GoodsID\n" +
- " inner join TP_MST_GoodsType gt\n" +
- " on gt.GoodsTypeID = g.GoodsTypeID\n" +
- " inner join TP_MST_Organization org\n" +
- " on org.OrganizationID = pd.OrganizationID\n" +
- " inner join TP_MST_DATADICTIONARY d\n" +
- " on d.DICTIONARYID = g.GLAZETYPEID\n" +
- " where pd.ValueFlag = '1'\n" +
- " and pd.AccountID = :AccountID\n";
- // 公坯、干补不算交坯工序的质量。
- if (se.ProductionFlag == "1")
- {
- selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
- selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- if (se.AccountDateStart.HasValue)
- {
- selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
- parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
- }
- if (se.AccountDateEnd.HasValue)
- {
- selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
- parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
- }
- selSql +=
- " group by grouping sets((pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName, g.GoodsId, g.GoodsCode, g.GOODSSPECIFICATION, d.Dictionaryvalue),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName),())\n" +
- " order by org.organizationcode\n" +
- " ,p.displayno\n" +
- " ,gt.goodstypecode\n" +
- " ,g.goodscode) t";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
- {
- //string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- /*
- selSql = selSql +
- "select " +
- "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
- "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
- "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
- "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
- "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
- "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
- "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
- "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
- "产量, " +
- "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
- "from " +
- "( " +
- " select " +
- " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
- " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
- " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
- " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
- " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
- " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
- " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
- " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
- " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
- " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
- " count(BarCode) as 产量 " +
- " from TP_PM_ProductionData " +
- " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
- " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
- " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
- " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
- " Where 1=1 " +
- " and TP_PM_ProductionData.ValueFlag = 1 " +
- // 公坯、干补不算交坯工序的质量。
- " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.IsPublicBody = '0' and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- " and TP_PM_ProductionData.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- if (se.AccountDateStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
- parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
- }
- if (se.AccountDateEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
- parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- "group by " +
- " rollup(TP_MST_Organization.OrganizationName, " +
- " TP_PM_ProductionData.ProductionLineName, " +
- " TP_PM_ProductionData.ProcedureName, " +
- " TP_MST_GOODSTYPE.GoodsTypeName, " +
- " TP_PM_ProductionData.GoodsCode, " +
- " TP_PM_ProductionData.BarCode, " +
- " TP_PM_ProductionData.UserCode, " +
- " TP_MST_Goods.GOODSSPECIFICATION, " +
- " TP_MST_DATADICTIONARY.Dictionaryvalue" +
- " ) " +
- " order by " +
- " TP_MST_Organization.OrganizationName, " +
- " TP_PM_ProductionData.ProductionLineName, " +
- " TP_PM_ProductionData.ProcedureName, " +
- " TP_MST_GOODSTYPE.GoodsTypeName " +
- ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
- " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
- "where 1=1 " +
- "and (temp.DICTIONARYVALUE!='--') " +
- "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
- "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
- "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
- */
- string selSql =
- " select " +
- " TP_MST_Organization.OrganizationName, " +
- " TP_PM_ProductionData.ProductionLineName, " +
- " TP_PM_ProductionData.ProcedureName, " +
- " TP_MST_GOODSTYPE.GoodsTypeName, " +
- " TP_PM_ProductionData.GoodsCode, " +
- " TP_MST_Goods.GoodsName, " +
- " TP_MST_Goods.GoodsModel, " +
- " TP_PM_ProductionData.BarCode, " +
- " TP_PM_ProductionData.UserCode, " +
- " TP_MST_Goods.GOODSSPECIFICATION, " +
- " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
- " TP_PM_ProductionData.CREATETIME, " +
- " TP_PM_ProductionData.KILNcarCODE, " +
- " TP_PM_ProductionData.KILNCODE, " +
- " cu.usercode createusercode, " +
- " cu.username CreateUserName, " +
- " gdd.glazingroom," +
- " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
- " from TP_PM_ProductionData " +
- " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
- " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
- " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
- " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
- " left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
- " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
- " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
- " Where TP_PM_ProductionData.ValueFlag = '1' " +
- // 公坯、干补不算交坯工序的质量。
- " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.IsPublicBody = '0' and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- " and TP_PM_ProductionData.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProductionLineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.OrganizationIDS))
- {
- selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
- parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
- }
- if (se.AccountDateStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
- parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
- }
- if (se.AccountDateEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
- parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
- }
- return selSql;
- }
- /// <summary>
- /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString = "SELECT decode(ts.gid,\n" +
- " 7,\n" +
- " '总计',\n" +
- " 3,\n" +
- " '合计【' || ts.zrprocedurename || '】',\n" +
- " 0,\n" +
- " ts.zrprocedurename,\n" +
- " '--') zrprocedurename\n" +
- " ,decode(ts.gid,\n" +
- " 1,\n" +
- " '小计【' || ts.goodstypename2 || '】',\n" +
- " 0,\n" +
- " ts.goodstypename2,\n" +
- " '--') goodstypename2\n" +
- " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
- " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
- " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
- " ,ts.productionlineid\n" +
- " ,ts.zrprocedureid\n" +
- " ,ts.goodstypecode2\n" +
- " ,ts.zruserid\n" +
- " ,ts.goodsid\n" +
- " ,ts.barcount\n" +
- " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
- " ,t.productionlineid\n" +
- " ,t.productionlinename\n" +
- " ,t.displayno\n" +
- " ,t.zrprocedureid\n" +
- " ,t.zrprocedurename\n" +
- " ,t.goodstypecode2\n" +
- " ,t.goodstypename2\n" +
- " ,t.zruserid\n" +
- " ,t.zrusercode\n" +
- " ,t.goodsid\n" +
- " ,t.goodscode\n" +
- " ,t.GOODSMODEL\n" +
- " ,COUNT(t.barcode) barcount\n" +
- " FROM (SELECT sp.productionlineid\n" +
- " ,pline.productionlinename\n" +
- " ,nvl(zp.displayno, -1) displayno\n" +
- " ,zp.procedureid zrprocedureid\n" +
- " ,zp.procedurename zrprocedurename\n" +
- " ,sr.userid zruserid\n" +
- " ,sr.usercode zrusercode\n" +
- " ,gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,g.goodsid\n" +
- " ,g.goodscode\n" +
- " ,g.GOODSMODEL\n" +
- " ,sp.barcode\n" +
- " FROM tp_pm_scrapproduct sp\n" +
- " LEFT JOIN TP_PM_ResponProcedure rp\n" +
- " ON rp.scrapproductid = sp.scrapproductid\n" +
- " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
- " ,t.ResponProcedureID\n" +
- " ,t.userid\n" +
- " ,t.usercode\n" +
- " FROM TP_PM_ScrapResponsible t) sr\n" +
- " ON sr.scrapproductid = sp.scrapproductid\n" +
- // wangx 2016-06-20
- " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON rp.barcode = gdd.barcode\n" +
- // wangx 2016-06-20 end
- " LEFT JOIN tp_pc_productionline pline\n" +
- " ON pline.productionlineid = sp.productionlineid\n" +
- " LEFT JOIN tp_pc_procedure zp\n" +
- " ON zp.procedureid = rp.procedureid\n" +
- " LEFT JOIN tp_mst_user cu\n" +
- " ON cu.userid = sp.createuserid\n" +
- " LEFT JOIN tp_mst_user au\n" +
- " ON au.userid = sp.auditor\n" +
- " LEFT JOIN tp_mst_goods g\n" +
- " ON g.goodsid = sp.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.accountid = gt.accountid\n" +
- " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " WHERE sp.valueflag = '1'\n" +
- " AND sp.AuditStatus = '1'\n" +
- // 生产线
- //" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=sp.ProductionLineId))" +
- // 完成工序
- //" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=sp.procedureid))" +
- // 责任工序
- //" AND (rp.procedureid is null or exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=rp.procedureid)))" +
- " AND sp.accountid = :AccountID\n" +
- (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
- (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
- " AND sp.ScrapType = '0'\n" +
- " AND (:ProductionLineID IS NULL OR\n" +
- " sp.ProductionLineID = :ProductionLineID)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
- " AND (:GoodsCode IS NULL OR\n" +
- " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:ProcedureIDS IS NULL OR\n" +
- " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
- " AND (:ResponProcedureIDS IS NULL OR\n" +
- " instr(:ResponProcedureIDS,\n" +
- " ',' || rp.ProcedureID || ',') > 0)\n" +
- " AND (:ResponUserIDS IS NULL OR\n" +
- " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
- // 损坯时间
- " AND (:ScrapDateStart IS NULL OR\n" +
- " sp.CreateTime >= :ScrapDateStart)\n" +
- " AND (:ScrapDateEnd IS NULL OR\n" +
- " sp.CreateTime <= :ScrapDateEnd)\n" +
- // 审核时间
- " AND (:AuditDateStart IS NULL OR\n" +
- " sp.AuditDate >= :AuditDateStart)\n" +
- " AND (:AuditDateEnd IS NULL OR\n" +
- " sp.AuditDate <= :AuditDateEnd)\n" +
- // 完成时间
- " AND (:CTimeStart IS NULL OR\n" +
- " sp.CreateTime >= :CTimeStart)\n" +
- " AND (:CTimeEnd IS NULL OR\n" +
- " sp.CreateTime <= :CTimeEnd)\n" +
- // 交坯时间
- " AND (:DTimeStart IS NULL OR\n" +
- " gdd.DeliverTime >= :DTimeStart)\n" +
- " AND (:DTimeEnd IS NULL OR\n" +
- " gdd.DeliverTime <= :DTimeEnd)\n" +
- // 注浆时间
- " AND (:GTimeStart IS NULL OR\n" +
- " gdd.GroutingDate >= :GTimeStart)\n" +
- " AND (:GTimeEnd IS NULL OR\n" +
- " gdd.GroutingDate <= :GTimeEnd)\n" +
- " AND (:CreatUser IS NULL OR\n" +
- " instr(cu.UserCode, :CreatUser) > 0)\n" +
- " AND (:AuditUser IS NULL OR\n" +
- " instr(au.UserCode, :AuditUser) > 0)) t\n" +
- " GROUP BY GROUPING SETS((t.productionlineid, t.productionlinename, t.displayno, t.zrprocedureid, t.zrprocedurename, t.goodstypecode2, t.goodstypename2, t.zruserid, t.zrusercode, t.goodsid, t.goodscode,t.GOODSMODEL),(t.productionlineid, t.productionlinename, t.displayno, t.zrprocedureid, t.zrprocedurename, t.goodstypecode2, t.goodstypename2),(t.productionlineid, t.productionlinename, t.displayno, t.zrprocedureid, t.zrprocedurename),())\n" +
- " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ProcedureIDS))
- {
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ResponProcedureIDS))
- {
- parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
- }
- if (string.IsNullOrEmpty(se.ResponUserIDS))
- {
- parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
- return sqlString;
- }
- /// <summary>
- /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT pline.productionlinename\n" +
- " ,p.procedurename\n" +
- " ,zp.procedurename zrprocedurename\n" +
- " ,sr.usercode zrusercode\n" +
- " ,sr.StaffNames zrStaffNames\n" +
- " ,gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gt.goodstypename\n" +
- " ,g.goodscode\n" +
- " ,g.GOODSMODEL\n" +
- " ,sp.barcode\n" +
- " ,sp.createtime Scrapdate\n" +
- " ,sp.Rreason\n" +
- " ,sp.GroutingUserCode\n" +
- " ,sp.GroutingLineCode\n" +
- " ,sp.GroutingMouldCode\n" +
- " ,sp.GroutingDate\n" +
- " ,sp.GroutingNum\n" +
- " ,cu.usercode CreateUserCode\n" +
- " ,au.usercode AuditorCode\n" +
- " ,sp.auditdate\n" +
- " ,gdd.DeliverTime\n" +
- " ,gdd.ISPUBLICBODY\n" +
- " ,gdd.SPECIALREPAIRFLAG\n" +
- " ,lg.logoname\n" +
- " ,sp.CreateTime\n" +
- " ,sp.Remarks\n" +
- " FROM tp_pm_scrapproduct sp\n" +
- " LEFT JOIN TP_PM_ResponProcedure rp\n" +
- " ON rp.scrapproductid = sp.scrapproductid\n" +
- " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
- " ,t.ResponProcedureID\n" +
- " ,t.userid\n" +
- " ,t.usercode\n" +
- " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
- " FROM TP_PM_ScrapResponsible t\n" +
- " LEFT JOIN TP_HR_Staff s \n" +
- " ON s.StaffID = t.StaffID \n" +
- " ) sr\n" +
- " ON sr.scrapproductid = sp.scrapproductid\n" +
- // wangx 2016-06-20
- " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON sp.barcode = gdd.barcode\n" +
- // wangx 2016-06-20 end
- " LEFT JOIN TP_mst_logo lg\n" +
- " ON lg.logoid = gdd.logoid\n" +
- " LEFT JOIN tp_pc_productionline pline\n" +
- " ON pline.productionlineid = sp.productionlineid\n" +
- " LEFT JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = sp.procedureid\n" +
- " LEFT JOIN tp_pc_procedure zp\n" +
- " ON zp.procedureid = rp.procedureid\n" +
- " LEFT JOIN tp_mst_user cu\n" +
- " ON cu.userid = sp.createuserid\n" +
- " LEFT JOIN tp_mst_user au\n" +
- " ON au.userid = sp.auditor\n" +
- " LEFT JOIN tp_mst_goods g\n" +
- " ON g.goodsid = sp.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.accountid = gt.accountid\n" +
- " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " WHERE sp.valueflag = '1'\n" +
- " AND sp.AuditStatus = '1'\n" +
- " AND sp.accountid = :accountid\n" +
- // 生产线
- //" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=sp.ProductionLineId))" +
- // 完成工序
- //" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=sp.procedureid))" +
- // 责任工序
- //" AND (rp.procedureid is null or exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=rp.procedureid)))" +
- //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
- (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
- (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
- " AND sp.ScrapType = '0'\n" +
- " AND (:ProductionLineID IS NULL OR\n" +
- " sp.ProductionLineID = :ProductionLineID)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
- " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:ProcedureIDS IS NULL OR\n" +
- " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
- " AND (:ResponProcedureIDS IS NULL OR\n" +
- " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
- " AND (:ResponUserIDS IS NULL OR\n" +
- " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
- // 损坯时间
- " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
- " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
- // 审核时间
- " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
- " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
- // 完成时间
- " AND (:CTimeStart IS NULL OR\n" +
- " sp.CreateTime >= :CTimeStart)\n" +
- " AND (:CTimeEnd IS NULL OR\n" +
- " sp.CreateTime <= :CTimeEnd)\n" +
- // 交坯时间
- " AND (:DTimeStart IS NULL OR\n" +
- " gdd.DeliverTime >= :DTimeStart)\n" +
- " AND (:DTimeEnd IS NULL OR\n" +
- " gdd.DeliverTime <= :DTimeEnd)\n" +
- // 注浆时间
- " AND (:GTimeStart IS NULL OR\n" +
- " gdd.GroutingDate >= :GTimeStart)\n" +
- " AND (:GTimeEnd IS NULL OR\n" +
- " gdd.GroutingDate <= :GTimeEnd)\n" +
- " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
- " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
- " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
- " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
- " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
- " AND (:RPF = 1 OR rp.procedureid is null)\n" +
- " AND (:RUF = 1 OR sr.userid is null)\n" +
- " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ProcedureIDS))
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ResponProcedureIDS))
- {
- parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
- }
- if (string.IsNullOrEmpty(se.ResponUserIDS))
- {
- parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
- if (se.ResponProcedureID == "")
- {
- parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
- }
- if (se.ResponUserID == "")
- {
- parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
- }
- return sqlString;
- }
- /// <summary>
- /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- selSql = selSql +
- "SELECT pdata.Procedureid Procedureid " +
- " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
- " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
- " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
- " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
- " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
- " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
- " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
- " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
- " ,OutKilnCount " +
- " FROM (SELECT grouping_id(pdata.Procedureid, " +
- " pdata.Userid ) gid " +
- " ,pdata.Procedureid " +
- " ,pdata.Procedurename " +
- " ,pdata.Userid " +
- " ,pdata.Usercode " +
- " ,pdata.Kilnid " +
- " ,pdata.Kilncode " +
- " ,pdata.goodstypename " +
- " ,pdata.Goodsid " +
- " ,pdata.Goodscode " +
- " ,COUNT(pdata.Barcode) AS OutKilnCount " +
- " FROM (SELECT DISTINCT " +
- //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
- //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
- //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
- //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
- //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
- //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
- //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
- //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
- //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
- "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
- //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
- (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
- "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
- "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
- " from TP_PM_ProductionData " +
- " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
- " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
- " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
- " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
- " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
- " inner join " +
- " ( " +
- " SELECT TP_PM_ProductionData.CreateTime, TP_PM_ProductionData.ProductionDataID, TP_PM_ProductionData.Barcode, TP_PM_ProductionData.Kilncode,TP_PM_ProductionData.KilnID, TP_PM_ProductionData.KilnCarID " +
- " from TP_PM_ProductionData " +
- " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
- if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
- {
- selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
- }
- selSql +=
- " where TP_PM_ProductionData.Accountid=:AccountID " +
- " and TP_PM_ProductionData.Valueflag='1' " +
- // 数据重复 modify by chenxy begin
- // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
- // 数据重复 modify by chenxy end
- " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
- //if (se.CreateTimeStart.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
- // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- //}
- //if (se.CreateTimeEnd.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
- // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- //}
- if (se.OutTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
- parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
- }
- if (se.OutTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
- parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.GTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
- }
- if (se.GTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.DTimeStart.HasValue)
- {
- selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
- }
- if (se.DTimeEnd.HasValue)
- {
- selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.Specialrepairflag)
- {
- selSql = selSql +
- " ) temp " +
- " on TP_PM_ProductionData.Barcode=temp.barcode " +
- " " +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
- " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
- " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
- " FROM TP_PM_ProductionData pp\n" +
- " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
- " AND pp.createtime < temp.createtime\n" +
- " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
- " where " +
- // 公坯、干补不算交坯工序的质量。
- // " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.IsPublicBody = '0' and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- // modify wangx 2015-12-3
- " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- " and TP_PM_ProductionData.Valueflag='1' " +
- " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
- parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- }
- else
- {
- selSql = selSql +
- " ) temp " +
- " on TP_PM_ProductionData.Barcode=temp.barcode " +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
- " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
- " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
- " FROM TP_PM_ProductionData pp\n" +
- " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
- " AND pp.createtime < temp.createtime\n" +
- " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
- " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
- " and TP_PM_ProductionData.Valueflag='1' ";
- parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- //else
- //{
- // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
- //}
- selSql = selSql + " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=TP_PM_ProductionData.ProductionLineId))";
- selSql = selSql + " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=TP_PM_ProductionData.procedureid))";
- parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
- if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
- parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql = selSql + " AND temp.KilnID=:KilnID ";
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
- {
- selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
- " GROUP BY GROUPING SETS((pdata.Procedureid, pdata.Procedurename, pdata.Userid, pdata.Usercode, pdata.Kilnid, pdata.Kilncode, pdata.goodstypename, pdata.Goodsid, pdata.Goodscode),(pdata.Procedureid, pdata.Procedurename),()) " +
- ") pdata"
- ;
- return selSql;
- }
- /// <summary>
- /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
- selSql = selSql +
- "select distinct " +
- "TP_PM_ProductionData.Barcode, " +
- //"TP_PM_ProductionData.UserCode, " +
- (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
- "pcp.ProcedureName, " +
- "tp_mst_goodstype.goodstypename, " +
- "TP_PM_ProductionData.Goodscode, " +
- "TP_PM_ProductionData.GroutingUserCode, " +
- "TP_PM_ProductionData.GroutingLineCode, " +
- "TP_PM_ProductionData.GroutingMouldCode, " +
- // 多次干补 重复条码
- //"TP_PM_ProductionData.Createtime OverDate, " +
- "temp.Kilnid, " +
- "temp.Kilncode, " +
- "temp.Kilncarcode, " +
- "temp.Createtime, " +
- "temp.DELIVERTIME DDate, " +
- "temp.GROUTINGDATE GDate, " +
- "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
- "from TP_PM_ProductionData " +
- "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
- "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
- "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
- "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
- " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
- "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
- "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
- "inner join " +
- "( " +
- " select " +
- " TP_PM_ProductionData.Barcode, " +
- " TP_PM_ProductionData.Kilncode, " +
- " TP_PM_ProductionData.Kilncarcode, " +
- " TP_PM_ProductionData.Createtime, " +
- " TP_PM_ProductionData.KilnID " +
- " ,gdd.DELIVERTIME " +
- " ,TP_PM_ProductionData.GROUTINGDATE " +
- " ,TP_PM_ProductionData.KilnCarID " +
- " from TP_PM_ProductionData " +
- " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
- //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
- //{
- // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
- //}
- " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
- // selSql +=
- " where TP_PM_ProductionData.Accountid=:AccountID " +
- " and TP_PM_ProductionData.Valueflag='1' " +
- // 数据重复 modify by chenxy begin
- " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
- // 数据重复 modify by chenxy end
- " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
- if (se.OutTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
- parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
- }
- if (se.OutTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
- parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.GTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
- }
- if (se.GTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.DTimeStart.HasValue)
- {
- selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
- }
- if (se.DTimeEnd.HasValue)
- {
- selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
- }
- if (se.Specialrepairflag)
- {
- selSql = selSql +
- ") temp " +
- "on TP_PM_ProductionData.Barcode=temp.barcode " +
- " " +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
- " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
- " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
- " FROM TP_PM_ProductionData pp\n" +
- " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
- " AND pp.createtime < temp.createtime\n" +
- " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
- "where " + // 公坯、干补不算交坯工序的质量。
- //" and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.IsPublicBody = '0' and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- // modify wangx 2015-12-3
- " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
- " and TP_PM_ProductionData.Valueflag='1' " +
- " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
- parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- }
- else
- {
- selSql = selSql +
- ") temp " +
- "on TP_PM_ProductionData.Barcode=temp.barcode " +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
- " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
- " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
- " FROM TP_PM_ProductionData pp\n" +
- " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
- " AND pp.createtime < temp.createtime\n" +
- " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
- // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
- " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
- " and TP_PM_ProductionData.Valueflag='1' ";
- parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (se.ProductionLineID.HasValue)
- {
- selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
- {
- selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- if (se.KilnID.HasValue)
- {
- selSql = selSql + " AND temp.KilnID=:KilnID ";
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
- {
- selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
- (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
- " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
- selSql = "select " +
- "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
- "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
- "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
- "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
- "Kilncarcode, " +
- "Remarks, " +
- "KilnCarCount " +
- " from " +
- " ( " +
- " select " +
- " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
- " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
- " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
- " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
- " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
- " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
- " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
- " from " +
- " ( " +
- " select " +
- " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
- " TP_PM_KilnCarData.Modeltype, " +
- " TP_PM_KilnCarData.Kilncarid, " +
- " TP_PM_KilnCarData.Kilnid, " +
- " TP_PM_KilnCarData.Userid, " +
- " TP_PM_KilnCarData.Remarks, " +
- " TP_PM_KilnCarData.Accountid, " +
- " TP_PM_KilnCarData.Usercode " +
- " from TP_PM_KilnCarData " +
- " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
- " where TP_PM_KilnCarData.Accountid=:AccountID " +
- " and TP_PM_KilnCarData.Valueflag=1 " +
- " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
- if (se.KilnID.HasValue)
- {
- selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- //if (se.KilnCarID.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
- // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
- //}
- if (!string.IsNullOrEmpty(se.KilnCarCode))
- {
- selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
- parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
- }
- if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
- {
- selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- else
- {
- if (se.KilnCarNumBegin.HasValue)
- {
- selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- }
- if (se.KilnCarNumEnd.HasValue)
- {
- selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- " ) TP_PM_KilnCarData " +
- "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
- "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
- "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
- "where 1=1";
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- selSql = selSql + "group by rollup( " +
- " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
- " TP_MST_Kiln.Kilncode, " +
- " TP_PM_KilnCarData.Usercode, " +
- " TP_PM_KilnCarData.Createtime, " +
- " TP_PM_KilnCarData.Remarks, " +
- " TP_MST_KilnCar.Kilncarcode " +
- " ) " +
- " ) temp " +
- " where (Kilncarcode !='--' ) " +
- " or " +
- " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
- " or (Remarks='--' and Proceduremodeltypename='总计') " +
- " or (Remarks='--' and createtime='小计' and kilncode!='--')";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
- selSql = selSql +
- "SELECT " +
- "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
- "decode(createtime,'小计','--',kilncode) kilncode, " +
- "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
- "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
- "decode(goodscode,'--','--',createtime) createtime, " +
- "GOODSTYPENAME, " +
- "Goodscode, " +
- "GOODSSPECIFICATION, " +
- "GoodsCount " +
- "from " +
- "( " +
- " SELECT " +
- " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
- " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
- " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
- " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
- " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
- " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
- " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
- " count(TP_MST_Goods.Goodscode) as GoodsCount " +
- " from " +
- " ( " +
- " SELECT TP_PM_ProductionData.Modeltype, " +
- " TP_PM_ProductionData.Goodsid, " +
- " TP_PM_ProductionData.KilnCarID, " +
- " TP_PM_ProductionData.Kilncode, " +
- //" TP_PM_ProductionData.Usercode, " +
- " kcd.Usercode, " +
- " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
- " from TP_PM_ProductionData " +
- " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
- " where " +
- " TP_PM_ProductionData.Accountid=:AccountID " +
- " and TP_PM_ProductionData.Valueflag=1 " +
- " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
- if (se.KilnID.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- //if (se.KilnCarID.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
- // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
- //}
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
- selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
- selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
- selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- " ) TP_PM_ProductionData " +
- " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
- " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
- " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
- " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
- " where 1=1 ";
- if (!string.IsNullOrEmpty(se.KilnCarCode))
- {
- selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
- parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
- }
- if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
- {
- selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- else
- {
- if (se.KilnCarNumBegin.HasValue)
- {
- selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- }
- if (se.KilnCarNumEnd.HasValue)
- {
- selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
- parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- selSql = selSql +
- " group by rollup( " +
- " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
- " TP_PM_ProductionData.Kilncode, " +
- " TP_PM_ProductionData.Usercode, " +
- " TP_MST_KilnCar.Kilncarcode, " +
- " TP_PM_ProductionData.CreateTime, " +
- " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
- " TP_MST_Goods.GOODSSPECIFICATION, " +
- " TP_MST_Goods.Goodscode " +
- " ) " +
- ") temp " +
- "where 1=1 and " +
- " (Goodscode !='--' ) or " +
- " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
- " (Goodscode='--' and Proceduremodeltypename='总计') or " +
- " (Goodscode='--' and createtime='小计' and usercode!='--')";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
- selSql = selSql +
- "select " +
- "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
- "decode(createtime,'小计','--',kilncode) kilncode, " +
- "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
- "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
- "decode(goodscode,'--','--',createtime) createtime, " +
- "GOODSTYPENAME, " +
- "Goodscode, " +
- "GOODSSPECIFICATION, " +
- "Barcode, " +
- "BarcodeCount, " +
- "LogoCodeName " +
- "from " +
- " ( " +
- " select " +
- " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
- " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
- " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
- " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
- " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
- " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
- " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
- " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
- " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
- " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
- " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
- " from " +
- " ( " +
- " select TP_PM_ProductionData.logoid," +
- " TP_PM_ProductionData.Modeltype, " +
- " TP_PM_ProductionData.Goodsid, " +
- " TP_PM_ProductionData.KilnCarID, " +
- " TP_PM_ProductionData.Kilncode, " +
- " TP_PM_ProductionData.Barcode, " +
- " TP_PM_ProductionData.Usercode, " +
- " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
- " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
- " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
- " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
- " where " +
- " TP_PM_ProductionData.Accountid=:AccountID " +
- " and TP_PM_ProductionData.Valueflag=1 " +
- " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
- if (se.KilnID.HasValue)
- {
- selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
- parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
- }
- //if (se.KilnCarID.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
- // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
- //}
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
- parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- " ) TP_PM_ProductionData " +
- " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
- " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
- " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
- " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
- " where 1=1";
- if (!string.IsNullOrEmpty(se.KilnCarCode))
- {
- selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
- parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
- }
- if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
- {
- selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- else
- {
- if (se.KilnCarNumBegin.HasValue)
- {
- selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
- parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
- }
- if (se.KilnCarNumEnd.HasValue)
- {
- selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
- parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
- }
- }
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
- parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- selSql = selSql +
- " group by rollup( " +
- " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
- " TP_PM_ProductionData.Kilncode, " +
- " TP_PM_ProductionData.Usercode, " +
- " TP_MST_KilnCar.Kilncarcode, " +
- " TP_PM_ProductionData.CreateTime, " +
- " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
- " TP_MST_Goods.Goodscode, " +
- " TP_MST_Goods.GOODSSPECIFICATION, " +
- " TP_PM_ProductionData.Barcode, " +
- " TP_PM_ProductionData.LogoCodeName " +
- " ) " +
- " ) temp " +
- "where 1=1 and " +
- "(Barcode !='--' and LogoCodeName!='--') or " +
- "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
- "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
- "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
- return selSql;
- }
- #region 工序交接数量汇总表
- /// <summary>
- /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT p.procedureid\n" +
- " ,decode(gid,\n" +
- " 7,\n" +
- " '总计',\n" +
- " 3,\n" +
- " '合计【' || p.procedurename || '】',\n" +
- " 1,\n" +
- " '--',\n" +
- " p.procedurename) procedurename\n" +
- " ,decode(gid,\n" +
- " 7,\n" +
- " '--',\n" +
- " 3,\n" +
- " '--',\n" +
- " 1,\n" +
- " '小计【' || p.goodstypename2 || '】',\n" +
- " p.goodstypename2) goodstypename2\n" +
- " ,p.goodstypecode2 \n" +
- " ,decode(gid, 0, p.userid, '--') userid\n" +
- " ,decode(gid, 0, p.usercode, '--') usercode\n" +
- " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
- " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
- " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
- " ,p.overcount\n" +
- " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
- " ,pdata.productionlineid\n" +
- " ,pdata.procedureid\n" +
- " ,to_char(pdata.procedurename) procedurename\n" +
- " ,to_char(pdata.userid) userid\n" +
- " ,pdata.usercode\n" +
- " ,to_char(pdata.goodsid) goodsid\n" +
- " ,pdata.goodscode\n" +
- " ,pdata.goodstypename\n" +
- " ,pdata.goodstypecode2\n" +
- " ,pdata.goodstypename2\n" +
- " ,COUNT(pdata.barcode) overcount\n" +
- " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
- " ,pd.productionlineid\n" +
- " ,pd.procedureid\n" +
- " ,pcp.procedurename\n" +
- (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
- //" ,pd.userid\n" +
- //" ,pd.usercode\n" +
- " ,t_over.goodsid\n" +
- " ,t_over.goodscode\n" +
- " ,t_over.goodstypename\n" +
- " ,t_over.goodstypecode2\n" +
- " ,t_over.goodstypename2\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_pc_procedure pcp\n" +
- " ON pcp.procedureid = pd.procedureid\n" +
- " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
- " ,pd.productiondataid\n" +
- " ,goods.goodsid\n" +
- " ,goods.goodscode\n" +
- " ,gt.goodstypename\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gt2.goodstypecode goodstypecode2\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON goods.goodstypeid = gt.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " --LEFT JOIN tp_pc_procedure pcp\n" +
- " -- ON pcp.procedureid = pd.procedureid\n" +
- ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
- " WHERE pd.valueflag = '1'\n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineId))" +
- " AND pd.accountid = :AccountID\n";
- // 生产线
- if (se.ProductionLineID.HasValue)
- {
- sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
- {
- sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 交接工序
- if (!string.IsNullOrEmpty(se.OverProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
- parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(se.OverUserIDS))
- {
- sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
- parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
- }
- // 交接时间
- if (se.OverTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
- parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.OverTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
- parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
- }
- // 注浆时间
- if (se.GTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
- }
- if (se.GTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯时间
- if (se.DTimeStart.HasValue)
- {
- sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
- }
- if (se.DTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
- }
- sqlString = sqlString +
- " ) t_over\n" +
- " ON pd.barcode = t_over.barcode\n" +
- // 交接工序在生产工序后
- " AND pd.productiondataid <= t_over.productiondataid\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND pd.accountid = :AccountID\n" +
- (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))";
- // 生产工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- // 生产工号
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
- parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
- }
- // 生产时间
- if (se.PTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
- parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
- }
- if (se.PTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
- parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
- }
- sqlString = sqlString +
- "\n ) pdata\n" +
- " GROUP BY GROUPING SETS((pdata.productionlineid, pdata.procedureid, pdata.procedurename, pdata.displayno, pdata.userid, pdata.usercode, pdata.goodsid, pdata.goodscode, pdata.goodstypename,pdata.goodstypecode2, pdata.goodstypename2),(pdata.productionlineid, pdata.procedureid, pdata.procedurename, pdata.displayno,pdata.goodstypecode2, pdata.goodstypename2),(pdata.productionlineid, pdata.procedureid, pdata.procedurename, pdata.displayno),())\n" +
- " ORDER BY pdata.displayno\n" +
- " ,pdata.goodstypename2\n" +
- " ,pdata.usercode\n" +
- " ,pdata.goodstypename\n" +
- " ,pdata.goodscode) p";
- return sqlString;
- }
- /// <summary>
- /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT distinct pcp.procedurename,pcp.displayno\n" +
- (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
- //" ,pd.usercode\n" +
- " ,t_over.barcode\n" +
- " ,t_over.goodscode\n" +
- " ,t_over.goodstypename\n" +
- " ,t_over.goodstypename2\n" +
- //" ,pd.createtime ptime\n" +
- //" ,t_over.overprocedurename\n" +
- //" ,t_over.overusercode\n" +
- //" ,t_over.overtime\n" +
- " ,t_over.groutingusercode\n" +
- " ,pd.groutinglinecode\n" +
- " ,pd.groutingmouldcode\n" +
- " ,t_over.groutingdate Gdate\n" +
- " ,t_over.DELIVERTIME Ddate\n" +
- " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_pc_procedure pcp\n" +
- " ON pcp.procedureid = pd.procedureid\n" +
- " LEFT JOIN TP_MST_logo logo\n" +
- " ON logo.logoid = pd.logoid\n" +
- " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
- " ,pd.productiondataid\n" +
- " ,goods.goodsid\n" +
- " ,goods.goodscode\n" +
- " ,gt.goodstypename\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- //" ,pcp.procedurename overprocedurename\n" +
- //" ,pd.usercode overusercode\n" +
- //" ,pd.createtime overtime\n" +
- " ,pd.groutingusercode\n" +
- " ,pd.groutingdate\n" +
- " ,gdd.DELIVERTIME\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON goods.goodstypeid = gt.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " LEFT JOIN tp_pc_procedure pcp\n" +
- " ON pcp.procedureid = pd.procedureid\n" +
- " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
- " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineId))" +
- " AND pd.accountid = :AccountID\n";
- // 生产线
- if (se.ProductionLineID.HasValue)
- {
- sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
- {
- sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsID))
- {
- sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
- parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 交接工序
- if (!string.IsNullOrEmpty(se.OverProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
- parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(se.OverUserIDS))
- {
- sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
- parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
- }
- // 交接时间
- if (se.OverTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
- parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.OverTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
- parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
- }
- // 注浆时间
- if (se.GTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
- parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
- }
- if (se.GTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
- parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯时间
- if (se.DTimeStart.HasValue)
- {
- sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
- parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
- }
- if (se.DTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
- parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
- }
- sqlString = sqlString +
- " ) t_over\n" +
- " ON pd.barcode = t_over.barcode\n" +
- // 交接工序在生产工序后
- " AND pd.productiondataid <= t_over.productiondataid\n" +
- " WHERE pd.valueflag = '1'\n" +
- " AND pd.accountid = :AccountID\n" +
- (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))";
- // 生产工序
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- // 生产工号
- if (!string.IsNullOrEmpty(se.UserIDS))
- {
- sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
- parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
- }
- // 生产时间
- if (se.PTimeStart.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
- parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
- }
- if (se.PTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
- parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
- }
- sqlString = sqlString +
- "\n ORDER BY pcp.displayno\n" +
- " ,t_over.goodstypename2\n" +
- (se.DisPUserCode ? " ,pd.usercode\n" : "") +
- " ,t_over.goodstypename\n" +
- " ,t_over.goodscode\n";
- return sqlString;
- }
- #endregion
- /// <summary>
- /// 取得RPT030108画面(成型信息汇总表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sqlString = "SELECT decode(g.gid,\n" +
- " 7,\n" +
- " '总计',\n" +
- " 3,\n" +
- " '合计【' || g.goodstypename2 || '】',\n" +
- " 0,\n" +
- " g.goodstypename2,\n" +
- " '--') goodstypename2\n" +
- " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
- " ,decode(g.gid,\n" +
- " 1,\n" +
- " '小计【' || g.goodscode || '】',\n" +
- " 0,\n" +
- " g.goodscode,\n" +
- " '--') goodscode\n" +
- " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
- " ,g.groutingcount\n" +
- " ,g.barcodecount\n" +
- " ,g.scrapcount\n" +
- " ,g.barscrapcount\n" +
- " ,g.delivercount\n" +
- " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
- " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
- " ,gdd.goodstypename2\n" +
- " ,gdd.goodstypename\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.usercode\n" +
- " ,SUM(groutingcount) groutingcount\n" +
- " ,SUM(barcodecount) barcodecount\n" +
- " ,SUM(scrapcount) scrapcount\n" +
- " ,SUM(barscrapcount) barscrapcount\n" +
- " ,SUM(delivercount) delivercount\n" +
- " FROM (SELECT gt2.goodstypename goodstypename2\n" +
- " ,gdd.usercode\n" +
- " ,goods.goodscode\n" +
- " ,gt.goodstypename\n" +
- " , CASE\n" +
- " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
- " gdd.groutingdate <= :gdataend THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END groutingcount\n" +
- " , CASE\n" +
- " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
- " gdd.groutingdate <= :gdataend AND\n" +
- " gdd.barcode IS NOT NULL THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END barcodecount\n" +
- " , CASE\n" +
- " WHEN gdd.scraptime >= :sdatabegin AND\n" +
- " gdd.scraptime <= :sdataend AND\n" +
- " gdd.scrapflag = '1' THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END scrapcount\n" +
- " , CASE\n" +
- " WHEN gdd.scraptime >= :sdatabegin AND\n" +
- " gdd.scraptime <= :sdataend AND\n" +
- " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END barscrapcount\n" +
- " , CASE\n" +
- " WHEN gdd.delivertime >= :ddatabegin AND\n" +
- " gdd.delivertime <= :ddataend AND\n" +
- " gdd.deliverflag = '1' THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END delivercount\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = gdd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = goods.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " WHERE gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.accountid = :accountid\n" +
- " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
- " gdd.groutingdate <= :gdataend) OR\n" +
- " (gdd.scraptime >= :sdatabegin AND\n" +
- " gdd.scraptime <= :sdataend) OR\n" +
- " (gdd.delivertime >= :ddatabegin AND\n" +
- " gdd.delivertime <= :ddataend))\n" +
- " AND (:usercode IS NULL OR\n" +
- " instr(gdd.usercode, :usercode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR\n" +
- " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:goodstypecode IS NULL OR\n" +
- " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- " ORDER BY gt2.goodstypename\n" +
- " ,gt.goodstypename\n" +
- " ,goods.goodscode\n" +
- " ,gdd.usercode) gdd\n" +
- " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
- " ORDER BY gdd.goodstypename2\n" +
- " ,gdd.goodstypename\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.usercode) g";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- #region 撤销产品汇总表
- /// <summary>
- /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT decode(p.gid,\n" +
- " 7,\n" +
- " '总计',\n" +
- " 3,\n" +
- " '合计【' || p.procedurename || '】',\n" +
- " 0,\n" +
- " p.procedurename,\n" +
- " '--') procedurename\n" +
- " ,decode(p.gid,\n" +
- " 1,\n" +
- " '小计【' || p.goodstypename2 || '】',\n" +
- " 0,\n" +
- " p.goodstypename2,\n" +
- " '--') goodstypename2\n" +
- " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
- " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
- " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
- " ,p.codecount\n" +
- " ,p.productionlineid\n" +
- " ,p.procedureid\n" +
- " ,p.goodstypecode2\n" +
- " ,p.goodsid\n" +
- " ,p.userid\n" +
- " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
- " ,pd.productionlineid\n" +
- " ,pd.procedureid\n" +
- " ,p.procedurename\n" +
- " ,p.displayno\n" +
- " ,gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gt.goodstypecode\n" +
- " ,gt.goodstypename\n" +
- " ,goods.goodsid\n" +
- " ,goods.goodscode\n" +
- " ,pd.userid\n" +
- " ,pd.usercode\n" +
- " ,COUNT(*) codecount\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = pd.procedureid\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = goods.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " WHERE pd.valueflag = '0'\n" +
- " AND pd.accountid = :accountid\n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineId))" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))" +
- " AND (:productionlineid IS NULL OR\n" +
- " pd.productionlineid = :productionlineid)\n" +
- " AND (:procedureids IS NULL OR\n" +
- " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
- " AND (:goodstypecode IS NULL OR\n" +
- " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- " AND (:goodscode IS NULL OR\n" +
- " instr(goods.goodscode, :goodscode) > 0)\n" +
- " AND (:PUserIDS IS NULL OR\n" +
- " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
- " AND (:backusercode IS NULL OR\n" +
- " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
- " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
- " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
- " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
- " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
- " GROUP BY GROUPING SETS((pd.productionlineid, pd.procedureid, p.procedurename, p.displayno, gt2.goodstypecode, gt2.goodstypename, gt.goodstypecode, gt.goodstypename, goods.goodsid, goods.goodscode, pd.userid, pd.usercode),(pd.productionlineid, pd.procedureid, p.procedurename, p.displayno, gt2.goodstypecode, gt2.goodstypename),(pd.productionlineid, pd.procedureid, p.procedurename, p.displayno),())\n" +
- " ORDER BY p.displayno\n" +
- " ,gt2.goodstypecode\n" +
- " ,gt.goodstypecode\n" +
- " ,goods.goodscode\n" +
- " ,pd.usercode) p";
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ProcedureIDS))
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- if (string.IsNullOrEmpty(se.UserIDS))
- {
- parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
- return sqlString;
- }
- /// <summary>
- /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString =
- "SELECT p.procedurename\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gt.goodstypename\n" +
- " ,goods.goodscode\n" +
- " ,pd.barcode\n" +
- " ,pd.usercode\n" +
- " ,pd.createtime ptime\n" +
- " ,pd.backoutusercode busercode\n" +
- " ,pd.backouttime btime\n" +
- " ,pd.groutingusercode\n" +
- " ,pd.groutinglinecode\n" +
- " ,pd.groutingmouldcode\n" +
- " ,pd.groutingdate GDate\n" +
- " FROM tp_pm_productiondata pd\n" +
- " LEFT JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = pd.procedureid\n" +
- " LEFT JOIN tp_mst_goods goods\n" +
- " ON goods.goodsid = pd.goodsid\n" +
- " LEFT JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = goods.goodstypeid\n" +
- " LEFT JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " WHERE pd.valueflag = '0'\n" +
- " AND pd.accountid = :accountid\n" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineId))" +
- " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))" +
- " AND (:productionlineid IS NULL OR\n" +
- " pd.productionlineid = :productionlineid)\n" +
- " AND (:procedureids IS NULL OR\n" +
- " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
- " AND (:goodstypecode IS NULL OR\n" +
- " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
- " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
- " AND (:PUserIDS IS NULL OR\n" +
- " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
- " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
- " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
- " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
- " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
- " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
- " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
- " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
- " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
- " ORDER BY p.displayno\n" +
- " ,gt2.goodstypename\n" +
- " ,gt.goodstypename\n" +
- " ,goods.goodscode\n" +
- " ,pd.usercode\n" +
- " ,pd.barcode\n" +
- " ,pd.backoutusercode\n" +
- " ,pd.backouttime";
- parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
- if (string.IsNullOrEmpty(se.ProcedureIDS))
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
- }
- if (string.IsNullOrEmpty(se.UserIDS))
- {
- parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
- }
- else
- {
- parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
- }
- parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
- return sqlString;
- }
- #endregion
- /// <summary>
- /// 工序收发存汇总表(初始化数据)
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- OracleParameter[] parameters = new OracleParameter[]
- {
- new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- };
- string sqlString =
- "SELECT t.ptid, t.name\n" +
- " FROM tp_mst_rpt_transfer t\n" +
- " WHERE t.AccountID = :AccountID\n" +
- " AND t.valueflag = '1'\n" +
- " ORDER BY t.displayno desc";
- DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
- ServiceResultEntity sre = new ServiceResultEntity();
- //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- //{
- // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- // return sre;
- //}
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 工序收发存汇总表
- /// </summary>
- /// <param name="user"></param>
- /// <param name="se"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] parameters = new OracleParameter[]
- {
- new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
- new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
- //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
- new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
- new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
- new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
- new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
- new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- //StringBuilder intdids = new StringBuilder();
- //foreach (DataRow row in data.Tables[0].Rows)
- //{
- // if (intdids.Length > 0)
- // {
- // intdids.Append(", ");
- // }
- // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
- //}
- //string sqlString =
- // "WITH ttm AS\n" +
- // " (SELECT *\n" +
- // " FROM TMP_RPT_TECDEP_D\n" +
- // " pivot(SUM(m)\n" +
- // " FOR intdid IN(" + intdids + ")))\n" +
- // "SELECT t.goodscode as c_goodscode, t.tecdepname as c_tecdepname, t.a C_A, t.b C_B, t.c C_C, t.d C_D, t.e C_E, t.f C_F, m.*\n" +
- // " FROM TMP_RPT_TECDEP_T t\n" +
- // " LEFT JOIN ttm m\n" +
- // " ON m.goodsid = t.goodsid\n" +
- // " AND m.outtdid = t.tecdepid\n" +
- // " ORDER BY t.goodscode, t.displayno";
- //data = conn.GetSqlResultToDs(sqlString);
- //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- //{
- // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- // return sre;
- //}
- conn.Commit();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- #endregion 汇总报表
- #region 公共函数
- /// <summary>
- /// 取得报表的查询数据源统计工序数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
- new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
- new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得报表数据源数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string selSql = " select "
- + " TP_MST_RptProcedure.Rptprocedureid,"
- + " TP_MST_RptProcedure.Rptprocedurecode,"
- + " TP_MST_RptProcedure.Rptprocedurename,"
- + " TP_MST_RptProcedure.Rptproceduretype,"
- + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
- + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
- + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
- + " TP_MST_RptProcedure.Optimestamp "
- + " from TP_MST_RptProcedure "
- + " where TP_MST_RptProcedure.ValueFlag=1 "
- + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得窑炉数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="pValue">使用标识条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string selSql = string.Empty;
- List<OracleParameter> parameters = new List<OracleParameter>();
- //根据帐套查询数据
- if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
- {
- selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
- + "from TP_MST_Kiln where AccountID = :AccountID";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- }
- //根据帐套和标识查询数据
- else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
- {
- selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
- + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
- parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- }
- DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得窑车数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string selSql = String.Empty;
- List<OracleParameter> parameters = new List<OracleParameter>();
- //获取窑车管理的数据
- selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
- + "from TP_MST_KilnCar where AccountID = :AccountID";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得生产线所有的工序
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string selSql = "select "
- + " tp_pc_procedure.procedureid, "
- + " tp_pc_procedure.Procedurename "
- + " from "
- + " ( "
- + " select TP_PM_ProductionData.Procedureid "
- + " from TP_PM_ProductionData "
- + " where TP_PM_ProductionData.accountid = :accountID "
- + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
- + " group by TP_PM_ProductionData.Procedureid "
- + " order by TP_PM_ProductionData.Procedureid "
- + " )temp left join tp_pc_procedure "
- + " on tp_pc_procedure.procedureid=temp.procedureid ";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
- DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得数据字典数据
- /// </summary>
- /// <param name="Pvalue">显示停用标识</param>
- /// <param name="dictionaryType">字典类别</param>
- /// <param name="user">登录用户信息</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string selSql = String.Empty;
- List<OracleParameter> parameters = new List<OracleParameter>();
- //根据帐套获得数据字典管理的数据
- if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
- {
- selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
- + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
- parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- }
- //根据帐套,标识获得数据字典管理的数据
- else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
- {
- selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
- + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
- parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
- }
- DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- #endregion 公共函数
- #endregion 统一使用Se模式rviceResultEntity类
- /// <summary>
- /// 获取注浆次数报表
- /// </summary>
- /// <param name="groutingLineEntity"></param>
- /// <param name="user"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
- {
- IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- con.Open();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
- groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
- new OracleParameter("FloorNo",OracleDbType.NVarchar2,
- groutingLineEntity.FLOORNO,ParameterDirection.Input),
- new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
- groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
- new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
- groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
- new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
- groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
- new OracleParameter("GMouldTypeID",OracleDbType.Int32,
- groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
- new OracleParameter("remarks",OracleDbType.NVarchar2,
- groutingLineEntity.REMARKS,ParameterDirection.Input),
- new OracleParameter("AccountID",OracleDbType.Int32,
- user.AccountID,ParameterDirection.Input),
- new OracleParameter("UserId",OracleDbType.Int32,
- user.UserID,ParameterDirection.Input),
- new OracleParameter("PurviewType",OracleDbType.Int32,
- groutingLineEntity.Purview,ParameterDirection.Input),
- new OracleParameter("rs_result",OracleDbType.RefCursor,
- ParameterDirection.Output),
- new OracleParameter("UserCode",OracleDbType.NVarchar2,
- groutingLineEntity.USERCODE,ParameterDirection.Input),
- };
- //调用获取符合条件的成型线信息
- DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (ds == null || ds.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- //DataTable dt=ds.Tables[0];
- sre.Data.Tables.Add(ds.Tables[0].Copy());
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (con.ConnState == ConnectionState.Open)
- {
- con.Close();
- }
- }
- }
- #region 在产产品汇总表
- /// <summary>
- /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
- {
- string selSql = "";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- selSql = selSql +
- //"select " +
- //" ProcedureID," +
- //" procedurecode, " +
- //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
- //" productionlineid, " +
- //" productionlinecode, " +
- //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
- //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
- //" subGoodsTypecode, " +
- //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
- //" Goodstypename, " +
- //" InCount " +
- "select " +
- " ProcedureID," +
- " procedurecode, " +
- " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
- " productionlineid, " +
- " productionlinecode, " +
- " productionlinename, " +
- " decode(productionlinename, '--', '--', Usercode) Usercode, " +
- " decode(productionlinename, '--', null, UserID) UserID, " +
- " subGoodsTypecode, " +
- " Goodsid," +
- " Goodscode, " +
- " Goodstypename, " +
- " InCount from (" +
- "select " +
- " ProcedureID," +
- " procedurecode, " +
- " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
- " productionlineid, " +
- " productionlinecode, " +
- " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
- " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
- " decode(ProcedureID,'总计',null,Userid) Userid, " +
- " subGoodsTypecode, " +
- " Goodsid," +
- " Goodscode, " +
- " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
- " InCount " +
- "from " +
- "(" +
- " select " +
- " ProcedureID, " +
- " procedurecode, " +
- " procedurename, " +
- " productionlineid, " +
- " productionlinecode, " +
- " productionlinename, " +
- " decode(procedurecode,'--','合计',Usercode) Usercode, " +
- " decode(procedurecode,'--',null,Userid) Userid, " +
- " subGoodsTypecode," +
- " Goodsid," +
- " Goodscode," +
- " Goodstypename, " +
- " InCount " +
- " from ( select " +
- " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
- " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
- " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
- " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
- " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
- " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
- " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
- " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
- " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
- " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
- " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
- " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
- " count(barcode) as InCount " +
- " from tp_pm_inproduction " +
- " left join tp_pc_procedure" +
- " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
- " left join TP_MST_User on tp_pm_inproduction.userid=TP_MST_User.Userid left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
- " Where 1=1 " +
- " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
- selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- selSql = selSql +
- "group by " +
- " rollup(tp_pc_procedure.ProcedureID, " +
- " tp_pc_procedure.procedurecode, " +
- " tp_pc_procedure.procedurename, " +
- " tp_pm_inproduction.productionlineid, " +
- " tp_pm_inproduction.productionlinecode, " +
- " tp_pm_inproduction.productionlinename, " +
- " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
- " TP_MST_User.Usercode," +
- " TP_MST_Goods.Goodscode, " +
- " TP_MST_User.UserID," +
- " TP_MST_Goods.GoodsID, " +
- " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
- "where 1=1 " +
- "and (Goodstypename!='--')" +
- "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
- "or (Goodstypename='--' and UserCode='合计') " +
- "or (Goodstypename='--' and UserCode='总计') )";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (se != null)
- {
- if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
- {
- //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
- sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
- parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.ProcedureIDS))
- {
- sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 总单点击查询用
- if (se.GoodsID.HasValue)
- {
- sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
- parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
- }
- if (se.UserID.HasValue)
- {
- sql.Append(" AND A.userid = :userid ");
- parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
- }
- }
- sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
- {
- string selSql =
- "SELECT " +
- " TP_PM_InProduction.BarCode, " +
- " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
- " TP_PM_InProduction.GoodsName, " +
- " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
- " TP_PM_InProduction.ProductionLineID, " +
- " TP_PM_InProduction.ProductionLineCode, " +
- " TP_PM_InProduction.ProductionLineName, " +
- " TP_PM_InProduction.ModelType, " +
- " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
- //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
- //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
- " TP_PM_InProduction.IsPublicBody, " +
- " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
- " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
- " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
- " TP_PM_InProduction.GroutingDailyID, " +
- " TP_PM_InProduction.GroutingDailyDetailID, " +
- " TP_PM_InProduction.GroutingDate, " +
- " TP_PM_InProduction.GroutingLineID, " +
- " TP_PM_InProduction.GroutingLineCode, " +
- " TP_PM_InProduction.GroutingLineName, " +
- " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
- " D.ProcedureName as CompleteProcedureName, " +
- " TP_PM_InProduction.GMouldTypeID, " +
- " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
- " TP_PM_InProduction.GroutingLineDetailID, " +
- " TP_PM_InProduction.GroutingMouldCode, " +
- " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
- " TP_PM_InProduction.GROUTINGUSERCODE, " +
- " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
- " TP_PM_InProduction.Remarks, " +
- " TP_PM_GroutingDailyDetail.glazingroom," +
- " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
- " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
- " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
- " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
- " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
- " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
- "FROM TP_PM_InProduction " +
- " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
- " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
- " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
- " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
- " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
- " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
- " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
- " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
- " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
- " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
- " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
- " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
- " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
- " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
- " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
- " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
- " and TP_PM_InProduction.AccountID=:AccountID ";
- return selSql;
- }
- #endregion
- /// <summary>
- /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
- {
- #region
- //string selSql = "";
- //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //selSql = selSql +
- // "select " +
- // " DefectProcedureID," +
- // " DefectProcedureCode, " +
- // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
- // " ProductionLineID, " +
- // " ProductionLineCode," +
- // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
- // " ProcedureID, " +
- // " ProcedureCode," +
- // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
- // " DefectCode, " +
- // " DefectName, " +
- // " DefectTypeName, " +
- // " Userid," +
- // " Usercode," +
- // " Username," +
- // " Goodstypename," +
- // " Goodsid," +
- // " Goodscode," +
- // " Goodsname," +
- // " InCount from (" +
- // "select " +
- // " DefectProcedureID," +
- // " DefectProcedureCode, " +
- // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
- // " ProductionLineID, " +
- // " ProductionLineCode, " +
- // " ProductionLineName, " +
- // " ProcedureID, " +
- // " ProcedureCode, " +
- // " ProcedureName, " +
- // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
- // " DefectName, " +
- // " DefectTypeName, " +
- // " Userid, " +
- // " Usercode, " +
- // " Username, " +
- // " Goodstypename, " +
- // " Goodsid, " +
- // " Goodscode, " +
- // " Goodsname, " +
- // " InCount " +
- // "from " +
- // "(" +
- // " select " +
- // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
- // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
- // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
- // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
- // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
- // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
- // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
- // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
- // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
- // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
- // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
- // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
- // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
- // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
- // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
- // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
- // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
- // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
- // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
- // " count(TP_PM_Defect.barcode) as InCount " +
- // " from TP_PM_Defect " +
- // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
- // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
- // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
- // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
- // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
- // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
- // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
- // " and TP_PM_Defect.AccountID=:AccountID ";
- //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- //{
- // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
- // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.LineIDS))
- //{
- // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
- // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- //{
- // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
- // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
- // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- //}
- //else
- //{
- // // modify by chenxy :没有选择时,应全查询出来。
- // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
- //}
- //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
- //{
- // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
- // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.KilnCode))
- //{
- // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
- // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.GoodsIDS))
- //{
- // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
- // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.GoodsCode))
- //{
- // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
- // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.DefectUserCode))
- //{
- // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
- // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
- //{
- // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
- // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.DefectCode))
- //{
- // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
- // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.DefectName))
- //{
- // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
- // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
- //}
- //if (!string.IsNullOrEmpty(se.CheckUserCode))
- //{
- // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
- // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
- //}
- //if (se.CreateTimeStart.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
- // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- //}
- //if (se.CreateTimeEnd.HasValue)
- //{
- // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
- // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- //}
- //selSql = selSql +
- // "group by " +
- // " rollup(TP_PM_Defect.DefectProcedureID, " +
- // " TP_PM_Defect.DefectProcedureCode, " +
- // " TP_PM_Defect.DefectProcedureName, " +
- // " TP_PM_Defect.ProductionLineID, " +
- // " TP_PM_Defect.ProductionLineCode, " +
- // " TP_PM_Defect.ProductionLineName, " +
- // " TP_PM_Defect.ProcedureID, " +
- // " TP_PM_Defect.ProcedureCode," +
- // " TP_PM_Defect.ProcedureName, " +
- // " TP_PM_Defect.DefectCode, " +
- // " TP_PM_Defect.DefectName, " +
- // " TP_MST_DefectType.DefectTypeName, " +
- // " TP_PM_Defect.Userid, " +
- // " TP_PM_Defect.Usercode, " +
- // " TP_PM_Defect.Username, " +
- // " TP_MST_GoodsType.Goodstypename, " +
- // " TP_PM_Defect.Goodsid, " +
- // " TP_PM_Defect.Goodscode, " +
- // " TP_PM_Defect.Goodsname " +
- // " )) temp ) temp2 " +
- // "where 1=1 " +
- // "and ((Goodsname!='--' )" +
- // "or (Goodsname='--' and defectcode='小计')" +
- // "or (Goodsname='--' and DefectProcedurename='合计') " +
- // "or (Goodsname='--' and DefectProcedureID='总计'))";
- //////----------------------
- ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
- ////{
- //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
- //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
- //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
- //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
- //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
- //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
- ////}
- //////----------------------
- //return selSql;
- #endregion
- string selSql =
- "SELECT t.ProductionLineID\n" +
- " ,t.ProductionLineCode\n" +
- " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
- " ,t.ProcedureID\n" +
- " ,t.ProcedureCode\n" +
- " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
- " ,t.DefectProcedureID\n" +
- " ,t.DefectProcedureCode\n" +
- " ,decode(t.gid,\n" +
- " 7,\n" +
- " '合计【' || t.DefectProcedureName || '】',\n" +
- " 0,\n" +
- " t.DefectProcedureName,\n" +
- " '--') DefectProcedureName\n" +
- " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
- " ,decode(t.gid,\n" +
- " 3,\n" +
- " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
- " 0,\n" +
- " t.DefectName,\n" +
- " '--') DefectName\n" +
- " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
- " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
- " ,t.Userid\n" +
- " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
- " ,decode(t.gid, 0, t.Username, '--') Username\n" +
- " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
- " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
- " ,t.Goodsid\n" +
- " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
- " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
- " ,t.InCount\n" +
- " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
- " pmd.DefectProcedureID,\n" +
- " pmd.DefectCode,\n" +
- " pmd.userid,\n" +
- " pmd.goodsid) gid\n" +
- " ,pmd.ProductionLineID\n" +
- " ,pmd.ProductionLineCode\n" +
- " ,pmd.ProductionLineName\n" +
- " ,pmd.ProcedureID\n" +
- " ,pmd.ProcedureCode\n" +
- " ,pmd.ProcedureName\n" +
- " ,pmd.DefectProcedureID\n" +
- " ,pmd.DefectProcedureCode\n" +
- " ,pmd.DefectProcedureName\n" +
- " ,pmd.DefectCode\n" +
- " ,pmd.DefectName\n" +
- " ,dt.DefectTypeName\n" +
- " ,pmd.Userid\n" +
- " ,pmd.Usercode\n" +
- " ,pmd.Username\n" +
- " ,gt.Goodstypename\n" +
- " ,pmd.Goodsid\n" +
- " ,pmd.Goodscode\n" +
- " ,pmd.Goodsname\n" +
- " ,COUNT(pmd.barcode) InCount\n" +
- " FROM tp_pm_defect pmd\n" +
- " LEFT JOIN TP_MST_Goods g\n" +
- " ON pmd.Goodsid = g.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_Defect mstd\n" +
- " ON pmd.DefectID = mstd.DefectID\n" +
- " LEFT JOIN TP_MST_DefectType dt\n" +
- " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
- " INNER JOIN tp_pm_productiondata pd\n" +
- " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
- " -- 交接工序\n" +
- " INNER JOIN tp_pm_productiondata hopd\n" +
- " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
- " AND hopd.valueflag = '1'\n" +
- " AND hopd.barcode = pd.barcode\n" +
- " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
- " WHERE pmd.valueflag = '1'\n" +
- " AND pd.ModelType = -1\n" +
- " AND pmd.AccountID = :AccountID\n";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
- selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
- parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- else
- {
- // modify by chenxy :没有选择时,应全查询出来。
- //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
- }
- if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.KilnCode))
- {
- selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
- parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectUserCode))
- {
- selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
- parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectTypeIDS))
- {
- selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectName))
- {
- selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
- parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCode))
- {
- selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 交接时间
- if (se.HandOverTimeStart.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
- parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.HandOverTimeEnd.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
- parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
- }
- selSql = selSql +
- " GROUP BY GROUPING SETS((pmd.ProductionLineID, pmd.ProductionLineCode, pmd.ProductionLineName, pmd.ProcedureID, pmd.ProcedureCode, pmd.ProcedureName, pmd.DefectProcedureID, pmd.DefectProcedureCode, pmd.DefectProcedureName, pmd.DefectCode, pmd.DefectName, dt.DefectTypeName, pmd.Userid, pmd.Usercode, pmd.Username, gt.Goodstypename, pmd.Goodsid, pmd.Goodscode, pmd.Goodsname),(pmd.ProductionLineID, pmd.ProductionLineCode, pmd.ProductionLineName, pmd.ProcedureID, pmd.ProcedureCode, pmd.ProcedureName, pmd.DefectProcedureID, pmd.DefectProcedureCode, pmd.DefectProcedureName, pmd.DefectCode, pmd.DefectName, dt.DefectTypeName),(pmd.ProductionLineID, pmd.ProductionLineCode, pmd.ProductionLineName, pmd.ProcedureID, pmd.ProcedureCode, pmd.ProcedureName, pmd.DefectProcedureID, pmd.DefectProcedureCode, pmd.DefectProcedureName),())\n" +
- " ORDER BY pmd.ProductionLineCode\n" +
- " ,pmd.ProcedureCode\n" +
- " ,pmd.DefectProcedureCode\n" +
- " ,pmd.DefectCode\n" +
- " ,pmd.Usercode\n" +
- " ,pmd.Goodscode) t";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
- {
- // string selSql = @"select
- // tp_pm_defect.productionlinename,
- // tp_pm_defect.procedurename,
- // tp_pm_defect.DefectProcedureCode,
- // tp_pm_defect.DefectProcedureName,
- // tp_pm_defect.DefectUserCode,
- // tp_pm_defect.defectusername,
- // tp_mst_defectType.DefectTypeName,
- // TP_MST_Defect.Remarks DefectRemarks,
- // tp_pm_defect.defectcode,
- // tp_pm_defect.defectname,
- // tp_pm_defect.UserCode,
- // tp_pm_defect.username,
- // tp_mst_goodstype.Goodstypename,
- // tp_pm_defect.goodscode,
- // tp_pm_defect.barcode,
- // tp_pm_productiondata.groutingdate,
- // tp_pm_productiondata.groutingnum,
- // tp_pm_productiondata.groutingMouldCode,
- // tp_pm_productiondata.KilnCarCode,
- // tp_pm_productiondata.Procedureid,
- // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
- // tp_pm_defect.DefectPositionCode,
- // tp_pm_defect.DefectPositionName,
- // tp_pm_productiondata.GroutingUserCode,
- // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
- // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
- // ,TP_PM_Defect.CreateTime
- // ,(select listagg(to_char(pd.UserCode), ',') within GROUP(ORDER BY pd.ProductionDataID) AS WorkUserCodes from tp_pm_ProductionData pd where pd.barcode = tp_pm_defect.barcode and pd.valueflag = '1' ) AS WorkUserCodes
- // ,TP_MST_DefectFine.DefectFineCode
- // ,TP_PM_Defect.DefectDeductionNum
- // from tp_pm_defect
- // left join TP_MST_Goods
- // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
- // left join TP_MST_GoodsType
- // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
- // left join TP_MST_Defect
- // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
- // left join TP_MST_DefectType
- // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
- // inner join tp_pm_productiondata
- // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
- // left join TP_MST_DefectFine
- // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
- // left join tp_mst_logo
- // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
- // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
- // 追加交接时间,改判标识。
- string selSql =
- "SELECT pmd.productionlinename\n" +
- " ,pmd.procedurename\n" +
- " ,pmd.DefectProcedureCode\n" +
- " ,pmd.DefectProcedureName\n" +
- " ,pmd.DefectUserCode\n" +
- " ,pmd.defectusername\n" +
- " ,dt.DefectTypeName\n" +
- " ,mstd.Remarks DefectRemarks\n" +
- " ,pmd.defectcode\n" +
- " ,d.alldefectcode\n" +
- " ,pmd.defectname\n" +
- " ,pmd.UserCode\n" +
- " ,pmd.username\n" +
- " ,gt.Goodstypename\n" +
- " ,pmd.goodscode\n" +
- " ,pmd.barcode\n" +
- " ,pd.groutingdate\n" +
- " ,pd.groutingnum\n" +
- " ,pd.groutingMouldCode\n" +
- " ,pd.groutingLineCode\n" +
- " ,pd.KilnCarCode\n" +
- " ,pd.Procedureid\n" +
- " ,gl.goodslevelname Goodsleveltype\n" +
- " ,pmd.DefectPositionCode\n" +
- " ,pmd.DefectPositionName\n" +
- " ,pd.GroutingUserCode\n" +
- " , CASE\n" +
- " WHEN logo.logoid IS NULL THEN\n" +
- " NULL\n" +
- " ELSE\n" +
- " logo.Logoname || '[' || logo.Logocode || ']'\n" +
- " END AS LogoCodeName\n" +
- " ,pmd.CreateTime\n" +
- " ,mstdf.DefectFineCode\n" +
- " ,pmd.DefectDeductionNum\n" +
- //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
- " ,hopd.createtime handovertime\n" +
- " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
- " FROM tp_pm_ProductionData pduc\n" +
- " WHERE pduc.barcode = pmd.barcode\n" +
- " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
- " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
- " FROM tp_pm_ProductionData pdcu\n" +
- " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
- " WHERE pdcu.barcode = pmd.barcode\n" +
- " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
- " , CASE\n" +
- " WHEN EXISTS (SELECT 1\n" +
- " FROM tp_pm_ProductionData pdud\n" +
- " WHERE pdud.barcode = pmd.barcode\n" +
- " AND pdud.modeltype = -1\n" +
- " AND pdud.procedureid = pd.procedureid\n" +
- " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
- " AND pdud.valueflag = '0') THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END AS undoflag\n" +
- " , CASE\n" +
- " WHEN EXISTS (SELECT 1\n" +
- " FROM tp_pm_semicheck sc\n" +
- " WHERE sc.barcode = pmd.barcode\n" +
- " AND sc.SEMICHECKTYPE = 1\n" +
- " AND sc.valueflag = '1') THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END reworkflag" +
- " ,gdd.glazingroom" +
- " FROM tp_pm_defect pmd\n" +
- " LEFT JOIN TP_MST_Goods g\n" +
- " ON pmd.Goodsid = g.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_Defect mstd\n" +
- " ON pmd.DefectID = mstd.DefectID\n" +
- " LEFT JOIN TP_MST_DefectType dt\n" +
- " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
- " INNER JOIN tp_pm_productiondata pd\n" +
- " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
- " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
- " LEFT JOIN tp_mst_goodslevel gl\n" +
- " ON pd.goodslevelid = gl.goodslevelid\n" +
- "-- 交接工序\n" +
- " INNER JOIN tp_pm_productiondata hopd\n" +
- " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
- " AND hopd.barcode = pd.barcode\n" +
- " AND hopd.valueflag = '1'\n" +
- " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
- " LEFT JOIN TP_MST_DefectFine mstdf\n" +
- " ON pmd.DefectFine = mstdf.DefectFineID\n" +
- " LEFT JOIN tp_mst_logo logo\n" +
- " ON pd.logoid = logo.logoid\n" +
- " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
- " FROM tp_pm_defect def\n" +
- " WHERE def.valueflag = '1'\n" +
- //def.createtime
- " group by def.barcode ) d\n" +
- " ON d.barcode = pmd.barcode\n" +
- " WHERE pmd.valueflag = '1' \n" +
- " AND pd.ModelType = -1\n" +
- " AND pmd.AccountID = :AccountID\n";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
- //selSql = selSql +
- // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
- // " and TP_PM_Defect.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
- selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
- parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- else
- {
- // modify by chenxy :没有选择时,应全查询出来。
- //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
- }
- if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.KilnCode))
- {
- selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
- parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
- {
- selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
- parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectUserCode))
- {
- selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
- parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectTypeIDS))
- {
- selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCodeS2D))
- {
- selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
- parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectName))
- {
- selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
- parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCode))
- {
- selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
- {
- selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
- parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
- }
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 交接时间
- if (se.HandOverTimeStart.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
- parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.HandOverTimeEnd.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
- parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
- }
- //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
- //{
- // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
- // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
- //}
- ////----------------------
- //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
- //{
- // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
- // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
- // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
- // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
- // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
- // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
- //}
- ////----------------------
- selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
- {
- // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
- // 追加交接时间,改判标识。
- string selSql =
- "SELECT pmd.productionlinename\n" +
- " ,pmd.procedurename\n" +
- " ,pmd.DefectProcedureCode\n" +
- " ,pmd.DefectProcedureName\n" +
- " ,pmd.DefectUserCode\n" +
- " ,pmd.defectusername\n" +
- " ,jobs.jobsname defectjobsname\n" +
- " ,dt.DefectTypeName\n" +
- " ,mstd.Remarks DefectRemarks\n" +
- " ,pd.Remarks barcodeRemarks\n" +
- " ,pmd.defectcode\n" +
- " ,d.alldefectcode\n" +
- " ,pmd.defectname\n" +
- " ,pmd.UserCode\n" +
- " ,pmd.username\n" +
- " ,gt.Goodstypename\n" +
- " ,pmd.goodscode\n" +
- " ,pmd.barcode\n" +
- " ,pd.groutingdate\n" +
- " ,pd.groutingnum\n" +
- " ,pd.groutingMouldCode\n" +
- " ,pd.GroutingLineCode\n" +
- " ,pd.KilnCarCode\n" +
- " ,pd.Procedureid\n" +
- " ,gl.goodslevelname Goodsleveltype\n" +
- " ,pmd.DefectPositionCode\n" +
- " ,pmd.DefectPositionName\n" +
- " ,pd.GroutingUserCode\n" +
- " , CASE\n" +
- " WHEN logo.logoid IS NULL THEN\n" +
- " NULL\n" +
- " ELSE\n" +
- " logo.Logoname || '[' || logo.Logocode || ']'\n" +
- " END AS LogoCodeName\n" +
- //" ,pmd.CreateTime\n" +
- " ,pd.CheckTime pdchecktime\n" +
- " ,pmd.CheckTime\n" +
- " ,mstdf.DefectFineCode\n" +
- " ,pmd.DefectDeductionNum\n" +
- //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
- " ,hopd.createtime handovertime\n" +
- " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
- " FROM tp_pm_ProductionData pduc\n" +
- " WHERE pduc.barcode = pmd.barcode\n" +
- " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
- " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
- " FROM tp_pm_ProductionData pdcu\n" +
- " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
- " WHERE pdcu.barcode = pmd.barcode\n" +
- " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
- " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
- " FROM TP_PM_DefectResponsible dr\n" +
- " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
- " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
- " ) AS DefectStaffNames\n" +
- " , CASE\n" +
- " WHEN pd.isrefire <> '0' THEN\n" +
- " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
- " ,',') within group(order by d.productiondefectid) bsqx\n" +
- " from tp_pm_productiondata p\n" +
- " inner join tp_pm_defect d\n" +
- " on d.productiondataid = p.productiondataid\n" +
- " where p.valueflag = '1'\n" +
- " and d.valueflag = '1'\n" +
- " and p.barcode = pd.barcode\n" +
- " and p.modeltype = -1\n" +
- " and p.isrefire = '0')\n" +
- " ELSE\n" +
- " null\n" +
- " END AS bsqx\n" +
- " , CASE\n" +
- " WHEN EXISTS (SELECT 1\n" +
- " FROM tp_pm_ProductionData pdud\n" +
- " WHERE pdud.barcode = pmd.barcode\n" +
- " AND pdud.modeltype = -1\n" +
- " AND pdud.procedureid = pd.procedureid\n" +
- " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
- " AND pdud.valueflag = '0') THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END AS undoflag\n" +
- " FROM tp_pm_defect pmd\n" +
- " LEFT JOIN TP_PC_Procedure p\n" +
- " ON p.procedureid = pmd.procedureid\n" +
- " LEFT JOIN TP_PC_Procedure pdd\n" +
- " ON pdd.procedureid = pmd.defectprocedureid\n" +
- " LEFT JOIN TP_MST_Goods g\n" +
- " ON pmd.Goodsid = g.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_Defect mstd\n" +
- " ON pmd.DefectID = mstd.DefectID\n" +
- " LEFT JOIN TP_MST_Jobs jobs\n" +
- " ON jobs.jobsid = pmd.Defectjobs\n" +
- " LEFT JOIN TP_MST_DefectType dt\n" +
- " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
- " INNER JOIN tp_pm_productiondata pd\n" +
- " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
- " LEFT JOIN tp_mst_goodslevel gl\n" +
- " ON pd.goodslevelid = gl.goodslevelid\n" +
- //"-- 交接工序\n" +
- //" INNER JOIN tp_pm_productiondata hopd\n" +
- //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
- //" AND hopd.valueflag = '1'\n" +
- //" AND hopd.barcode = pd.barcode\n" +
- //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
- " INNER JOIN tp_pm_productiondata hopd\n" +
- " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
- " AND hopd.barcode = pd.barcode\n" +
- " AND hopd.valueflag = '1'\n" +
- " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
- " LEFT JOIN TP_MST_DefectFine mstdf\n" +
- " ON pmd.DefectFine = mstdf.DefectFineID\n" +
- " LEFT JOIN tp_mst_logo logo\n" +
- " ON pd.logoid = logo.logoid\n" +
- " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
- " FROM tp_pm_defect def\n" +
- " WHERE def.valueflag = '1'\n" +
- //def.createtime
- " group by def.barcode ) d\n" +
- " ON d.barcode = pmd.barcode\n" +
- " WHERE pmd.valueflag = '1' \n" +
- " AND pd.ModelType = -1\n" +
- " AND pmd.AccountID = :AccountID\n";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
- //selSql = selSql +
- // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
- // " and TP_PM_Defect.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
- selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
- parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- else
- {
- // modify by chenxy :没有选择时,应全查询出来。
- //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
- }
- if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.KilnCode))
- {
- selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
- parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
- {
- selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
- parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectUserCode))
- {
- selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
- parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectTypeIDS))
- {
- selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCodeS2D))
- {
- selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
- parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectName))
- {
- selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
- parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCode))
- {
- selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
- {
- selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
- parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
- }
- //if (se.CreateTimeStart.HasValue)
- //{
- // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
- // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- //}
- //if (se.CreateTimeEnd.HasValue)
- //{
- // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
- // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- //}
- // 成检登记时间
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 缺陷登记时间
- if (se.CheckTimeStart.HasValue)
- {
- selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
- parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CheckTimeEnd.HasValue)
- {
- selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
- parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
- }
- // 交接时间
- if (se.HandOverTimeStart.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
- parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.HandOverTimeEnd.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
- parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
- }
- //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
- selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
- {
- // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
- // 追加交接时间,改判标识。
- string selSql =
- //"SELECT pmd.productionlinename\n" +
- //" ,pmd.procedurename\n" +
- //" ,pmd.DefectProcedureCode\n" +
- //" ,pmd.DefectProcedureName\n" +
- //" ,pmd.DefectUserCode\n" +
- //" ,pmd.defectusername\n" +
- //" ,jobs.jobsname defectjobsname\n" +
- //" ,dt.DefectTypeName\n" +
- //" ,mstd.Remarks DefectRemarks\n" +
- //" ,pd.Remarks barcodeRemarks\n" +
- //" ,pmd.defectcode\n" +
- //" ,d.alldefectcode\n" +
- //" ,pmd.defectname\n" +
- //" ,pmd.UserCode\n" +
- //" ,pmd.username\n" +
- //" ,gt.Goodstypename\n" +
- //" ,pmd.goodscode\n" +
- //" ,pmd.barcode\n" +
- //" ,pd.groutingdate\n" +
- //" ,pd.groutingnum\n" +
- //" ,pd.groutingMouldCode\n" +
- //" ,pd.GroutingLineCode\n" +
- //" ,pd.KilnCarCode\n" +
- //" ,pd.Procedureid\n" +
- //" ,gl.goodslevelname Goodsleveltype\n" +
- //" ,pmd.DefectPositionCode\n" +
- //" ,pmd.DefectPositionName\n" +
- //" ,pd.GroutingUserCode\n" +
- //" , CASE\n" +
- //" WHEN logo.logoid IS NULL THEN\n" +
- //" NULL\n" +
- //" ELSE\n" +
- //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
- //" END AS LogoCodeName\n" +
- ////" ,pmd.CreateTime\n" +
- //" ,pd.CheckTime pdchecktime\n" +
- //" ,pmd.CheckTime\n" +
- //" ,mstdf.DefectFineCode\n" +
- //" ,pmd.DefectDeductionNum\n" +
- ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
- //" ,hopd.createtime handovertime\n" +
- //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
- //" FROM tp_pm_ProductionData pduc\n" +
- //" WHERE pduc.barcode = pmd.barcode\n" +
- //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
- //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
- //" FROM tp_pm_ProductionData pdcu\n" +
- //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
- //" WHERE pdcu.barcode = pmd.barcode\n" +
- //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
- //" , CASE\n" +
- //" WHEN EXISTS (SELECT 1\n" +
- //" FROM tp_pm_ProductionData pdud\n" +
- //" WHERE pdud.barcode = pmd.barcode\n" +
- //" AND pdud.modeltype = -1\n" +
- //" AND pdud.procedureid = pd.procedureid\n" +
- //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
- //" AND pdud.valueflag = '0') THEN\n" +
- //" 1\n" +
- //" ELSE\n" +
- //" 0\n" +
- //" END AS undoflag\n" +
- "SELECT pmd.goodscode\n" +
- " ,pmd.barcode\n" +
- " ,pmd.defectcode\n" +
- " ,pmd.defectname\n" +
- " ,pmd.DefectPositionCode\n" +
- " ,pmd.DefectPositionName\n" +
- " ,gl.goodslevelname Goodsleveltype\n" +
- " , CASE\n" +
- " WHEN logo.logoid IS NULL THEN\n" +
- " NULL\n" +
- " ELSE\n" +
- " logo.Logoname || '[' || logo.Logocode || ']'\n" +
- " END AS LogoCodeName\n" +
- //" ,pmd.CreateTime\n" +
- " ,pd.CheckTime pdchecktime\n" +
- " ,pmd.CheckTime\n" +
- " ,proddata.CheckTime protime\n" +
- " ,proddata.UserCode prousercode\n" +
- " ,proddata.PROCEDURENAME proname\n" +
- " ,pd.KILNCARCODE KILNCARCODE\n" +
- " FROM tp_pm_defect pmd\n" +
- " INNER JOIN tp_pm_productiondata proddata\n" +
- " ON proddata.barcode = pmd.barcode\n " +
- //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
- " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
- " AND proddata.valueflag = '1'\n" +
- " INNER JOIN tp_pm_productiondata pd\n" +
- " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
- " LEFT JOIN TP_PC_Procedure p\n" +
- " ON p.procedureid = pmd.procedureid\n" +
- " LEFT JOIN TP_PC_Procedure pdd\n" +
- " ON pdd.procedureid = pmd.defectprocedureid\n" +
- " LEFT JOIN TP_MST_Goods g\n" +
- " ON pmd.Goodsid = g.Goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " LEFT JOIN TP_MST_Defect mstd\n" +
- " ON pmd.DefectID = mstd.DefectID\n" +
- " LEFT JOIN TP_MST_Jobs jobs\n" +
- " ON jobs.jobsid = pmd.Defectjobs\n" +
- " LEFT JOIN TP_MST_DefectType dt\n" +
- " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
- " LEFT JOIN tp_mst_goodslevel gl\n" +
- " ON pd.goodslevelid = gl.goodslevelid\n" +
- "-- 交接工序\n" +
- " INNER JOIN tp_pm_productiondata hopd\n" +
- " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
- " AND hopd.barcode = pd.barcode\n" +
- " AND hopd.valueflag = '1'\n" +
- " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
- " LEFT JOIN TP_MST_DefectFine mstdf\n" +
- " ON pmd.DefectFine = mstdf.DefectFineID\n" +
- " LEFT JOIN tp_mst_logo logo\n" +
- " ON pd.logoid = logo.logoid\n" +
- //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
- //" FROM tp_pm_defect def\n" +
- //" WHERE def.valueflag = '1'\n" +
- ////def.createtime
- //" group by def.barcode ) d\n" +
- //" ON d.barcode = pmd.barcode\n" +
- " WHERE pmd.valueflag = '1' \n" +
- " AND pd.ModelType = -1\n" +
- " AND pmd.AccountID = :AccountID\n";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
- //selSql = selSql +
- // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
- // " and TP_PM_Defect.AccountID=:AccountID ";
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.LineIDS))
- {
- selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
- parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
- selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
- parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- else
- {
- // modify by chenxy :没有选择时,应全查询出来。
- //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
- }
- if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
- {
- selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.KilnCode))
- {
- selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
- parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsIDS))
- {
- selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
- parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
- {
- selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
- parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectUserCode))
- {
- selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
- parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectTypeIDS))
- {
- selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectCodeS2D))
- {
- selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
- parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.DefectName))
- {
- selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
- parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCode))
- {
- selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
- {
- selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
- parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
- }
- //if (se.CreateTimeStart.HasValue)
- //{
- // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
- // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- //}
- //if (se.CreateTimeEnd.HasValue)
- //{
- // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
- // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- //}
- // 成检登记时间
- if (se.CreateTimeStart.HasValue)
- {
- selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CreateTimeEnd.HasValue)
- {
- selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
- }
- // 缺陷登记时间
- if (se.CheckTimeStart.HasValue)
- {
- selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
- parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
- }
- if (se.CheckTimeEnd.HasValue)
- {
- selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
- parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
- }
- // 交接时间
- if (se.HandOverTimeStart.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
- parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
- }
- if (se.HandOverTimeEnd.HasValue)
- {
- selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
- parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
- }
- //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
- selSql = selSql + " order by proddata.CheckTime ";
- return selSql;
- }
- /// <summary>
- /// 窑车状态主表查询
- /// </summary>
- /// <param name="kilnCode">窑炉编码</param>
- /// <param name="kilnCarCode">窑车编码</param>
- /// <param name="sUserInfo">用户基本信息</param>
- /// <returns></returns>
- public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
- {
- IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- con.Open();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
- new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
- new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
- new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (con != null &&
- con.ConnState == ConnectionState.Open)
- {
- con.Close();
- }
- }
- }
- /// <summary>
- /// 窑车状态明细表查询
- /// </summary>
- /// <param name="kilnCarCode">窑车编码</param>
- /// <param name="sUserInfo">用户基本信息</param>
- /// <returns></returns>
- public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
- {
- IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- con.Open();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
- new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
- new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
- new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
- sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (con != null &&
- con.ConnState == ConnectionState.Open)
- {
- con.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Clear();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- #region
- #endregion
- string sql = @"
- select gd.groutinglinecode,
- gd.groutingmouldcode,
- gd.mouldcode,
- gd.usercode,
- gs.goodscode,
- gs.goodsname,
- gs.goodsspecification,
- gms.gmouldstatusname, -- 模具状态
- --gs.goodsmodel,
- gd.groutingcount, -- 注浆次数
- --gd.groutingnum,
- gd.scrapnum, -- 开模损坯数
- gd.deliverpnum, -- 交坯数
- gd.mingroutingdate, -- 开始注浆时间
- gd.maxgroutingdate, -- 最后注浆时间
- gld.beginuseddate, -- 开始使用时间
- gld.enduseddate, -- 结束使用时间
- zl.OutKilnCount, -- 质量登记数
- zl.GoodCount, -- 正品数
- zl.SubstandardCount, -- 副品数
- zl.ReFireCount, -- 重烧数
- zl.BadCount -- 次品数
- from (select gdd.groutinglinecode,
- gdd.groutingmouldcode,
- gdd.mouldcode,
- gdd.goodsid,
- gdd.groutinglinedetailid,
- wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
- max(gdd.groutingcount) groutingcount,
- sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
- sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
- sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
- min(gdd.groutingdate) mingroutingdate,
- max(gdd.groutingdate) maxgroutingdate
- from tp_pm_groutingdailydetail gdd
- where gdd.groutingflag = '1'
- and gdd.AccountID = :AccountID
-
- ";
- // 成型线编码
- if (!string.IsNullOrEmpty(se.groutinglinecode))
- {
- //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
- sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
- parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
- }
- // 模具编码
- if (!string.IsNullOrEmpty(se.groutingmouldcode))
- {
- //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
- sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
- parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
- }
- sql = sql + @"
- group by gdd.groutinglinecode,
- gdd.groutingmouldcode,
- gdd.mouldcode,
- gdd.goodsid,
- gdd.groutinglinedetailid) gd
- left join (select pdbc.mouldcode,
- sum(1) OutKilnCount,
- sum(case
- when defect.defectprocedureid is not null and
- glt.goodsleveltypeid in (5, 6, 7) then
- 0
- else
- 1
- end) GoodCount,
- sum(case
- when defect.defectprocedureid is not null and
- glt.goodsleveltypeid = 7 then
- 1
- else
- 0
- end) SubstandardCount,
- sum(case
- when defect.defectprocedureid is not null and
- glt.goodsleveltypeid = 6 then
- 1
- else
- 0
- end) ReFireCount,
- sum(case
- when defect.defectprocedureid is not null and
- glt.goodsleveltypeid = 5 then
- 1
- else
- 0
- end) BadCount
- from (select distinct pd.barcode,
- pd.mouldcode,
- pd.kilncarbatchno
- from tp_pm_productiondata pd
- where pd.valueflag = '1'";
- // 开始注浆--开始
- if (se.beginCreateTime.HasValue)
- {
- sql = sql + " and pd.createtime>=:groutingDateStart ";
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- //--and pd.createtime > 查询条件。开始注浆日期开始
- // --and pd.procedureid = :in_rptSprocedureId
- sql = sql + @"
- and pd.procedureid = 11
- and pd.AccountID = 1) pdbc
- left join (select kcbc.barcode,
- kcbc.kilncarbatchno,
- kcbc.goodsleveltypeid,
- kcbc.productiondataid
- from (select pd.barcode,
- pd.kilncarbatchno,
- pd.goodsleveltypeid,
- pd.productiondataid,
- ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
- from tp_pm_productiondata pd
- where pd.valueflag = '1'
- --and pd.AccountID = :AccountID
- and pd.AccountID = :AccountID";
- //--and pd.createtime > 查询条件。开始注浆日期开始
- // 开始注浆--开始
- if (se.beginCreateTime.HasValue)
- {
- sql = sql + " and pd.createtime>=:groutingDateStart ";
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- sql = sql + @" and length(pd.kilncarbatchno) > 0
- and pd.modeltype = -1) kcbc
- where kcbc.dataid = 1) glt
- on pdbc.kilncarbatchno = glt.kilncarbatchno
- and pdbc.barcode = glt.barcode
- left join (select distinct productiondataid, defectprocedureid
- from tp_pm_defect def
- where def.valueflag = '1'";
- //--and pd.createtime > 查询条件。开始注浆日期开始
- // 开始注浆--开始
- if (se.beginCreateTime.HasValue)
- {
- sql = sql + " and def.createtime>=:groutingDateStart ";
- parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- sql = sql + @"
- and def.AccountID = :AccountID) defect
- on defect.productiondataid = glt.productiondataid
- group by pdbc.mouldcode) zl
- on zl.mouldcode = gd.mouldcode
- left join tp_mst_goods gs
- on gs.goodsid = gd.goodsid
- left join tp_pc_groutinglinedetail gld
- on gld.groutinglinedetailid = gd.groutinglinedetailid
- and gld.mouldcode = gd.mouldcode
- left join tp_sys_gmouldstatus gms
- on gms.gmouldstatusid = gld.gmouldstatus
- where 1=1
- ";
- // 产品编码
- if (!string.IsNullOrEmpty(se.goodscode))
- {
- //sql = sql + " and gs.goodscode=:goodscode";
- sql = sql + " and instr(gs.goodscode,:goodscode)>0";
- parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrEmpty(se.groutingUserCode))
- {
- //sql = sql + " and gd.usercode=:usercode";
- sql = sql + " and instr(gd.usercode,:usercode)>0";
- parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
- }
- // 开始注浆--开始
- if (se.beginCreateTime.HasValue)
- {
- sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
- }
- // 开始注浆--结束
- if (se.endCreateTime.HasValue)
- {
- sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
- }
- // 结束注浆--开始
- if (se.beginCreateTime2.HasValue)
- {
- sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
- parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
- }
- // 结束注浆--结束
- if (se.endCreateTime2.HasValue)
- {
- sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
- parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
- }
- // 模具状态
- if (!string.IsNullOrEmpty(se.gmouldstatus))
- {
- sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
- parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
- }
- sql = sql + " order by groutinglinecode,groutingmouldcode";
- return sql;
- }
- #region 工资产量统计
- /// <summary>
- /// 取得RPT080102画面(成型工产量)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
- new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
- new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
- new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
- new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
- new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
- new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
- };
- conn.IsCommandTimeout = false;
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- conn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- /// <summary>
- /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
- new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
- new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
- new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
- new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- conn.IsCommandTimeout = false;
- //DataSet data = null;
- //if (se.ProcedureIDS.Contains(","))
- //{
- // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
- //}
- //else
- //{
- // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
- //}
- DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data = data;
- conn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- /// <summary>
- /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
- {
- IDBTransaction conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- conn.Connect();
- OracleParameter[] paras = new OracleParameter[]{
- new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
- new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
- new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
- new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
- new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
- new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
- };
- conn.IsCommandTimeout = false;
- DataSet data = null;
- if (se.ProcedureIDS.Contains(","))
- {
- data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
- }
- else
- {
- data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
- }
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = data;
- //string sqlString =
- //"SELECT kk.procedurename\n" +
- //" ,kk.usercode\n" +
- //" ,kk.kilncode\n" +
- //" ,kk.kdate\n" +
- //" ,COUNT(*) kcount\n" +
- //" FROM (SELECT k.usercode\n" +
- //" ,kiln.kilncode\n" +
- //" ,p.procedurename\n" +
- //" ,trunc(k.createtime) kdate\n" +
- //" FROM tp_pm_kilncardata k\n" +
- //" LEFT JOIN tp_mst_kiln kiln\n" +
- //" ON kiln.kilnid = k.kilnid\n" +
- //" LEFT JOIN tp_pc_procedure p\n" +
- //" ON p.procedureid = k.procedureid\n" +
- //" WHERE k.valueflag = '1'\n" +
- //" AND k.AccountID = :in_AccountID\n" +
- //" AND k.createtime >= :in_BeginDate\n" +
- //" AND k.createtime <= :in_EndDate\n" +
- //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
- //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
- //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
- string sqlString = "WITH kilnData AS\n" +
- " (SELECT k.usercode\n" +
- " ,kiln.kilncode\n" +
- " ,p.procedurename\n" +
- " ,trunc(k.createtime) kdate\n" +
- " ,k.userid\n" +
- " ,k.procedureid\n" +
- " ,k.kilnid\n" +
- " ,k.KILNCARBATCHNO\n" +
- " FROM tp_pm_kilncardata k\n" +
- " LEFT JOIN tp_mst_kiln kiln\n" +
- " ON kiln.kilnid = k.kilnid\n" +
- " LEFT JOIN tp_pc_procedure p\n" +
- " ON p.procedureid = k.procedureid\n" +
- " WHERE k.valueflag = '1'\n" +
- " AND k.AccountID = :in_AccountID\n" +
- " AND k.createtime >= :in_BeginDate\n" +
- " AND k.createtime <= :in_EndDate\n" +
- " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
- "SELECT kd.procedurename\n" +
- " ,kd.usercode\n" +
- " ,kd.kilncode\n" +
- " ,kd.kdate\n" +
- " ,kd.kcount\n" +
- " ,kpd.kpcount\n" +
- " FROM (SELECT kk.procedurename\n" +
- " ,kk.usercode\n" +
- " ,kk.kilncode\n" +
- " ,kk.kdate\n" +
- " ,kk.procedureid\n" +
- " ,kk.userid\n" +
- " ,kk.kilnid\n" +
- " ,COUNT(*) kcount\n" +
- " FROM kilnData kk\n" +
- " GROUP BY kk.procedurename\n" +
- " ,kk.usercode\n" +
- " ,kk.kilncode\n" +
- " ,kk.kdate\n" +
- " ,kk.procedureid\n" +
- " ,kk.userid\n" +
- " ,kk.kilnid) kd\n" +
- " LEFT JOIN (SELECT kk.kdate\n" +
- " ,kk.procedureid\n" +
- " ,kk.userid\n" +
- " ,kk.kilnid\n" +
- " ,COUNT(*) kpcount\n" +
- " FROM kilnData kk\n" +
- " INNER JOIN tp_pm_productiondata pd\n" +
- " ON pd.valueflag = '1'\n" +
- " AND pd.procedureid = kk.procedureid\n" +
- " AND pd.kilnid = kk.kilnid\n" +
- " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
- " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
- " ON kpd.kdate = kd.kdate\n" +
- " AND kpd.procedureid = kd.procedureid\n" +
- " AND kpd.userid = kd.userid\n" +
- " AND kpd.kilnid = kd.kilnid\n" +
- " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
- OracleParameter[] parascount = new OracleParameter[]{
- new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
- new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
- new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
- new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
- };
- DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
- if (dt != null)
- {
- sre.Data.Tables.Add(dt);
- }
- conn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Disconnect();
- }
- }
- }
- #endregion
- /// <summary>
- /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
- /// </summary>
- /// <param name="searchEntity">生产数据实体类</param>
- /// <param name="user">用户基本信息</param>
- /// <returns>DataTable</returns>
- public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string procsql = "PRO_RPT_GetProductionData";
- try
- {
- IDataParameter[] paras = new OracleParameter[]
- {
- new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
- new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
- new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
- new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
- new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
- new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
- new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
- new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
- new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
- new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
- new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
- new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
- new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
- new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
- new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
- new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
- new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
- new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
- new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
- };
- oracleConn.Open();
- DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
- if (returnDs != null && returnDs.Tables.Count > 0)
- {
- return returnDs.Tables[0];
- }
- else
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT080106(温湿计明细)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
- {
- string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
- Left join TP_MST_User u On cr.ThermometerID = u.UserId
- Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
- Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- if (!string.IsNullOrEmpty(se.ThermometerIDS))
- {
- selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
- parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
- }
- if (!string.IsNullOrEmpty(se.Remarks))
- {
- selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
- parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
- }
- if (se.RecordDate.HasValue)
- {
- selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
- parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
- }
- if (se.RecordDateEnd.HasValue)
- {
- selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
- parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
- }
- selSql +=
- // 温湿计查看权限
- " AND EXISTS (SELECT UP.PurviewID" +
- " FROM TP_MST_UserPurview UP" +
- " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
- " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
- " AND UP.UserId = :UPUserId)";
- parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- selSql = selSql + " order by RecordDate asc";
- return selSql;
- }
- /// <summary>
- /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
- DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- #region
- // string sqlString = @"
- // SELECT t.reworkprocedureid -- 返工工序id
- // ,decode(gid,
- // 7,
- // '总计',
- // 3,
- // '合计【' || t.reworkprocedurename || '】',
- // 0,
- // t.reworkprocedurename,
- // '--') reworkprocedurename -- 返工工序
- // ,t.goodstypecode2 -- 产品二级类别
- // ,decode(gid,
- // 1,
- // '小计【' || t.goodstypename2 || '】',
- // 0,
- // t.goodstypename2,
- // '--') goodstypename2 -- 产品二级类别
- // ,t.reworkuserid -- 返工工号id
- // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
- // ,t.goodsid -- 产品id
- // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
- // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
- // ,t.reworkcount -- 返工数
- // ,t.badcount -- 不合格数
- // ,t.regoodcount -- 复检合格数
- // ,t.rebadcount -- 复检不合格数
- // ,t.renocount -- 未复检
- // --,t.renocountsum -- 待返工
- // ,(SELECT COUNT(*)
- // FROM tp_pm_semicheck sci
- // WHERE sci.valueflag = '1'
- // AND sci.backoutflag = '0'
- // AND sci.semichecktype = 1
- // AND sci.resemichecktype = 0
- // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
- // AND (t.goodsid is null or sci.goodsid = t.goodsid)
- // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
- // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
- // ,sc.reworkprocedureid
- // ,rp.procedurename reworkprocedurename
- // ,gt2.goodstypecode goodstypecode2
- // ,gt2.goodstypename goodstypename2
- // ,sc.reworkuserid
- // ,sc.reworkusercode
- // ,g.goodsid
- // ,g.goodscode
- // ,gt.goodstypename
- // , SUM(CASE
- // WHEN sc.semichecktype = 1 THEN
- // 1
- // ELSE
- // 0
- // END) reworkcount
- // , SUM(CASE
- // WHEN sc.semichecktype = 2 THEN
- // 1
- // ELSE
- // 0
- // END) badcount
- // , SUM(CASE
- // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
- // 1
- // ELSE
- // 0
- // END) renocount
- // , SUM(CASE
- // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
- // 1
- // ELSE
- // 0
- // END) regoodcount
- // , SUM(CASE
- // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
- // 1
- // ELSE
- // 0
- // END) rebadcount
- // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
- // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
- // --FROM tp_pm_semicheck sc
- // FROM (SELECT semicheckid
- // ,barcode
- // ,productionlineid
- // ,procedureid
- // ,proceduretime
- // ,proceduremodel
- // ,modeltype
- // ,organizationid
- // ,goodsid
- // ,goodscode
- // ,userid
- // ,usercode
- // ,productiondataid
- // ,logoid
- // ,ispublicbody
- // ,specialrepairflag
- // ,goodslevelid
- // ,goodsleveltypeid
- // ,groutingdailyid
- // ,groutingdailydetailid
- // ,groutinglineid
- // ,groutinglinecode
- // ,groutinglinename
- // ,gmouldtypeid
- // ,canmanytimes
- // ,groutinglinedetailid
- // ,groutingdate
- // ,groutingmouldcode
- // ,mouldcode
- // ,groutinguserid
- // ,groutingusercode
- // ,groutingnum
- // ,semichecktype
- // ,semicheckuserid
- // ,semicheckusercode
- // ,semichecktime
- // ,reworkprocedureid
- // ,reworkprocedurecode
- // ,reworkuserid
- // ,reworkusercode
- // ,resemichecktype
- // ,resemicheckuserid
- // ,resemicheckusercode
- // ,resemichecktime
- // ,backoutflag
- // ,backouttime
- // ,backoutuserid
- // ,backoutusercode
- // ,remarks
- // ,createtime
- // ,createuserid
- // ,updateuserid
- // FROM tp_pm_semicheck sc
- // WHERE sc.accountid = :accountid
- // AND sc.valueflag = '1'
- // AND sc.semichecktype = 1
- // AND sc.backoutflag = '0'
- // UNION ALL
- // SELECT DISTINCT sc.semicheckid
- // ,sc.barcode
- // ,sc.productionlineid
- // ,sc.procedureid
- // ,sc.proceduretime
- // ,sc.proceduremodel
- // ,sc.modeltype
- // ,sc.organizationid
- // ,sc.goodsid
- // ,sc.goodscode
- // ,sc.userid
- // ,sc.usercode
- // ,sc.productiondataid
- // ,sc.logoid
- // ,sc.ispublicbody
- // ,sc.specialrepairflag
- // ,sc.goodslevelid
- // ,sc.goodsleveltypeid
- // ,sc.groutingdailyid
- // ,sc.groutingdailydetailid
- // ,sc.groutinglineid
- // ,sc.groutinglinecode
- // ,sc.groutinglinename
- // ,sc.gmouldtypeid
- // ,sc.canmanytimes
- // ,sc.groutinglinedetailid
- // ,sc.groutingdate
- // ,sc.groutingmouldcode
- // ,sc.mouldcode
- // ,sc.groutinguserid
- // ,sc.groutingusercode
- // ,sc.groutingnum
- // ,sc.semichecktype
- // ,sc.semicheckuserid
- // ,sc.semicheckusercode
- // ,sc.semichecktime
- // --,sc.reworkprocedureid
- // --,sc.reworkprocedurecode
- // --,sc.reworkuserid
- // --,sc.reworkusercode
- // ,scd.defectprocedureid
- // ,scdp.procedurename
- // ,scd.defectuserid
- // ,scd.defectusercode
- // ,sc.resemichecktype
- // ,sc.resemicheckuserid
- // ,sc.resemicheckusercode
- // ,sc.resemichecktime
- // ,sc.backoutflag
- // ,sc.backouttime
- // ,sc.backoutuserid
- // ,sc.backoutusercode
- // ,sc.remarks
- // ,sc.createtime
- // ,sc.createuserid
- // ,sc.updateuserid
- // FROM tp_pm_semicheck sc
- // LEFT JOIN TP_PM_SemiCheckDefect scd
- // ON sc.semicheckid = scd.semicheckid
- // LEFT JOIN tp_pc_procedure scdp
- // ON scdp.procedureid = scd.defectprocedureid
- // WHERE sc.accountid = :accountid
- // AND sc.valueflag = '1'
- // AND sc.semichecktype = 2
- // AND sc.backoutflag = '0'
- // ) sc
- // LEFT JOIN tp_pc_procedure rp
- // ON rp.procedureid = sc.reworkprocedureid
- // INNER JOIN tp_mst_goods g
- // ON g.goodsid = sc.goodsid
- // INNER JOIN tp_mst_goodstype gt
- // ON gt.goodstypeid = g.goodstypeid
- // INNER JOIN tp_mst_goodstype gt2
- // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
- // AND gt2.accountid = gt.accountid
- // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
- // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
- // WHERE exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=sc.procedureid))";
- #endregion
- string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
- " ,decode(gid,\n" +
- " 7,\n" +
- " '总计',\n" +
- " 3,\n" +
- " '合计【' || t.reworkprocedurename || '】',\n" +
- " 0,\n" +
- " t.reworkprocedurename,\n" +
- " '--') reworkprocedurename -- 返工工序\n" +
- " ,t.goodstypecode2 -- 产品二级类别\n" +
- " ,decode(gid,\n" +
- " 1,\n" +
- " '小计【' || t.goodstypename2 || '】',\n" +
- " 0,\n" +
- " t.goodstypename2,\n" +
- " '--') goodstypename2 -- 产品二级类别\n" +
- " ,t.reworkuserid -- 返工工号id\n" +
- " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
- " ,t.goodsid -- 产品id\n" +
- " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
- " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
- " ,t.reworkcount -- 返工数\n" +
- " ,t.badcount -- 不合格数\n" +
- " ,t.regoodcount -- 复检合格数\n" +
- " ,t.rebadcount -- 复检不合格数\n" +
- " ,t.renocount -- 未复检\n" +
- " ,t.renocountsum -- 待返工\n" +
- " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
- " sct.goodstypecode2,\n" +
- " sct.goodsid) gid\n" +
- " ,sct.displayno\n" +
- " ,sct.reworkprocedureid\n" +
- " ,sct.reworkprocedurename\n" +
- " ,sct.goodstypecode2\n" +
- " ,sct.goodstypename2\n" +
- " ,sct.reworkuserid\n" +
- " ,sct.reworkusercode\n" +
- " ,sct.goodsid\n" +
- " ,sct.goodscode\n" +
- " ,sct.goodstypename\n" +
- " ,SUM(sct.reworkcount) reworkcount\n" +
- " ,SUM(sct. badcount) badcount\n" +
- " ,SUM(sct. renocount) renocount\n" +
- " ,SUM(sct.regoodcount) regoodcount\n" +
- " ,SUM(sct.rebadcount) rebadcount\n" +
- " ,SUM(sct.renocountsum) renocountsum\n" +
- " FROM (SELECT rp.displayno\n" +
- " ,sc.reworkprocedureid\n" +
- " ,rp.procedurename reworkprocedurename\n" +
- " ,gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,sc.reworkuserid\n" +
- " ,sc.reworkusercode\n" +
- " ,g.goodsid\n" +
- " ,g.goodscode\n" +
- " ,gt.goodstypename\n" +
- " , SUM(CASE\n" +
- " WHEN sc.semichecktype = 1 THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END) reworkcount\n" +
- " , SUM(CASE\n" +
- " WHEN sc.semichecktype = 2 THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END) badcount\n" +
- " , SUM(CASE\n" +
- " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END) renocount\n" +
- " , SUM(CASE\n" +
- " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END) regoodcount\n" +
- " , SUM(CASE\n" +
- " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
- " 1\n" +
- " ELSE\n" +
- " 0\n" +
- " END) rebadcount\n" +
- " ,(SELECT COUNT(*)\n" +
- " FROM tp_pm_semicheck sci\n" +
- " WHERE sci.valueflag = '1'\n" +
- " AND sci.backoutflag = '0'\n" +
- " AND sci.semichecktype = 1\n" +
- " AND sci.resemichecktype = 0\n" +
- " AND sci.accountid = :accountid\n" +
- " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
- " AND sci.reworkuserid = sc.reworkuserid\n" +
- " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
- " FROM (SELECT semicheckid\n" +
- " ,barcode\n" +
- " ,productionlineid\n" +
- " ,procedureid\n" +
- " ,proceduretime\n" +
- " ,proceduremodel\n" +
- " ,modeltype\n" +
- " ,organizationid\n" +
- " ,goodsid\n" +
- " ,goodscode\n" +
- " ,userid\n" +
- " ,usercode\n" +
- " ,productiondataid\n" +
- " ,logoid\n" +
- " ,ispublicbody\n" +
- " ,specialrepairflag\n" +
- " ,goodslevelid\n" +
- " ,goodsleveltypeid\n" +
- " ,groutingdailyid\n" +
- " ,groutingdailydetailid\n" +
- " ,groutinglineid\n" +
- " ,groutinglinecode\n" +
- " ,groutinglinename\n" +
- " ,gmouldtypeid\n" +
- " ,canmanytimes\n" +
- " ,groutinglinedetailid\n" +
- " ,groutingdate\n" +
- " ,groutingmouldcode\n" +
- " ,mouldcode\n" +
- " ,groutinguserid\n" +
- " ,groutingusercode\n" +
- " ,groutingnum\n" +
- " ,semichecktype\n" +
- " ,semicheckuserid\n" +
- " ,semicheckusercode\n" +
- " ,semichecktime\n" +
- " ,reworkprocedureid\n" +
- " ,reworkprocedurecode\n" +
- " ,reworkuserid\n" +
- " ,reworkusercode\n" +
- " ,resemichecktype\n" +
- " ,resemicheckuserid\n" +
- " ,resemicheckusercode\n" +
- " ,resemichecktime\n" +
- " ,backoutflag\n" +
- " ,backouttime\n" +
- " ,backoutuserid\n" +
- " ,backoutusercode\n" +
- " ,remarks\n" +
- " ,createtime\n" +
- " ,createuserid\n" +
- " ,updateuserid\n" +
- " FROM tp_pm_semicheck sc\n" +
- " WHERE sc.accountid = :accountid\n" +
- " AND sc.valueflag = '1'\n" +
- " AND sc.semichecktype = 1\n" +
- " AND sc.backoutflag = '0'\n" +
- " UNION ALL\n" +
- " SELECT DISTINCT sc.semicheckid\n" +
- " ,sc.barcode\n" +
- " ,sc.productionlineid\n" +
- " ,sc.procedureid\n" +
- " ,sc.proceduretime\n" +
- " ,sc.proceduremodel\n" +
- " ,sc.modeltype\n" +
- " ,sc.organizationid\n" +
- " ,sc.goodsid\n" +
- " ,sc.goodscode\n" +
- " ,sc.userid\n" +
- " ,sc.usercode\n" +
- " ,sc.productiondataid\n" +
- " ,sc.logoid\n" +
- " ,sc.ispublicbody\n" +
- " ,sc.specialrepairflag\n" +
- " ,sc.goodslevelid\n" +
- " ,sc.goodsleveltypeid\n" +
- " ,sc.groutingdailyid\n" +
- " ,sc.groutingdailydetailid\n" +
- " ,sc.groutinglineid\n" +
- " ,sc.groutinglinecode\n" +
- " ,sc.groutinglinename\n" +
- " ,sc.gmouldtypeid\n" +
- " ,sc.canmanytimes\n" +
- " ,sc.groutinglinedetailid\n" +
- " ,sc.groutingdate\n" +
- " ,sc.groutingmouldcode\n" +
- " ,sc.mouldcode\n" +
- " ,sc.groutinguserid\n" +
- " ,sc.groutingusercode\n" +
- " ,sc.groutingnum\n" +
- " ,sc.semichecktype\n" +
- " ,sc.semicheckuserid\n" +
- " ,sc.semicheckusercode\n" +
- " ,sc.semichecktime\n" +
- " --,sc.reworkprocedureid\n" +
- " --,sc.reworkprocedurecode\n" +
- " --,sc.reworkuserid\n" +
- " --,sc.reworkusercode\n" +
- " ,scd.defectprocedureid\n" +
- " ,scdp.procedurename\n" +
- " ,scd.defectuserid\n" +
- " ,scd.defectusercode\n" +
- " ,sc.resemichecktype\n" +
- " ,sc.resemicheckuserid\n" +
- " ,sc.resemicheckusercode\n" +
- " ,sc.resemichecktime\n" +
- " ,sc.backoutflag\n" +
- " ,sc.backouttime\n" +
- " ,sc.backoutuserid\n" +
- " ,sc.backoutusercode\n" +
- " ,sc.remarks\n" +
- " ,sc.createtime\n" +
- " ,sc.createuserid\n" +
- " ,sc.updateuserid\n" +
- " FROM tp_pm_semicheck sc\n" +
- " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
- " ON sc.semicheckid = scd.semicheckid\n" +
- " AND scd.valueflag='1'\n" +
- " LEFT JOIN tp_pc_procedure scdp\n" +
- " ON scdp.procedureid = scd.defectprocedureid\n" +
- " WHERE sc.accountid = :accountid\n" +
- " AND sc.valueflag = '1'\n" +
- " AND sc.semichecktype = 2\n" +
- " AND sc.backoutflag = '0') sc\n" +
- " LEFT JOIN tp_pc_procedure rp\n" +
- " ON rp.procedureid = sc.reworkprocedureid\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = sc.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " INNER JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " AND gt2.accountid = gt.accountid\n" +
- " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
- " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
- " sc.GroutingDailyDetailID\n" //+
- //" WHERE EXISTS (SELECT 1\n" +
- //" FROM TP_MST_UserPurview up\n" +
- //" WHERE up.PurviewType = 9\n" +
- //" AND up.UserID = :UserID\n" +
- //" AND (up.PurviewID = -1 OR\n" +
- //" up.PurviewID = sc.procedureid))\n"
- ;
- // 完成工序集
- if (!string.IsNullOrEmpty(se.CProcedureIDS))
- {
- sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
- parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
- }
- // 完成时间起始
- if (se.CDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
- parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成时间结束
- if (se.CDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
- parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成工号
- if (!string.IsNullOrEmpty(se.CUserCode))
- {
- sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
- }
- // 产品类别
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrEmpty(se.GroutingUserCode))
- {
- sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 注浆时间起始
- if (se.GroutingDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
- parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
- }
- // 注浆时间结束
- if (se.GroutingDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
- parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯时间起始
- if (se.DeliveryDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
- }
- // 交坯时间结束
- if (se.DeliveryDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检状态
- if (!string.IsNullOrEmpty(se.SemiCheckType))
- {
- sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
- parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
- }
- // 半检时间起始
- if (se.SemiCheckDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
- }
- // 半检时间结束
- if (se.SemiCheckDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检工号
- if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
- {
- sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
- parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
- }
- // 返工工序
- if (!string.IsNullOrEmpty(se.RProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
- }
- // 返工工号
- if (!string.IsNullOrEmpty(se.ReworkUserCode))
- {
- sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
- parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
- }
- // 复检状态
- if (!string.IsNullOrEmpty(se.ReSemiCheckType))
- {
- sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
- parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
- }
- // 复检时间起始
- if (se.ReSemiCheckDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
- parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
- }
- // 复检时间结束
- if (se.ReSemiCheckDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
- parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 复检工号
- if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
- {
- sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
- parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
- }
- // sqlString += @" GROUP BY GROUPING SETS((rp.displayno, sc.reworkprocedureid, rp.procedurename, gt2.goodstypecode, gt2.goodstypename, sc.reworkuserid, sc.reworkusercode, g.goodsid, g.goodscode, gt.goodstypename),(rp.displayno, sc.reworkprocedureid, rp.procedurename, gt2.goodstypecode, gt2.goodstypename),(rp.displayno, sc.reworkprocedureid, rp.procedurename),())
- // ORDER BY rp.displayno
- // ,gt2.goodstypename
- // ,sc.reworkusercode
- // ,g.goodscode
- // ,gt.goodstypename, gid) t
- // ";
- sqlString = sqlString +
- " GROUP BY rp.displayno\n" +
- " ,sc.reworkprocedureid\n" +
- " ,rp.procedurename\n" +
- " ,gt2.goodstypecode\n" +
- " ,gt2.goodstypename\n" +
- " ,sc.reworkuserid\n" +
- " ,sc.reworkusercode\n" +
- " ,g.goodsid\n" +
- " ,g.goodscode\n" +
- " ,gt.goodstypename) sct\n" +
- " GROUP BY GROUPING SETS((sct.displayno, sct.reworkprocedureid, sct.reworkprocedurename, sct.goodstypecode2, sct.goodstypename2, sct.reworkuserid, sct.reworkusercode, sct.goodsid, sct.goodscode, sct.goodstypename),(sct.displayno, sct.reworkprocedureid, sct.reworkprocedurename, sct.goodstypecode2, sct.goodstypename2),(sct.displayno, sct.reworkprocedureid, sct.reworkprocedurename),())\n" +
- " ORDER BY sct.displayno\n" +
- " ,sct.goodstypename\n" +
- " ,sct.reworkusercode\n" +
- " ,sct.goodscode\n" +
- " ,sct.goodstypename\n" +
- " ,gid) t";
- return sqlString;
- }
- /// <summary>
- /// 取得RPT080107(半检登记明细)的信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- //xuwei add 2019-10-14
- /// <summary>
- /// 取得RPT080108(半检返修登记明细)的信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString = @"
- SELECT
- sr.SEMIREWORKID ,--AS SEMIREWORKID,
- p.PROCEDURECODE ,--AS 完成工序编码,
- p.PROCEDURENAME ,--AS 完成工序,
- sr.PROCEDURETIME ,--AS 完成时间,
- sr.USERCODE ,--完成工号,
- gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
- gt.GOODSTYPENAME ,--AS 产品类别,
- g.GOODSCODE ,--AS 产品编码,
- g.GOODSNAME,--AS 产品名称,
- sr.BARCODE ,--AS 产品条码,
- sr.SEMIREWORKUSERCODE ,--AS 半检工号,
- sr.SEMIREWORKTIME ,--AS 半检时间,
- pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
- pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
- sr.BACKOUTFLAG ,--AS 撤销标识,
- sr.BACKOUTUSERCODE ,--AS 撤销工号,
- sr.BACKOUTTIME ,--AS 撤销时间,
- sr.GROUTINGUSERCODE ,--AS 成型工号,
- sr.GROUTINGLINECODE ,--AS 成型线编码,
- sr.GROUTINGMOULDCODE ,--AS 模具编号,
- sr.GROUTINGDATE ,--AS 注浆时间,
- gd.DELIVERTIME ,--AS 交坯时间,
- l.LOGONAME ,--AS 商标,
- srd.DEFECTCODE ,--AS 缺陷编码,
- srd.DEFECTNAME ,--AS 缺陷名称,
- srd.DEFECTPOSITIONCODE ,--AS 位置编码,
- srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
- pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
- pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
- srd.DEFECTUSERCODE ,--AS 责任工号,
- inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
- FROM
- TP_PM_SEMIREWORK sr
- LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
- LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
- LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
- LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
- LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
- LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
- LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
- AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
- LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
- LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
- LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
- LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
- WHERE
- sr.VALUEFLAG = '1'
- AND srd.VALUEFLAG = '1'
- AND sr.AccountID=:AccountID
- ";
- //AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=sr.procedureid))
- // 完成工序
- if (!string.IsNullOrEmpty(se.CProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
- parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
- }
- // 完成时间起始
- if (se.CDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
- parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成时间结束
- if (se.CDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
- parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成工号
- if (!string.IsNullOrEmpty(se.CUserCode))
- {
- sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
- }
- // 产品类别
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrEmpty(se.GroutingUserCode))
- {
- sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 注浆时间起始
- if (se.GroutingDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
- parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
- }
- // 注浆时间结束
- if (se.GroutingDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
- parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯时间起始
- if (se.DeliveryDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
- }
- // 交坯时间结束
- if (se.DeliveryDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检状态
- if (!string.IsNullOrEmpty(se.SemiCheckType))
- {
- sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sr.SemiCheckType||',')>0 ";
- parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
- }
- // 半检时间起始
- if (se.SemiCheckDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
- }
- // 半检时间结束
- if (se.SemiCheckDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检工号
- if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
- {
- sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
- parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
- }
- // 返修工序
- if (!string.IsNullOrEmpty(se.RProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
- parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
- }
- // 返修工号
- if (!string.IsNullOrEmpty(se.ReworkUserCode))
- {
- sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
- parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
- }
- //// 复检状态
- //if (!string.IsNullOrEmpty(se.ReSemiCheckType))
- //{
- // sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sr.ReSemiCheckType||',')>0 ";
- // parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
- //}
- //// 复检时间起始
- //if (se.ReSemiCheckDateTimeStart.HasValue)
- //{
- // sqlString = sqlString + " AND sr.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
- // parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
- //}
- //// 复检时间结束
- //if (se.ReSemiCheckDateTimeEnd.HasValue)
- //{
- // sqlString = sqlString + " AND sr.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
- // parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- //}
- //// 复检工号
- //if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
- //{
- // sqlString = sqlString + " AND instr(sr.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
- // parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
- //}
- // 撤销标识
- if (!string.IsNullOrEmpty(se.BackOutFlag))
- {
- sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
- parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
- }
- // 撤销时间起始
- if (se.BackOutTimeStart.HasValue)
- {
- sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
- parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
- }
- // 撤销时间结束
- if (se.BackOutTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
- parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
- }
- // 撤销工号
- if (!string.IsNullOrEmpty(se.BackOutUserCode))
- {
- sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
- parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
- }
- // 产品条码
- if (!string.IsNullOrEmpty(se.BarCode))
- {
- sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
- parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
- }
- // 缺陷编码
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- // 缺陷位置集
- if (!string.IsNullOrEmpty(se.DefectPositionIDS))
- {
- sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
- }
- // 责任工序集
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- // 责任工号
- if (!string.IsNullOrEmpty(se.DefectUser))
- {
- sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
- parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
- }
- return sqlString;
- }
- //xuwei end
- //xuwei add 2019-10-21
- /// <summary>
- /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
- /// </summary>
- /// <param name="user">用户</param>
- /// <param name="dataStr">统计日期</param>
- /// <returns></returns>
- public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlStr = $@"
- SELECT
- nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
- nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
- nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
- to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
- FROM
- TP_PM_SEMIREWORK sr
- LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
- LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
- WHERE
- sr.VALUEFLAG = '1'
- AND sr.ACCOUNTID = '{user.AccountID}'
- AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
- AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
- GROUP BY
- grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
- ";
- DataTable data = conn.GetSqlResultToDt(sqlStr);
- ServiceResultEntity sre = new ServiceResultEntity();
- //if (data == null || data.Rows.Count == 0)
- //{
- // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- // return sre;
- //}
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- //xuwei end
- /// <summary>
- /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString = @"
- select
- SemiCheck.SemiCheckID,
- CProcedure.ProcedureName as CProcedureName,
- SemiCheck.ProcedureTime,
- SemiCheck.UserCode,
- GoodsType2.GoodsTypeName as LevelGoodsTypeName,
- GoodsType.GoodsTypeName,
- Goods.GoodsCode,
- SemiCheck.BarCode,
- -- 复检后不显示半检状态
- SemiCheckType.SemiCheckTypeName,
- --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
- SemiCheck.SemiCheckUserCode,
- SemiCheck.SemiCheckTime,
- ReSemiCheckType.ReSemiCheckTypeName,
- SemiCheck.ReSemiCheckUserCode,
- SemiCheck.ReSemiCheckTime,
- decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
- SemiCheck.BackOutUserCode,
- SemiCheck.BackOutTime,
- SemiCheck.GroutingUserCode,
- SemiCheck.GroutingLineCode,
- SemiCheck.GroutingMouldCode,
- SemiCheck.GroutingDate,
- GroutingDailyDetail.DeliverTime,
- logo.logoName,
- RProcedure.ProcedureName as RProcedureName,
- SemiCheck.ReworkUserCode,
- SemiCheckDefect.DefectCode,
- SemiCheckDefect.DefectName as DefectName1,
- concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
- SemiCheckDefect.DefectPositionName,
- SemiCheckDefect.DefectPositionCode,
- concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
- Procedure.ProcedureName,
- inpp.ProcedureName CurrProcedureName,
- DefectUser.username as DefectUser
- from TP_PM_SemiCheck SemiCheck
- left join TP_PC_Procedure CProcedure
- on SemiCheck.ProcedureID=CProcedure.ProcedureID
- left join TP_MST_Goods Goods
- on SemiCheck.GoodsID=Goods.GoodsID
- left join TP_MST_GoodsType GoodsType
- on Goods.GoodsTypeID=GoodsType.GoodsTypeID
- left join TP_MST_GoodsType GoodsType2
- on GoodsType2.accountid=GoodsType.accountid
- and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
- left join TP_SYS_SemiCheckType SemiCheckType
- on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
- left join TP_SYS_ReSemiCheckType ReSemiCheckType
- on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
- left join TP_PM_GroutingDailyDetail GroutingDailyDetail
- on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
- left join TP_MST_Logo logo
- on GroutingDailyDetail.LogoID=logo.LogoID
- left join TP_PC_Procedure RProcedure
- on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
- left join TP_PM_SemiCheckDefect SemiCheckDefect
- on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
- and SemiCheckDefect.ValueFlag='1'
- left join TP_PC_Procedure Procedure
- on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
- left join TP_MST_User DefectUser
- on DefectUser.userid=SemiCheckDefect.DefectUserID
- left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
- left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
- where SemiCheck.AccountID=:AccountID
- ";
- //AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=SemiCheck.procedureid))
- // 完成工序
- if (!string.IsNullOrEmpty(se.CProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
- }
- // 完成时间起始
- if (se.CDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
- parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成时间结束
- if (se.CDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
- parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
- }
- // 完成工号
- if (!string.IsNullOrEmpty(se.CUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
- parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
- }
- // 产品类别
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 成型工号
- if (!string.IsNullOrEmpty(se.GroutingUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
- parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
- }
- // 注浆时间起始
- if (se.GroutingDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
- parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
- }
- // 注浆时间结束
- if (se.GroutingDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
- parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 交坯时间起始
- if (se.DeliveryDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
- }
- // 交坯时间结束
- if (se.DeliveryDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
- parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检状态
- if (!string.IsNullOrEmpty(se.SemiCheckType))
- {
- sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
- parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
- }
- // 半检时间起始
- if (se.SemiCheckDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
- }
- // 半检时间结束
- if (se.SemiCheckDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
- parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 半检工号
- if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
- parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
- }
- // 返工工序
- if (!string.IsNullOrEmpty(se.RProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
- parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
- }
- // 返工工号
- if (!string.IsNullOrEmpty(se.ReworkUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
- parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
- }
- // 复检状态
- if (!string.IsNullOrEmpty(se.ReSemiCheckType))
- {
- sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
- parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
- }
- // 复检时间起始
- if (se.ReSemiCheckDateTimeStart.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
- parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
- }
- // 复检时间结束
- if (se.ReSemiCheckDateTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
- parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
- }
- // 复检工号
- if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
- parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
- }
- // 撤销标识
- if (!string.IsNullOrEmpty(se.BackOutFlag))
- {
- sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
- parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
- }
- // 撤销时间起始
- if (se.BackOutTimeStart.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
- parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
- }
- // 撤销时间结束
- if (se.BackOutTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
- parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
- }
- // 撤销工号
- if (!string.IsNullOrEmpty(se.BackOutUserCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
- parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
- }
- // 产品条码
- if (!string.IsNullOrEmpty(se.BarCode))
- {
- sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
- parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
- }
- // 缺陷编码
- if (!string.IsNullOrEmpty(se.DefectCode))
- {
- sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
- parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
- }
- // 缺陷位置集
- if (!string.IsNullOrEmpty(se.DefectPositionIDS))
- {
- sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
- }
- // 责任工序集
- if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
- {
- sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
- parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
- }
- // 责任工号
- if (!string.IsNullOrEmpty(se.DefectUser))
- {
- sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
- parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
- }
- return sqlString;
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
- /// </summary>
- /// <returns>sql</returns>
- private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
- string sqlString = @"SELECT ts.gid
- ,logoid
- ,decode(ts.gid,
- '23',
- '总计【' || orderno || '】',
- decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
- ,decode(ts.gid,
- '3',
- '合计【' || logoname || '】',
- decode(ts.gid, '1', '--', logoname)) AS logoname
- ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
- ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
- ,GoodsSpecification
- ,fhtime
- ,COUNT
- FROM (SELECT grouping_id(l.logoid,
- o.orderno,
- l.logoname,
- g.goodscode,
- to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
- ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
- ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
- ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
- ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
- ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
- ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
- ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
- 1,
- '--',
- to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
- ,COUNT(f.fhtime) AS COUNT
- FROM tp_pm_finishedproduct F
- LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
- LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
- LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
- LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
- where f.fhtime is not null and f.AccountID=:AccountID ";
- // 交接时间起始
- if (se.FHTimeStart.HasValue)
- {
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
- }
- // 交接时间结束
- if (se.FHTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
- }
- // 订单号
- if (!string.IsNullOrEmpty(se.OrderNo))
- {
- sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
- parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
- }
- // 产品类别编码
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsModel))
- {
- sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
- parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
- }
- // 产品商标ID集
- if (!string.IsNullOrEmpty(se.LogoIDS))
- {
- sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
- parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(se.FHUserCode))
- {
- sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
- parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
- }
- sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
- order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
- )ts
- where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
- or (goodscode!='--')
- or(logoname!='')
- or (orderno!='--') and ts.gid!='7'";
- return sqlString;
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
- string sqlString = "SELECT nvl2(o.orderno,\n" +
- " nvl2(l.logoname,\n" +
- " o.orderno,\n" +
- " to_char('合计[') || o.orderno ||\n" +
- " to_char(']')),\n" +
- " '总计') orderno\n" +
- " ,nvl2(l.logoname,\n" +
- " nvl2(g.goodscode,\n" +
- " l.logoname,\n" +
- " to_char('小计[' || l.logoname || ']')),\n" +
- " '--') logoname\n" +
- " ,nvl(g.goodscode, '--') goodscode" +
- " ,nvl(g.goodsmodel, '--') goodsmodel" +
- " ,nvl(gdd.materialcode, '--') mcode" +
- " ,f.logoid" +
- " ,f.goodsid" +
- " ,f.fhorderid" +
- " ,COUNT(*) count" +
- " FROM tp_pm_finishedproduct f\n" +
- " inner JOIN tp_pm_groutingdailydetail gdd\n" +
- " ON gdd.barcode = f.barcode\n" +
- " LEFT JOIN tp_mst_logo l\n" +
- " ON f.logoid = l.logoid\n" +
- " LEFT JOIN TP_PM_Order O\n" +
- " ON f.Fhorderid = O.Orderid\n" +
- " LEFT JOIN tp_mst_goods G\n" +
- " ON g.goodsid = f.goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " WHERE f.fhtime IS NOT NULL\n" +
- " AND f.AccountID = :AccountID\n";
- // 交接时间起始
- if (cre.Properties["FHTimeStart"] != null)
- {
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
- }
- // 交接时间结束
- if (cre.Properties["FHTimeEnd"] != null)
- {
- sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
- }
- // 订单号
- if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
- {
- sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
- parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
- }
- // 产品类别编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
- parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
- }
- // 产品商标ID集
- if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
- {
- sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
- parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
- {
- sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
- parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
- }
- //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
- sqlString += " group by grouping sets((o.orderno, l.logoname, g.goodscode, g.goodsmodel, gdd.materialcode,f.logoid,f.goodsid,f.fhorderid),(o.orderno, l.logoname,f.logoid,f.fhorderid),(o.orderno,f.fhorderid),())";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
- DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
- {
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- string sqlString = "SELECT O.ORDERNO,\n" +
- " F.FHTIME,\n" +
- " F.FHUSERCODE,\n" +
- " F.BARCODE,\n" +
- " F.GOODSCODE,\n" +
- " L.LOGONAME,\n" +
- " F.GROUTINGUSERCODE,\n" +
- " F.GROUTINGLINECODE,\n" +
- " F.GROUTINGMOULDCODE,\n" +
- " F.GROUTINGDATE,\n" +
- " G.DELIVERTIME,\n" +
- " GOODS.goodsmodel,\n" +
- //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
- //" nvl(g.outlabelcode, GOODS.MATERIALCODE || (select a.workcode from tp_mst_account a where a.accountid = g.accountid) || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
- " G.outlabelcode AS FINISHEDBARCODE,\n" +
- " G.MATERIALCODE AS mcode,\n" +
- " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
- " FROM TP_PM_FINISHEDPRODUCT F\n" +
- " LEFT JOIN TP_PM_ORDER O\n" +
- " ON F.FHORDERID = O.ORDERID\n" +
- " LEFT JOIN TP_MST_LOGO L\n" +
- " ON F.LOGOID = L.LOGOID\n" +
- " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
- " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
- " LEFT JOIN TP_MST_GOODS GOODS\n" +
- " ON F.GOODSID = GOODS.GOODSID\n" +
- " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
- " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
- " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
- " AND F.FHTIME IS NOT NULL";
- // 交接时间起始
- if (se.FHTimeStart.HasValue)
- {
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
- }
- // 交接时间结束
- if (se.FHTimeEnd.HasValue)
- {
- sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
- }
- // 订单号
- if (!string.IsNullOrEmpty(se.OrderNo))
- {
- //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
- sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
- parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
- }
- // 产品类别编码
- if (!string.IsNullOrEmpty(se.GoodsTypeCode))
- {
- sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(se.GoodsCode))
- {
- sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(se.GoodsModel))
- {
- sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
- parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
- }
- // 产品商标ID集
- if (!string.IsNullOrEmpty(se.LogoIDS))
- {
- sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
- parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(se.FHUserCode))
- {
- sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
- parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
- }
- if (se.OrderID != null)
- {
- sqlString = sqlString + " AND F.fhorderid = :fhorderid";
- parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
- }
- if (se.GoodsID != null)
- {
- sqlString = sqlString + " AND F.GoodsID = :GoodsID";
- parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
- }
- if (se.LogoID != null)
- {
- sqlString = sqlString + " AND F.LogoID = :LogoID";
- parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
- }
- return sqlString;
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
- string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
- " nvl2(l.logoname,\n" +
- " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
- " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
- " to_char(']')),\n" +
- " '总计') fhtime\n" +
- " ,nvl2(l.logoname,\n" +
- " nvl2(g.goodscode,\n" +
- " l.logoname,\n" +
- " to_char('小计[' || l.logoname || ']')),\n" +
- " '--') logoname\n" +
- " ,nvl(g.goodscode, '--') goodscode" +
- " ,nvl(g.goodsmodel, '--') goodsmodel" +
- " ,nvl(gdd.materialcode, '--') mcode" +
- " ,COUNT(*) goodscount" +
- " FROM tp_pm_finishedproduct f\n" +
- " inner JOIN tp_pm_groutingdailydetail gdd\n" +
- " ON gdd.barcode = f.barcode\n" +
- " LEFT JOIN tp_mst_logo l\n" +
- " ON f.logoid = l.logoid\n" +
- " LEFT JOIN TP_PM_Order O\n" +
- " ON f.Fhorderid = O.Orderid\n" +
- " LEFT JOIN tp_mst_goods G\n" +
- " ON g.goodsid = f.goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " WHERE f.fhtime IS NOT NULL\n" +
- " AND f.AccountID = :AccountID\n";
- // 交接时间起始
- if (cre.Properties["FHTimeStart"] != null)
- {
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
- }
- // 交接时间结束
- if (cre.Properties["FHTimeEnd"] != null)
- {
- sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
- }
- // 订单号
- if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
- {
- sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
- parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
- }
- // 产品类别编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
- parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
- }
- // 产品商标ID集
- if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
- {
- sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
- parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
- {
- sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
- parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
- }
- //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
- sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
- string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
- //" nvl2(l.logoname,\n" +
- //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
- //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
- //" to_char(']')),\n" +
- //" '总计') fhtime\n" +
- //" ,nvl2(l.logoname,\n" +
- //" nvl2(g.goodscode,\n" +
- //" l.logoname,\n" +
- //" to_char('小计[' || l.logoname || ']')),\n" +
- //" '--') logoname\n" +
- " nvl(g.goodscode, '合计') goodscode" +
- " ,nvl(g.goodsmodel, '--') goodsmodel" +
- " ,nvl(gdd.materialcode, '--') mcode" +
- " ,COUNT(*) goodscount" +
- " FROM tp_pm_finishedproduct f\n" +
- " inner JOIN tp_pm_groutingdailydetail gdd\n" +
- " ON gdd.barcode = f.barcode\n" +
- " LEFT JOIN tp_mst_logo l\n" +
- " ON f.logoid = l.logoid\n" +
- " LEFT JOIN TP_PM_Order O\n" +
- " ON f.Fhorderid = O.Orderid\n" +
- " LEFT JOIN tp_mst_goods G\n" +
- " ON g.goodsid = f.goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " WHERE f.fhtime IS NOT NULL\n" +
- " AND f.AccountID = :AccountID\n";
- // 交接时间起始
- if (cre.Properties["FHTimeStart"] != null)
- {
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
- }
- // 交接时间结束
- if (cre.Properties["FHTimeEnd"] != null)
- {
- sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
- }
- // 订单号
- if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
- {
- sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
- parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
- }
- // 产品类别编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
- {
- sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
- parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
- }
- // 产品编码
- if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
- {
- sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
- parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
- }
- // 产品商标ID集
- if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
- {
- sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
- parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
- }
- // 交接工号
- if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
- {
- sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
- parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
- }
- //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
- sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得PDA(产成品交接汇总表)的交接数量
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- DateTime dateStart = date;
- DateTime dateEnd = dateStart.AddDays(1);
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
- " FROM tp_pm_finishedproduct f\n" +
- " LEFT JOIN TP_PM_Order O\n" +
- " ON f.Fhorderid = O.Orderid\n" +
- " LEFT JOIN tp_mst_goods G\n" +
- " ON g.goodsid = f.goodsid\n" +
- " LEFT JOIN TP_MST_GoodsType gt\n" +
- " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
- " WHERE f.fhtime IS NOT NULL\n" +
- " AND f.AccountID = :AccountID\n";
- sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
- parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
- sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
- parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
- // 产品型号
- if (!string.IsNullOrEmpty(goodscode))
- {
- sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
- }
- sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
- DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
- ServiceResultEntity sre = new ServiceResultEntity();
- if (data == null || data.Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = new DataSet();
- sre.Data.Tables.Add(data);
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 获取在产品备份表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "SELECT inpb.BackupMonth\n" +
- " ,gdd.BarCode\n" +
- //" ,inpb.GoodsID\n" +
- " ,inpb.GoodsCode\n" +
- " ,inpb.GoodsName\n" +
- //" ,inpb.Userid\n" +
- " ,worker.USERNAME AS UserName\n" +
- " ,worker.USERCode AS UserCode\n" +
- //" ,inpb.ProductionLineID\n" +
- " ,inpb.ProductionLineCode\n" +
- " ,inpb.ProductionLineName\n" +
- //" ,inpb.ModelType\n" +
- " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
- " ,inpb.IsPublicBody\n" +
- " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
- " ,inpb.IsReworkFlag\n" +
- " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
- " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
- //" ,inpb.GroutingDailyID\n" +
- //" ,inpb.GroutingDailyDetailID\n" +
- " ,inpb.GroutingDate\n" +
- //" ,inpb.GroutingLineID\n" +
- " ,inpb.GroutingLineCode\n" +
- " ,inpb.GroutingLineName\n" +
- //" ,inpb.ProcedureID CompleteProcedureID\n" +
- " ,pro.ProcedureName AS CompleteProcedureName\n" +
- //" ,inpb.GMouldTypeID\n" +
- " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
- //" ,inpb.GroutingLineDetailID\n" +
- " ,inpb.GroutingMouldCode\n" +
- " ,inpb.SPECIALREPAIRFLAG\n" +
- " ,inpb.GROUTINGUSERCODE\n" +
- " ,gdd.GROUTINGCOUNT\n" +
- " ,gdd.delivertime\n" +
- " ,inpb.proceduretime\n" +
- " ,inpb.Remarks\n" +
- //" ,inpb.GoodsLevelID\n" +
- " ,mgl.GOODSLEVELNAME\n" +
- //" ,inpb.GoodsLevelTypeID\n" +
- " ,mglt.GOODSLEVELTYPENAME\n" +
- " ,inpb.BackupTime\n" +
- " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
- //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
- " ,nvl(gdd.outlabelcode, Goods.MaterialCode || (select a.workcode from tp_mst_account a where a.accountid = gdd.accountid) || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
- " FROM TP_PM_InProduction_BakByMonth inpb\n" +
- " INNER JOIN TP_MST_User worker\n" +
- " ON worker.UserID = inpb.Userid\n" +
- " INNER JOIN TP_PC_Procedure pro\n" +
- " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
- " INNER JOIN TP_MST_GMouldType gmt\n" +
- " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
- " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
- " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
- //" INNER JOIN TP_PM_GroutingDaily gd\n" +
- //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
- " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
- " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
- //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
- //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
- " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
- " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
- " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
- " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
- " LEFT JOIN TP_MST_Logo logo\n" +
- " ON inpb.logoid = logo.logoid\n" +
- " LEFT JOIN TP_MST_Goods Goods\n" +
- " ON inpb.GoodsID = Goods.GoodsID\n" +
- " WHERE inpb.AccountID = :AccountID" +
- " AND inpb.BackupMonth = :BackupMonth" +
- " ORDER BY pro.displayno,inpb.proceduretime";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new Oracle.DataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
- new Oracle.DataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
- };
- oracleConn.Open();
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- oracleConn.Close();
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 产成品单值明细表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- string sql =
- "SELECT up.id, up.NAME\n" +
- " FROM tp_mst_unitprice up\n" +
- " WHERE up.accountid = :AccountID\n" +
- " AND up.valueflag = '1'\n" +
- " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
- " ORDER BY up.displayno";
- OracleParameter[] opara = new OracleParameter[]
- {
- new Oracle.DataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
- };
- DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
- StringBuilder upNames = new StringBuilder();
- StringBuilder upTotals = new StringBuilder();
- StringBuilder upSUMs = new StringBuilder();
- foreach (DataRow item in upTable.Rows)
- {
- upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
- upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
- upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
- }
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
- " ,g.goodscode\n" +
- " ,g.materialcode\n" +
- " ,lg.logoname\n" +
- " ,nvl(fpcount, 0) fpcount\n" +
- // " ,u1 AS \"单值1\"\n" +
- //" ,u2 AS \"单值2\"\n" +
- upNames +
- //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
- //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
- upTotals +
- " FROM (SELECT up.goodsid\n" +
- " ,up.logoid\n" +
- //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
- //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
- upSUMs +
- " FROM TP_MST_UnitPriceGoods up\n" +
- " WHERE up.accountid = :AccountID\n" +
- " GROUP BY up.goodsid, up.logoid) upg\n" +
- " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
- " FROM tp_pm_finishedproduct fp\n" +
- " WHERE fp.accountid = :AccountID\n" +
- " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
- " AND (:GoodsCode IS NULL OR\n" +
- " instr(fp.goodscode, :GoodsCode) > 0)\n" +
- " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
- " ON fpp.goodsid = upg.goodsid\n" +
- " AND fpp.logoid = upg.logoid\n" +
- " INNER JOIN tp_mst_logo lg\n" +
- " ON lg.logoid = upg.logoid\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = upg.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON gt.goodstypeid = g.goodstypeid\n" +
- " INNER JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.accountid = :AccountID\n" +
- " AND length(gt2.goodstypecode) = 6\n" +
- " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
- " WHERE (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
- " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
- " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
- " ORDER BY g.goodscode, lg.displayno";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new Oracle.DataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
- new Oracle.DataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
- };
- oracleConn.Open();
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Close();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 产成品单值明细表-单值名管理
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
- " FROM TP_MST_UnitPrice t\n" +
- " WHERE t.accountid = :accountid\n" +
- " ORDER BY t.id";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new Oracle.DataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- };
- oracleConn.Open();
- sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- oracleConn.Close();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 产成品单值明细表-单值名管理
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- // 检验参数的有效性
- if (cre.Data == null && cre.Data.Tables.Count == 0 ||
- cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
- {
- return sre;
- }
- oracleTrConn.Connect();
- foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
- {
- // 新建
- if (dataRow.RowState == DataRowState.Added)
- {
- #region 新增
- string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
- " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
- "VALUES\n" +
- " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
- new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
- new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
- new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
- };
- oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
- #endregion
- }
- else if (dataRow.RowState == DataRowState.Modified)
- {
- #region 更新
- string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
- + " Name = :Name,"
- + " DisplayNo = :DisplayNo,"
- + " ValueFlag = :ValueFlag,"
- + " UpdateUserID = :UserID"
- + " WHERE ID = :ID";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
- new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
- new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
- new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
- new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
- };
- oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
- #endregion
- }
- else if (dataRow.RowState == DataRowState.Deleted)
- {
- #region 删除
- string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
- };
- oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
- #endregion
- }
- }
- oracleTrConn.Commit();
- oracleTrConn.Disconnect();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleTrConn.ConnState == ConnectionState.Open)
- {
- oracleTrConn.Rollback();
- oracleTrConn.Disconnect();
- }
- throw ex;
- }
- finally
- {
- if (oracleTrConn.ConnState == ConnectionState.Open)
- {
- oracleTrConn.Disconnect();
- }
- }
- }
- /// <summary>
- /// 获取模具跟踪表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取模具收发存汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
- new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
- new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
- new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取废弃产品汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
- new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
- new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
- new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取废品损失汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
- new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取废品损失汇总-明细表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
- new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取废品损失汇总表-半成品损失汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
- new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- StringBuilder cols = new StringBuilder();
- StringBuilder sumCols = new StringBuilder();
- foreach (DataRow item in result.Tables[0].Rows)
- {
- cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
- sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
- }
- string sqlString = "SELECT gid\n" +
- " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
- " ,decode(gid, 0, td2name, '--') td2name\n" +
- " ,gg.gc\n" +
- " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
- " ,d\n" +
- " ,c\n" +
- " ,d-c g\n" +
- cols +
- " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
- " ,nvl(t.tecdepid, -1) gt2id\n" +
- " ,t.tecdepname gt2name\n" +
- " ,td2.name td2name\n" +
- " ,td2.displayno td2displayno\n" +
- " ,SUM(g.d) d\n" +
- " ,SUM(g.c) c\n" +
- sumCols +
- " FROM TMP_RPT_TECDEP_G g\n" +
- " INNER JOIN TMP_RPT_TECDEP_T t\n" +
- " ON g.goodsid = t.goodsid\n" +
- " INNER JOIN tmp_rpt_tecdep_s s1\n" +
- " ON s1.procedureid = g.pid\n" +
- " INNER JOIN tp_mst_tecdep td1\n" +
- " ON td1.id = s1.intecdepid\n" +
- " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
- " ON s2.procedureid = g.f\n" +
- " LEFT JOIN tp_mst_tecdep td2\n" +
- " ON td2.id = s2.intecdepid\n" +
- " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
- " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
- " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
- " ORDER BY t.tecdepname, td2.displayno) tt\n" +
- " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
- " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN TMP_RPT_TECDEP_T t\n" +
- " ON gdd.goodsid = t.goodsid\n" +
- " WHERE gdd.accountid = :in_accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
- " :in_datetimeend\n" +
- " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
- " ON gg.gt2id = tt.gt2id\n" +
- " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
- oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- };
- result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取成型存坯汇总表-注浆产品存坯汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- /*
- string sqlString =
- "SELECT gdrd.goodsid\n" +
- " ,gdrd.goodscode\n" +
- //" ,gdrd.groutinglineid\n" +
- //" ,gdrd.groutinglinecode\n" +
- //" ,gdrd.userid\n" +
- //" ,gdrd.usercode\n" +
- " ,gdrd.gddc rdcount -- 存坯数\n" +
- " ,rdd.gldcount -- 模具数\n" +
- " , CASE\n" +
- " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
- " round(gdrd.gddc / rdd.gldcount, 2)\n" +
- " ELSE\n" +
- " NULL\n" +
- " END rddays -- 存坯天数\n" +
- " ,gdrd.reserveddays -- 应存天数\n" +
- " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
- " FROM (SELECT gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- //" ,gdd.groutinglineid\n" +
- //" ,gdd.groutinglinecode\n" +
- //" ,gdd.userid\n" +
- //" ,gdd.usercode\n" +
- " ,g.reserveddays\n" +
- " ,COUNT(*) gddc\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON g.goodstypeid = gt.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " AND gdd.scrapflag = '0'\n" +
- " AND gdd.deliverflag = '0'\n" +
- " AND (:LineCode IS NULL OR\n" +
- " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
- " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
- " AND (:DateBegin IS NULL OR\n" +
- " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
- " GROUP BY gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- //" ,gdd.groutinglineid\n" +
- //" ,gdd.groutinglinecode\n" +
- //" ,gdd.userid\n" +
- //" ,gdd.usercode\n" +
- " ,g.reserveddays) gdrd\n" +
- " LEFT JOIN (SELECT gld.goodsid\n" +
- //" ,gld.groutinglineid\n" +
- " ,COUNT(*) gldcount\n" +
- " FROM tp_pc_groutinglinedetail gld\n" +
- " INNER JOIN tp_pc_groutingline gl\n" +
- " ON gl.groutinglineid = gld.groutinglineid\n" +
- " WHERE gld.valueflag = '1'\n" +
- " AND gld.gmouldstatus = 1\n" +
- " AND gl.accountid = :accountid\n" +
- " AND gl.valueflag = '1'\n" +
- " AND gl.gmouldstatus = 1\n" +
- " GROUP BY gld.goodsid\n" +
- //" ,gld.groutinglineid\n" +
- " ) rdd\n" +
- " ON rdd.goodsid = gdrd.goodsid\n" +
- //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
- " ORDER BY gdrd.goodscode\n" +
- //" ,gdrd.groutinglinecode, gdrd.usercode"
- "";
- */
- string sqlString =
- "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
- " ,t.goodstypecode2\n" +
- " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
- " 3,\n" +
- " '总计',\n" +
- " 1,\n" +
- " '合计[' || t.goodstypename2 || ']',\n" +
- " t.goodstypename2) goodstypename2\n" +
- " ,t.goodsid\n" +
- " ,t.goodscode\n" +
- //" ,t.groutinglineid\n" +
- //" ,t.groutinglinecode\n" +
- //" ,t.userid\n" +
- //" ,t.usercode\n" +
- " ,SUM(t.rdcount) rdcount\n" +
- " ,t.gldcount -- 模具数\n" +
- " ,t.rddays -- 存坯天数\n" +
- " ,t.reserveddays -- 应存天数\n" +
- " ,SUM(t.ProfitNum) ProfitNum\n" +
- " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gdrd.goodsid\n" +
- " ,gdrd.goodscode\n" +
- //" ,gdrd.groutinglineid\n" +
- //" ,gdrd.groutinglinecode\n" +
- //" ,gdrd.userid\n" +
- //" ,gdrd.usercode\n" +
- " ,gdrd.gddc rdcount -- 存坯数\n" +
- " ,rdd.gldcount -- 模具数\n" +
- " , CASE\n" +
- " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
- " round(gdrd.gddc / rdd.gldcount, 2)\n" +
- " ELSE\n" +
- " NULL\n" +
- " END rddays -- 存坯天数\n" +
- " ,gdrd.reserveddays -- 应存天数\n" +
- // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
- " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
- " FROM (SELECT gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- //" ,gdd.groutinglineid\n" +
- //" ,gdd.groutinglinecode\n" +
- //" ,gdd.userid\n" +
- //" ,gdd.usercode\n" +
- " ,g.reserveddays\n" +
- " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
- " ,COUNT(*) gddc\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON g.goodstypeid = gt.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " AND gdd.scrapflag = '0'\n" +
- " AND gdd.deliverflag = '0'\n" +
- " AND (:LineCode IS NULL OR\n" +
- " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
- " AND (:UserCode IS NULL OR\n" +
- " instr(gdd.UserCode, :UserCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR\n" +
- " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
- " AND (:DateBegin IS NULL OR\n" +
- " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
- " GROUP BY gt.goodstypecode\n" +
- " ,gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- //" ,gdd.groutinglineid\n" +
- //" ,gdd.groutinglinecode\n" +
- //" ,gdd.userid\n" +
- //" ,gdd.usercode\n" +
- " ,g.reserveddays) gdrd\n" +
- " LEFT JOIN (SELECT gld.goodsid\n" +
- //" ,gld.groutinglineid\n" +
- " ,COUNT(*) gldcount\n" +
- " FROM tp_pc_groutinglinedetail gld\n" +
- " INNER JOIN tp_pc_groutingline gl\n" +
- " ON gl.groutinglineid = gld.groutinglineid\n" +
- " WHERE gld.valueflag = '1'\n" +
- " AND gld.gmouldstatus = 1\n" +
- " AND gl.accountid = :accountid\n" +
- " AND gl.valueflag = '1'\n" +
- " AND gl.gmouldstatus = 1\n" +
- " GROUP BY gld.goodsid\n" +
- //" , gld.groutinglineid" +
- " ) rdd\n" +
- " ON rdd.goodsid = gdrd.goodsid\n" +
- //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
- " INNER JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.accountid = :accountid\n" +
- " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
- " ORDER BY gt2.goodstypecode\n" +
- " ,gdrd.goodscode\n" +
- //" ,gdrd.groutinglinecode\n" +
- //" ,gdrd.usercode" +
- " ) t\n" +
- " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
- new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
- };
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取成型存坯汇总表-成型工号存坯汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- /*
- string sqlString =
- "SELECT gdrd.goodsid\n" +
- " ,gdrd.goodscode\n" +
- " ,gdrd.groutinglineid\n" +
- " ,gdrd.groutinglinecode\n" +
- " ,gdrd.userid\n" +
- " ,gdrd.usercode\n" +
- " ,gdrd.gddc rdcount -- 存坯数\n" +
- " ,rdd.gldcount -- 模具数\n" +
- " , CASE\n" +
- " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
- " round(gdrd.gddc / rdd.gldcount, 2)\n" +
- " ELSE\n" +
- " NULL\n" +
- " END rddays -- 存坯天数\n" +
- " ,gdrd.reserveddays -- 应存天数\n" +
- " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
- " FROM (SELECT gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.groutinglineid\n" +
- " ,gdd.groutinglinecode\n" +
- " ,gdd.userid\n" +
- " ,gdd.usercode\n" +
- " ,g.reserveddays\n" +
- " ,COUNT(*) gddc\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON g.goodstypeid = gt.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " AND gdd.scrapflag = '0'\n" +
- " AND gdd.deliverflag = '0'\n" +
- " AND (:LineCode IS NULL OR\n" +
- " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
- " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
- " AND (:DateBegin IS NULL OR\n" +
- " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
- " GROUP BY gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.groutinglineid\n" +
- " ,gdd.groutinglinecode\n" +
- " ,gdd.userid\n" +
- " ,gdd.usercode\n" +
- " ,g.reserveddays) gdrd\n" +
- " LEFT JOIN (SELECT gld.goodsid\n" +
- " ,gld.groutinglineid\n" +
- " ,COUNT(*) gldcount\n" +
- " FROM tp_pc_groutinglinedetail gld\n" +
- " INNER JOIN tp_pc_groutingline gl\n" +
- " ON gl.groutinglineid = gld.groutinglineid\n" +
- " WHERE gld.valueflag = '1'\n" +
- " AND gld.gmouldstatus = 1\n" +
- " AND gl.accountid = :accountid\n" +
- " AND gl.valueflag = '1'\n" +
- " AND gl.gmouldstatus = 1\n" +
- " GROUP BY gld.goodsid\n" +
- " ,gld.groutinglineid\n" +
- " ) rdd\n" +
- " ON rdd.goodsid = gdrd.goodsid\n" +
- " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
- " ORDER BY gdrd.goodscode\n" +
- " ,gdrd.groutinglinecode, gdrd.usercode" +
- "";
- */
- string sqlString =
- "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
- " ,t.goodstypecode2\n" +
- " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
- " 3,\n" +
- " '总计',\n" +
- " 1,\n" +
- " '合计[' || t.goodstypename2 || ']',\n" +
- " t.goodstypename2) goodstypename2\n" +
- " ,t.goodsid\n" +
- " ,t.goodscode\n" +
- " ,t.groutinglineid\n" +
- " ,t.groutinglinecode\n" +
- " ,t.userid\n" +
- " ,t.usercode\n" +
- " ,SUM(t.rdcount) rdcount\n" +
- " ,t.gldcount -- 模具数\n" +
- " ,t.rddays -- 存坯天数\n" +
- " ,t.reserveddays -- 应存天数\n" +
- " ,SUM(t.ProfitNum) ProfitNum\n" +
- " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
- " ,gt2.goodstypename goodstypename2\n" +
- " ,gdrd.goodsid\n" +
- " ,gdrd.goodscode\n" +
- " ,gdrd.groutinglineid\n" +
- " ,gdrd.groutinglinecode\n" +
- " ,gdrd.userid\n" +
- " ,gdrd.usercode\n" +
- " ,gdrd.gddc rdcount -- 存坯数\n" +
- " ,rdd.gldcount -- 模具数\n" +
- " , CASE\n" +
- " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
- " round(gdrd.gddc / rdd.gldcount, 2)\n" +
- " ELSE\n" +
- " NULL\n" +
- " END rddays -- 存坯天数\n" +
- " ,gdrd.reserveddays -- 应存天数\n" +
- " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
- " FROM (SELECT gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.groutinglineid\n" +
- " ,gdd.groutinglinecode\n" +
- " ,gdd.userid\n" +
- " ,gdd.usercode\n" +
- " ,g.reserveddays\n" +
- " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
- " ,COUNT(*) gddc\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON g.goodstypeid = gt.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " AND gdd.scrapflag = '0'\n" +
- " AND gdd.deliverflag = '0'\n" +
- " AND (:LineCode IS NULL OR\n" +
- " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
- " AND (:UserCode IS NULL OR\n" +
- " instr(gdd.UserCode, :UserCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR\n" +
- " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
- " AND (:DateBegin IS NULL OR\n" +
- " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
- " GROUP BY gt.goodstypecode\n" +
- " ,gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- " ,gdd.groutinglineid\n" +
- " ,gdd.groutinglinecode\n" +
- " ,gdd.userid\n" +
- " ,gdd.usercode\n" +
- " ,g.reserveddays) gdrd\n" +
- " LEFT JOIN (SELECT gld.goodsid\n" +
- " ,gld.groutinglineid\n" +
- " ,COUNT(*) gldcount\n" +
- " FROM tp_pc_groutinglinedetail gld\n" +
- " INNER JOIN tp_pc_groutingline gl\n" +
- " ON gl.groutinglineid = gld.groutinglineid\n" +
- " WHERE gld.valueflag = '1'\n" +
- " AND gld.gmouldstatus = 1\n" +
- " AND gl.accountid = :accountid\n" +
- " AND gl.valueflag = '1'\n" +
- " AND gl.gmouldstatus = 1\n" +
- " GROUP BY gld.goodsid, gld.groutinglineid) rdd\n" +
- " ON rdd.goodsid = gdrd.goodsid\n" +
- " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
- " INNER JOIN tp_mst_goodstype gt2\n" +
- " ON gt2.accountid = :accountid\n" +
- " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
- " ORDER BY gt2.goodstypecode\n" +
- " ,gdrd.goodscode\n" +
- " ,gdrd.groutinglinecode\n" +
- " ,gdrd.usercode) t\n" +
- " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2, t.goodsid, t.goodscode, t.groutinglineid, t.groutinglinecode, t.userid, t.usercode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
- new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
- };
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 获取成型存坯汇总表-成型存坯明细表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "SELECT gdd.barcode\n" +
- //" ,gdd.groutinglineid\n" +
- " ,gdd.groutinglinecode\n" +
- " ,gdd.GroutingMouldCode\n" +
- //" ,gdd.goodsid\n" +
- " ,gdd.goodscode\n" +
- //" ,gdd.userid\n" +
- " ,gdd.usercode\n" +
- " ,gdd.groutingdate\n" +
- " FROM tp_pm_groutingdailydetail gdd\n" +
- " INNER JOIN tp_mst_goods g\n" +
- " ON g.goodsid = gdd.goodsid\n" +
- " INNER JOIN tp_mst_goodstype gt\n" +
- " ON g.goodstypeid = gt.goodstypeid\n" +
- " WHERE gdd.accountid = :accountid\n" +
- " AND gdd.valueflag = '1'\n" +
- " AND gdd.groutingflag = '1'\n" +
- " AND gdd.barcode IS NOT NULL\n" +
- " AND gdd.scrapflag = '0'\n" +
- " AND gdd.deliverflag = '0'\n" +
- " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
- " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
- " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
- " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
- " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
- " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
- " AND (:GoodsTypeCode IS NULL OR\n" +
- " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
- " AND (:DateBegin IS NULL OR\n" +
- " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
- " ORDER BY gdd.barcode\n" +
- //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
- "";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
- new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
- new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
- new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
- new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
- new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
- };
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 年度各工序月产量统计表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
- string sqlString = "select gt2.goodstypecode\n" +
- " ,nvl2(gt2.goodstypename\n" +
- " ,nvl2(t.procedureid\n" +
- " ,gt2.goodstypename\n" +
- " ,'小计[' || gt2.goodstypename || ']')\n" +
- " ,'总计') goodstypename\n" +
- " ,p.displayno\n" +
- " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
- " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
- " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
- " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
- " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
- " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
- " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
- " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
- " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
- " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
- " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
- " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
- " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
- " ,sum(t.pcount) msum\n" +
- " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
- " gt.goodstypecode\n" +
- " ,0 procedureid\n" +
- " ,to_char(pd.groutingdate, 'mm') mm\n" +
- " ,count(*) pcount\n" +
- " from tp_pm_groutingdailydetail pd\n" +
- " inner join tp_mst_goods g\n" +
- " on g.goodsid = pd.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " where pd.accountid = :accountid\n" +
- " and pd.groutingflag = '1'\n" +
- " and pd.groutingdate >= :begindate\n" +
- " and pd.groutingdate < :enddate\n" +
- " group by --substr(gt.goodstypecode, 1, 6)\n" +
- " gt.goodstypecode\n" +
- " ,to_char(pd.groutingdate, 'mm')\n" +
- " union all\n" +
- " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
- " gt.goodstypecode\n" +
- " ,pd.procedureid\n" +
- " ,to_char(pd.createtime, 'mm') mm\n" +
- " ,count(*) pcount\n" +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_mst_goods g\n" +
- " on g.goodsid = pd.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " where pd.accountid = :accountid\n" +
- " and pd.createtime >= :begindate\n" +
- " and pd.createtime < :enddate\n" +
- (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
- " group by --substr(gt.goodstypecode, 1, 6)\n" +
- " gt.goodstypecode\n" +
- " ,pd.procedureid\n" +
- " ,to_char(pd.createtime, 'mm')" +
- " union all\n" +
- " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
- " gt.goodstypecode\n" +
- " ,pd.procedureid\n" +
- " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
- " ,count(*) pcount\n" +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_mst_goods g\n" +
- " on g.goodsid = pd.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " where pd.accountid = :accountid\n" +
- " and pd.valueflag = '0'\n" +
- " and pd.BACKOUTTIME >= :begindate\n" +
- " and pd.BACKOUTTIME < :enddate\n" +
- (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
- " group by --substr(gt.goodstypecode, 1, 6)\n" +
- " gt.goodstypecode\n" +
- " ,pd.procedureid\n" +
- " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on gt2.accountid = 1\n" +
- " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
- " left join tp_pc_procedure p\n" +
- " on p.procedureid = t.procedureid\n" +
- " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
- new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
- };
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- oracleConn?.Close();
- }
- }
- /// <summary>
- /// 半检返修缺陷汇总表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "select dp.defectpositionid\n" +
- " ,dp.defectpositioncode\n" +
- " ,dp.defectpositionname\n" +
- " ,'D_' || dp.defectpositionid colname\n" +
- " from tp_mst_scdefectposition dp\n" +
- " where dp.valueflag = '1'\n" +
- " and dp.accountid = " + sUserInfo.AccountID + "\n";
- if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
- {
- sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
- }
- sqlString += " order by dp.displayno";
- DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
- if (scdTable == null || scdTable.Rows.Count == 0)
- {
- return sre;
- }
- List<string> pivotFor = new List<string>();
- foreach (DataRow item in scdTable.Rows)
- {
- pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
- }
- List<OracleParameter> oracleParameters = new List<OracleParameter>();
- oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
- sqlString = "select *\n" +
- " from (select srd.defectid\n" +
- " ,scd.defectcode\n" +
- " ,scd.defectname\n" +
- " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
- " ,count(srd.semireworkdefectid) cc\n" +
- " from TP_PM_SEMIREWORKDEFECT srd\n" +
- " inner join TP_PM_SEMIREWORK sr\n" +
- " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
- " left join tp_mst_semicheckdefect scd\n" +
- " on scd.defectid = srd.defectid\n" +
- " left join tp_mst_scdefectposition scdp\n" +
- " on scdp.defectpositionid = srd.defectpositionid\n" +
- " where srd.valueflag = '1'\n" +
- " and sr.BACKOUTFLAG = '0'\n" +
- " and sr.valueflag = '1'\n" +
- " and sr.accountid = :accountid\n";
- // 半检日期
- if (cre.Properties["SemireWorkTimeBegin"] != null)
- {
- sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
- oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
- }
- if (cre.Properties["SemireWorkTimeEnd"] != null)
- {
- sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
- oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
- }
- // 产品编码 GOODSCODE
- if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
- {
- sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
- oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
- }
- // 成型工号 GROUTINGUSERCODE
- if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
- {
- //xuwei modify 2019-11-13
- //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
- sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
- //xuwei end
- oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
- }
- // 半检工号 SEMIREWORKUSERCODE
- if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
- {
- //xuwei modify 2019-11-13
- //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
- sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
- //xuwei end
- oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
- }
- // 缺陷位置 scdp.defectpositionname
- if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
- {
- sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
- oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
- }
- if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
- {
- sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
- oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
- }
- // 缺陷名称 scd.defectname
- if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
- {
- sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
- oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
- }
- // 缺陷名称 scd.defectcode
- if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
- {
- sqlString += " and instr(scd.defectcode,:defectcode) > 0 \n";
- oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
- }
- sqlString +=
- " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid))) t\n" +
- "pivot(sum(cc)\n" +
- " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
- " order by defectid";
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- DataTable table = result.Tables[0];
- DataRow dataRow = table.Rows[table.Rows.Count - 1];
- dataRow["defectname"] = "合计";
- foreach (DataRow item in scdTable.Rows)
- {
- string colname = item["colname"] + "";
- if (table.Columns.Contains(colname))
- {
- if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
- {
- table.Columns.Remove(colname);
- }
- else
- {
- table.Columns[colname].Caption = item["defectpositionname"] + "";
- }
- }
- }
- table.Columns["D_0"].Caption = "合计";
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- oracleConn?.Close();
- }
- }
- /// <summary>
- /// 模具注浆分析表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
- new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
- new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
- new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 成检产品预算分析表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
- new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
- new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
- new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
- new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
- new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
- new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
- new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
- new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
- };
- DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 成检产品预算分析表-设置
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
- " FROM tp_qco_prosetting s\n" +
- " LEFT JOIN tp_pc_procedure p\n" +
- " ON s.procedureid = p.procedureid\n" +
- " WHERE s.accountid = :accountid";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- };
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
- " FROM tp_mst_kiln k\n" +
- " WHERE k.accountid = :accountid\n" +
- " AND k.valueflag = '1'";
- DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
- result.Tables.Add(dt);
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 成检产品预算分析表-设置
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- OracleParameter[] oracleParameter = null;
- string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
- "where s.accountid=:accountid and s.settingkey=:settingkey";
- foreach (DataRow item in cre.Data.Tables[0].Rows)
- {
- oracleParameter = new OracleParameter[]
- {
- new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
- new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
- new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
- };
- oracleConn.ExecuteNonQuery(sql, oracleParameter);
- }
- sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
- "where k.accountid=:accountid and k.kilnid=:kilnid";
- foreach (DataRow item in cre.Data.Tables[1].Rows)
- {
- oracleParameter = new OracleParameter[]
- {
- new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
- new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
- };
- oracleConn.ExecuteNonQuery(sql, oracleParameter);
- }
- oracleConn.Commit();
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Disconnect();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 各工序质量表-恒洁三水
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- int p1ID = 11; // 成检交接工序
- int p2ID = 12; // 成检登记工序
- string gtcode2 = cre.Properties["gtcode2"] + "";
- if (gtcode2 != "001001" && gtcode2 != "001002")
- {
- gtcode2 = "[ALL]";
- }
- // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
- // goodsleveltypeid 次品 7
- string sqlString = "select t.*\n" +
- " ,gt.goodstypename\n" +
- " ,nvl(outk.outkcount, 0) outkcount\n" +
- " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
- " ,decode(nvl(outk.outkcount, 0)\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
- " nvl(outk.outkcount, 0)\n" +
- " ,4)) ccp\n" +
- " from (select 10 pcode\n" +
- " ,'成型' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 交坯、干补\n" +
- //" and dd.defectprocedureid in (1, 17, 18)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (89,90,91,92,93,94,95,96,105,106,124,125,134,135,136,137,138,139,140,157,158,159,133,181,166,164,171,142,181))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (89,90,91,92,93,94,95,96,105,106,124,125,134,135,136,137,138,139,140,151,157,158,159,133,133,192,166,164,168,155,172,173,174,180,181))\n" +
- " )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 20 pcode\n" +
- " ,'改洗' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 改洗、吹风\n" +
- //" and dd.defectprocedureid in (2, 62)\n" +
- ////" -- 除不平\n" +
- //" and dd.defectid not in (91, 240)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
- " )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 30 pcode\n" +
- " ,'二检' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 二检\n" +
- //" and dd.defectprocedureid in (61)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
- " )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 40 pcode\n" +
- " ,'施釉' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 施釉\n" +
- //" and dd.defectprocedureid in (3, 4)\n" +
- ////" -- 除铁、铜脏\n" +
- //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (353,354,117,146,153,130,119,147,196,197,118,198,355,357,170,199,120,148,175,120,197,197,128,345,347,349,540,353,398,399))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (117,146,153,130,119,147,196,197,118,198,355,357,170,199,120,148,175,154,162,121,128,345,347,349,353,398,399))\n" +
- " )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 50 pcode\n" +
- " ,'刮登' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 登窑、入窑、卸窑\n" +
- //" and dd.defectprocedureid in (5, 9, 10)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (131,221,223,156,126,132,222,129,150,178,179,122,188,219,220,225,229,227))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (131,221,156,126,132,222,129,150,179,122,188,189,219,220,225,229))\n" +
- " )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 60 pcode\n" +
- " ,'烧成' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
- //" and dd.defectid in (385\n" +
- //" ,203\n" +
- //" ,836\n" +
- //" ,234\n" +
- //" ,384\n" +
- //" ,202\n" +
- //" ,835\n" +
- //" ,390\n" +
- //" ,818\n" +
- //" ,389\n" +
- //" ,204\n" +
- //" ,814\n" +
- //" ,837\n" +
- //" ,387)\n" +
- " and dd.defectid in (234,385,386,387,388,389,390)\n" +
- //" and ((gt2.goodstypecode='001001' and dd.defectid in (131,221,223,156,126,132,222,129,150,178,179,122,188,219,220,225,229,227))\n" +
- //" or (gt2.goodstypecode='001002' and dd.defectid in (131,221,156,126,132,222,129,150,179,122,188,189,219,220,225,229))\n" +
- //" )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 70 pcode\n" +
- " ,'杂锈点' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
- //" and dd.defectid in\n" +
- //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
- " and dd.defectid in (170,389,398,399)\n" +
- //" and ((gt2.goodstypecode='001001' and dd.defectid in (131,221,223,156,126,132,222,129,150,178,179,122,188,219,220,225,229,227))\n" +
- //" or (gt2.goodstypecode='001002' and dd.defectid in (131,221,156,126,132,222,129,150,179,122,188,189,219,220,225,229))\n" +
- //" )\n" +
- " group by gt2.goodstypecode\n" +
- " union all\n" +
- " select 80 pcode\n" +
- " ,'其他' pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and dd.procedureid = :p2ID\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n" +
- ////" -- 成检撞伤、炸坯、炸裂\n" +
- //" and dd.defectid in (393, 180, 394, 395)\n" +
- " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
- " )\n" +
- " group by gt2.goodstypecode) t\n" +
- " left join (select gt2.goodstypecode gtcode2\n" +
- " ,count(*) outkcount\n" +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_mst_goods g\n" +
- " on pd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.accountid = :accountid\n" +
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and pd.procedureid = :p1ID\n" +
- " and pd.createtime >= :timebegin\n" +
- " and pd.createtime < :timeend\n" +
- " group by gt2.goodstypecode) outk\n" +
- " on t.gtcode2 = outk.gtcode2\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypecode = t.gtcode2\n" +
- " and gt.accountid = :accountid\n" +
- " order by t.pcode, t.gtcode2";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
- new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
- new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
- new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
- new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
- };
- ServiceResultEntity sre = new ServiceResultEntity();
- sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
- {
- sre.Data.Tables[0].TableName = "S";
- cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
- cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
- cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
- ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
- if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
- {
- sre1.Data.Tables[0].TableName = "D";
- sre.Data.Merge(sre1.Data.Tables[0]);
- }
- }
- sqlString =
- "select t.gtcode2\n" +
- " ,nvl(t.gtname2, '合计') gtname2\n" +
- " ,sum(t.outk) outk\n" +
- " ,sum(t.cipin) cipin\n" +
- " ,sum(t.outk) - sum(t.cipin) hege\n" +
- " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
- " from (select gt2.goodstypecode gtcode2\n" +
- " ,gt2.goodstypename gtname2\n" +
- " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
- " ,nvl(sum(case\n" +
- " when pd.procedureid = :p2ID and\n" +
- " pd.goodsleveltypeid in (6, 7) then\n" +
- " 1\n" +
- " else\n" +
- " 0\n" +
- " end)\n" +
- " ,0) cipin\n" +
- " from tp_pm_productiondata pd\n" +
- " inner join tp_mst_goods g\n" +
- " on pd.goodsid = g.goodsid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on g.goodstypeid = gt.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on length(gt2.goodstypecode) = 6\n" +
- " and gt2.accountid = gt.accountid\n" +
- " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
- " where pd.valueflag = '1'\n" +
- " and pd.accountid = :accountid\n" +
- " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
- " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
- //" and pd.checktime > date '2018-01-01'\n" +
- " and pd.checktime >= :timebegin\n" +
- " and pd.checktime < :timeend\n" +
- " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
- " group by grouping sets((t.gtcode2, t.gtname2),())";
- oracleParameter = new OracleParameter[]
- {
- new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
- new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
- new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
- new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
- new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
- };
- DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
- alldata.TableName = "A";
- DataTable data = sre.Data.Tables[0];
- foreach (DataRow item in alldata.Rows)
- {
- data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
- }
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 各工序质量表-缺陷明细-恒洁三水
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- //int p1ID = 11; // 成检交接工序
- int p2ID = 12; // 成检登记工序
- int pcode = Convert.ToInt32(cre.Properties["pcode"]);
- string sqlString =
- "select :pcode pcode\n" +
- " ,:pname pname\n" +
- " ,gt2.goodstypecode gtcode2\n" +
- " ,gt2.goodstypename gtname2\n" +
- " ,dd.defectcode\n" +
- " ,dd.defectname\n" +
- " ,count(*) defectcount\n" +
- " from tp_pm_defect dd\n" +
- //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
- " inner join tp_mst_goods g\n" +
- " on dd.goodsid = g.goodsid\n" +
- " inner join tp_pm_productiondata pd\n" +
- " on dd.productiondataid = pd.productiondataid\n" +
- " inner join tp_mst_goodstype gt\n" +
- " on gt.goodstypeid = g.goodstypeid\n" +
- " inner join tp_mst_goodstype gt2\n" +
- " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
- " and gt2.accountid = :accountid\n" +
- " where dd.valueflag = '1'\n" +
- " and dd.accountid = :accountid\n" +
- " and pd.goodsleveltypeid = 7\n" + // 次品
- " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
- " and dd.procedureid = :p2ID\n" +
- " and gt2.goodstypecode = :gtcode2\n" +
- " and dd.checktime >= :timebegin\n" +
- " and dd.checktime < :timeend\n";
- switch (pcode)
- {
- case 10:
- ////" -- 交坯、干补\n" +
- //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
- sqlString +=
- " and ((gt2.goodstypecode='001001' and dd.defectid in (89,90,91,92,93,94,95,96,105,106,124,125,134,135,136,137,138,139,140,157,158,159,133,181,166,164,171,142,181))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (89,90,91,92,93,94,95,96,105,106,124,125,134,135,136,137,138,139,140,151,157,158,159,133,133,192,166,164,168,155,172,173,174,180,181))\n" +
- " )\n";
- break;
- case 20:
- sqlString +=
- ////" -- 改洗、吹风\n" +
- //" and dd.defectprocedureid in (2, 62)\n" +
- ////" -- 除不平\n" +
- //" and dd.defectid not in (91, 240)\n";
- " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
- " )\n";
- break;
- case 30:
- sqlString +=
- ////" -- 二检\n" +
- //" and dd.defectprocedureid in (61)\n";
- " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
- " )\n";
- break;
- case 40:
- sqlString +=
- ////" -- 施釉\n" +
- //" and dd.defectprocedureid in (3, 4)\n" +
- ////" -- 除铁、铜脏\n" +
- //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
- " and ((gt2.goodstypecode='001001' and dd.defectid in (353,354,117,146,153,130,119,147,196,197,118,198,355,357,170,199,120,148,175,120,197,197,128,345,347,349,540,353,398,399))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (117,146,153,130,119,147,196,197,118,198,355,357,170,199,120,148,175,154,162,121,128,345,347,349,353,398,399))\n" +
- " )\n";
- break;
- case 50:
- sqlString +=
- ////" -- 登窑、入窑、卸窑\n" +
- //" and dd.defectprocedureid in (5, 9, 10)\n";
- " and ((gt2.goodstypecode='001001' and dd.defectid in (131,221,223,156,126,132,222,129,150,178,179,122,188,219,220,225,229,227))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (131,221,156,126,132,222,129,150,179,122,188,189,219,220,225,229))\n" +
- " )\n";
- break;
- case 60:
- sqlString +=
- ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
- //" and dd.defectid in (385\n" +
- //" ,203\n" +
- //" ,836\n" +
- //" ,234\n" +
- //" ,384\n" +
- //" ,202\n" +
- //" ,835\n" +
- //" ,390\n" +
- //" ,818\n" +
- //" ,389\n" +
- //" ,204\n" +
- //" ,814\n" +
- //" ,837\n" +
- //" ,387)\n";
- " and dd.defectid in (234,385,386,387,388,389,390)\n";
- break;
- case 70:
- sqlString +=
- ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
- //" and dd.defectid in\n" +
- //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
- " and dd.defectid in (170,389,398,399)\n";
- break;
- case 80:
- sqlString +=
- ////" -- 成检撞伤、炸坯、炸裂\n" +
- //" and dd.defectid in (393, 180, 394, 395)\n";
- " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
- " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
- " )\n";
- break;
- default:
- break;
- }
- sqlString +=
- " group by gt2.goodstypecode\n" +
- " ,gt2.goodstypename\n" +
- " ,dd.defectcode\n" +
- " ,dd.defectname\n" +
- " order by dd.defectcode";
- OracleParameter[] oracleParameter = new OracleParameter[]
- {
- new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
- //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
- new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
- new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
- new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
- new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
- new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
- new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
- };
- ServiceResultEntity sre = new ServiceResultEntity();
- sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
- return sre;
- }
- catch (Exception ex)
- {
- if (oracleConn.ConnState == ConnectionState.Open)
- {
- oracleConn.Close();
- }
- throw ex;
- }
- }
- /// <summary>
- /// 综合合格率分析表-半成品报废率分析表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- List<OracleParameter> oracleParameters = new List<OracleParameter>();
- oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
- string sqlString = "select g.goodscode\n" +
- " ,tt.d_num\n" +
- " ,tt.b_num\n" +
- " ,tt.f_num\n" +
- " ,tt.s_num\n" +
- " ,decode(tt.d_num\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
- " from (select t.goodsid\n" +
- " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
- " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
- " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
- " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
- " from (select gdd.goodsid\n" +
- " ,'A' numtype\n" +
- " ,count(gdd.groutingdailydetailid) id_num\n" +
- " from tp_pm_groutingdailydetail gdd\n" +
- " where gdd.groutingflag = '1'\n" +
- " and gdd.valueflag = '1'\n" +
- " and gdd.accountid = :accountid\n" +
- " and gdd.deliverflag = '1'\n" +
- " and gdd.delivertime >= :datebegin\n" +
- " and gdd.delivertime < :dateend\n" +
- " group by gdd.goodsid\n" +
- " union all\n" +
- " -- 半检不合格数 复检不合格数 损坯数\n" +
- " select sp.goodsid\n" +
- " ,sp.SCRAPTYPE numtype\n" +
- " ,count(sp.scrapproductid) id_num\n" +
- " from tp_pm_scrapproduct sp\n" +
- " where sp.valueflag = '1'\n" +
- " and sp.accountid = :accountid\n" +
- " and sp.auditstatus = 1\n" +
- " and sp.KILNID is null\n" +
- " and sp.SCRAPTYPE <> '1'\n" +
- " and sp.AUDITDATE >= :datebegin\n" +
- " and sp.AUDITDATE < :dateend\n" +
- " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
- " group by t.goodsid) tt\n" +
- " inner join tp_mst_goods g\n" +
- " on tt.goodsid = g.goodsid\n" +
- " order by g.goodscode";
- oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
- oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
- //// 产品编码 GOODSCODE
- //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
- //{
- // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
- // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
- //}
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- oracleConn?.Close();
- }
- }
- /// <summary>
- /// 综合合格率分析表-综合优等率分析表
- /// </summary>
- /// <param name="cre"></param>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
- {
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- try
- {
- ServiceResultEntity sre = new ServiceResultEntity();
- List<OracleParameter> oracleParameters = new List<OracleParameter>();
- oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
- string sqlString = "\n" +
- "select g.goodscode\n" +
- " ,pp.b_out_num\n" +
- " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
- " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
- " ,decode(pp.b_out_num\n" +
- " ,0\n" +
- " ,to_number(null)\n" +
- " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
- " pp.b_out_num,4)) zh_r\n" +
- " from (select p.goodsid\n" +
- " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
- " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
- " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
- " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
- " from tp_pm_productiondata p\n" +
- " where p.valueflag = '1'\n" +
- " and p.accountid = :accountid\n" +
- " and (p.procedureid in (11, 58) or\n" +
- " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
- " and p.createtime >= :datebegin\n" +
- " and p.createtime < :dateend\n" +
- " group by p.goodsid) pp\n" +
- " inner join tp_mst_goods g\n" +
- " on g.goodsid = pp.goodsid\n" +
- " order by g.goodscode";
- oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
- oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
- //// 产品编码 GOODSCODE
- //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
- //{
- // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
- // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
- //}
- DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- return sre;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- oracleConn?.Close();
- }
- }
- #region 产成品交接撤销汇总表
- /// <summary>
- /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlString = "SELECT TS.GID,\n" +
- " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
- " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
- " GOODSCOUNT\n" +
- " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
- " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
- " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
- " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
- " FROM TP_PM_FHUNDO F\n" +
- " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
- " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
- " LEFT JOIN TP_MST_GOODS G\n" +
- " ON G.GOODSID = GDD.GOODSID\n" +
- " WHERE F.ACCOUNTID = :AccountID\n";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- // 撤销时间
- if (orderEntity.UndoTimeStart != null)
- {
- sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
- parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
- {
- sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
- }
- sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
- " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
- " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
- ServiceResultEntity sre = new ServiceResultEntity();
- DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- /// <summary>
- /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
- /// </summary>
- /// <param name="user">登录用户信息</param>
- /// <param name="se">查询条件</param>
- /// <returns>查询结果</returns>
- public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
- {
- IDBConnection conn = null;
- try
- {
- conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
- string sqlString = "SELECT O.ORDERNO,\n" +
- " F.FHTIME,\n" +
- " F.FHUSERCODE,\n" +
- " GDD.BARCODE,\n" +
- " GOODS.GOODSCODE,\n" +
- " L.LOGONAME,\n" +
- " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
- " GDD.GROUTINGLINECODE,\n" +
- " GDD.GROUTINGMOULDCODE,\n" +
- " GDD.GROUTINGDATE,\n" +
- " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
- //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
- " nvl(GDD.outlabelcode, GOODS.MATERIALCODE || (select a.workcode from tp_mst_account a where a.accountid = gdd.accountid) || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
- " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
- " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
- " FROM TP_PM_FHUNDO F\n" +
- " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
- " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
- " LEFT JOIN TP_PM_ORDER O\n" +
- " ON F.FHORDERID = O.ORDERID\n" +
- " LEFT JOIN TP_MST_LOGO L\n" +
- " ON GDD.LOGOID = L.LOGOID\n" +
- " LEFT JOIN TP_MST_GOODS GOODS\n" +
- " ON GDD.GOODSID = GOODS.GOODSID\n" +
- " LEFT JOIN TP_MST_USER UNDOUSER\n" +
- " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
- " WHERE F.ACCOUNTID = :AccountID";
- List<OracleParameter> parameters = new List<OracleParameter>();
- parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
- // 撤销时间
- if (orderEntity.UndoTimeStart != null)
- {
- sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
- parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
- parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
- }
- // 产品型号
- if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
- {
- sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
- parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
- }
- ServiceResultEntity sre = new ServiceResultEntity();
- DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
- if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
- {
- sre.Status = Constant.ServiceResultStatus.NoSearchResults;
- }
- sre.Data = result;
- return sre;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- if (conn != null &&
- conn.ConnState == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- }
- #endregion
- }
- }
|