ReportModuleLogic.cs 778 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:ReportModuleLogic.cs
  5. * 2.功能描述:生产线报表分析
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/11/08 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using Oracle.ManagedDataAccess.Client;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DataAccess;
  17. using Dongke.IBOSS.PRD.Service.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.ReportModule;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  21. using Dongke.WinForm.Utilities;
  22. namespace Dongke.IBOSS.PRD.Service.ReportModuleLogic
  23. {
  24. /// <summary>
  25. /// 生产线报表分析
  26. /// </summary>
  27. public class ReportModuleLogic
  28. {
  29. #region 综合报表
  30. #region 跟踪统计表
  31. #region 生产管理
  32. /// <summary>
  33. /// 产品跟踪明细查询
  34. /// </summary>
  35. /// <param name="searchGoodsFollowingEntity">产品跟踪统计实体类</param>
  36. /// <param name="sUserInfo">用户基本信息</param>
  37. /// <returns>DataSet</returns>
  38. public static DataSet GetSearchGoodsFollowingDetailModule(SearchGoodsFollowingEntity searchGoodsFollowingEntity, SUserInfo sUserInfo)
  39. {
  40. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  41. try
  42. {
  43. con.Open();
  44. OracleParameter[] paras = new OracleParameter[]{
  45. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  46. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  47. };
  48. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetRPTDetailData", paras);
  49. return dsSearchReport;
  50. }
  51. catch (Exception ex)
  52. {
  53. throw ex;
  54. }
  55. finally
  56. {
  57. if (con.ConnState == ConnectionState.Open)
  58. {
  59. con.Close();
  60. }
  61. }
  62. }
  63. #endregion
  64. #endregion
  65. #endregion
  66. #region 统一使用ServiceResultEntity类模式
  67. #region 跟踪报表
  68. /// <summary>
  69. /// 取得RPT020101_1画面(产品跟踪)的查询数据
  70. /// </summary>
  71. /// <param name="user">登录用户信息</param>
  72. /// <param name="se">查询条件</param>
  73. /// <returns>查询结果</returns>
  74. public static ServiceResultEntity GetRPT020101SData(SUserInfo user, RPT020101_SE se)
  75. {
  76. IDBConnection conn = null;
  77. try
  78. {
  79. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  80. OracleParameter[] paras = new OracleParameter[]{
  81. new OracleParameter("in_barCode",OracleDbType.Varchar2,se.Barcode,ParameterDirection.Input),
  82. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  83. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  84. new OracleParameter("out_result1",OracleDbType.RefCursor,ParameterDirection.Output),
  85. };
  86. //DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  87. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetGoodsFollowingData", paras);
  88. ServiceResultEntity sre = new ServiceResultEntity();
  89. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  90. {
  91. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  92. return sre;
  93. }
  94. sre.Data = new DataSet();
  95. sre.Data = data;
  96. return sre;
  97. }
  98. catch (Exception ex)
  99. {
  100. throw ex;
  101. }
  102. finally
  103. {
  104. if (conn != null &&
  105. conn.ConnState == ConnectionState.Open)
  106. {
  107. conn.Close();
  108. }
  109. }
  110. }
  111. #endregion
  112. #region 明细报表
  113. /// <summary>
  114. /// 取得RPT010101_1画面(注浆明细表)的查询数据
  115. /// </summary>
  116. /// <param name="user">登录用户信息</param>
  117. /// <param name="se">查询条件</param>
  118. /// <returns>查询结果</returns>
  119. public static ServiceResultEntity GetRPT010101SData(SUserInfo user, RPT010101_SE se)
  120. {
  121. IDBConnection conn = null;
  122. try
  123. {
  124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  125. List<OracleParameter> parameters = new List<OracleParameter>();
  126. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010101SSQL());
  127. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  128. if (se != null)
  129. {
  130. // 成型线类型ids
  131. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  132. {
  133. sql.Append("AND instr(','||:GMouldTypeIDS||',',','||TP_MST_GMouldType.gMouldTypeId||',')>0 ");
  134. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  135. }
  136. // 成型线IDS
  137. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  138. {
  139. sql.Append("AND instr(','||:GroutingLineIDS||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  140. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  141. }
  142. // 产品IDS
  143. if (!string.IsNullOrEmpty(se.GoodsIDS))
  144. {
  145. sql.Append("AND instr(','||:GoodsIDS||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  146. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  147. }
  148. // 产品类别IDS
  149. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  150. {
  151. // sql.Append("AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ");
  152. sql.Append("AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ");
  153. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  154. }
  155. // 模具号
  156. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  157. {
  158. sql.Append("AND instr(TP_PM_GroutingDailyDetail.GroutingMouldCode,:GroutingMouldCode)>0 ");
  159. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  160. }
  161. // 注浆时间-开始
  162. if (se.GroutingDateStart.HasValue)
  163. {
  164. sql.Append("AND TP_PM_GroutingDailyDetail.GroutingDate >= :GroutingDateStart ");
  165. parameters.Add(new OracleParameter(":GroutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  166. }
  167. // 模具类型IDS
  168. if (se.GroutingDateEnd.HasValue)
  169. {
  170. sql.Append("AND TP_PM_GroutingDailyDetail.GroutingDate <= :GroutingDateEnd ");
  171. parameters.Add(new OracleParameter(":GroutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  172. }
  173. if (se.GroutingBatchNo.HasValue)
  174. {
  175. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingBatchNo = :GroutingBatchNo");
  176. sql.Append(" AND instr(TP_PM_GroutingDailyDetail.GroutingBatchNo,:GroutingBatchNo)>0");
  177. parameters.Add(new OracleParameter(":GroutingBatchNo", OracleDbType.Int32, se.GroutingBatchNo, ParameterDirection.Input));
  178. }
  179. // 成型工号IDS
  180. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  181. {
  182. sql.Append("and instr(',' || :GroutingUserIDS || ',' ,','||TP_PM_GroutingDailyDetail.UserID||',' )>0 ");
  183. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.Clob, se.GroutingUserIDS, ParameterDirection.Input));
  184. }
  185. // 未注浆原因
  186. if (!string.IsNullOrEmpty(se.NoGroutingRreason))
  187. {
  188. sql.Append("AND instr(b.dictionaryvalue,:NoGroutingRreason)>0 ");
  189. parameters.Add(new OracleParameter(":NoGroutingRreason", OracleDbType.NVarchar2, se.NoGroutingRreason, ParameterDirection.Input));
  190. }
  191. // 生产工号IDS
  192. if (!string.IsNullOrEmpty(se.CreateUserIDS))
  193. {
  194. sql.Append("and instr(',' || :CreateUserIDS || ',' ,','||TP_PM_GroutingDailyDetail.CreateUserID||',' )>0 ");
  195. parameters.Add(new OracleParameter(":CreateUserIDS", OracleDbType.NVarchar2, se.CreateUserIDS, ParameterDirection.Input));
  196. }
  197. // 备注
  198. if (!string.IsNullOrEmpty(se.Remarks))
  199. {
  200. sql.Append(" AND INSTR(TP_PM_GroutingDailyDetail.Remarks, :Remarks) > 0");
  201. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  202. }
  203. // 注浆标识
  204. if (!string.IsNullOrEmpty(se.GroutingFlag))
  205. {
  206. sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingFlag = :GroutingFlag");
  207. parameters.Add(new OracleParameter(":GroutingFlag", OracleDbType.Char, se.GroutingFlag, ParameterDirection.Input));
  208. }
  209. // 损坯标识
  210. if (!string.IsNullOrEmpty(se.ScrapFlag))
  211. {
  212. sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapFlag = :ScrapFlag");
  213. parameters.Add(new OracleParameter(":ScrapFlag", OracleDbType.Char, se.ScrapFlag, ParameterDirection.Input));
  214. }
  215. // 绑定条码
  216. if (!string.IsNullOrEmpty(se.BarCodeFlag))
  217. {
  218. if ("1" == se.BarCodeFlag)
  219. {
  220. sql.Append(" AND LENGTH(TP_PM_GroutingDailyDetail.BarCode) > 0");
  221. }
  222. else
  223. {
  224. sql.Append(" AND (TP_PM_GroutingDailyDetail.BarCode IS NULL OR LENGTH(TP_PM_GroutingDailyDetail.BarCode) = 0)");
  225. }
  226. }
  227. // 交坯日期-开始
  228. if (se.DeliverTimeBegin.HasValue)
  229. {
  230. sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverTime >= :DeliverTimeBegin");
  231. parameters.Add(new OracleParameter(":DeliverTimeBegin", OracleDbType.Date, se.DeliverTimeBegin.Value, ParameterDirection.Input));
  232. }
  233. // 交坯日期-结束
  234. if (se.DeliverTimeEnd.HasValue)
  235. {
  236. sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverTime <= :DeliverTimeEnd");
  237. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.DeliverTimeEnd.Value, ParameterDirection.Input));
  238. }
  239. // 交坯标识
  240. if (!string.IsNullOrEmpty(se.DeliverFlag))
  241. {
  242. sql.Append(" AND TP_PM_GroutingDailyDetail.DeliverFlag = :DeliverFlag");
  243. parameters.Add(new OracleParameter(":DeliverFlag", OracleDbType.Char, se.DeliverFlag, ParameterDirection.Input));
  244. }
  245. // 损坯日期-开始
  246. if (se.ScrapTimeBegin.HasValue)
  247. {
  248. sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapTime >= :ScrapTimeBegin");
  249. parameters.Add(new OracleParameter(":ScrapTimeBegin", OracleDbType.Date, se.ScrapTimeBegin.Value, ParameterDirection.Input));
  250. }
  251. // 损坯日期-结束
  252. if (se.ScrapTimeEnd.HasValue)
  253. {
  254. sql.Append(" AND TP_PM_GroutingDailyDetail.ScrapTime <= :ScrapTimeEnd");
  255. parameters.Add(new OracleParameter(":ScrapTimeEnd", OracleDbType.Date, se.ScrapTimeEnd.Value, ParameterDirection.Input));
  256. }
  257. // 注浆操作时间-开始
  258. if (se.GCTimeBegin.HasValue)
  259. {
  260. sql.Append(" AND TP_PM_GroutingDailyDetail.CreateTime >= :GCTimeBegin");
  261. parameters.Add(new OracleParameter(":GCTimeBegin", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  262. }
  263. // 注浆操作时间-结束
  264. if (se.GCTimeEnd.HasValue)
  265. {
  266. sql.Append(" AND TP_PM_GroutingDailyDetail.CreateTime <= :GCTimeEnd");
  267. parameters.Add(new OracleParameter(":GCTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  268. }
  269. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingLineID in(Select PurviewID from TP_MST_UserPurview where PurviewType= 5 and UserID = :UserID) ");
  270. 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))");
  271. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  272. }
  273. sql.Append(" order by TP_PM_GroutingDailyDetail.GroutingDate desc, ");
  274. sql.Append(" TP_PM_GroutingDailyDetail.GroutingLineCode, ");
  275. sql.Append(" TP_PM_GroutingDailyDetail.GroutingBatchNo, ");
  276. sql.Append(" TP_PM_GroutingDailyDetail.GroutingMouldCode");
  277. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  278. ServiceResultEntity sre = new ServiceResultEntity();
  279. if (data == null || data.Rows.Count == 0)
  280. {
  281. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  282. return sre;
  283. }
  284. sre.Data = new DataSet();
  285. sre.Data.Tables.Add(data);
  286. return sre;
  287. }
  288. catch (Exception ex)
  289. {
  290. throw ex;
  291. }
  292. finally
  293. {
  294. if (conn != null &&
  295. conn.ConnState == ConnectionState.Open)
  296. {
  297. conn.Close();
  298. }
  299. }
  300. }
  301. /// <summary>
  302. /// 获取RPT010101_1画面(注浆明细表)的查询sql
  303. /// </summary>
  304. /// <returns>sql</returns>
  305. private static string GetRPT010101SSQL()
  306. {
  307. string selSql =
  308. "select " +
  309. " TP_PM_GroutingDailyDetail.GroutingDate, " +
  310. " TP_PM_GroutingDailyDetail.GroutingBatchNo, " +
  311. " TP_PM_GroutingDailyDetail.GroutingLineCode, " +
  312. " TP_MST_GMouldType.Gmouldtypename, " +
  313. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  314. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  315. " TP_MST_GOODS.GOODSSPECIFICATION, " +
  316. " TP_PM_GroutingDailyDetail.GroutingMouldCode, " +
  317. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  318. " TP_PM_GroutingDailyDetail.Groutingcount, " +
  319. " TP_PM_GroutingDailyDetail.Barcode, " +
  320. " tp_mst_user.UserCode CreateUserCode, " +
  321. " tp_mst_user.username CreateUserName, " +
  322. " TP_PM_GroutingDailyDetail.UserCode, " +
  323. " TP_PM_GroutingDailyDetail.SCRAPFLAG, " +
  324. " TP_PM_GroutingDailyDetail.GoodsName, " +
  325. " TP_PM_GroutingDailyDetail.GROUTINGFLAG, " +
  326. " TP_PM_GroutingDailyDetail.GMOULDSTATUS, " +
  327. " TP_PM_GroutingDailyDetail.DeliverTime, " +
  328. " TP_PM_GroutingDailyDetail.DeliverFlag, " +
  329. " tp_sys_gmouldstatus.gmouldstatusname, " +
  330. " b.dictionaryvalue AS NoGroutingRreason, " +
  331. " TP_PM_GroutingDailyDetail.SCRAPTIME, " +
  332. " TP_PM_GroutingDailyDetail.CreateTime GCTime, " +
  333. " mu.usercode MONITORCODE, " +
  334. " mu.username MONITORNAME, " +
  335. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  336. "from TP_PM_GroutingDailyDetail " +
  337. "inner join TP_PM_GroutingDaily gd on gd.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID " +
  338. "left join tp_mst_user mu on mu.userid = gd.MONITORID " +
  339. "inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID " +
  340. "inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID " +
  341. "inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_GroutingDailyDetail.GoodsID " +
  342. "inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.Glazetypeid " +
  343. "inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  344. "inner join tp_sys_gmouldstatus on TP_PM_GroutingDailyDetail.gmouldstatus = tp_sys_gmouldstatus.gmouldstatusid " +
  345. "left join tp_mst_user on TP_PM_GroutingDailyDetail.CreateUserID=tp_mst_user.userid " +
  346. "left join TP_MST_DataDictionary b on TP_PM_GroutingDailyDetail.NoGroutingRreason=b.DictionaryID " +
  347. "left join TP_MST_logo on TP_PM_GroutingDailyDetail.logoid=TP_MST_logo.logoid " +
  348. "Where 1=1 " +
  349. "and TP_PM_GroutingDailyDetail.Valueflag=1 " +
  350. "and TP_PM_GroutingDailyDetail.AccountID=:AccountID ";
  351. return selSql;
  352. }
  353. /// <summary>
  354. /// 取得RPT010102_1画面(半检明细表)的查询数据
  355. /// </summary>
  356. /// <param name="user">登录用户信息</param>
  357. /// <param name="se">查询条件</param>
  358. /// <returns>查询结果</returns>
  359. public static ServiceResultEntity GetRPT010102SData(SUserInfo user, RPT010102_SE se)
  360. {
  361. IDBConnection conn = null;
  362. try
  363. {
  364. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  365. OracleParameter[] paras = new OracleParameter[]{
  366. new OracleParameter("in_goodsID",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  367. new OracleParameter("in_testUserID",OracleDbType.Varchar2,se.TestUserIDS,ParameterDirection.Input),
  368. new OracleParameter("in_groutingUserID",OracleDbType.Varchar2,se.GroutingUserIDS,ParameterDirection.Input),
  369. new OracleParameter("in_goodsTypeID",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  370. new OracleParameter("in_semiTestTypeID",OracleDbType.Varchar2,se.semiTestTypeID,ParameterDirection.Input),
  371. new OracleParameter("in_remarks",OracleDbType.Varchar2,se.Remarks,ParameterDirection.Input),
  372. new OracleParameter("in_semiTestDateStart",OracleDbType.Varchar2,se.SemiTestDateStart,ParameterDirection.Input),
  373. new OracleParameter("in_semiTestDateEnd",OracleDbType.Varchar2,se.SemiTestDateEnd,ParameterDirection.Input),
  374. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  375. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  376. };
  377. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetSemiTestDetail", paras);
  378. ServiceResultEntity sre = new ServiceResultEntity();
  379. if (data == null || data.Tables.Count == 0)
  380. {
  381. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  382. return sre;
  383. }
  384. sre.Data = new DataSet();
  385. sre.Data = data;
  386. return sre;
  387. }
  388. catch (Exception ex)
  389. {
  390. throw ex;
  391. }
  392. finally
  393. {
  394. if (conn != null &&
  395. conn.ConnState == ConnectionState.Open)
  396. {
  397. conn.Close();
  398. }
  399. }
  400. }
  401. /// <summary>
  402. /// 取得RPT010103画面(交坯明细表)的查询数据
  403. /// </summary>
  404. /// <param name="user">登录用户信息</param>
  405. /// <param name="se">查询条件</param>
  406. /// <returns>查询结果</returns>
  407. public static ServiceResultEntity GetRPT010103SData(SUserInfo user, RPT010103_SE se)
  408. {
  409. IDBConnection conn = null;
  410. try
  411. {
  412. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  413. List<OracleParameter> parameters = new List<OracleParameter>();
  414. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010103SSQL());
  415. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  416. // parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  417. if (se != null)
  418. {
  419. //成型线IDS
  420. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  421. {
  422. sql.Append(" and instr(','||:GroutingLineIDS||',',','||pd.GroutingLineID||',')>0 ");
  423. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  424. }
  425. // 成型线类别
  426. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  427. {
  428. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||gt.GMouldTypeID||',')>0 ");
  429. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  430. }
  431. // 交坯日期-开始
  432. if (se.CreateTimeBegin.HasValue)
  433. {
  434. sql.Append(" AND pd.CreateTime >= :CreateTimeBegin ");
  435. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.CreateTimeBegin.Value, ParameterDirection.Input));
  436. }
  437. // 交坯日期-结束
  438. if (se.CreateTimeEnd.HasValue)
  439. {
  440. sql.Append(" AND pd.CreateTime <= :CreateTimeEnd ");
  441. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  442. }
  443. // 注浆模具编号
  444. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  445. {
  446. //sql.Append(" AND INSTR(','||:GroutingMouldCode||',',','||pd.GroutingMouldCode||',') > 0 ");
  447. sql.Append(" AND INSTR(pd.GroutingMouldCode,:GroutingMouldCode) > 0 ");
  448. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  449. }
  450. //产品IDS
  451. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  452. {
  453. // sql.Append(" and instr(','||:GoodsTypeIDS||',',','||gdt.GoodsTypeCode||',')=1");
  454. sql.Append("AND instr(gdt.GoodsTypeCode,:GoodsTypeIDS)=1 ");
  455. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  456. }
  457. //产品类别IDS
  458. if (!string.IsNullOrEmpty(se.GoodsIDS))
  459. {
  460. sql.Append(" and instr(','||:GoodsIDS||',',','||pd.goodsid||',')>0");
  461. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  462. }
  463. // 备注
  464. if (!string.IsNullOrEmpty(se.Remarks))
  465. {
  466. sql.Append(" AND INSTR(pd.Remarks, :Remarks) > 0");
  467. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  468. }
  469. // 注浆工号
  470. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  471. {
  472. sql.Append(" AND INSTR( ','||:GroutingUserCode||',',','||pd.GroutingUserCode||',') > 0");
  473. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  474. }
  475. // 条码
  476. if (!string.IsNullOrEmpty(se.BarCode))
  477. {
  478. //sql.Append(" AND INSTR(','||:BarCode||',',','||pd.BarCode||',') > 0");
  479. sql.Append(" AND INSTR(pd.BarCode,:BarCode) > 0");
  480. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  481. }
  482. // 生产工号和注浆工号不同
  483. if (se.ProdUserIsGroutingUserFlag == 1)
  484. {
  485. sql.Append(" and pd.usercode<>pd.GroutingUserCode");
  486. }
  487. }
  488. sql.Append(" ORDER BY pd.CreateTime, pd.GroutingLineCode, pd.GroutingMouldCode");
  489. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  490. ServiceResultEntity sre = new ServiceResultEntity();
  491. if (data == null || data.Rows.Count == 0)
  492. {
  493. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  494. return sre;
  495. }
  496. sre.Data = new DataSet();
  497. sre.Data.Tables.Add(data);
  498. return sre;
  499. }
  500. catch (Exception ex)
  501. {
  502. throw ex;
  503. }
  504. finally
  505. {
  506. if (conn != null &&
  507. conn.ConnState == ConnectionState.Open)
  508. {
  509. conn.Close();
  510. }
  511. }
  512. }
  513. /// <summary>
  514. /// 获取RPT010103画面(交坯明细表)的查询sql
  515. /// </summary>
  516. /// <returns>sql</returns>
  517. private static string GetRPT010103SSQL()
  518. {
  519. string selSql =
  520. "select "
  521. //---产品条码
  522. + "pd.barcode, "
  523. //注浆时间
  524. + "pd.groutingdate,"
  525. //交坯时间
  526. + "pd.CreateTime,"
  527. //---产品类别
  528. + "g.GoodsTypeID,"
  529. //---产品类别编码
  530. + "gdt.GoodsTypeCode,"
  531. //---产品类别名称
  532. + "gdt.GoodsTypeName,"
  533. //----产品ID
  534. + "pd.goodsid,"
  535. //----产品编码
  536. + "pd.goodscode,"
  537. //----产品名称
  538. + "pd.goodsname,"
  539. //----规格
  540. + "g.GoodsSpecification,"
  541. //----釉色类别ID
  542. + "g.GlazeTypeID,"
  543. //----釉色类别描述
  544. + "dd.dictionaryvalue as GlazeTypeName,"
  545. //----注浆模具
  546. + "pd.GroutingMouldCode,"
  547. //---生产线号
  548. + "pd.ProductionLineID,"
  549. //---成型线编码
  550. + "pd.ProductionLineCode,"
  551. //---成型线名称
  552. + "pd.ProductionLineName,"
  553. //---成型线号Id
  554. + " pd.GroutingLineID,"
  555. //---成型线号
  556. + " pd.GroutingLineCode,"
  557. //---成型线类型ID
  558. + "gt.GMouldTypeID,"
  559. //---成型线类型
  560. + "gt.GMouldTypeName,"
  561. //---生产工号
  562. + "pd.UserID,"
  563. //---生产工号用户编号
  564. + "u.usercode,"
  565. //----注浆工号
  566. + "pd.GroutingUserID,"
  567. //---注浆工号用户编号
  568. + "pd.GroutingUserCode, "
  569. //--公坯标识
  570. + " pd.ISPUBLICBODY, "
  571. //--注浆次数
  572. + " gdd.GROUTINGCOUNT, "
  573. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  574. //--查油工号
  575. + " , uc.usercode check1 "
  576. //生产数据
  577. + "from TP_PM_PRODUCTIONDATA pd "
  578. //注浆明细
  579. + " inner join TP_PM_GROUTINGDAILYDETAIL gdd on pd.GROUTINGDAILYDETAILID=gdd.GROUTINGDAILYDETAILID "
  580. //模具类型
  581. + "inner join TP_MST_GMouldType gt "
  582. + "on pd.GMOULDTYPEID=gt.GMouldTypeID "
  583. //产品档案
  584. + "inner join TP_MST_Goods g "
  585. + "on pd.goodsid=g.goodsid "
  586. //数据字典,TPC002为釉色类别
  587. + "inner join TP_MST_DataDictionary dd "
  588. //
  589. + "on dd.DictionaryType = 'TPC002' "
  590. //
  591. + "and dd.dictionaryid= g.GlazeTypeID "
  592. //用户信息
  593. + "inner join tp_mst_user u "
  594. + "on pd.userid=u.userid "
  595. + "inner join tp_mst_user uc "
  596. + "on pd.createuserid=uc.userid "
  597. //
  598. + "inner join TP_MST_GoodsType gdt "
  599. + "on g.GoodsTypeID=gdt.GoodsTypeID "
  600. + "inner join TP_MST_logo "
  601. + "on gdd.logoid=TP_MST_logo.logoid "
  602. // 交坯
  603. + " WHERE pd.modeltype=5 "
  604. // 账套
  605. + " and pd.AccountID=:AccountID"
  606. + " and pd.ValueFlag='" + (int)Constant.ValueFlag.Effective + "'";
  607. //成型线查看权限
  608. //+ " and exists (select up.PurviewID "
  609. //+ " from TP_MST_UserPurview up where up.PurviewType='"
  610. //+ (int)Constant.PurviewType.ViewGroutingLine
  611. //+ "' and up.PurviewID=pd.GroutingLineID "
  612. //+ " and up.UserId=:UPUserId)";
  613. return selSql;
  614. }
  615. /// <summary>
  616. /// 取得RPT010105画面(成型线模具使用明细表)的查询数据
  617. /// </summary>
  618. /// <param name="user">登录用户信息</param>
  619. /// <param name="se">查询条件</param>
  620. /// <returns>查询结果</returns>
  621. public static ServiceResultEntity GetRPT010105SData(SUserInfo user, RPT010105_SE se)
  622. {
  623. IDBConnection conn = null;
  624. try
  625. {
  626. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  627. string sqlString =
  628. "SELECT t.groutinglinecode\n" +
  629. " ,gl.BuildingNo\n" +
  630. " ,gl.FloorNo\n" +
  631. " ,gl.GroutingLineNo\n" +
  632. " ,t.usercode\n" +
  633. " ,t.goodscode\n" +
  634. " ,t.GOODSSPECIFICATION\n" +
  635. " ,t.goodstypename\n" +
  636. " ,t.MouldQuantity\n" +
  637. " ,gld.groutingmouldcode\n" +
  638. " ,gms.gmouldstatusname\n" +
  639. " ,gld.beginuseddate\n" +
  640. " ,(SELECT MIN(ggg.groutingdate)\n" +
  641. " FROM tp_pm_groutingdailydetail ggg\n" +
  642. " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
  643. " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
  644. " ,SUM(t.groutingflag) sumgroutingcount\n" +
  645. " ,MAX(t.GroutingCount) maxGroutingCount\n" +
  646. " ,gld.groutingcount\n" +
  647. " FROM (SELECT gd.groutinglinecode\n" +
  648. " ,gd.usercode\n" +
  649. " ,gdd.goodsid\n" +
  650. " ,gd.MouldQuantity\n" +
  651. " ,gdd.groutinglinedetailid\n" +
  652. " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
  653. " ,gdd.GroutingCount\n" +
  654. " ,gt.goodstypename\n" +
  655. " ,g.goodscode\n" +
  656. " ,g.GOODSSPECIFICATION\n" +
  657. " FROM TP_PM_GroutingDaily gd\n" +
  658. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  659. " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  660. " INNER JOIN TP_MST_Goods g\n" +
  661. " ON g.goodsid = gdd.goodsid\n" +
  662. " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  663. " ON gt.goodstypeid = g.goodstypeid\n" +
  664. " WHERE gd.accountid = :AccountID\n" +
  665. " AND gd.groutingdate >= :GDateBegin\n" +
  666. " AND gd.groutingdate <= :GDateEnd\n" +
  667. " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  668. " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  669. " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  670. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  671. " ) t\n" +
  672. " INNER JOIN tp_pc_groutinglinedetail gld\n" +
  673. " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
  674. " INNER JOIN tp_pc_groutingline gl\n" +
  675. " ON gld.groutinglineid = gl.groutinglineid\n" +
  676. " INNER JOIN TP_SYS_GMouldStatus gms\n" +
  677. " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
  678. " GROUP BY t.groutinglinecode\n" +
  679. " ,gl.BuildingNo\n" +
  680. " ,gl.FloorNo\n" +
  681. " ,gl.GroutingLineNo\n" +
  682. " ,t.usercode\n" +
  683. " ,t.goodscode\n" +
  684. " ,t.GOODSSPECIFICATION\n" +
  685. " ,t.goodstypename\n" +
  686. " ,t.MouldQuantity\n" +
  687. " ,gld.groutingmouldcode\n" +
  688. " ,gms.gmouldstatusname\n" +
  689. " ,gld.beginuseddate\n" +
  690. " ,gld.groutingcount\n" +
  691. " ,t.groutinglinedetailid\n" +
  692. " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
  693. List<OracleParameter> parameters = new List<OracleParameter>();
  694. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  695. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  696. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  697. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  698. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  699. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  700. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  701. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  702. ServiceResultEntity sre = new ServiceResultEntity();
  703. if (data == null || data.Rows.Count == 0)
  704. {
  705. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  706. return sre;
  707. }
  708. sre.Data = new DataSet();
  709. sre.Data.Tables.Add(data);
  710. return sre;
  711. }
  712. catch (Exception ex)
  713. {
  714. throw ex;
  715. }
  716. finally
  717. {
  718. if (conn != null &&
  719. conn.ConnState == ConnectionState.Open)
  720. {
  721. conn.Close();
  722. }
  723. }
  724. }
  725. /// <summary>
  726. /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
  727. /// </summary>
  728. /// <param name="user">登录用户信息</param>
  729. /// <param name="se">查询条件</param>
  730. /// <returns>查询结果</returns>
  731. public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
  732. {
  733. IDBConnection conn = null;
  734. try
  735. {
  736. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  737. string sqlString =
  738. "SELECT gl.buildingno\n" +
  739. " ,gl.floorno\n" +
  740. " ,gl.groutinglineno\n" +
  741. " ,gl.groutinglinecode\n" +
  742. " ,gl.Remarks\n" +
  743. " ,decode(UserCount,\n" +
  744. " 1,\n" +
  745. " mu.usercode,\n" +
  746. " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
  747. " FROM tp_pc_groutinguser gu\n" +
  748. " INNER JOIN tp_mst_user gmu\n" +
  749. " ON gmu.userid = gu.userid\n" +
  750. " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
  751. " ,g.goodscode\n" +
  752. " ,g.goodsspecification\n" +
  753. " ,gt.goodstypename\n" +
  754. " --,gl.mouldquantity\n" +
  755. " ,gldd.mouldquantity\n" +
  756. " ,gmt.gmouldtypename\n" +
  757. " ,gms.gmouldstatusname\n" +
  758. " ,gldd.beginuseddate -- 上模日期\n" +
  759. " ,gldd.groutingdate -- 首次注浆日期\n" +
  760. " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
  761. " ,gldd.groutingcount -- 最大注浆次数\n" +
  762. " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
  763. " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
  764. " ,gldd.sumgroutingcount -- 总注浆次数\n" +
  765. " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
  766. " ,round(decode(gl.mouldquantity,\n" +
  767. " 0,\n" +
  768. " 0,\n" +
  769. " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
  770. " gl.mouldquantity),\n" +
  771. " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
  772. " FROM tp_pc_groutingline gl\n" +
  773. " INNER JOIN (SELECT gld.groutinglineid\n" +
  774. " ,gld.goodsid\n" +
  775. " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
  776. " ,MIN(gld.beginuseddate) beginuseddate\n" +
  777. " ,MIN(gddd.groutingdate) groutingdate\n" +
  778. " /* ,(SELECT MIN(gdd.groutingdate)\n" +
  779. " FROM tp_pm_groutingdailydetail gdd\n" +
  780. " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  781. " AND gdd.groutingflag = '1') groutingdate*/\n" +
  782. " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  783. " ,MAX(gld.groutingcount) groutingcount\n" +
  784. " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
  785. " ,SUM(gld.groutingcount) sumgroutingcount\n" +
  786. " FROM tp_pc_groutinglinedetail gld\n" +
  787. " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
  788. " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  789. " -- AND gdd.groutingflag = '1'\n" +
  790. " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
  791. " ,gdd.mouldcode\n" +
  792. " ,MIN(gdd.groutingdate) groutingdate\n" +
  793. " FROM tp_pm_groutingdailydetail gdd\n" +
  794. " WHERE gdd.accountid = :AccountID\n" +
  795. " AND gdd.groutingflag = '1'\n" +
  796. " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
  797. " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  798. " AND gddd.mouldcode = gld.mouldcode\n" +
  799. " WHERE gld.valueflag = '1'\n" +
  800. " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
  801. " ON gldd.groutinglineid = gl.groutinglineid\n" +
  802. " INNER JOIN tp_mst_goods g\n" +
  803. " ON g.goodsid = gldd.goodsid\n" +
  804. " INNER JOIN tp_mst_goodstype gt\n" +
  805. " ON gt.goodstypeid = g.goodstypeid\n" +
  806. " INNER JOIN tp_mst_gmouldtype gmt\n" +
  807. " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
  808. " INNER JOIN tp_sys_gmouldstatus gms\n" +
  809. " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
  810. " INNER JOIN tp_mst_user mu\n" +
  811. " ON mu.userid = gl.userid\n" +
  812. " WHERE gl.accountid = :AccountID\n" +
  813. " AND gl.valueflag = '1'\n" +
  814. " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
  815. " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
  816. " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
  817. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  818. " ORDER BY gl.groutinglinecode, g.goodscode";
  819. List<OracleParameter> parameters = new List<OracleParameter>();
  820. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  821. parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
  822. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  823. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  824. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  825. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  826. ServiceResultEntity sre = new ServiceResultEntity();
  827. if (data == null || data.Rows.Count == 0)
  828. {
  829. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  830. return sre;
  831. }
  832. sre.Data = new DataSet();
  833. sre.Data.Tables.Add(data);
  834. return sre;
  835. }
  836. catch (Exception ex)
  837. {
  838. throw ex;
  839. }
  840. finally
  841. {
  842. if (conn != null &&
  843. conn.ConnState == ConnectionState.Open)
  844. {
  845. conn.Close();
  846. }
  847. }
  848. }
  849. /// <summary>
  850. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  851. /// </summary>
  852. /// <param name="user">登录用户信息</param>
  853. /// <param name="se">查询条件</param>
  854. /// <returns>查询结果</returns>
  855. public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
  856. {
  857. IDBConnection conn = null;
  858. try
  859. {
  860. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  861. List<OracleParameter> parameters = new List<OracleParameter>();
  862. // 校验时间--开始
  863. if (se.beginCreateTime.HasValue)
  864. {
  865. parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  866. }
  867. // 校验时间--结束
  868. if (se.endCreateTime.HasValue)
  869. {
  870. parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  871. }
  872. conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
  873. parameters.Clear();
  874. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
  875. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  876. ServiceResultEntity sre = new ServiceResultEntity();
  877. if (data == null || data.Rows.Count == 0)
  878. {
  879. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  880. return sre;
  881. }
  882. sre.Data = new DataSet();
  883. sre.Data.Tables.Add(data);
  884. return sre;
  885. }
  886. catch (Exception ex)
  887. {
  888. throw ex;
  889. }
  890. finally
  891. {
  892. if (conn != null &&
  893. conn.ConnState == ConnectionState.Open)
  894. {
  895. conn.Close();
  896. }
  897. }
  898. }
  899. /// <summary>
  900. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  901. /// </summary>
  902. /// <returns>sql</returns>
  903. private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  904. {
  905. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  906. #region
  907. /*
  908. selSql = selSql +
  909. "select * from (" +
  910. "select " +
  911. "MissProcedureID, " +
  912. "MissProcedureCode, " +
  913. "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
  914. "MissProcedureName, " +
  915. "MissID, " +
  916. "BarCode, " +
  917. "OrganizationID, " +
  918. "OrganizationName, " +
  919. "OrganizationCode, " +
  920. "OrganizationFullName, " +
  921. "CompleteProcedureID, " +
  922. "CompleteProcedureCode, " +
  923. "CompleteProcedureName, " +
  924. "ProcedureID, " +
  925. "ProcedureCode, " +
  926. "ProcedureName, " +
  927. "GoodsID, " +
  928. "GoodsCode, " +
  929. "GoodsName, " +
  930. "result.GoodsTypeID, " +
  931. "result.CreateTime, " +
  932. "result.GoodsTypeName, " +
  933. "UserName, " +
  934. "MissUserCode, " +
  935. "barcodecount, seqno " +
  936. "from " +
  937. " ( " +
  938. " select " +
  939. " MissProcedureID, " +
  940. " MissProcedureCode, " +
  941. " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
  942. " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
  943. " MissID, " +
  944. " BarCode, " +
  945. " OrganizationID, " +
  946. " OrganizationName, " +
  947. " OrganizationCode, " +
  948. " OrganizationFullName, " +
  949. " CompleteProcedureID, " +
  950. " CompleteProcedureCode, " +
  951. " CompleteProcedureName, " +
  952. " ProcedureID, " +
  953. " ProcedureCode, " +
  954. " ProcedureName, " +
  955. " GoodsID, " +
  956. " GoodsCode, " +
  957. " GoodsName, " +
  958. " GoodsTypeID, " +
  959. " CreateTime, " +
  960. " GoodsTypeName, " +
  961. " UserName, " +
  962. " MissUserCode, " +
  963. " barcodecount,rownum seqno " +
  964. " from " +
  965. " ( " +
  966. " select " +
  967. " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
  968. " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
  969. " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
  970. " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
  971. " decode(grouping(MissID),1,'--',MissID) MissID, " +
  972. " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
  973. " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
  974. " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
  975. " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
  976. " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
  977. " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
  978. " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
  979. " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
  980. " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
  981. " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
  982. " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
  983. " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
  984. " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
  985. " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
  986. " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
  987. " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
  988. " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
  989. " decode(grouping(UserName),1,'--',UserName) UserName, " +
  990. " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
  991. " count(barcode) barcodecount " +
  992. " from " +
  993. " ( " +
  994. " select TP_PM_BarCodeMissing.MissProcedureID, " +
  995. " TP_PM_BarCodeMissing.MissProcedureCode, " +
  996. " TP_PM_BarCodeMissing.MissProcedureName, " +
  997. " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
  998. " TP_PM_BarCodeMissing.MissID, " +
  999. " TP_PM_BarCodeMissing.BarCode, " +
  1000. " TP_PM_BarCodeMissing.OrganizationID, " +
  1001. " TP_PM_BarCodeMissing.OrganizationName, " +
  1002. " TP_PM_BarCodeMissing.OrganizationCode, " +
  1003. " TP_PM_BarCodeMissing.OrganizationFullName, " +
  1004. " TP_PM_BarCodeMissing.CompleteProcedureID, " +
  1005. " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
  1006. " TP_PM_BarCodeMissing.CompleteProcedureName, " +
  1007. " TP_PM_BarCodeMissing.ProcedureID, " +
  1008. " TP_PM_BarCodeMissing.ProcedureCode, " +
  1009. " TP_PM_BarCodeMissing.ProcedureName, " +
  1010. " TP_PM_BarCodeMissing.GoodsID, " +
  1011. " TP_PM_BarCodeMissing.GoodsCode, " +
  1012. " TP_PM_BarCodeMissing.GoodsName, " +
  1013. " TP_PM_BarCodeMissing.GoodsTypeID, " +
  1014. " TP_PM_BarCodeMissing.MissUserCode, " +
  1015. " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
  1016. " TP_MST_GoodsType.GoodsTypeName, " +
  1017. " TP_MST_USER.UserName " +
  1018. " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
  1019. " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
  1020. " left join TP_MST_USER " +
  1021. " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
  1022. " where TP_PM_BarCodeMissing.valueflag=1 " +
  1023. " and TP_PM_BarCodeMissing.accountid=:AccountID ";
  1024. // 产品条码
  1025. if (!string.IsNullOrEmpty(se.Barcode))
  1026. {
  1027. selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
  1028. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1029. }
  1030. // 组织结构
  1031. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1032. {
  1033. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
  1034. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1035. }
  1036. // 完成工序
  1037. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1038. {
  1039. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
  1040. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1041. }
  1042. // 校验工序
  1043. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1044. {
  1045. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
  1046. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1047. }
  1048. // 漏扫工序
  1049. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1050. {
  1051. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
  1052. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1053. }
  1054. // 产品IDS
  1055. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1056. {
  1057. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
  1058. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1059. }
  1060. // 产品IDS
  1061. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1062. {
  1063. selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
  1064. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1065. }
  1066. // 校验时间--开始
  1067. if (se.beginCreateTime.HasValue)
  1068. {
  1069. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
  1070. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1071. }
  1072. // 校验时间--结束
  1073. if (se.endCreateTime.HasValue)
  1074. {
  1075. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
  1076. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1077. }
  1078. selSql = selSql +
  1079. // " order by missprocedureid,username " +
  1080. " ) " +
  1081. " group by rollup( " +
  1082. " GoodsType, " +
  1083. " MissProcedureID, " +
  1084. " MissProcedureCode, " +
  1085. " MissProcedureName, " +
  1086. " MissID, " +
  1087. " BarCode, " +
  1088. " OrganizationID, " +
  1089. " OrganizationName, " +
  1090. " OrganizationCode, " +
  1091. " OrganizationFullName, " +
  1092. " CompleteProcedureID, " +
  1093. " CompleteProcedureCode, " +
  1094. " CompleteProcedureName, " +
  1095. " ProcedureID, " +
  1096. " ProcedureCode, " +
  1097. " ProcedureName, " +
  1098. " GoodsID, " +
  1099. " GoodsCode, " +
  1100. " GoodsName, " +
  1101. " GoodsTypeID, " +
  1102. " CreateTime, " +
  1103. " GoodsTypeName,MissUserCode, " +
  1104. " UserName ) " +
  1105. " ) " +
  1106. " where UserName!='--' or " +
  1107. " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
  1108. " or " +
  1109. " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
  1110. " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
  1111. + " ) order by seqno";
  1112. */
  1113. #endregion
  1114. string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
  1115. " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
  1116. " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
  1117. " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
  1118. " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
  1119. " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
  1120. " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
  1121. " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
  1122. " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
  1123. " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
  1124. " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
  1125. " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
  1126. " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
  1127. " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
  1128. " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
  1129. " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
  1130. " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
  1131. " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
  1132. " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
  1133. " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
  1134. " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
  1135. " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
  1136. " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
  1137. " decode(tt.gid, 0, tt.username, '--') username,\n" +
  1138. " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
  1139. " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
  1140. " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
  1141. " tt.barcodecount, --数量\n" +
  1142. " tt.LogoCodeName\n" +
  1143. " from (select grouping_id(t.goodstypename2, --产品大类\n" +
  1144. " --t.MissProcedureCode,\n" +
  1145. " t.MissProcedureName,\n" +
  1146. " t.MissID) gid,\n" +
  1147. " t.MissID, --漏扫ID\n" +
  1148. " t.BarCode, --产品条码\n" +
  1149. " --t.OrganizationID,\n" +
  1150. " --t.OrganizationCode,\n" +
  1151. " t.OrganizationName, --漏扫部门\n" +
  1152. " --t.OrganizationFullName,\n" +
  1153. " --t.CompleteProcedureID,\n" +
  1154. " --t.CompleteProcedureCode,\n" +
  1155. " t.CompleteProcedureName, --完成工序\n" +
  1156. " --t.ProcedureID,\n" +
  1157. " --t.ProcedureCode,\n" +
  1158. " t.ProcedureName, --校验工序\n" +
  1159. " --t.MissProcedureID,\n" +
  1160. " --t.MissProcedureCode,\n" +
  1161. " t.MissProcedureName, --漏扫工序\n" +
  1162. " t.GoodsID,\n" +
  1163. " t.GoodsCode, --产品编码\n" +
  1164. " t.GoodsName, --产品名称\n" +
  1165. " t.GoodsTypeID,\n" +
  1166. " t.MissUserID,\n" +
  1167. " t.MissUserCode, --漏扫工号\n" +
  1168. " t.CreateTime, --校验漏扫时间\n" +
  1169. " t.CreateUserID,\n" +
  1170. " t.username, --校验者\n" +
  1171. " t.repaircode, --补扫操作工号\n" +
  1172. " t.prepaircode, --补扫生产工号\n" +
  1173. " t.goodstypename2, --产品大类\n" +
  1174. " count(t.barcodecount) barcodecount, --数量\n" +
  1175. " t.LogoCodeName\n" +
  1176. " from (select bcm.MissID, --漏扫ID\n" +
  1177. " bcm.BarCode, --产品条码\n" +
  1178. " --bcm.OrganizationID,\n" +
  1179. " --bcm.OrganizationCode,\n" +
  1180. " bcm.OrganizationName, --漏扫部门\n" +
  1181. " --bcm.OrganizationFullName,\n" +
  1182. " --bcm.CompleteProcedureID,\n" +
  1183. " --bcm.CompleteProcedureCode,\n" +
  1184. " --bcm.CompleteProcedureName, --完成工序\n" +
  1185. " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
  1186. " --bcm.ProcedureID,\n" +
  1187. " --bcm.ProcedureCode,\n" +
  1188. " --bcm.ProcedureName, --校验工序\n" +
  1189. " cp.ProcedureName, --校验工序\n" +
  1190. " --bcm.MissProcedureID,\n" +
  1191. " --bcm.MissProcedureCode,\n" +
  1192. " --bcm.MissProcedureName, --漏扫工序\n" +
  1193. " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
  1194. " bcm.GoodsID,\n" +
  1195. " bcm.GoodsCode, --产品编码\n" +
  1196. " bcm.GoodsName, --产品名称\n" +
  1197. " bcm.GoodsTypeID,\n" +
  1198. " bcm.MissUserID,\n" +
  1199. " bcm.MissUserCode, --漏扫工号\n" +
  1200. " bcm.CreateTime, --校验漏扫时间\n" +
  1201. " bcm.CreateUserID,\n" +
  1202. " u.username, --校验者\n" +
  1203. //" MU.usercode repaircode, --补扫操作工号\n" +
  1204. //" MU.pusercode prepaircode, --补扫生产工号\n" +
  1205. " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
  1206. " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
  1207. " gt2.goodstypename goodstypename2, --产品大类\n" +
  1208. " 1 barcodecount, --数量\n" +
  1209. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
  1210. " from TP_PM_BarCodeMissing bcm\n" +
  1211. " left join TP_MST_User u\n" +
  1212. " on bcm.CreateUserID = u.userid\n" +
  1213. " left join TP_MST_GoodsType gt\n" +
  1214. " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
  1215. " left join TP_MST_GoodsType gt2\n" +
  1216. " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
  1217. " and gt.accountid = gt2.accountid\n" +
  1218. /*
  1219. //" left join TP_PM_ProductionData PD\n" +
  1220. //" on PD.BarCode = bcm.BarCode\n" +
  1221. //" and PD.ProcedureID = bcm.MissProcedureID\n" +
  1222. //" left join TP_MST_User MU\n" +
  1223. //" on MU.UserID = PD.CreateUserID\n" +
  1224. " left join (select pd.barcode,\n" +
  1225. " pd.procedureid,\n" +
  1226. " pd.usercode pusercode,\n" +
  1227. " mu.usercode,\n" +
  1228. //" pd.usercode,\n" +
  1229. " max(bm.missid) missid\n" +
  1230. //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
  1231. " from tp_pm_productiondata pd\n" +
  1232. " inner join tp_pm_barcodemissing bm\n" +
  1233. " on bm.barcode = pd.barcode\n" +
  1234. " and bm.missprocedureid = pd.procedureid\n" +
  1235. " and bm.createtime < pd.createtime\n" +
  1236. " and bm.valueflag ='1'\n" +
  1237. " inner join tp_mst_user mu\n" +
  1238. " on mu.userid = pd.createuserid\n" +
  1239. " where pd.valueflag = '1'\n" +
  1240. " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
  1241. " ) MU\n" +
  1242. " on MU.barcode = bcm.barcode\n" +
  1243. " and MU.procedureid = bcm.missprocedureid\n" +
  1244. " and MU.missid = bcm.missid" +
  1245. //" and MU.rnum = 1" +
  1246. */
  1247. " left join tp_pc_procedure cedp \n" +
  1248. " on cedp.procedureid = bcm.CompleteProcedureID\n" +
  1249. " left join tp_pc_procedure cp \n" +
  1250. " on cp.procedureid = bcm.ProcedureID\n" +
  1251. " left join tp_pc_procedure mp \n" +
  1252. " on mp.procedureid = bcm.MissProcedureID\n" +
  1253. " left join TP_PM_GroutingDailyDetail \n" +
  1254. " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
  1255. " left join tp_mst_logo \n" +
  1256. " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
  1257. " where bcm.valueflag='1' \n" +
  1258. " and bcm.accountid=:AccountID \n";
  1259. // 产品条码
  1260. if (!string.IsNullOrEmpty(se.Barcode))
  1261. {
  1262. selSql = selSql + " and bcm.barcode=:Barcode ";
  1263. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1264. }
  1265. // 组织结构
  1266. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1267. {
  1268. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
  1269. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1270. }
  1271. // 完成工序
  1272. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1273. {
  1274. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
  1275. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1276. }
  1277. // 校验工序
  1278. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1279. {
  1280. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
  1281. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1282. }
  1283. // 漏扫工序
  1284. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1285. {
  1286. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
  1287. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1288. }
  1289. // 产品IDS
  1290. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1291. {
  1292. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
  1293. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1294. }
  1295. // 产品IDS
  1296. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1297. {
  1298. //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
  1299. selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
  1300. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1301. }
  1302. // 校验时间--开始
  1303. if (se.beginCreateTime.HasValue)
  1304. {
  1305. selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
  1306. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1307. }
  1308. // 校验时间--结束
  1309. if (se.endCreateTime.HasValue)
  1310. {
  1311. selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
  1312. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1313. }
  1314. selSql += "\n" +
  1315. //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
  1316. //" --bcm.GoodsCode,\n" +
  1317. //" bcm.BarCode,\n" +
  1318. //" bcm.ProcedureCode,\n" +
  1319. //" bcm.CompleteProcedureCode\n" +
  1320. //" ) t\n" +
  1321. " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
  1322. " --bcm.GoodsCode,\n" +
  1323. " bcm.BarCode,\n" +
  1324. " cp.ProcedureName,\n" +
  1325. " cedp.ProcedureName\n" +
  1326. " ) t\n" +
  1327. " group by grouping sets((t.MissID, --漏扫ID\n" +
  1328. " t.BarCode, --产品条码\n" +
  1329. " t.goodstypename2, --产品大类\n" +
  1330. " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
  1331. " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
  1332. " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
  1333. " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
  1334. " t.GoodsID, t.GoodsCode, --产品编码\n" +
  1335. " t.GoodsName, --产品名称\n" +
  1336. " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
  1337. " t.CreateTime, --校验漏扫时间\n" +
  1338. " t.CreateUserID, t.username, --校验者\n" +
  1339. " t.repaircode, --补扫工号\n" +
  1340. " t.prepaircode, --补扫工号\n" +
  1341. " t.LogoCodeName --商标\n" +
  1342. " ),(t.goodstypename2, --产品大类\n" +
  1343. " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
  1344. " ),(t.goodstypename2 --产品大类\n" +
  1345. " ),())) tt";
  1346. return selSql;
  1347. }
  1348. /// <summary>
  1349. /// 取得RPT010301_1画面(条码变更明细表)的查询数据
  1350. /// </summary>
  1351. /// <param name="user">登录用户信息</param>
  1352. /// <param name="se">查询条件</param>
  1353. /// <returns>查询结果</returns>
  1354. public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
  1355. {
  1356. IDBConnection conn = null;
  1357. try
  1358. {
  1359. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1360. List<OracleParameter> parameters = new List<OracleParameter>();
  1361. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
  1362. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1363. if (se != null)
  1364. {
  1365. // 更换条码时间-开始
  1366. if (se.createTimeBegin.HasValue)
  1367. {
  1368. sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
  1369. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  1370. }
  1371. // 更换条码时间-结束
  1372. if (se.createTimeEnd.HasValue)
  1373. {
  1374. sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
  1375. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  1376. }
  1377. //成型线IDS
  1378. if (!string.IsNullOrEmpty(se.Barcode))
  1379. {
  1380. // 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 )");
  1381. 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 )");
  1382. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1383. }
  1384. }
  1385. sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
  1386. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1387. ServiceResultEntity sre = new ServiceResultEntity();
  1388. if (data == null || data.Rows.Count == 0)
  1389. {
  1390. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1391. return sre;
  1392. }
  1393. sre.Data = new DataSet();
  1394. sre.Data.Tables.Add(data);
  1395. return sre;
  1396. }
  1397. catch (Exception ex)
  1398. {
  1399. throw ex;
  1400. }
  1401. finally
  1402. {
  1403. if (conn != null &&
  1404. conn.ConnState == ConnectionState.Open)
  1405. {
  1406. conn.Close();
  1407. }
  1408. }
  1409. }
  1410. /// <summary>
  1411. /// 获取RPT010301_1画面(条码变更明细表)的查询sql
  1412. /// </summary>
  1413. /// <returns>sql</returns>
  1414. private static string GetRPT010301SSQL()
  1415. {
  1416. string selSql =
  1417. " SELECT "
  1418. + " TP_PM_BarCodeRecord.BarCode, "
  1419. + " TP_PM_BarCodeRecord.NewBarCode, "
  1420. + " TP_PM_BarCodeRecord.FirstBarCode, "
  1421. + " TP_PM_BarCodeRecord.FinalBarCode, "
  1422. + " TP_PM_BarCodeRecord.Createtime, "
  1423. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
  1424. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
  1425. + " TP_MST_GMouldType.Gmouldtypename, "
  1426. + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
  1427. + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
  1428. + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
  1429. + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
  1430. + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
  1431. + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
  1432. + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
  1433. + " TP_PC_PROCEDURE.PROCEDURECODE, "
  1434. + " TP_PC_PROCEDURE.PROCEDURENAME, "
  1435. + " TP_MST_USER.USERNAME, "
  1436. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  1437. + " from TP_PM_BarCodeRecord "
  1438. + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
  1439. + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
  1440. + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
  1441. + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
  1442. + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
  1443. + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
  1444. + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
  1445. return selSql;
  1446. }
  1447. /// <summary>
  1448. /// 取得RPT010401画面(在产品明细表)的查询数据
  1449. /// </summary>
  1450. /// <param name="user">登录用户信息</param>
  1451. /// <param name="se">查询条件</param>
  1452. /// <returns>查询结果</returns>
  1453. public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
  1454. {
  1455. IDBConnection conn = null;
  1456. try
  1457. {
  1458. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1459. List<OracleParameter> parameters = new List<OracleParameter>();
  1460. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
  1461. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1462. if (se != null)
  1463. {
  1464. // 条码
  1465. if (!string.IsNullOrEmpty(se.Barcode))
  1466. {
  1467. //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
  1468. sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
  1469. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1470. }
  1471. // 产品IDS
  1472. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1473. {
  1474. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
  1475. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1476. }
  1477. //生产线IDS
  1478. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1479. {
  1480. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  1481. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1482. }
  1483. //完成工序IDS
  1484. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1485. {
  1486. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  1487. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1488. }
  1489. //生产工号IDS
  1490. if (!string.IsNullOrEmpty(se.UserIDS))
  1491. {
  1492. sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
  1493. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  1494. }
  1495. // 成型线IDS
  1496. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1497. {
  1498. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
  1499. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1500. }
  1501. // 成型线类型IDS
  1502. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1503. {
  1504. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
  1505. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1506. }
  1507. // 交坯时间--开始
  1508. if (se.CreateTimeStart.HasValue)
  1509. {
  1510. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
  1511. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1512. }
  1513. // 交坯时间--结束
  1514. if (se.CreateTimeEnd.HasValue)
  1515. {
  1516. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
  1517. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1518. }
  1519. // 完成时间--开始
  1520. if (se.UpdateTimeStart.HasValue)
  1521. {
  1522. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  1523. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  1524. }
  1525. // 完成时间--结束
  1526. if (se.UpdateTimeEnd.HasValue)
  1527. {
  1528. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  1529. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  1530. }
  1531. if (se.inscrapflag != 2)
  1532. {
  1533. sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
  1534. parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
  1535. }
  1536. if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
  1537. {
  1538. sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
  1539. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1540. }
  1541. }
  1542. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  1543. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1544. ServiceResultEntity sre = new ServiceResultEntity();
  1545. if (data == null || data.Rows.Count == 0)
  1546. {
  1547. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1548. return sre;
  1549. }
  1550. sre.Data = new DataSet();
  1551. sre.Data.Tables.Add(data);
  1552. return sre;
  1553. }
  1554. catch (Exception ex)
  1555. {
  1556. throw ex;
  1557. }
  1558. finally
  1559. {
  1560. if (conn != null &&
  1561. conn.ConnState == ConnectionState.Open)
  1562. {
  1563. conn.Close();
  1564. }
  1565. }
  1566. }
  1567. /// <summary>
  1568. /// 获取RPT010401画面(在产品明细表)的查询sql
  1569. /// </summary>
  1570. /// <returns>sql</returns>
  1571. private static string GetRPT010401SSQL()
  1572. {
  1573. string selSql =
  1574. "SELECT " +
  1575. " TP_PM_InProduction.BarCode, " +
  1576. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  1577. " TP_PM_InProduction.GoodsName, gt.goodstypename," +
  1578. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  1579. " TP_PM_InProduction.ProductionLineID, " +
  1580. " TP_PM_InProduction.ProductionLineCode, " +
  1581. " TP_PM_InProduction.ProductionLineName, " +
  1582. " TP_PM_InProduction.ModelType, " +
  1583. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  1584. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1585. " TP_PM_InProduction.IsPublicBody, " +
  1586. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  1587. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  1588. " TP_PM_InProduction.IsReworkFlag, " +
  1589. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  1590. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  1591. " TP_PM_InProduction.GroutingDailyID, " +
  1592. " TP_PM_InProduction.GroutingDailyDetailID, " +
  1593. " TP_PM_InProduction.GroutingDate, " +
  1594. " TP_PM_InProduction.GroutingLineID, " +
  1595. " TP_PM_InProduction.GroutingLineCode, " +
  1596. " TP_PM_InProduction.GroutingLineName, " +
  1597. " TP_PM_InProduction.KILNCODE, " +
  1598. " TP_PM_InProduction.KILNCARCODE, " +
  1599. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  1600. " D.ProcedureName as CompleteProcedureName, " +
  1601. " TP_PM_InProduction.GMouldTypeID, " +
  1602. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1603. " TP_PM_InProduction.GroutingLineDetailID, " +
  1604. " TP_PM_InProduction.GroutingMouldCode, " +
  1605. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  1606. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  1607. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  1608. " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
  1609. " TP_PM_GroutingDailyDetail.delivertime, " +
  1610. " TP_PM_InProduction.proceduretime, " +
  1611. " TP_PM_InProduction.Remarks, " +
  1612. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1613. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1614. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  1615. " TP_PM_GroutingDailyDetail.glazingroom," +
  1616. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  1617. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  1618. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
  1619. //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1620. " 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 " +
  1621. "FROM TP_PM_InProduction " +
  1622. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  1623. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  1624. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  1625. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  1626. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  1627. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  1628. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  1629. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  1630. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  1631. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  1632. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  1633. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  1634. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  1635. " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
  1636. " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
  1637. " Where TP_PM_InProduction.ValueFlag = 1 " +
  1638. " and TP_PM_InProduction.AccountID=:AccountID ";
  1639. return selSql;
  1640. }
  1641. /// <summary>
  1642. /// 取得RPT010402画面(产成品明细表)的查询数据
  1643. /// </summary>
  1644. /// <param name="user">登录用户信息</param>
  1645. /// <param name="se">查询条件</param>
  1646. /// <returns>查询结果</returns>
  1647. public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
  1648. {
  1649. IDBConnection conn = null;
  1650. try
  1651. {
  1652. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1653. List<OracleParameter> parameters = new List<OracleParameter>();
  1654. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
  1655. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1656. if (se != null)
  1657. {
  1658. // 条码
  1659. if (!string.IsNullOrEmpty(se.Barcode))
  1660. {
  1661. //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
  1662. sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
  1663. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1664. }
  1665. // 产品IDS
  1666. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1667. {
  1668. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
  1669. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1670. }
  1671. // 生产线IDS
  1672. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1673. {
  1674. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
  1675. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1676. }
  1677. // 成型线ids
  1678. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1679. {
  1680. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
  1681. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1682. }
  1683. // 成型线类型ids
  1684. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1685. {
  1686. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
  1687. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1688. }
  1689. // 财务日期--开始
  1690. if (se.AccountDateStart.HasValue)
  1691. {
  1692. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
  1693. sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
  1694. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  1695. }
  1696. // 财务日期--结束
  1697. if (se.AccountDateEnd.HasValue)
  1698. {
  1699. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
  1700. sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
  1701. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  1702. }
  1703. // 注浆时间--开始
  1704. if (se.CreateTimeStart.HasValue)
  1705. {
  1706. sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
  1707. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1708. }
  1709. // 注浆时间--结束
  1710. if (se.CreateTimeEnd.HasValue)
  1711. {
  1712. sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
  1713. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1714. }
  1715. }
  1716. sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
  1717. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1718. ServiceResultEntity sre = new ServiceResultEntity();
  1719. if (data == null || data.Rows.Count == 0)
  1720. {
  1721. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1722. return sre;
  1723. }
  1724. sre.Data = new DataSet();
  1725. sre.Data.Tables.Add(data);
  1726. return sre;
  1727. }
  1728. catch (Exception ex)
  1729. {
  1730. throw ex;
  1731. }
  1732. finally
  1733. {
  1734. if (conn != null &&
  1735. conn.ConnState == ConnectionState.Open)
  1736. {
  1737. conn.Close();
  1738. }
  1739. }
  1740. }
  1741. /// <summary>
  1742. /// 获取RPT010402画面(产成品明细表)的查询sql
  1743. /// </summary>
  1744. /// <returns>sql</returns>
  1745. private static string GetRPT010402SSQL()
  1746. {
  1747. string selSql =
  1748. "SELECT " +
  1749. " TP_PM_FinishedProduct.BarCode, " +
  1750. " TP_PM_FinishedProduct.GoodsID, " +
  1751. " TP_PM_FinishedProduct.GoodsCode, " +
  1752. " TP_PM_FinishedProduct.GoodsName, " +
  1753. " TP_PM_FinishedProduct.ProductionLineID, " +
  1754. " TP_PM_FinishedProduct.ProductionLineCode, " +
  1755. " TP_PM_FinishedProduct.ProductionLineName, " +
  1756. //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1757. //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
  1758. " TP_PM_FinishedProduct.IsPublicBody, " +
  1759. " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
  1760. " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
  1761. " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
  1762. " TP_PM_FinishedProduct.GroutingDailyID, " +
  1763. " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
  1764. " TP_PM_FinishedProduct.GroutingDate, " +
  1765. " TP_PM_FinishedProduct.GroutingLineID, " +
  1766. " TP_PM_FinishedProduct.GroutingLineCode," +
  1767. " TP_PM_FinishedProduct.GroutingLineName, " +
  1768. " TP_PM_FinishedProduct.GMouldTypeID, " +
  1769. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1770. " TP_PM_FinishedProduct.GroutingLineDetailID, " +
  1771. " TP_PM_FinishedProduct.GroutingMouldCode," +
  1772. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
  1773. " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
  1774. " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
  1775. " TP_PM_FinishedProduct.KILNID," +
  1776. " TP_PM_FinishedProduct.KILNCODE," +
  1777. " TP_PM_FinishedProduct.KILNNAME," +
  1778. " TP_PM_FinishedProduct.KILNCARID," +
  1779. " TP_PM_FinishedProduct.KILNCARCODE," +
  1780. " TP_PM_FinishedProduct.KILNCARNAME," +
  1781. " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
  1782. " TP_PM_FinishedProduct.MouldCode, " +
  1783. " TP_PM_FinishedProduct.Remarks, " +
  1784. " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1785. " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
  1786. " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1787. " TP_PM_FinishedProduct.FHUSERCODE, " +
  1788. " TP_PM_FinishedProduct.FHTIME, " +
  1789. " odr.ORDERNO, " +
  1790. " TP_PM_FinishedProduct.AccountID, " +
  1791. " TP_PM_FinishedProduct.ValueFlag, " +
  1792. " TP_PM_FinishedProduct.AccountDate, " +
  1793. " TP_PM_FinishedProduct.CreateTime, " +
  1794. " TP_PM_FinishedProduct.CreateUserID, " +
  1795. " B.USERNAME as CreateUserName, " +
  1796. " TP_PM_FinishedProduct.UpdateTime, " +
  1797. " TP_PM_FinishedProduct.UpdateUserID, " +
  1798. " C.USERNAME as UpdateUserName, " +
  1799. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
  1800. " TP_PM_GroutingDailyDetail.Materialcode," +
  1801. //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1802. " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
  1803. " FROM TP_PM_FinishedProduct " +
  1804. " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
  1805. " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
  1806. " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
  1807. " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
  1808. " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
  1809. " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
  1810. " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
  1811. " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
  1812. " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
  1813. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
  1814. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
  1815. " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
  1816. " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
  1817. " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
  1818. " and TP_PM_FinishedProduct.AccountID=:AccountID ";
  1819. return selSql;
  1820. }
  1821. /// <summary>
  1822. /// 取得RPT010403画面(生产数据明细表)的查询数据
  1823. /// </summary>
  1824. /// <param name="user">登录用户信息</param>
  1825. /// <param name="se">查询条件</param>
  1826. /// <returns>查询结果</returns>
  1827. public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
  1828. {
  1829. IDBConnection conn = null;
  1830. try
  1831. {
  1832. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1833. List<OracleParameter> parameters = new List<OracleParameter>();
  1834. string sqlString =
  1835. "SELECT *\n" +
  1836. " FROM (SELECT pd.barcode\n" +
  1837. " ,gt2.goodstypename as goodstypename2\n" +
  1838. " ,gt.goodstypename\n" +
  1839. " ,g.goodscode\n" +
  1840. " ,PD.ProductionLineName\n" +
  1841. " ,to_char(p.ProcedureName) AS ProcedureName\n" +
  1842. " ,op.organizationfullname AS porgname\n" +
  1843. " ,pd.CreateTime\n" +
  1844. " ,PD.UserCode\n" +
  1845. " ,cu.Usercode AS CreateUsercode\n" +
  1846. " ,cu.Username AS CreateUserName\n" +
  1847. " ,co.organizationfullname corgname\n" +
  1848. " , CASE\n" +
  1849. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
  1850. " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
  1851. " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1852. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
  1853. " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
  1854. " ELSE\n" +
  1855. " to_char(GL.GOODSLEVELNAME)\n" +
  1856. " END || CASE\n" +
  1857. " WHEN pd.modeltype = 1 THEN\n" +
  1858. " '[' || to_char(pd.kilncarcode) || ']'\n" +
  1859. " ELSE\n" +
  1860. " ''\n" +
  1861. " END GOODSLEVELNAME\n" +
  1862. " ,gdd.glazingroom" +
  1863. " FROM TP_PM_ProductionData PD\n" +
  1864. " INNER JOIN tp_pc_procedure p\n" +
  1865. " ON p.procedureid = pd.procedureid\n" +
  1866. " LEFT JOIN tp_mst_goods g\n" +
  1867. " ON g.goodsid = pd.goodsid\n" +
  1868. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  1869. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  1870. " LEFT JOIN tp_mst_goodstype gt\n" +
  1871. " ON gt.goodstypeid = g.goodstypeid\n" +
  1872. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1873. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1874. " AND gt2.AccountID = :AccountID\n" +
  1875. " INNER JOIN tp_mst_organization op\n" +
  1876. " ON op.organizationid = p.organizationid\n" +
  1877. " INNER JOIN tp_mst_user cu\n" +
  1878. " ON cu.userid = PD.Createuserid\n" +
  1879. " INNER JOIN tp_mst_organization co\n" +
  1880. " ON co.organizationid = cu.organizationid\n" +
  1881. " LEFT JOIN tp_mst_user bu\n" +
  1882. " ON bu.userid = PD.Backoutuserid\n" +
  1883. " LEFT JOIN tp_mst_goodslevel GL\n" +
  1884. " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
  1885. " AND gl.AccountID = :AccountID\n" +
  1886. " WHERE PD.AccountID = :AccountID\n" +
  1887. " AND PD.Createtime >= :CreatetimeBegin\n" +
  1888. " AND PD.Createtime <= :CreatetimeEnd\n" +
  1889. " AND (:ProductionLineID IS NULL OR\n" +
  1890. " pd.productionlineid = :ProductionLineID)\n" +
  1891. " AND (:GoodsTypeCode IS NULL OR\n" +
  1892. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1893. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  1894. " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
  1895. " UNION ALL\n" +
  1896. " -- 报损\n" +
  1897. " SELECT sp.barcode\n" +
  1898. " ,gt2.goodstypename as goodstypename2\n" +
  1899. " ,gt.goodstypename\n" +
  1900. " ,g.goodscode\n" +
  1901. " ,sp.productionlinename\n" +
  1902. //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
  1903. //" to_char(p.procedurename) || '】' AS procedurename\n" +
  1904. " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
  1905. " WHEN rpp.procedureid IS NOT NULL THEN\n" +
  1906. " to_char(rpp.procedurename)\n" +
  1907. " ELSE\n" +
  1908. " '无'\n" +
  1909. " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
  1910. " to_char(sruser.Username) || '】-原因【' ||\n" +
  1911. " to_char(sp.rreason) || '】' AS procedurename" +
  1912. " ,NULL AS porgname\n" +
  1913. " ,sp.Createtime\n" +
  1914. " ,NULL AS Usercode\n" +
  1915. " ,u.Usercode AS CreateUsercode\n" +
  1916. " ,U.Username AS CreateUserName\n" +
  1917. " ,co.organizationfullname corgname\n" +
  1918. " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
  1919. " WHEN Length(AU.usercode) > 0 THEN\n" +
  1920. " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
  1921. " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1922. " ELSE\n" +
  1923. " ''\n" +
  1924. " END || CASE\n" +
  1925. " WHEN sp.valueflag = '0' THEN\n" +
  1926. " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
  1927. " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1928. " ELSE\n" +
  1929. " ''\n" +
  1930. " END AS GOODSLEVELNAME\n" +
  1931. " ,null glazingroom\n" +
  1932. " FROM tp_pm_scrapproduct sp\n" +
  1933. " LEFT JOIN tp_mst_goods g\n" +
  1934. " ON g.goodsid = sp.goodsid\n" +
  1935. " LEFT JOIN tp_mst_goodstype gt\n" +
  1936. " ON gt.goodstypeid = g.goodstypeid\n" +
  1937. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1938. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1939. " AND gt2.AccountID = :AccountID\n" +
  1940. " INNER JOIN tp_pc_procedure p\n" +
  1941. " ON p.procedureid = sp.procedureid\n" +
  1942. " --inner join tp_mst_organization op\n" +
  1943. " -- on op.organizationid = p.organizationid\n" +
  1944. " INNER JOIN tp_mst_user U\n" +
  1945. " ON U.userid = sp.CREATEUSERID\n" +
  1946. " INNER JOIN tp_mst_organization co\n" +
  1947. " ON co.organizationid = u.organizationid\n" +
  1948. " INNER JOIN tp_mst_user uu\n" +
  1949. " ON uu.userid = sp.Updateuserid\n" +
  1950. " INNER JOIN tp_sys_AuditStatus A\n" +
  1951. " ON A.AuditStatusid = sp.AuditStatus\n" +
  1952. " LEFT JOIN tp_mst_goodslevel gl\n" +
  1953. " ON gl.goodsleveltypeid = 8\n" +
  1954. " AND gl.accountid = 1\n" +
  1955. " LEFT JOIN tp_mst_user AU\n" +
  1956. " ON au.userid = sp.auditor\n" +
  1957. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  1958. " ON rp.scrapproductid = sp.scrapproductid\n" +
  1959. " LEFT JOIN tp_pc_procedure rpp\n" +
  1960. " ON rpp.procedureid = rp.procedureid\n" +
  1961. " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
  1962. " FROM TP_PM_ScrapResponsible sr\n" +
  1963. " WHERE sr.AccountID = :AccountID\n" +
  1964. " -- 编辑后 时间不一致\n" +
  1965. " --AND sr.Createtime >= :CreatetimeBegin\n" +
  1966. " --AND sr.Createtime <= :CreatetimeEnd\n" +
  1967. " ) sru\n" +
  1968. " ON sru.scrapproductid = sp.scrapproductid\n" +
  1969. " LEFT JOIN tp_mst_user sruser\n" +
  1970. " ON sruser.userid = sru.userid" +
  1971. " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
  1972. " AND sp.scraptype = '0'\n" +
  1973. " AND sp.AccountID = :AccountID\n" +
  1974. " AND sp.Createtime >= :CreatetimeBegin\n" +
  1975. " AND sp.Createtime <= :CreatetimeEnd\n" +
  1976. " AND (:ProductionLineID IS NULL OR\n" +
  1977. " sp.productionlineid = :ProductionLineID)\n" +
  1978. " AND (:GoodsTypeCode IS NULL OR\n" +
  1979. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1980. " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
  1981. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
  1982. " ORDER BY t.barcode, t.Createtime";
  1983. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1984. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1985. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  1986. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1987. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  1988. parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
  1989. parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
  1990. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  1991. ServiceResultEntity sre = new ServiceResultEntity();
  1992. if (data == null || data.Rows.Count == 0)
  1993. {
  1994. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1995. return sre;
  1996. }
  1997. sre.Data = new DataSet();
  1998. sre.Data.Tables.Add(data);
  1999. return sre;
  2000. }
  2001. catch (Exception ex)
  2002. {
  2003. throw ex;
  2004. }
  2005. finally
  2006. {
  2007. if (conn != null &&
  2008. conn.ConnState == ConnectionState.Open)
  2009. {
  2010. conn.Close();
  2011. }
  2012. }
  2013. }
  2014. /// <summary>
  2015. /// 取得RPT010302画面(商标变更明细表)的查询数据
  2016. /// </summary>
  2017. /// <param name="user">登录用户信息</param>
  2018. /// <param name="se">查询条件</param>
  2019. /// <returns>查询结果</returns>
  2020. public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
  2021. {
  2022. IDBConnection conn = null;
  2023. try
  2024. {
  2025. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2026. List<OracleParameter> parameters = new List<OracleParameter>();
  2027. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
  2028. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2029. if (se != null)
  2030. {
  2031. // 更换条码时间-开始
  2032. if (se.createTimeBegin.HasValue)
  2033. {
  2034. sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
  2035. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  2036. }
  2037. // 更换条码时间-结束
  2038. if (se.createTimeEnd.HasValue)
  2039. {
  2040. sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
  2041. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  2042. }
  2043. //成型线IDS
  2044. if (!string.IsNullOrEmpty(se.Barcode))
  2045. {
  2046. // 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 )");
  2047. sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
  2048. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2049. }
  2050. }
  2051. sql.Append(" ORDER BY lcr.CREATETIME ");
  2052. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2053. ServiceResultEntity sre = new ServiceResultEntity();
  2054. if (data == null || data.Rows.Count == 0)
  2055. {
  2056. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2057. return sre;
  2058. }
  2059. sre.Data = new DataSet();
  2060. sre.Data.Tables.Add(data);
  2061. return sre;
  2062. }
  2063. catch (Exception ex)
  2064. {
  2065. throw ex;
  2066. }
  2067. finally
  2068. {
  2069. if (conn != null &&
  2070. conn.ConnState == ConnectionState.Open)
  2071. {
  2072. conn.Close();
  2073. }
  2074. }
  2075. }
  2076. /// <summary>
  2077. /// 获取RPT010302画面(商标变更明细表)的查询sql
  2078. /// </summary>
  2079. /// <returns>sql</returns>
  2080. private static string GetRPT010302SSQL()
  2081. {
  2082. string selSql =
  2083. "SELECT lcr.BarCode\n" +
  2084. " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
  2085. " '[]',\n" +
  2086. " '') AS oldLogoCodeName\n" +
  2087. " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
  2088. " '[]',\n" +
  2089. " '') AS newLogoCodeName\n" +
  2090. " ,lcr.Createtime\n" +
  2091. " ,gdd.GroutingLineCode\n" +
  2092. " ,gdd.GroutingLineName\n" +
  2093. " ,gdd.GroutingDate\n" +
  2094. " ,gdd.GroutingMouldCode\n" +
  2095. " ,gdd.MouldCode\n" +
  2096. " ,gdd.UserCode GroutingUserCode\n" +
  2097. " ,gdd.GroutingCount\n" +
  2098. " ,gdd.GoodsCode\n" +
  2099. " ,gdd.GoodsName\n" +
  2100. " ,p.PROCEDURECODE\n" +
  2101. " ,p.PROCEDURENAME\n" +
  2102. " ,u.USERCode\n" +
  2103. " ,u.USERNAME\n" +
  2104. " FROM TP_PM_LogoChangedRecord lcr\n" +
  2105. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
  2106. " ON lcr.barcode = gdd.Barcode\n" +
  2107. " LEFT JOIN TP_PC_PROCEDURE p\n" +
  2108. " ON lcr.Procedureid = p.PROCEDUREID\n" +
  2109. " LEFT JOIN TP_MST_USER u\n" +
  2110. " ON lcr.CreateUserID = u.USERID\n" +
  2111. " LEFT JOIN TP_MST_logo oldlogo\n" +
  2112. " ON lcr.oldlogoid = oldlogo.logoid\n" +
  2113. " LEFT JOIN TP_MST_logo newlogo\n" +
  2114. " ON lcr.newlogoid = newlogo.logoid\n" +
  2115. " WHERE lcr.ACCOUNTID = :AccountID";
  2116. return selSql;
  2117. }
  2118. #endregion 明细报表
  2119. #region 分析报表
  2120. /// <summary>
  2121. /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
  2122. /// </summary>
  2123. /// <param name="user">登录用户信息</param>
  2124. /// <param name="se">查询条件</param>
  2125. /// <returns>查询结果</returns>
  2126. public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
  2127. {
  2128. IDBConnection conn = null;
  2129. try
  2130. {
  2131. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2132. #region
  2133. /*
  2134. List<OracleParameter> parameters = new List<OracleParameter>();
  2135. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2136. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2137. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2138. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2139. parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2140. if (se != null)
  2141. {
  2142. // 成型线IDS
  2143. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2144. {
  2145. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  2146. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2147. }
  2148. // 成型工IDS
  2149. if (!string.IsNullOrEmpty(se.UserIDS))
  2150. {
  2151. sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
  2152. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2153. }
  2154. //产品类型IDS
  2155. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2156. {
  2157. sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
  2158. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2159. }
  2160. //产品IDS
  2161. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2162. {
  2163. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  2164. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2165. }
  2166. }
  2167. sql.Append(" group by ");
  2168. sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
  2169. sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
  2170. sql.Append(" line.GroutinglineCode, ");
  2171. sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
  2172. sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
  2173. sql.Append(" TP_MST_Goods.Goodsspecification, ");
  2174. sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
  2175. sql.Append(" MouldQuantity ");
  2176. sql.Append(" ) temp ");
  2177. sql.Append(" ) a ");
  2178. sql.Append(" group by rollup( ");
  2179. sql.Append(" UserCode, ");
  2180. sql.Append(" Groutinglinecode, ");
  2181. sql.Append(" GoodsTypeName, ");
  2182. sql.Append(" GoodsCode, ");
  2183. sql.Append(" Goodsspecification, ");
  2184. sql.Append(" DICTIONARYVALUE, ");
  2185. sql.Append(" MouldQuantity, ");
  2186. sql.Append(" 注浆量, ");
  2187. sql.Append(" 交坯量 ");
  2188. sql.Append(" ) ");
  2189. sql.Append(") Temp where 交坯量 is not null");
  2190. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2191. */
  2192. #endregion
  2193. List<OracleParameter> parameters = new List<OracleParameter>();
  2194. //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2195. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2196. //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2197. string sqlGroutingdate = null;
  2198. StringBuilder sql = new StringBuilder();
  2199. if (se != null)
  2200. {
  2201. // 成型线IDS
  2202. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2203. {
  2204. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
  2205. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2206. }
  2207. // 成型工IDS
  2208. if (!string.IsNullOrEmpty(se.UserIDS))
  2209. {
  2210. sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
  2211. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2212. }
  2213. //产品类型IDS
  2214. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2215. {
  2216. //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
  2217. sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
  2218. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2219. }
  2220. //产品IDS
  2221. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2222. {
  2223. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
  2224. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2225. }
  2226. if (se.GroutingDateStart.HasValue)
  2227. {
  2228. //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
  2229. //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
  2230. sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
  2231. + " and gdd.groutingdate <= :groutingDateEnd \n";
  2232. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2233. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2234. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2235. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2236. }
  2237. else if (se.GCTimeBegin.HasValue)
  2238. {
  2239. //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
  2240. //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
  2241. sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
  2242. + " and gdd.createtime <= :groutingDateEnd \n";
  2243. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  2244. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  2245. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2246. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2247. }
  2248. }
  2249. string sqlString =
  2250. "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
  2251. " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
  2252. " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
  2253. " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
  2254. " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
  2255. " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
  2256. " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
  2257. //" select gddata.usercode,\n" +
  2258. //" gddata.goodscode,\n" +
  2259. //" gddata.goodstypename,\n" +
  2260. //" gddata.goodsspecification,\n" +
  2261. //" gddata.GlazeType,\n" +
  2262. //" gddata.groutinglinecode,\n" +
  2263. //" gddata.MouldQuantity,\n" +
  2264. " gddata.GroutingNum,\n" +
  2265. " gddata.StrippingNum,\n" +
  2266. " gddata.DeliverNum,\n" +
  2267. " decode(gddata.GroutingNum,\n" +
  2268. " 0,\n" +
  2269. " '0.00%',\n" +
  2270. " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
  2271. " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
  2272. " decode(gddata.GroutingNum,\n" +
  2273. " 0,\n" +
  2274. " '0.00%',\n" +
  2275. " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
  2276. " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
  2277. " decode(gddata.StrippingNum,\n" +
  2278. " 0,\n" +
  2279. " '0.00%',\n" +
  2280. " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
  2281. " '9,990.00') || '%') SDPercent -- 成交比,\n" +
  2282. " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2283. //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2284. " gdd.usercode,\n" +
  2285. " gdd.goodscode,\n" +
  2286. " gdd.goodstypename,\n" +
  2287. " gdd.goodsspecification,\n" +
  2288. " gdd.GlazeType,\n" +
  2289. " gdd.groutinglinecode,\n" +
  2290. " gdd.MouldQuantity,\n" +
  2291. " sum(gdd.GroutingNum) GroutingNum,\n" +
  2292. " sum(gdd.StrippingNum) StrippingNum,\n" +
  2293. " sum(gdd.DeliverNum) DeliverNum\n" +
  2294. " from (select 1 flag,\n" +
  2295. //" select 1 flag,\n" +
  2296. " gddgroup.usercode,\n" +
  2297. " gddgroup.goodscode,\n" +
  2298. " gddgroup.goodstypename,\n" +
  2299. " gddgroup.goodsspecification,\n" +
  2300. " gddgroup.GlazeType,\n" +
  2301. " gddgroup.groutinglinecode,\n" +
  2302. " gddgroup.MouldQuantity,\n" +
  2303. " sum(gddgroup.GroutingNum) GroutingNum,\n" +
  2304. " sum(gddgroup.StrippingNum) StrippingNum,\n" +
  2305. " sum(gddgroup.DeliverNum) DeliverNum\n" +
  2306. " from (select --gdd.groutingdailydetailid,\n" +
  2307. " gd.groutinglinecode,\n" +
  2308. " gt.goodstypename,\n" +
  2309. " g.goodscode,\n" +
  2310. " g.goodsspecification,\n" +
  2311. " dd.dictionaryvalue GlazeType,\n" +
  2312. //" gdd.usercode,\n" +
  2313. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2314. " gd.MouldQuantity,\n" +
  2315. " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
  2316. " case\n" +
  2317. " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
  2318. " 1\n" +
  2319. " else\n" +
  2320. " 0\n" +
  2321. " end StrippingNum,\n" +
  2322. " 0 DeliverNum\n" +
  2323. " from tp_pm_groutingdaily gd\n" +
  2324. " inner join tp_pm_groutingdailydetail gdd\n" +
  2325. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2326. " left join tp_mst_user mu\n" +
  2327. " on mu.userid = gd.MonitorID\n" +
  2328. " inner join tp_mst_goods g\n" +
  2329. " on gdd.goodsid = g.goodsid\n" +
  2330. " inner join tp_mst_goodstype gt\n" +
  2331. " on g.goodstypeid = gt.goodstypeid\n" +
  2332. " inner join tp_mst_datadictionary dd\n" +
  2333. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2334. " where gd.valueflag = '1'\n" +
  2335. " and gd.accountid = :AccountID\n"
  2336. + sqlGroutingdate +
  2337. //" and gdd.groutingdate >= :groutingDateStart \n" +
  2338. //" and gdd.groutingdate <= :groutingDateEnd \n" +
  2339. sql +
  2340. " union all\n" +
  2341. " select --gdd.groutingdailydetailid,\n" +
  2342. " gd.groutinglinecode,\n" +
  2343. " gt.goodstypename,\n" +
  2344. " g.goodscode,\n" +
  2345. " g.goodsspecification,\n" +
  2346. " dd.dictionaryvalue GlazeType,\n" +
  2347. //" gdd.usercode,\n" +
  2348. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2349. " gd.MouldQuantity,\n" +
  2350. " 0 GroutingNum,\n" +
  2351. " 0 StrippingNum,\n" +
  2352. " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
  2353. " from tp_pm_groutingdaily gd\n" +
  2354. " inner join tp_pm_groutingdailydetail gdd\n" +
  2355. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2356. " left join tp_mst_user mu\n" +
  2357. " on mu.userid = gd.MonitorID\n" +
  2358. " inner join tp_mst_goods g\n" +
  2359. " on gdd.goodsid = g.goodsid\n" +
  2360. " inner join tp_mst_goodstype gt\n" +
  2361. " on g.goodstypeid = gt.goodstypeid\n" +
  2362. " inner join tp_mst_datadictionary dd\n" +
  2363. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2364. " where gd.valueflag = '1'\n" +
  2365. " and gd.accountid = :AccountID\n" +
  2366. " and gdd.DeliverTime >= :DeliverTimeStart \n" +
  2367. " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
  2368. " ) gddgroup\n" +
  2369. " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
  2370. " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
  2371. " ) gdd\n" +
  2372. " 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" +
  2373. //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
  2374. ") gddata";
  2375. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2376. ServiceResultEntity sre = new ServiceResultEntity();
  2377. if (data == null || data.Rows.Count == 0)
  2378. {
  2379. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2380. return sre;
  2381. }
  2382. sre.Data = new DataSet();
  2383. sre.Data.Tables.Add(data);
  2384. return sre;
  2385. }
  2386. catch (Exception ex)
  2387. {
  2388. throw ex;
  2389. }
  2390. finally
  2391. {
  2392. if (conn != null &&
  2393. conn.ConnState == ConnectionState.Open)
  2394. {
  2395. conn.Close();
  2396. }
  2397. }
  2398. }
  2399. /// <summary>
  2400. /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
  2401. /// </summary>
  2402. /// <returns>sql</returns>
  2403. private static string GetRPT040101SSQL()
  2404. {
  2405. string selSql =
  2406. "select " +
  2407. "UserCode, " +
  2408. "Groutinglinename, " +
  2409. "GoodsTypeName, " +
  2410. "GoodsCode, " +
  2411. "Goodsspecification, " +
  2412. "DICTIONARYVALUE, " +
  2413. "MouldQuantity, " +
  2414. "注浆量, " +
  2415. "交坯量, " +
  2416. "交坯率 " +
  2417. "from " +
  2418. "( " +
  2419. " select " +
  2420. " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
  2421. " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
  2422. " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
  2423. " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
  2424. " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
  2425. " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
  2426. " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
  2427. " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
  2428. " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
  2429. " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
  2430. " from " +
  2431. " ( " +
  2432. " select " +
  2433. " UserCode, " +
  2434. " Groutinglinecode, " +
  2435. " GoodsTypeName, " +
  2436. " GoodsCode, " +
  2437. " Goodsspecification, " +
  2438. " DICTIONARYVALUE, " +
  2439. " MouldQuantity, " +
  2440. " 注浆量, " +
  2441. " ( " +
  2442. " select count(TP_PM_ProductionData.Productiondataid) " +
  2443. " from TP_PM_ProductionData " +
  2444. " where " +
  2445. " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
  2446. " and TP_PM_ProductionData.Usercode=temp.UserCode " +
  2447. " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
  2448. //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
  2449. //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
  2450. //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
  2451. //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2452. //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2453. //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2454. //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2455. //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
  2456. //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
  2457. //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2458. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
  2459. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2460. " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
  2461. " ) as 交坯量 " +
  2462. " from " +
  2463. " ( " +
  2464. " select " +
  2465. " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
  2466. " TP_PM_GroutingDailyDetail.Groutinglineid, " +
  2467. " line.GroutinglineCode, " +
  2468. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  2469. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  2470. " TP_MST_Goods.Goodsspecification, " +
  2471. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  2472. " line.MouldQuantity, " +
  2473. " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
  2474. " from " +
  2475. " TP_PM_GroutingDailyDetail " +
  2476. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
  2477. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
  2478. " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
  2479. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
  2480. " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
  2481. " where " +
  2482. " TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2483. " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2484. " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2485. " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2486. " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
  2487. return selSql;
  2488. }
  2489. /// <summary>
  2490. /// 取得RPT040102_1画面(工序产量分析表)的查询数据
  2491. /// </summary>
  2492. /// <param name="user">登录用户信息</param>
  2493. /// <param name="se">查询条件</param>
  2494. /// <returns>查询结果</returns>
  2495. public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
  2496. {
  2497. IDBConnection conn = null;
  2498. try
  2499. {
  2500. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2501. //OracleParameter[] paras = new OracleParameter[]{
  2502. // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2503. // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2504. // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2505. // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
  2506. // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
  2507. // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2508. // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2509. //};
  2510. /*
  2511. OracleParameter[] paras = new OracleParameter[]{
  2512. new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2513. new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
  2514. new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2515. new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2516. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2517. new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
  2518. new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
  2519. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2520. };
  2521. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
  2522. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
  2523. ServiceResultEntity sre = new ServiceResultEntity();
  2524. if (data == null || data.Tables.Count == 0)
  2525. {
  2526. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2527. return sre;
  2528. }
  2529. sre.Data = new DataSet();
  2530. sre.Data = data;
  2531. return sre;
  2532. */
  2533. ServiceResultEntity sre = new ServiceResultEntity();
  2534. List<OracleParameter> parameters = new List<OracleParameter>();
  2535. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2536. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2537. string sqlString =
  2538. "select p.procedureid, p.procedurecode, p.procedurename\n" +
  2539. " from tp_pc_procedure p\n" +
  2540. " where p.valueflag = '1'\n" +
  2541. " and p.AccountID = :AccountID" +
  2542. " and p.productionlineid = :productionlineid\n";
  2543. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2544. {
  2545. sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
  2546. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2547. }
  2548. sqlString += "order by p.Displayno";
  2549. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2550. if (data == null || data.Rows.Count == 0)
  2551. {
  2552. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2553. return sre;
  2554. }
  2555. parameters.Clear();
  2556. StringBuilder sql1 = new StringBuilder();
  2557. StringBuilder sql2 = new StringBuilder();
  2558. StringBuilder sql3 = new StringBuilder();
  2559. foreach (DataRow item in data.Rows)
  2560. {
  2561. //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
  2562. //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2563. //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2564. sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
  2565. sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2566. sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2567. }
  2568. sqlString =
  2569. "select --pdg.gid,\n" +
  2570. " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
  2571. " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
  2572. " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
  2573. " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
  2574. " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
  2575. " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
  2576. sql3 +
  2577. " from ( select " +
  2578. " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
  2579. " pdata.productionlineid,\n" +
  2580. " pdata.goodstypename2,\n" +
  2581. " pdata.goodstypename,\n" +
  2582. " pdata.goodscode,\n" +
  2583. " pdata.goodsspecification,\n" +
  2584. " pdata.GOODSMODEL,\n" +
  2585. " pdata.GLAZETYPE\n" +
  2586. sql2 +
  2587. " from (" +
  2588. " select\n" +
  2589. " pd.productionlineid,\n" +
  2590. " gt2.goodstypename goodstypename2,\n" +
  2591. " gt.goodstypename,\n" +
  2592. " g.goodscode,\n" +
  2593. " g.goodsspecification,\n" +
  2594. " g.GOODSMODEL,\n" +
  2595. " dd.dictionaryvalue GLAZETYPE\n" +
  2596. sql1 +
  2597. " from tp_pm_productiondata pd\n" +
  2598. " inner join tp_mst_goods g\n" +
  2599. " on g.goodsid = pd.goodsid\n" +
  2600. " inner join tp_mst_goodstype gt\n" +
  2601. " on gt.goodstypeid = g.goodstypeid\n" +
  2602. " inner join tp_mst_goodstype gt2\n" +
  2603. " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  2604. " and gt2.accountid = gt.accountid\n" +
  2605. " inner join tp_mst_datadictionary dd\n" +
  2606. " on dd.dictionaryid = g.GLAZETYPEID\n" +
  2607. " where pd.valueflag = '1'\n" +
  2608. // 公坯、干补不算交坯工序的产量。
  2609. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2610. // modify wangx 2015-12-3
  2611. (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  2612. " and pd.accountid = :accountid\n" +
  2613. " and pd.productionlineid = :productionlineid\n" +
  2614. " and pd.createtime >= :createtimeStart\n" +
  2615. " and pd.createtime <= :createtimeEnd\n";
  2616. StringBuilder sql = new StringBuilder(sqlString);
  2617. if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
  2618. {
  2619. sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
  2620. parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2621. }
  2622. if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
  2623. {
  2624. //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
  2625. sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
  2626. parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2627. }
  2628. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2629. {
  2630. sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
  2631. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2632. }
  2633. 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))");
  2634. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2635. sqlString =
  2636. " group by \n" +
  2637. " pd.productionlineid,\n" +
  2638. " gt2.goodstypename,\n" +
  2639. " gt.goodstypename,\n" +
  2640. " g.goodscode,\n" +
  2641. " g.goodsspecification,\n" +
  2642. " g.GOODSMODEL,\n" +
  2643. " dd.dictionaryvalue\n" +
  2644. " order by gt2.goodstypename, g.goodscode" +
  2645. " ) pdata\n" +
  2646. " group by grouping sets((pdata.productionlineid,\n" +
  2647. " pdata.goodstypename2,\n" +
  2648. " pdata.goodstypename,\n" +
  2649. " pdata.goodsspecification,\n" +
  2650. " pdata.GOODSMODEL,\n" +
  2651. " pdata.GLAZETYPE,\n" +
  2652. " pdata.goodscode),\n" +
  2653. " (pdata.productionlineid,pdata.goodstypename2),\n" +
  2654. " pdata.productionlineid)\n" +
  2655. " ) pdg";
  2656. sql.Append(sqlString);
  2657. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2658. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  2659. parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
  2660. parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
  2661. DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2662. if (data1 == null || data1.Rows.Count == 0)
  2663. {
  2664. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2665. return sre;
  2666. }
  2667. sre.Data = new DataSet();
  2668. sre.Data.Tables.Add(data1);
  2669. return sre;
  2670. }
  2671. catch (Exception ex)
  2672. {
  2673. throw ex;
  2674. }
  2675. finally
  2676. {
  2677. if (conn != null &&
  2678. conn.ConnState == ConnectionState.Open)
  2679. {
  2680. conn.Close();
  2681. }
  2682. }
  2683. }
  2684. /// <summary>
  2685. /// 取得RPT040103画面(工序质量分析表)的查询数据
  2686. /// </summary>
  2687. /// <param name="user">登录用户信息</param>
  2688. /// <param name="se">查询条件</param>
  2689. /// <returns>查询结果</returns>
  2690. public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
  2691. {
  2692. IDBConnection conn = null;
  2693. try
  2694. {
  2695. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2696. List<OracleParameter> parameters = new List<OracleParameter>();
  2697. //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
  2698. string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
  2699. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  2700. ServiceResultEntity sre = new ServiceResultEntity();
  2701. if (data == null || data.Rows.Count == 0)
  2702. {
  2703. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2704. return sre;
  2705. }
  2706. sre.Data = new DataSet();
  2707. sre.Data.Tables.Add(data);
  2708. return sre;
  2709. }
  2710. catch (Exception ex)
  2711. {
  2712. throw ex;
  2713. }
  2714. finally
  2715. {
  2716. if (conn != null &&
  2717. conn.ConnState == ConnectionState.Open)
  2718. {
  2719. conn.Close();
  2720. }
  2721. }
  2722. }
  2723. /// <summary>
  2724. /// 获取RPT040103画面(工序质量分析表)的查询sql
  2725. /// </summary>
  2726. /// <returns>sql</returns>
  2727. private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2728. {
  2729. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2730. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2731. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2732. // 2015-06-16 modify by chenxy
  2733. string sqlString = "\n" +
  2734. "select qdgroup.gid,\n" +
  2735. " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  2736. " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
  2737. " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  2738. " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  2739. " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
  2740. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  2741. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  2742. " qdgroup.OutKilnCount,\n" +
  2743. " qdgroup.GoodCount,\n" +
  2744. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  2745. " qdgroup.SubstandardCount,\n" +
  2746. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  2747. " '990.00') || '%' SubstandardPercent,\n" +
  2748. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  2749. " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  2750. " '990.00') || '%' QualifiedPercent,\n" +
  2751. " qdgroup.BadCount,\n" +
  2752. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  2753. " qdgroup.ReFireCount,\n" +
  2754. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  2755. " '990.00') || '%' ReFirePercent\n" +
  2756. " from (select grouping_id(pcpl.productionlinename,\n" +
  2757. " pcp.procedurename,\n" +
  2758. " mstkiln.kilncode,\n" +
  2759. " mstgoodstype2.goodstypename,\n" +
  2760. " qd.usercode,\n" +
  2761. " --mstgoodstype.goodstypename,\n" +
  2762. " mstgoods.goodscode) gid,\n" +
  2763. " pcpl.productionlinename,\n" +
  2764. " pcp.procedurename,\n" +
  2765. " --qd.kilnid,\n" +
  2766. " mstkiln.kilncode,\n" +
  2767. " mstgoodstype2.goodstypename goodstypename2,\n" +
  2768. " qd.usercode,\n" +
  2769. " mstgoodstype.goodstypename,\n" +
  2770. " mstgoods.goodscode,\n" +
  2771. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  2772. " sum(qd.GoodCount) GoodCount,\n" +
  2773. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  2774. " sum(qd.BadCount) BadCount,\n" +
  2775. " sum(qd.ReFireCount) ReFireCount\n" +
  2776. " from (select --pdbc.barcode,\n" +
  2777. " pdbc.productionlineid,\n" +
  2778. " pdata.procedureid,\n" +
  2779. " pdata.usercode,\n" +
  2780. " pdbc.goodsid,\n" +
  2781. " pdbc.kilnid,\n" +
  2782. " --pdbc.kilncarid,\n" +
  2783. " --pdbc.kilncarbatchno,\n" +
  2784. " 1 OutKilnCount,\n" +
  2785. " case\n" +
  2786. " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
  2787. " 0\n" +
  2788. " else\n" +
  2789. " 1\n" +
  2790. " end GoodCount,\n" +
  2791. " case\n" +
  2792. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
  2793. " 1\n" +
  2794. " else\n" +
  2795. " 0\n" +
  2796. " end SubstandardCount,\n" +
  2797. " case\n" +
  2798. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
  2799. " 1\n" +
  2800. " else\n" +
  2801. " 0\n" +
  2802. " end ReFireCount,\n" +
  2803. " case\n" +
  2804. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
  2805. " 1\n" +
  2806. " else\n" +
  2807. " 0\n" +
  2808. " end BadCount\n" +
  2809. " from (select distinct pd.barcode,\n" +
  2810. " pd.productionlineid,\n" +
  2811. " pd.goodsid,\n" +
  2812. " pd.kilnid,\n" +
  2813. " --pd.kilncarid,\n" +
  2814. " pd.kilncarbatchno\n" +
  2815. " from tp_pm_productiondata pd\n" +
  2816. " where pd.valueflag = '1'\n" +
  2817. " and pd.procedureid = :in_rptSprocedureId \n" +
  2818. " and pd.AccountID = :AccountID\n ";
  2819. StringBuilder selSql = new StringBuilder(sqlString);
  2820. if (se.CreateTimeStart.HasValue)
  2821. {
  2822. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  2823. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2824. }
  2825. if (se.CreateTimeEnd.HasValue)
  2826. {
  2827. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  2828. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2829. }
  2830. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2831. {
  2832. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  2833. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2834. }
  2835. if (se.ProductionLineID.HasValue)
  2836. {
  2837. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  2838. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2839. }
  2840. //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))");
  2841. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2842. if (se.KilnID.HasValue)
  2843. {
  2844. selSql.Append(" AND pd.KilnID = :KilnID\n");
  2845. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  2846. }
  2847. sqlString =
  2848. " ) pdbc\n" + // 成检交接工序
  2849. " inner join (select distinct pd.barcode,\n" +
  2850. " pd.userid,\n" +
  2851. " pd.usercode,\n" +
  2852. " pd.procedureid\n" +
  2853. " from tp_pm_productiondata pd\n" +
  2854. " where pd.valueflag = '1'\n" +
  2855. " and pd.AccountID = :AccountID\n" +
  2856. // 公坯、干补不算交坯工序的质量。
  2857. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2858. // 干补不算交坯工序的质量。
  2859. " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
  2860. " and exists\n" +
  2861. " (select 1\n" +
  2862. " from tp_mst_rpttprocedure rptt\n" +
  2863. " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
  2864. selSql.Append(sqlString);
  2865. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  2866. {
  2867. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  2868. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  2869. }
  2870. //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))");
  2871. selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
  2872. if (!string.IsNullOrEmpty(se.UserIDS))
  2873. {
  2874. selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
  2875. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2876. }
  2877. sqlString =
  2878. " ) pdata\n" + // 生产工序
  2879. " on pdata.barcode = pdbc.barcode\n" +
  2880. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
  2881. " from (select pd.barcode,\n" +
  2882. " pd.kilncarbatchno,\n" +
  2883. " pd.goodsleveltypeid,\n" +
  2884. " pd.productiondataid,\n" +
  2885. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  2886. " from tp_pm_productiondata pd\n" +
  2887. " where pd.valueflag = '1'\n" +
  2888. " and pd.AccountID = :AccountID\n" +
  2889. " and length(pd.kilncarbatchno) > 0\n" +
  2890. " AND pd.createtime >= :CreateTimeStart\n" +
  2891. " and pd.modeltype = -1) kcbc\n" +
  2892. " where kcbc.dataid = 1) glt\n" +
  2893. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  2894. " and pdbc.barcode = glt.barcode\n" +
  2895. " left join (select distinct productiondataid, defectprocedureid" +
  2896. " from tp_pm_defect def " +
  2897. " where def.valueflag='1'" +
  2898. " and def.AccountID = :AccountID\n" +
  2899. " AND def.createtime >= :CreateTimeStart) defect\n" +
  2900. " on defect.productiondataid = glt.productiondataid\n" +
  2901. " and pdata.procedureid = defect.defectprocedureid\n" +
  2902. " ) qd\n" +
  2903. " inner join tp_pc_productionline pcpl\n" +
  2904. " on pcpl.productionlineid = qd.productionlineid\n" +
  2905. " inner join tp_pc_procedure pcp\n" +
  2906. " on pcp.procedureid = qd.procedureid\n" +
  2907. " inner join tp_mst_kiln mstkiln\n" +
  2908. " on mstkiln.kilnid = qd.kilnid\n" +
  2909. " inner join tp_mst_goods mstgoods\n" +
  2910. " on mstgoods.goodsid = qd.goodsid\n" +
  2911. " inner join tp_mst_goodstype mstgoodstype\n" +
  2912. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  2913. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  2914. " inner join tp_mst_goodstype mstgoodstype2\n" +
  2915. " on mstgoodstype2.goodstypecode =\n" +
  2916. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  2917. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  2918. " where 1=1\n";
  2919. selSql.Append(sqlString);
  2920. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2921. {
  2922. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
  2923. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  2924. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2925. }
  2926. sqlString =
  2927. " group by grouping sets((pcpl.productionlinename,\n" +
  2928. " pcp.procedurename,\n" +
  2929. " mstkiln.kilncode,\n" +
  2930. " mstgoodstype2.goodstypename,\n" +
  2931. " qd.usercode,\n" +
  2932. " mstgoodstype.goodstypename,\n" +
  2933. " mstgoods.goodscode),\n" +
  2934. " (pcpl.productionlinename,\n" +
  2935. " pcp.procedurename,\n" +
  2936. " mstkiln.kilncode,\n" +
  2937. " mstgoodstype2.goodstypename),\n" +
  2938. " (pcpl.productionlinename,\n" +
  2939. " pcp.procedurename,\n" +
  2940. " mstkiln.kilncode),\n" +
  2941. " (pcpl.productionlinename, pcp.procedurename))\n" +
  2942. " order by pcpl.productionlinename,\n" +
  2943. " pcp.procedurename,\n" +
  2944. " mstkiln.kilncode,\n" +
  2945. " mstgoodstype2.goodstypename,\n" +
  2946. " qd.usercode,\n" +
  2947. " mstgoodstype.goodstypename,\n" +
  2948. " mstgoods.goodscode\n" +
  2949. " ) qdgroup\n";
  2950. selSql.Append(sqlString);
  2951. return selSql.ToString();
  2952. }
  2953. /// <summary>
  2954. /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
  2955. /// </summary>
  2956. /// <returns>sql</returns>
  2957. private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2958. {
  2959. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2960. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2961. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2962. string sqlString = "select qdgroup.gid\n" +
  2963. " ,qdgroup.productionlinename\n" +
  2964. " ,decode(qdgroup.gid\n" +
  2965. " ,15\n" +
  2966. " ,'总计[' || qdgroup.procedurename || ']'\n" +
  2967. " ,qdgroup.procedurename) procedurename\n" +
  2968. " ,decode(qdgroup.gid\n" +
  2969. " ,7\n" +
  2970. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  2971. " ,15\n" +
  2972. " ,'--'\n" +
  2973. " ,qdgroup.kilncode) kilncode\n" +
  2974. " ,decode(qdgroup.gid\n" +
  2975. " ,3\n" +
  2976. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  2977. " ,15\n" +
  2978. " ,'--'\n" +
  2979. " ,7\n" +
  2980. " ,'--'\n" +
  2981. " ,qdgroup.goodstypename2) goodstypename2\n" +
  2982. " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
  2983. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  2984. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  2985. " ,qdgroup.OutKilnCount\n" +
  2986. " ,qdgroup.GoodCount\n" +
  2987. " ,decode(qdgroup.OutKilnCount\n" +
  2988. " ,0\n" +
  2989. " ,to_number(null)\n" +
  2990. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  2991. " ,qdgroup.SubstandardCount\n" +
  2992. " ,decode(qdgroup.OutKilnCount\n" +
  2993. " ,0\n" +
  2994. " ,to_number(null)\n" +
  2995. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  2996. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  2997. " ,decode(qdgroup.OutKilnCount\n" +
  2998. " ,0\n" +
  2999. " ,to_number(null)\n" +
  3000. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3001. " qdgroup.OutKilnCount\n" +
  3002. " ,4)) QualifiedPercent\n" +
  3003. " ,qdgroup.BadCount\n" +
  3004. " ,decode(qdgroup.OutKilnCount\n" +
  3005. " ,0\n" +
  3006. " ,to_number(null)\n" +
  3007. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3008. " ,qdgroup.ReFireCount\n" +
  3009. " ,decode(qdgroup.OutKilnCount\n" +
  3010. " ,0\n" +
  3011. " ,to_number(null)\n" +
  3012. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3013. " from (select grouping_id(pcpl.productionlinename\n" +
  3014. " ,pcp.procedurename\n" +
  3015. " ,mstkiln.kilncode\n" +
  3016. " ,mstgoodstype2.goodstypecode\n" +
  3017. " ,pdata.usercode\n" +
  3018. " ,mstgoods.goodscode) gid\n" +
  3019. " ,pcpl.productionlinename\n" +
  3020. " ,pcp.procedurename\n" +
  3021. " ,mstkiln.kilncode\n" +
  3022. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3023. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3024. " ,pdata.usercode\n" +
  3025. " ,mstgoodstype.goodstypename\n" +
  3026. " ,mstgoods.goodscode\n" +
  3027. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3028. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3029. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3030. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3031. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3032. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3033. " ,pd.barcode\n" +
  3034. " ,pd.productionlineid\n" +
  3035. " ,pd.goodsid\n" +
  3036. " ,pd.kilnid\n" +
  3037. " ,pd.kilncarbatchno\n" +
  3038. " ,0 procedureid\n" +
  3039. " ,1 cc\n" +
  3040. " from tp_pm_productiondata pd\n" +
  3041. " where pd.valueflag = '1'\n" +
  3042. " and pd.procedureid = :in_rptSprocedureId\n" +
  3043. " and pd.accountid = :in_AccountID\n";
  3044. StringBuilder selSql = new StringBuilder(sqlString);
  3045. if (se.CreateTimeStart.HasValue)
  3046. {
  3047. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3048. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3049. }
  3050. if (se.CreateTimeEnd.HasValue)
  3051. {
  3052. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3053. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3054. }
  3055. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3056. {
  3057. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3058. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3059. }
  3060. if (se.ProductionLineID.HasValue)
  3061. {
  3062. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3063. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3064. }
  3065. if (se.KilnID.HasValue)
  3066. {
  3067. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3068. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3069. }
  3070. sqlString =
  3071. " union all\n" +
  3072. " select distinct ppd.goodsleveltypeid\n" +
  3073. " ,dd.barcode\n" +
  3074. " ,dd.productionlineid\n" +
  3075. " ,dd.goodsid\n" +
  3076. " ,ppd.kilnid\n" +
  3077. " ,ppd.kilncarbatchno\n" +
  3078. " ,dd.defectprocedureid procedureid\n" +
  3079. " ,1 cc\n" +
  3080. " from (select pd.productiondataid\n" +
  3081. " ,pd.goodsleveltypeid\n" +
  3082. " ,pd.kilnid\n" +
  3083. " ,pd.kilncarbatchno\n" +
  3084. " from tp_pm_productiondata pd\n" +
  3085. " where pd.valueflag = '1'\n" +
  3086. " and pd.AccountID = :in_AccountID\n" +
  3087. " and length(pd.kilncarbatchno) > 0\n" +
  3088. " and pd.modeltype = -1\n";
  3089. selSql.Append(sqlString);
  3090. if (se.CreateTimeStart.HasValue)
  3091. {
  3092. selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3093. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3094. }
  3095. if (se.CreateTimeEnd.HasValue)
  3096. {
  3097. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3098. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3099. }
  3100. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3101. {
  3102. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3103. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3104. }
  3105. if (se.ProductionLineID.HasValue)
  3106. {
  3107. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3108. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3109. }
  3110. if (se.KilnID.HasValue)
  3111. {
  3112. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3113. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3114. }
  3115. sqlString =
  3116. " and exists\n" +
  3117. " (select 1\n" +
  3118. " from tp_pm_productiondata outpd\n" +
  3119. " where outpd.barcode = pd.barcode\n" +
  3120. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3121. " and outpd.valueflag = '1'\n" +
  3122. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3123. " inner join tp_pm_defect dd\n" +
  3124. " on dd.productiondataid = ppd.productiondataid\n" +
  3125. //" --and dd.checktime >= in_DateBegin\n" +
  3126. //" --and dd.checktime <= in_DateEnd\n" +
  3127. " ) ppcc\n" +
  3128. " inner join tp_pm_productiondata pdata\n" +
  3129. " on pdata.barcode = ppcc.barcode\n" +
  3130. // 干补不算交坯工序的质量。
  3131. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3132. " and exists\n" +
  3133. " (select 1\n" +
  3134. " from tp_mst_rpttprocedure rptt\n" +
  3135. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3136. selSql.Append(sqlString);
  3137. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3138. {
  3139. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3140. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3141. }
  3142. sqlString =
  3143. " and rptt.procedureid = pdata.procedureid)\n" +
  3144. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3145. selSql.Append(sqlString);
  3146. if (!string.IsNullOrEmpty(se.UserIDS))
  3147. {
  3148. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3149. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3150. }
  3151. sqlString =
  3152. " inner join tp_pc_productionline pcpl\n" +
  3153. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3154. " inner join tp_pc_procedure pcp\n" +
  3155. " on pcp.procedureid = pdata.procedureid\n" +
  3156. " inner join tp_mst_kiln mstkiln\n" +
  3157. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3158. " inner join tp_mst_goods mstgoods\n" +
  3159. " on mstgoods.goodsid = pdata.goodsid\n" +
  3160. " inner join tp_mst_goodstype mstgoodstype\n" +
  3161. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3162. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3163. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3164. " on mstgoodstype2.goodstypecode =\n" +
  3165. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3166. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3167. // 产品类别
  3168. selSql.Append(sqlString);
  3169. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3170. {
  3171. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3172. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3173. }
  3174. sqlString =
  3175. " 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" +
  3176. " order by pcpl.productionlinename\n" +
  3177. " ,pcp.displayno\n" +
  3178. " ,pcp.procedurename\n" +
  3179. " ,mstkiln.kilncode\n" +
  3180. " ,mstgoodstype2.goodstypecode\n" +
  3181. " ,pdata.usercode\n" +
  3182. " ,mstgoodstype.goodstypecode\n" +
  3183. " ,mstgoods.goodscode) qdgroup";
  3184. selSql.Append(sqlString);
  3185. return selSql.ToString();
  3186. }
  3187. /// <summary>
  3188. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3189. /// </summary>
  3190. /// <param name="user">登录用户信息</param>
  3191. /// <param name="se">查询条件</param>
  3192. /// <returns>查询结果</returns>
  3193. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3194. {
  3195. IDBConnection conn = null;
  3196. try
  3197. {
  3198. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3199. List<OracleParameter> parameters = new List<OracleParameter>();
  3200. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3201. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3202. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3203. ServiceResultEntity sre = new ServiceResultEntity();
  3204. if (data == null || data.Rows.Count == 0)
  3205. {
  3206. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3207. return sre;
  3208. }
  3209. sre.Data = new DataSet();
  3210. sre.Data.Tables.Add(data);
  3211. return sre;
  3212. }
  3213. catch (Exception ex)
  3214. {
  3215. throw ex;
  3216. }
  3217. finally
  3218. {
  3219. if (conn != null &&
  3220. conn.ConnState == ConnectionState.Open)
  3221. {
  3222. conn.Close();
  3223. }
  3224. }
  3225. }
  3226. /// <summary>
  3227. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3228. /// </summary>
  3229. /// <returns>sql</returns>
  3230. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3231. {
  3232. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3233. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3234. // 2015-06-16 modify by chenxy
  3235. string sqlString = "\n" +
  3236. "select qdgroup.gid,\n" +
  3237. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3238. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3239. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3240. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3241. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3242. " qdgroup.OutKilnCount,\n" +
  3243. " qdgroup.GoodCount,\n" +
  3244. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3245. " qdgroup.SubstandardCount,\n" +
  3246. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3247. " '990.00') || '%' SubstandardPercent,\n" +
  3248. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3249. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3250. " '990.00') || '%' QualifiedPercent,\n" +
  3251. " qdgroup.BadCount,\n" +
  3252. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3253. " qdgroup.ReFireCount,\n" +
  3254. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3255. " '990.00') || '%' ReFirePercent\n" +
  3256. " from (select grouping_id(pcpl.productionlinename,\n" +
  3257. " mstkiln.kilncode,\n" +
  3258. " mstgoodstype2.goodstypename,\n" +
  3259. " --mstgoodstype.goodstypename,\n" +
  3260. " mstgoods.goodscode) gid,\n" +
  3261. " pcpl.productionlinename,\n" +
  3262. " --qd.kilnid,\n" +
  3263. " mstkiln.kilncode,\n" +
  3264. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3265. " mstgoodstype.goodstypename,\n" +
  3266. " mstgoods.goodscode,\n" +
  3267. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3268. " sum(qd.GoodCount) GoodCount,\n" +
  3269. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3270. " sum(qd.BadCount) BadCount,\n" +
  3271. " sum(qd.ReFireCount) ReFireCount\n" +
  3272. " from (select --pdbc.barcode,\n" +
  3273. " pdbc.productionlineid,\n" +
  3274. " pdbc.goodsid,\n" +
  3275. " pdbc.kilnid,\n" +
  3276. " --pdbc.kilncarid,\n" +
  3277. " --pdbc.kilncarbatchno,\n" +
  3278. " 1 OutKilnCount,\n" +
  3279. " case\n" +
  3280. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3281. " 0\n" +
  3282. " else\n" +
  3283. " 1\n" +
  3284. " end GoodCount,\n" +
  3285. " case\n" +
  3286. " when glt.goodsleveltypeid = 7 then\n" +
  3287. " 1\n" +
  3288. " else\n" +
  3289. " 0\n" +
  3290. " end SubstandardCount,\n" +
  3291. " case\n" +
  3292. " when glt.goodsleveltypeid = 6 then\n" +
  3293. " 1\n" +
  3294. " else\n" +
  3295. " 0\n" +
  3296. " end ReFireCount,\n" +
  3297. " case\n" +
  3298. " when glt.goodsleveltypeid = 5 then\n" +
  3299. " 1\n" +
  3300. " else\n" +
  3301. " 0\n" +
  3302. " end BadCount\n" +
  3303. " from (select distinct pd.barcode,\n" +
  3304. " pd.productionlineid,\n" +
  3305. " pd.goodsid,\n" +
  3306. " pd.kilnid,\n" +
  3307. " --pd.kilncarid,\n" +
  3308. " pd.kilncarbatchno\n" +
  3309. " from tp_pm_productiondata pd\n" +
  3310. " where pd.valueflag = '1'\n" +
  3311. " and pd.procedureid = :in_rptSprocedureId \n" +
  3312. " and pd.AccountID = :AccountID\n";
  3313. StringBuilder selSql = new StringBuilder(sqlString);
  3314. if (se.CreateTimeStart.HasValue)
  3315. {
  3316. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3317. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3318. }
  3319. if (se.CreateTimeEnd.HasValue)
  3320. {
  3321. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3322. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3323. }
  3324. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3325. {
  3326. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3327. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3328. }
  3329. if (se.ProductionLineID.HasValue)
  3330. {
  3331. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3332. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3333. }
  3334. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3335. {
  3336. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3337. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3338. }
  3339. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3340. {
  3341. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3342. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3343. }
  3344. //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))");
  3345. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3346. if (se.KilnID.HasValue)
  3347. {
  3348. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3349. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3350. }
  3351. sqlString =
  3352. " ) pdbc\n" +
  3353. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3354. " from (select pd.barcode,\n" +
  3355. " pd.kilncarbatchno,\n" +
  3356. " pd.goodsleveltypeid,\n" +
  3357. " pd.productiondataid,\n" +
  3358. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3359. " from tp_pm_productiondata pd\n" +
  3360. " where pd.valueflag = '1'\n" +
  3361. " and pd.AccountID = :AccountID\n" +
  3362. " and length(pd.kilncarbatchno) > 0\n" +
  3363. " AND pd.createtime >= :CreateTimeStart\n" +
  3364. " and pd.modeltype = -1) kcbc\n" +
  3365. " where kcbc.dataid = 1) glt\n" +
  3366. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3367. " and pdbc.barcode = glt.barcode) qd\n" +
  3368. " inner join tp_pc_productionline pcpl\n" +
  3369. " on pcpl.productionlineid = qd.productionlineid\n" +
  3370. " inner join tp_mst_kiln mstkiln\n" +
  3371. " on mstkiln.kilnid = qd.kilnid\n" +
  3372. " inner join tp_mst_goods mstgoods\n" +
  3373. " on mstgoods.goodsid = qd.goodsid\n" +
  3374. " inner join tp_mst_goodstype mstgoodstype\n" +
  3375. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3376. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3377. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3378. " on mstgoodstype2.goodstypecode =\n" +
  3379. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3380. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3381. " where 1=1\n";
  3382. selSql.Append(sqlString);
  3383. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3384. {
  3385. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3386. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3387. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3388. }
  3389. sqlString =
  3390. " group by grouping sets((pcpl.productionlinename,\n" +
  3391. " mstkiln.kilncode,\n" +
  3392. " mstgoodstype2.goodstypename,\n" +
  3393. " mstgoodstype.goodstypename,\n" +
  3394. " mstgoods.goodscode),\n" +
  3395. " (pcpl.productionlinename,\n" +
  3396. " mstkiln.kilncode,\n" +
  3397. " mstgoodstype2.goodstypename),\n" +
  3398. " (pcpl.productionlinename,\n" +
  3399. " mstkiln.kilncode),\n" +
  3400. " pcpl.productionlinename)\n" +
  3401. " order by pcpl.productionlinename,\n" +
  3402. " mstkiln.kilncode,\n" +
  3403. " mstgoodstype2.goodstypename,\n" +
  3404. " mstgoodstype.goodstypename,\n" +
  3405. " mstgoods.goodscode\n" +
  3406. " ) qdgroup\n";
  3407. selSql.Append(sqlString);
  3408. return selSql.ToString();
  3409. }
  3410. /// <summary>
  3411. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3412. /// </summary>
  3413. /// <returns>sql</returns>
  3414. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3415. {
  3416. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3417. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3418. string sqlString = "select qdgroup.gid\n" +
  3419. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3420. " ,decode(qdgroup.gid\n" +
  3421. " ,3\n" +
  3422. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3423. " ,7\n" +
  3424. " ,'--'\n" +
  3425. " ,qdgroup.kilncode) kilncode\n" +
  3426. " ,decode(qdgroup.gid\n" +
  3427. " ,1\n" +
  3428. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3429. " ,0\n" +
  3430. " ,qdgroup.goodstypename2\n" +
  3431. " ,'--') goodstypename2\n" +
  3432. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3433. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3434. " ,qdgroup.OutKilnCount\n" +
  3435. " ,qdgroup.GoodCount\n" +
  3436. " ,decode(qdgroup.OutKilnCount\n" +
  3437. " ,0\n" +
  3438. " ,to_number(null)\n" +
  3439. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3440. " ,qdgroup.SubstandardCount\n" +
  3441. " ,decode(qdgroup.OutKilnCount\n" +
  3442. " ,0\n" +
  3443. " ,to_number(null)\n" +
  3444. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3445. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3446. " ,decode(qdgroup.OutKilnCount\n" +
  3447. " ,0\n" +
  3448. " ,to_number(null)\n" +
  3449. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3450. " qdgroup.OutKilnCount\n" +
  3451. " ,4)) QualifiedPercent\n" +
  3452. " ,qdgroup.BadCount\n" +
  3453. " ,decode(qdgroup.OutKilnCount\n" +
  3454. " ,0\n" +
  3455. " ,to_number(null)\n" +
  3456. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3457. " ,qdgroup.ReFireCount\n" +
  3458. " ,decode(qdgroup.OutKilnCount\n" +
  3459. " ,0\n" +
  3460. " ,to_number(null)\n" +
  3461. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3462. " from (select grouping_id(pcpl.productionlinename\n" +
  3463. " ,mstkiln.kilncode\n" +
  3464. " ,mstgoodstype2.goodstypecode\n" +
  3465. " ,mstgoods.goodscode) gid\n" +
  3466. " ,pcpl.productionlinename\n" +
  3467. " ,mstkiln.kilncode\n" +
  3468. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3469. " ,mstgoodstype.goodstypename\n" +
  3470. " ,mstgoods.goodscode\n" +
  3471. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3472. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3473. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3474. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3475. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3476. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3477. " ,pd.barcode\n" +
  3478. " ,pd.productionlineid\n" +
  3479. " ,pd.goodsid\n" +
  3480. " ,pd.kilnid\n" +
  3481. " ,pd.kilncarbatchno\n" +
  3482. " ,1 cc\n" +
  3483. " from tp_pm_productiondata pd\n" +
  3484. " where pd.valueflag = '1'\n" +
  3485. " and pd.procedureid = :in_rptSprocedureId\n" +
  3486. " and pd.accountid = :in_AccountID\n";
  3487. StringBuilder selSql = new StringBuilder(sqlString);
  3488. if (se.CreateTimeStart.HasValue)
  3489. {
  3490. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3491. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3492. }
  3493. if (se.CreateTimeEnd.HasValue)
  3494. {
  3495. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3496. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3497. }
  3498. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3499. {
  3500. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3501. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3502. }
  3503. if (se.ProductionLineID.HasValue)
  3504. {
  3505. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3506. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3507. }
  3508. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3509. {
  3510. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3511. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3512. }
  3513. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3514. {
  3515. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3516. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3517. }
  3518. if (se.KilnID.HasValue)
  3519. {
  3520. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3521. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3522. }
  3523. sqlString =
  3524. " union all\n" +
  3525. " select distinct pd.goodsleveltypeid\n" +
  3526. " ,pd.barcode\n" +
  3527. " ,pd.productionlineid\n" +
  3528. " ,pd.goodsid\n" +
  3529. " ,pd.kilnid\n" +
  3530. " ,pd.kilncarbatchno\n" +
  3531. " ,1 cc\n" +
  3532. " from tp_pm_productiondata pd\n" +
  3533. " where pd.valueflag = '1'\n" +
  3534. " and pd.modeltype = -1\n" +
  3535. " and pd.AccountID = :in_AccountID\n" +
  3536. " and length(pd.kilncarbatchno) > 0\n";
  3537. selSql.Append(sqlString);
  3538. if (se.CreateTimeStart.HasValue)
  3539. {
  3540. selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3541. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3542. }
  3543. if (se.CreateTimeEnd.HasValue)
  3544. {
  3545. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3546. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3547. }
  3548. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3549. {
  3550. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3551. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3552. }
  3553. if (se.ProductionLineID.HasValue)
  3554. {
  3555. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3556. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3557. }
  3558. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3559. {
  3560. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3561. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3562. }
  3563. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3564. {
  3565. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3566. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3567. }
  3568. if (se.KilnID.HasValue)
  3569. {
  3570. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3571. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3572. }
  3573. sqlString =
  3574. " and exists\n" +
  3575. " (select 1\n" +
  3576. " from tp_pm_productiondata outpd\n" +
  3577. " where outpd.barcode = pd.barcode\n" +
  3578. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3579. " and outpd.valueflag = '1'\n" +
  3580. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  3581. " inner join tp_pc_productionline pcpl\n" +
  3582. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  3583. " inner join tp_mst_kiln mstkiln\n" +
  3584. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3585. " inner join tp_mst_goods mstgoods\n" +
  3586. " on mstgoods.goodsid = ppcc.goodsid\n" +
  3587. " inner join tp_mst_goodstype mstgoodstype\n" +
  3588. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3589. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3590. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3591. " on mstgoodstype2.goodstypecode =\n" +
  3592. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3593. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3594. // 产品类别
  3595. selSql.Append(sqlString);
  3596. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3597. {
  3598. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3599. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3600. }
  3601. sqlString =
  3602. " 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" +
  3603. " order by pcpl.productionlinename\n" +
  3604. " ,mstkiln.kilncode\n" +
  3605. " ,mstgoodstype2.goodstypecode\n" +
  3606. " ,mstgoodstype.goodstypecode\n" +
  3607. " ,mstgoods.goodscode) qdgroup\n";
  3608. selSql.Append(sqlString);
  3609. return selSql.ToString();
  3610. }
  3611. /// <summary>
  3612. /// 取得RPT040105画面(质量报表)的查询数据
  3613. /// </summary>
  3614. /// <param name="user">登录用户信息</param>
  3615. /// <param name="se">查询条件</param>
  3616. /// <returns>查询结果</returns>
  3617. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  3618. {
  3619. IDBConnection conn = null;
  3620. try
  3621. {
  3622. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3623. List<OracleParameter> parameters = new List<OracleParameter>();
  3624. string sqlString =
  3625. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  3626. " FROM tp_pm_groutingdailydetail gdd\n" +
  3627. " INNER JOIN tp_mst_goods g\n" +
  3628. " ON g.goodsid = gdd.goodsid\n" +
  3629. " INNER JOIN tp_mst_goodstype gt\n" +
  3630. " ON gt.goodstypeid = g.goodstypeid\n" +
  3631. " WHERE gdd.accountid = :accountid\n" +
  3632. " AND gdd.valueflag = '1'\n" +
  3633. " AND gdd.groutingdate >= :datebegin\n" +
  3634. " AND gdd.groutingdate <= :dateend\n" +
  3635. " AND gdd.groutingflag = '1'\n" +
  3636. " AND gdd.barcode IS NOT NULL\n" +
  3637. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  3638. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3639. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  3640. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  3641. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3642. parameters.Clear();
  3643. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  3644. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  3645. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3646. ServiceResultEntity sre = new ServiceResultEntity();
  3647. if (data == null || data.Rows.Count == 0)
  3648. {
  3649. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3650. return sre;
  3651. }
  3652. data.Columns.Add("GCount", typeof(int));
  3653. //data.Columns.Add("OutGCount", typeof(string));
  3654. //data.Columns.Add("GoodGCount", typeof(string));
  3655. data.Columns.Add("OutGCount", typeof(decimal));
  3656. data.Columns.Add("GoodGCount", typeof(decimal));
  3657. foreach (DataRow item in data.Rows)
  3658. {
  3659. int gid = Convert.ToInt32(item["gid"]);
  3660. if (gid < 2)
  3661. {
  3662. continue;
  3663. }
  3664. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  3665. int goodCount = Convert.ToInt32(item["Qualified"]);
  3666. DataRow[] drs = null;
  3667. if (gid == 2)
  3668. {
  3669. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  3670. }
  3671. else if (gid == 3)
  3672. {
  3673. drs = dataCount.Select("goodstypecode2 is null");
  3674. }
  3675. if (drs != null && drs.Length > 0)
  3676. {
  3677. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  3678. item["GCount"] = barcodecount;
  3679. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3680. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3681. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  3682. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  3683. }
  3684. else
  3685. {
  3686. item["GCount"] = 0;
  3687. //item["OutGCount"] = "#DIV/0!";
  3688. //item["GoodGCount"] = "#DIV/0!";
  3689. item["OutGCount"] = DBNull.Value;
  3690. item["GoodGCount"] = DBNull.Value;
  3691. }
  3692. }
  3693. sre.Data = new DataSet();
  3694. sre.Data.Tables.Add(data);
  3695. return sre;
  3696. }
  3697. catch (Exception ex)
  3698. {
  3699. throw ex;
  3700. }
  3701. finally
  3702. {
  3703. if (conn != null &&
  3704. conn.ConnState == ConnectionState.Open)
  3705. {
  3706. conn.Close();
  3707. }
  3708. }
  3709. }
  3710. /// <summary>
  3711. /// 获取RPT040105画面(质量报表)的查询sql
  3712. /// </summary>
  3713. /// <returns>sql</returns>
  3714. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3715. {
  3716. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3717. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3718. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3719. // 2015-06-16 modify by chenxy
  3720. string sqlString = "\n" +
  3721. "select qdgroup.gid,\n" +
  3722. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3723. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3724. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3725. " qdgroup.goodstypecode2,\n" +
  3726. " qdgroup.OutKilnCount,\n" +
  3727. " qdgroup.GoodCount,\n" +
  3728. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3729. " qdgroup.SubstandardCount,\n" +
  3730. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3731. " '990.00') || '%' SubstandardPercent,\n" +
  3732. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3733. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3734. " '990.00') || '%' QualifiedPercent,\n" +
  3735. " qdgroup.BadCount,\n" +
  3736. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3737. " qdgroup.ReFireCount,\n" +
  3738. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3739. " '990.00') || '%' ReFirePercent\n" +
  3740. " from (select grouping_id(pcpl.productionlinename,\n" +
  3741. " mstkiln.kilncode,\n" +
  3742. " mstgoodstype2.goodstypecode) gid,\n" +
  3743. " pcpl.productionlinename,\n" +
  3744. " mstkiln.kilncode,\n" +
  3745. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  3746. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3747. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3748. " sum(qd.GoodCount) GoodCount,\n" +
  3749. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3750. " sum(qd.BadCount) BadCount,\n" +
  3751. " sum(qd.ReFireCount) ReFireCount\n" +
  3752. " from (select --pdbc.barcode,\n" +
  3753. " pdbc.productionlineid,\n" +
  3754. " pdbc.goodsid,\n" +
  3755. " pdbc.kilnid,\n" +
  3756. " 1 OutKilnCount,\n" +
  3757. " case\n" +
  3758. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3759. " 0\n" +
  3760. " else\n" +
  3761. " 1\n" +
  3762. " end GoodCount,\n" +
  3763. " case\n" +
  3764. " when glt.goodsleveltypeid = 7 then\n" +
  3765. " 1\n" +
  3766. " else\n" +
  3767. " 0\n" +
  3768. " end SubstandardCount,\n" +
  3769. " case\n" +
  3770. " when glt.goodsleveltypeid = 6 then\n" +
  3771. " 1\n" +
  3772. " else\n" +
  3773. " 0\n" +
  3774. " end ReFireCount,\n" +
  3775. " case\n" +
  3776. " when glt.goodsleveltypeid = 5 then\n" +
  3777. " 1\n" +
  3778. " else\n" +
  3779. " 0\n" +
  3780. " end BadCount\n" +
  3781. " from (select distinct pd.barcode,\n" +
  3782. " pd.productionlineid,\n" +
  3783. " pd.goodsid,\n" +
  3784. " pd.kilnid,\n" +
  3785. " pd.kilncarbatchno\n" +
  3786. " from tp_pm_productiondata pd\n" +
  3787. " where pd.valueflag = '1'\n" +
  3788. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  3789. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  3790. " and pd.AccountID = :AccountID\n";
  3791. StringBuilder selSql = new StringBuilder(sqlString);
  3792. if (se.CreateTimeStart.HasValue)
  3793. {
  3794. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3795. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3796. }
  3797. if (se.CreateTimeEnd.HasValue)
  3798. {
  3799. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3800. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3801. }
  3802. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3803. {
  3804. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3805. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3806. }
  3807. if (se.ProductionLineID.HasValue)
  3808. {
  3809. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3810. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3811. }
  3812. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3813. {
  3814. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3815. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3816. }
  3817. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3818. {
  3819. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3820. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3821. }
  3822. // 不控制权限
  3823. //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))");
  3824. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3825. if (se.KilnID.HasValue)
  3826. {
  3827. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3828. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3829. }
  3830. sqlString =
  3831. " ) pdbc\n" +
  3832. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3833. " from (select pd.barcode,\n" +
  3834. " pd.kilncarbatchno,\n" +
  3835. " pd.goodsleveltypeid,\n" +
  3836. " pd.productiondataid,\n" +
  3837. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3838. " from tp_pm_productiondata pd\n" +
  3839. " where pd.valueflag = '1'\n" +
  3840. " and pd.AccountID = :AccountID\n" +
  3841. " and length(pd.kilncarbatchno) > 0\n" +
  3842. " AND pd.createtime >= :CreateTimeStart\n" +
  3843. " and pd.modeltype = -1) kcbc\n" +
  3844. " where kcbc.dataid = 1) glt\n" +
  3845. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3846. " and pdbc.barcode = glt.barcode) qd\n" +
  3847. " inner join tp_pc_productionline pcpl\n" +
  3848. " on pcpl.productionlineid = qd.productionlineid\n" +
  3849. " inner join tp_mst_kiln mstkiln\n" +
  3850. " on mstkiln.kilnid = qd.kilnid\n" +
  3851. " inner join tp_mst_goods mstgoods\n" +
  3852. " on mstgoods.goodsid = qd.goodsid\n" +
  3853. " inner join tp_mst_goodstype mstgoodstype\n" +
  3854. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3855. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3856. " on mstgoodstype2.goodstypecode =\n" +
  3857. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3858. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3859. " where 1=1\n";
  3860. selSql.Append(sqlString);
  3861. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3862. {
  3863. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  3864. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3865. }
  3866. sqlString =
  3867. " group by grouping sets((pcpl.productionlinename,\n" +
  3868. " mstkiln.kilncode,\n" +
  3869. " mstgoodstype2.goodstypecode,\n" +
  3870. " mstgoodstype2.goodstypename),\n" +
  3871. " (pcpl.productionlinename,\n" +
  3872. " mstgoodstype2.goodstypecode,\n" +
  3873. " mstgoodstype2.goodstypename),\n" +
  3874. " (pcpl.productionlinename,\n" +
  3875. " mstkiln.kilncode),\n" +
  3876. " pcpl.productionlinename)\n" +
  3877. " order by pcpl.productionlinename,\n" +
  3878. " mstkiln.kilncode,\n" +
  3879. " mstgoodstype2.goodstypename\n" +
  3880. " ) qdgroup\n";
  3881. selSql.Append(sqlString);
  3882. return selSql.ToString();
  3883. }
  3884. /// <summary>
  3885. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  3886. /// </summary>
  3887. /// <returns>sql</returns>
  3888. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3889. {
  3890. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3891. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3892. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3893. string sqlString = "select qdgroup.gid\n" +
  3894. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  3895. " ,decode(qdgroup.gid\n" +
  3896. " ,1\n" +
  3897. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3898. " ,0\n" +
  3899. " ,qdgroup.kilncode\n" +
  3900. " ,'--') kilncode\n" +
  3901. " ,decode(qdgroup.gid\n" +
  3902. " ,2\n" +
  3903. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  3904. " ,0\n" +
  3905. " ,qdgroup.goodstypename2\n" +
  3906. " ,'--') goodstypename2\n" +
  3907. " ,qdgroup.goodstypecode2\n" +
  3908. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3909. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3910. " ,qdgroup.OutKilnCount\n" +
  3911. " ,qdgroup.GoodCount\n" +
  3912. " ,decode(qdgroup.OutKilnCount\n" +
  3913. " ,0\n" +
  3914. " ,to_number(null)\n" +
  3915. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3916. " ,qdgroup.SubstandardCount\n" +
  3917. " ,decode(qdgroup.OutKilnCount\n" +
  3918. " ,0\n" +
  3919. " ,to_number(null)\n" +
  3920. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3921. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3922. " ,decode(qdgroup.OutKilnCount\n" +
  3923. " ,0\n" +
  3924. " ,to_number(null)\n" +
  3925. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3926. " qdgroup.OutKilnCount\n" +
  3927. " ,4)) QualifiedPercent\n" +
  3928. " ,qdgroup.BadCount\n" +
  3929. " ,decode(qdgroup.OutKilnCount\n" +
  3930. " ,0\n" +
  3931. " ,to_number(null)\n" +
  3932. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3933. " ,qdgroup.ReFireCount\n" +
  3934. " ,decode(qdgroup.OutKilnCount\n" +
  3935. " ,0\n" +
  3936. " ,to_number(null)\n" +
  3937. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3938. " from (select grouping_id(pcpl.productionlinename\n" +
  3939. " ,mstkiln.kilncode\n" +
  3940. " ,mstgoodstype2.goodstypecode) gid\n" +
  3941. " ,pcpl.productionlinename\n" +
  3942. " ,mstkiln.kilncode\n" +
  3943. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3944. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3945. //" ,mstgoodstype.goodstypename\n" +
  3946. //" ,mstgoods.goodscode\n" +
  3947. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3948. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3949. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3950. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3951. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3952. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3953. " ,pd.barcode\n" +
  3954. " ,pd.productionlineid\n" +
  3955. " ,pd.goodsid\n" +
  3956. " ,pd.kilnid\n" +
  3957. " ,pd.kilncarbatchno\n" +
  3958. " ,1 cc\n" +
  3959. " from tp_pm_productiondata pd\n" +
  3960. " where pd.valueflag = '1'\n" +
  3961. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  3962. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  3963. " and pd.accountid = :in_AccountID\n";
  3964. StringBuilder selSql = new StringBuilder(sqlString);
  3965. if (se.CreateTimeStart.HasValue)
  3966. {
  3967. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3968. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3969. }
  3970. if (se.CreateTimeEnd.HasValue)
  3971. {
  3972. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3973. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3974. }
  3975. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3976. {
  3977. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3978. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3979. }
  3980. if (se.ProductionLineID.HasValue)
  3981. {
  3982. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3983. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3984. }
  3985. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3986. {
  3987. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3988. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3989. }
  3990. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3991. {
  3992. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3993. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3994. }
  3995. if (se.KilnID.HasValue)
  3996. {
  3997. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3998. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3999. }
  4000. sqlString =
  4001. " union all\n" +
  4002. " select distinct pd.goodsleveltypeid\n" +
  4003. " ,pd.barcode\n" +
  4004. " ,pd.productionlineid\n" +
  4005. " ,pd.goodsid\n" +
  4006. " ,pd.kilnid\n" +
  4007. " ,pd.kilncarbatchno\n" +
  4008. " ,1 cc\n" +
  4009. " from tp_pm_productiondata pd\n" +
  4010. " where pd.valueflag = '1'\n" +
  4011. " and pd.modeltype = -1\n" +
  4012. " and pd.AccountID = :in_AccountID\n" +
  4013. " and length(pd.kilncarbatchno) > 0\n";
  4014. selSql.Append(sqlString);
  4015. if (se.CreateTimeStart.HasValue)
  4016. {
  4017. selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4018. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4019. }
  4020. if (se.CreateTimeEnd.HasValue)
  4021. {
  4022. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4023. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4024. }
  4025. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4026. {
  4027. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4028. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4029. }
  4030. if (se.ProductionLineID.HasValue)
  4031. {
  4032. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4033. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4034. }
  4035. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4036. {
  4037. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4038. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4039. }
  4040. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4041. {
  4042. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4043. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4044. }
  4045. if (se.KilnID.HasValue)
  4046. {
  4047. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4048. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4049. }
  4050. sqlString =
  4051. " and exists\n" +
  4052. " (select 1\n" +
  4053. " from tp_pm_productiondata outpd\n" +
  4054. " where outpd.barcode = pd.barcode\n" +
  4055. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4056. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4057. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4058. " and outpd.valueflag = '1'\n" +
  4059. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4060. " inner join tp_pc_productionline pcpl\n" +
  4061. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4062. " inner join tp_mst_kiln mstkiln\n" +
  4063. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4064. " inner join tp_mst_goods mstgoods\n" +
  4065. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4066. " inner join tp_mst_goodstype mstgoodstype\n" +
  4067. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4068. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4069. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4070. " on mstgoodstype2.goodstypecode =\n" +
  4071. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4072. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4073. // 产品类别
  4074. selSql.Append(sqlString);
  4075. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4076. {
  4077. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4078. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4079. }
  4080. sqlString =
  4081. " 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" +
  4082. " order by pcpl.productionlinename\n" +
  4083. " ,mstkiln.kilncode\n" +
  4084. " ,mstgoodstype2.goodstypecode\n" +
  4085. " ) qdgroup\n";
  4086. selSql.Append(sqlString);
  4087. return selSql.ToString();
  4088. }
  4089. /// <summary>
  4090. /// 取得RPT040106画面(缺陷报表)的查询数据
  4091. /// </summary>
  4092. /// <param name="user">登录用户信息</param>
  4093. /// <param name="se">查询条件</param>
  4094. /// <returns>查询结果</returns>
  4095. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4096. {
  4097. IDBConnection conn = null;
  4098. try
  4099. {
  4100. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4101. string sqlString = null;
  4102. OracleParameter[] parameters = null;
  4103. if (se.OutKilnNumByGoodsType)
  4104. {
  4105. sqlString = "SELECT Defect.productionlinename\n" +
  4106. " ,Defect.procedurename\n" +
  4107. " ,Defect.Defectcode\n" +
  4108. " ,Defect.Defectname\n" +
  4109. " ,Defect.goodstypename2\n" +
  4110. " ,Defect.DefectCount\n" +
  4111. " ,OUT.outNum OutKilnCount\n" +
  4112. " ,decode(OUT.outNum,\n" +
  4113. " 0,\n" +
  4114. " to_number(NULL),\n" +
  4115. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4116. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4117. " ,tp_pc_procedure.procedurename\n" +
  4118. " ,TP_MST_DefectType.Defecttypename\n" +
  4119. " ,TP_MST_Defect.Defectcode\n" +
  4120. " ,TP_MST_Defect.Defectname\n" +
  4121. " ,goodstype2.goodstypename goodstypename2\n" +
  4122. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4123. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4124. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4125. " FROM TP_PM_Defect\n" +
  4126. " LEFT JOIN tp_pc_procedure\n" +
  4127. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4128. " LEFT JOIN tp_pc_productionline\n" +
  4129. " ON TP_PM_Defect.Productionlineid =\n" +
  4130. " tp_pc_productionline.Productionlineid\n" +
  4131. " LEFT JOIN TP_MST_Goods\n" +
  4132. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4133. " LEFT JOIN TP_MST_GoodsType\n" +
  4134. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4135. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4136. " ON goodstype2.goodstypecode =\n" +
  4137. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4138. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4139. " LEFT JOIN TP_MST_Defect\n" +
  4140. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4141. " LEFT JOIN TP_MST_DefectType\n" +
  4142. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4143. " --LEFT JOIN TP_PM_ProductionData\n" +
  4144. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4145. " -- TP_PM_Defect.ProductionDataID\n" +
  4146. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4147. " --AND tp_pc_procedure.ModelType = -1\n" +
  4148. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4149. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4150. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4151. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4152. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4153. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4154. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4155. " ,tp_pc_procedure.procedurename\n" +
  4156. " ,TP_MST_DefectType.Defecttypename\n" +
  4157. " ,TP_MST_Defect.Defectcode\n" +
  4158. " ,TP_MST_Defect.Defectname\n" +
  4159. " ,goodstype2.goodstypecode\n" +
  4160. " ,goodstype2.goodstypename) Defect\n" +
  4161. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4162. " FROM tp_pm_productiondata pd\n" +
  4163. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4164. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4165. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4166. " WHERE pd.valueflag = '1'\n" +
  4167. " AND pd.procedureid = :procedureid\n" +
  4168. " AND pd.AccountID = :AccountID\n" +
  4169. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4170. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4171. " GROUP BY gt2.goodstypecode) OUT \n" +
  4172. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4173. parameters = new OracleParameter[]
  4174. {
  4175. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4176. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4177. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4178. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4179. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4180. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4181. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4182. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4183. };
  4184. }
  4185. else
  4186. {
  4187. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4188. " FROM tp_pm_productiondata pd\n" +
  4189. " WHERE pd.valueflag = '1'\n" +
  4190. " AND pd.procedureid = :procedureid\n" +
  4191. " AND pd.AccountID = :AccountID\n" +
  4192. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4193. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4194. parameters = new OracleParameter[]
  4195. {
  4196. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4197. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4198. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4199. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4200. };
  4201. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4202. sqlString = "SELECT Defect.productionlinename\n" +
  4203. " ,Defect.procedurename\n" +
  4204. " ,Defect.Defectcode\n" +
  4205. " ,Defect.Defectname\n" +
  4206. " ,Defect.goodstypename2\n" +
  4207. " ,Defect.DefectCount\n" +
  4208. " ,:OutKilnCount OutKilnCount\n" +
  4209. " ,decode(:OutKilnCount,\n" +
  4210. " 0,\n" +
  4211. " to_number(NULL),\n" +
  4212. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4213. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4214. " ,tp_pc_procedure.procedurename\n" +
  4215. " ,TP_MST_DefectType.Defecttypename\n" +
  4216. " ,TP_MST_Defect.Defectcode\n" +
  4217. " ,TP_MST_Defect.Defectname\n" +
  4218. " ,goodstype2.goodstypename goodstypename2\n" +
  4219. " ,:OutKilnCount OutKilnCount\n" +
  4220. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4221. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4222. " FROM TP_PM_Defect\n" +
  4223. " LEFT JOIN tp_pc_procedure\n" +
  4224. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4225. " LEFT JOIN tp_pc_productionline\n" +
  4226. " ON TP_PM_Defect.Productionlineid =\n" +
  4227. " tp_pc_productionline.Productionlineid\n" +
  4228. " LEFT JOIN TP_MST_Goods\n" +
  4229. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4230. " LEFT JOIN TP_MST_GoodsType\n" +
  4231. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4232. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4233. " ON goodstype2.goodstypecode =\n" +
  4234. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4235. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4236. " LEFT JOIN TP_MST_Defect\n" +
  4237. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4238. " LEFT JOIN TP_MST_DefectType\n" +
  4239. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4240. " --LEFT JOIN TP_PM_ProductionData\n" +
  4241. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4242. " -- TP_PM_Defect.ProductionDataID\n" +
  4243. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4244. " --AND tp_pc_procedure.ModelType = -1\n" +
  4245. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4246. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4247. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4248. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4249. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4250. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4251. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4252. " ,tp_pc_procedure.procedurename\n" +
  4253. " ,TP_MST_DefectType.Defecttypename\n" +
  4254. " ,TP_MST_Defect.Defectcode\n" +
  4255. " ,TP_MST_Defect.Defectname\n" +
  4256. " ,goodstype2.goodstypename) Defect";
  4257. parameters = new OracleParameter[]
  4258. {
  4259. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4260. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4261. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4262. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4263. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4264. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4265. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4266. };
  4267. }
  4268. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4269. ServiceResultEntity sre = new ServiceResultEntity();
  4270. if (data == null || data.Rows.Count == 0)
  4271. {
  4272. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4273. return sre;
  4274. }
  4275. sre.Data = new DataSet();
  4276. sre.Data.Tables.Add(data);
  4277. return sre;
  4278. }
  4279. catch (Exception ex)
  4280. {
  4281. throw ex;
  4282. }
  4283. finally
  4284. {
  4285. if (conn != null &&
  4286. conn.ConnState == ConnectionState.Open)
  4287. {
  4288. conn.Close();
  4289. }
  4290. }
  4291. }
  4292. /// <summary>
  4293. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4294. /// </summary>
  4295. /// <param name="user">登录用户信息</param>
  4296. /// <param name="se">查询条件</param>
  4297. /// <returns>查询结果</returns>
  4298. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4299. {
  4300. IDBConnection conn = null;
  4301. try
  4302. {
  4303. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4304. List<OracleParameter> parameters = new List<OracleParameter>();
  4305. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4306. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4307. string sqlString =
  4308. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4309. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4310. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4311. " p.procedurename || '\"',\n" +
  4312. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4313. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4314. " ,to_char(p.procedurename) procedurename\n" +
  4315. " ,p.displayno\n" +
  4316. " ,p.productionlineid plid\n" +
  4317. " ,p.procedureid pid\n" +
  4318. " FROM tp_pc_procedure p\n" +
  4319. " WHERE p.valueflag = '1'\n" +
  4320. " AND p.modeltype <> -1\n" +
  4321. " AND p.accountid = :AccountID\n" +
  4322. " UNION ALL\n" +
  4323. " SELECT to_char(p.procedureid) || 'S'\n" +
  4324. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4325. " ,p.displayno\n" +
  4326. " ,p.productionlineid plid\n" +
  4327. " ,p.procedureid pid\n" +
  4328. " FROM tp_pc_procedure p\n" +
  4329. " WHERE p.valueflag = '1'\n" +
  4330. " AND p.modeltype = -1\n" +
  4331. " AND p.accountid = :AccountID) p" +
  4332. " 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" +
  4333. " 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";
  4334. // 生产线
  4335. if (se.ProductionLineID.HasValue)
  4336. {
  4337. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4338. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4339. }
  4340. // 生产工序
  4341. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4342. {
  4343. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4344. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4345. }
  4346. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4347. ServiceResultEntity sre = new ServiceResultEntity();
  4348. if (cols == null || cols.Rows.Count == 0)
  4349. {
  4350. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4351. return sre;
  4352. }
  4353. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4354. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4355. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4356. {
  4357. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4358. return sre;
  4359. }
  4360. parameters.Clear();
  4361. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4362. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4363. sqlString =
  4364. "WITH pd_data AS\n" +
  4365. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4366. " ,pd.groutingdailydetailid\n" +
  4367. " ,decode(pd.MODELTYPE,\n" +
  4368. " -1,\n" +
  4369. " to_char(pd.procedureid) || 'S',\n" +
  4370. " to_char(pd.procedureid)) procedureid\n" +
  4371. " FROM tp_pm_productiondata pd\n" +
  4372. " LEFT JOIN tp_mst_goods goods\n" +
  4373. " ON goods.goodsid = pd.goodsid\n" +
  4374. " LEFT JOIN tp_mst_goodstype gt\n" +
  4375. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4376. " WHERE pd.valueflag = '1'\n" +
  4377. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4378. " AND pd.accountid = :AccountID\n" +
  4379. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4380. " 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" +
  4381. " 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";
  4382. // 生产线
  4383. if (se.ProductionLineID.HasValue)
  4384. {
  4385. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4386. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4387. }
  4388. // 生产工序
  4389. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4390. {
  4391. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4392. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4393. }
  4394. // 产品型号
  4395. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4396. {
  4397. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4398. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4399. }
  4400. // 产品编码
  4401. if (!string.IsNullOrEmpty(se.GoodsCode))
  4402. {
  4403. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4404. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4405. }
  4406. // 注浆时间
  4407. if (se.GTimeStart.HasValue)
  4408. {
  4409. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4410. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4411. }
  4412. if (se.GTimeEnd.HasValue)
  4413. {
  4414. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4415. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4416. }
  4417. sqlString +=
  4418. " ),\n" +
  4419. "pivot_data AS\n" +
  4420. " (SELECT *\n" +
  4421. " FROM pd_data\n" +
  4422. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4423. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4424. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4425. " 3,\n" +
  4426. " '合计',\n" +
  4427. " 1,\n" +
  4428. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4429. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4430. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4431. " 0,\n" +
  4432. " groutdetail.goodscode,\n" +
  4433. " '--') \"产品编码\"\n" +
  4434. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4435. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4436. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4437. " ," + groupsum + "\n" +
  4438. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4439. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4440. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4441. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4442. " FROM tp_pm_groutingdailydetail gdd\n" +
  4443. " LEFT JOIN tp_mst_goods goods\n" +
  4444. " ON goods.goodsid = gdd.goodsid\n" +
  4445. " LEFT JOIN tp_mst_goodstype gt\n" +
  4446. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4447. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4448. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4449. " AND gt2.accountid = gt.accountid\n" +
  4450. " WHERE gdd.valueflag = '1'\n" +
  4451. " AND gdd.accountid = :AccountID\n";
  4452. // 产品型号
  4453. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4454. {
  4455. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4456. }
  4457. // 产品编码
  4458. if (!string.IsNullOrEmpty(se.GoodsCode))
  4459. {
  4460. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4461. }
  4462. // 注浆时间
  4463. if (se.GTimeStart.HasValue)
  4464. {
  4465. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4466. }
  4467. if (se.GTimeEnd.HasValue)
  4468. {
  4469. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4470. }
  4471. sqlString +=
  4472. " AND gdd.groutingflag = '1'\n" +
  4473. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4474. " LEFT JOIN pivot_data pd\n" +
  4475. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4476. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4477. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4478. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4479. if (data == null || data.Rows.Count == 0)
  4480. {
  4481. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4482. return sre;
  4483. }
  4484. sre.Data = new DataSet();
  4485. sre.Data.Tables.Add(data);
  4486. return sre;
  4487. }
  4488. catch (Exception ex)
  4489. {
  4490. throw ex;
  4491. }
  4492. finally
  4493. {
  4494. if (conn != null &&
  4495. conn.ConnState == ConnectionState.Open)
  4496. {
  4497. conn.Close();
  4498. }
  4499. }
  4500. }
  4501. /// <summary>
  4502. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  4503. /// </summary>
  4504. /// <param name="user">登录用户信息</param>
  4505. /// <param name="se">查询条件</param>
  4506. /// <returns>查询结果</returns>
  4507. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  4508. {
  4509. IDBConnection conn = null;
  4510. try
  4511. {
  4512. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4513. //string sqlString =
  4514. // "SELECT t.groutinglinecode\n" +
  4515. // " ,t.BuildingNo\n" +
  4516. // " ,t.FloorNo\n" +
  4517. // " ,t.GroutingLineNo\n" +
  4518. // " ,t.usercode\n" +
  4519. // " ,t.goodscode\n" +
  4520. // " ,t.GOODSSPECIFICATION\n" +
  4521. // " ,t.goodstypename\n" +
  4522. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  4523. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  4524. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  4525. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  4526. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  4527. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  4528. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  4529. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  4530. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  4531. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  4532. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  4533. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  4534. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  4535. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  4536. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  4537. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  4538. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  4539. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  4540. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  4541. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  4542. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  4543. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  4544. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  4545. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  4546. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  4547. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  4548. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  4549. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  4550. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  4551. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  4552. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  4553. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  4554. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  4555. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  4556. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  4557. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  4558. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  4559. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  4560. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  4561. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  4562. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  4563. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  4564. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  4565. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  4566. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  4567. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  4568. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  4569. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  4570. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  4571. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  4572. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  4573. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  4574. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  4575. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  4576. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  4577. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  4578. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  4579. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  4580. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  4581. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  4582. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  4583. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  4584. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  4585. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  4586. // " FROM (SELECT gd.groutinglinecode\n" +
  4587. // " ,gl.BuildingNo\n" +
  4588. // " ,gl.FloorNo\n" +
  4589. // " ,gl.GroutingLineNo\n" +
  4590. // " ,gd.usercode\n" +
  4591. // " ,gdd.goodscode\n" +
  4592. // " ,g.GOODSSPECIFICATION\n" +
  4593. // " ,gt.goodstypename\n" +
  4594. // //" ,gd.MouldQuantity\n" +
  4595. // " ,gl.MouldQuantity\n" +
  4596. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  4597. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  4598. // " , CASE\n" +
  4599. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  4600. // " gd.groutingdate <= :GDateEnd AND\n" +
  4601. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  4602. // " 1\n" +
  4603. // " ELSE\n" +
  4604. // " 0\n" +
  4605. // " END c -- 成坯量\n" +
  4606. // " , CASE\n" +
  4607. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  4608. // " gdd.delivertime <= :GDateEnd AND\n" +
  4609. // " gdd.deliverflag = '1' THEN\n" +
  4610. // " 1\n" +
  4611. // " ELSE\n" +
  4612. // " 0\n" +
  4613. // " END d -- 交坯量\n" +
  4614. // " FROM TP_PM_GroutingDaily gd\n" +
  4615. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  4616. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  4617. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  4618. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  4619. // " INNER JOIN TP_MST_Goods g\n" +
  4620. // " ON g.goodsid = gdd.goodsid\n" +
  4621. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  4622. // " ON gt.goodstypeid = g.goodstypeid\n" +
  4623. // " WHERE gd.accountid = :AccountID\n" +
  4624. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  4625. // " gd.groutingdate <= :GDateEnd) OR\n" +
  4626. // " (gdd.delivertime >= :GDateBegin AND\n" +
  4627. // " gdd.delivertime <= :GDateEnd))\n" +
  4628. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4629. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4630. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4631. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  4632. // " ) t\n" +
  4633. // " GROUP BY t.groutinglinecode\n" +
  4634. // " ,t.BuildingNo\n" +
  4635. // " ,t.FloorNo\n" +
  4636. // " ,t.GroutingLineNo\n" +
  4637. // " ,t.usercode\n" +
  4638. // " ,t.goodscode\n" +
  4639. // " ,t.GOODSSPECIFICATION\n" +
  4640. // " ,t.goodstypename\n" +
  4641. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  4642. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  4643. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  4644. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  4645. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  4646. " ,nvl(t.usercode, '--') usercode\n" +
  4647. " ,nvl2(t.groutinglinecode\n" +
  4648. " ,t.goodscode\n" +
  4649. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  4650. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  4651. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  4652. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  4653. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  4654. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  4655. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  4656. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  4657. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  4658. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  4659. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  4660. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  4661. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  4662. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  4663. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  4664. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  4665. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  4666. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  4667. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  4668. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  4669. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  4670. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  4671. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  4672. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  4673. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  4674. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  4675. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  4676. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  4677. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  4678. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  4679. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  4680. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  4681. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  4682. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  4683. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  4684. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  4685. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  4686. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  4687. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  4688. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  4689. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  4690. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  4691. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  4692. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  4693. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  4694. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  4695. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  4696. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  4697. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  4698. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  4699. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  4700. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  4701. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  4702. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  4703. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  4704. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  4705. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  4706. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  4707. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  4708. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  4709. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  4710. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  4711. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  4712. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  4713. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  4714. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  4715. " from (select gd.groutinglinecode\n" +
  4716. " ,gl.BuildingNo\n" +
  4717. " ,gl.FloorNo\n" +
  4718. " ,gl.GroutingLineNo\n" +
  4719. " ,gd.usercode\n" +
  4720. " ,gdd.goodscode\n" +
  4721. " ,g.GOODSSPECIFICATION\n" +
  4722. " ,gt.goodstypename\n" +
  4723. " ,gl.MouldQuantity\n" +
  4724. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  4725. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  4726. " ,case\n" +
  4727. " when gd.groutingdate >= :GDateBegin and\n" +
  4728. " gd.groutingdate <= :GDateEnd and\n" +
  4729. " gdd.GroutingFlag = '1' and\n" +
  4730. " gdd.ScrapFlag = '0' then\n" +
  4731. " 1\n" +
  4732. " else\n" +
  4733. " 0\n" +
  4734. " end c -- 成坯量\n" +
  4735. " ,case\n" +
  4736. " when gdd.delivertime >= :GDateBegin and\n" +
  4737. " gdd.delivertime <= :GDateEnd and\n" +
  4738. " gdd.deliverflag = '1' then\n" +
  4739. " 1\n" +
  4740. " else\n" +
  4741. " 0\n" +
  4742. " end d -- 交坯量\n" +
  4743. " from TP_PM_GroutingDaily gd\n" +
  4744. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  4745. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  4746. " inner join TP_PC_GroutingLine gl\n" +
  4747. " on gl.groutinglineid = gd.groutinglineid\n" +
  4748. " inner join TP_MST_Goods g\n" +
  4749. " on g.goodsid = gdd.goodsid\n" +
  4750. " inner join TP_MST_GOODSTYPE gt\n" +
  4751. " on gt.goodstypeid = g.goodstypeid\n" +
  4752. " where gd.accountid = :AccountID\n" +
  4753. " and ((gd.groutingdate >= :GDateBegin and\n" +
  4754. " gd.groutingdate <= :GDateEnd) or\n" +
  4755. " (gdd.delivertime >= :GDateBegin and\n" +
  4756. " gdd.delivertime <= :GDateEnd))\n" +
  4757. " and (:groutinglinecode is null or\n" +
  4758. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4759. " and (:groutingusercode is null or\n" +
  4760. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4761. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4762. " and (:goodstypecode is null or\n" +
  4763. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  4764. " 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" +
  4765. " order by t.goodscode, t.groutinglinecode, t.usercode";
  4766. List<OracleParameter> parameters = new List<OracleParameter>();
  4767. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4768. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  4769. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  4770. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  4771. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  4772. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4773. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4774. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4775. ServiceResultEntity sre = new ServiceResultEntity();
  4776. if (data == null || data.Rows.Count == 0)
  4777. {
  4778. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4779. return sre;
  4780. }
  4781. sre.Data = new DataSet();
  4782. sre.Data.Tables.Add(data);
  4783. return sre;
  4784. }
  4785. catch (Exception ex)
  4786. {
  4787. throw ex;
  4788. }
  4789. finally
  4790. {
  4791. if (conn != null &&
  4792. conn.ConnState == ConnectionState.Open)
  4793. {
  4794. conn.Close();
  4795. }
  4796. }
  4797. }
  4798. /// <summary>
  4799. /// 取得RPT040109画面(整体质量分析表)的查询数据
  4800. /// </summary>
  4801. /// <param name="user">登录用户信息</param>
  4802. /// <param name="se">查询条件</param>
  4803. /// <returns>查询结果</returns>
  4804. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  4805. {
  4806. IDBTransaction conn = null;
  4807. try
  4808. {
  4809. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4810. conn.Connect();
  4811. OracleParameter[] parameters = new OracleParameter[]
  4812. {
  4813. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4814. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4815. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4816. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  4817. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  4818. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4819. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4820. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4821. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4822. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4823. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4824. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4825. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4826. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4827. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4828. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4829. };
  4830. //out_data1 -- 质量整体情况
  4831. //out_data2 -- 各缺陷类型成品率
  4832. //out_data3 -- 各缺陷类型缺陷率
  4833. //out_data4 -- 产品质量排行榜
  4834. //out_data21 -- 各缺陷类型成品率-总成品率
  4835. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4836. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4837. //out_table1 -- 缺陷类别
  4838. //out_table2 -- 工号分组
  4839. //out_table3 -- 缺陷扣罚
  4840. //out_table4 -- 缺陷
  4841. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4842. ServiceResultEntity sre = new ServiceResultEntity();
  4843. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4844. {
  4845. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4846. return sre;
  4847. }
  4848. data.Tables[0].TableName = "TQ";
  4849. data.Tables[1].TableName = "FR";
  4850. data.Tables[2].TableName = "DR";
  4851. data.Tables[3].TableName = "DL";
  4852. data.Tables[4].TableName = "FR1";
  4853. data.Tables[5].TableName = "DR1";
  4854. data.Tables[6].TableName = "DR2";
  4855. data.Tables[7].TableName = "DT";
  4856. data.Tables[8].TableName = "WG";
  4857. data.Tables[9].TableName = "DF";
  4858. data.Tables[10].TableName = "D";
  4859. DataTable dtFR = data.Tables["FR"];
  4860. DataTable dtFRClone = dtFR.Clone();
  4861. for (int i = 0; i < dtFR.Columns.Count; i++)
  4862. {
  4863. dtFRClone.Columns[i].DataType = typeof(string);
  4864. }
  4865. foreach (DataRow item in dtFR.Rows)
  4866. {
  4867. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4868. dtFRClone.Rows.Add(item.ItemArray);
  4869. }
  4870. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  4871. //DataRow drFR = dtFRClone.NewRow();
  4872. //drFR["goodstypename2"] = "成品率(%)";
  4873. //foreach (DataRow row in data.Tables["FR1"].Rows)
  4874. //{
  4875. // string tid = row["tid"].ToString();
  4876. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4877. // foreach (DataColumn col in dtFRClone.Columns)
  4878. // {
  4879. // if (col.ColumnName.StartsWith(tid))
  4880. // {
  4881. // drFR[col.ColumnName] = overRate;
  4882. // }
  4883. // }
  4884. //}
  4885. //dtFRClone.Rows.Add(drFR);
  4886. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  4887. foreach (DataRow row in data.Tables["FR1"].Rows)
  4888. {
  4889. string tcode = row["goodstypecode2"].ToString();
  4890. DataRow drFR = null;
  4891. if (drFRs.ContainsKey(tcode))
  4892. {
  4893. drFR = drFRs[tcode];
  4894. }
  4895. else
  4896. {
  4897. drFR = dtFRClone.NewRow();
  4898. drFRs.Add(tcode, drFR);
  4899. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  4900. }
  4901. string tid = row["tid"].ToString();
  4902. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4903. foreach (DataColumn col in dtFRClone.Columns)
  4904. {
  4905. if (col.ColumnName.StartsWith(tid))
  4906. {
  4907. drFR[col.ColumnName] = overRate;
  4908. }
  4909. }
  4910. }
  4911. foreach (DataRow item in drFRs.Values)
  4912. {
  4913. dtFRClone.Rows.Add(item);
  4914. }
  4915. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4916. data.Tables.Remove(dtFR);
  4917. data.Tables.Remove(data.Tables["FR1"]);
  4918. data.Tables.Add(dtFRClone);
  4919. DataTable dtDR = data.Tables["DR"];
  4920. DataTable dtDRClone = dtDR.Clone();
  4921. for (int i = 0; i < dtDR.Columns.Count; i++)
  4922. {
  4923. dtDRClone.Columns[i].DataType = typeof(string);
  4924. }
  4925. foreach (DataRow item in dtDR.Rows)
  4926. {
  4927. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4928. dtDRClone.Rows.Add(item.ItemArray);
  4929. }
  4930. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  4931. //DataRow drDR = dtDRClone.NewRow();
  4932. //drDR["goodstypename2"] = "缺陷率(%)";
  4933. //foreach (DataRow row in data.Tables["DR2"].Rows)
  4934. //{
  4935. // string tid = row["tdfid"].ToString();
  4936. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4937. // drDR[tid] = defectRate;
  4938. //}
  4939. //dtDRClone.Rows.Add(drDR);
  4940. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  4941. foreach (DataRow row in data.Tables["DR2"].Rows)
  4942. {
  4943. string tcode = row["goodstypecode2"].ToString();
  4944. DataRow drDR = null;
  4945. if (drDRs.ContainsKey(tcode))
  4946. {
  4947. drDR = drDRs[tcode];
  4948. }
  4949. else
  4950. {
  4951. drDR = dtDRClone.NewRow();
  4952. drDRs.Add(tcode, drDR);
  4953. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  4954. }
  4955. string tid = row["tdfid"].ToString();
  4956. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4957. drDR[tid] = defectRate;
  4958. }
  4959. foreach (DataRow item in drDRs.Values)
  4960. {
  4961. dtDRClone.Rows.Add(item);
  4962. }
  4963. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4964. data.Tables.Remove(dtDR);
  4965. data.Tables.Remove(data.Tables["DR2"]);
  4966. data.Tables.Add(dtDRClone);
  4967. conn.Commit();
  4968. sre.Data = data;
  4969. return sre;
  4970. }
  4971. catch (Exception ex)
  4972. {
  4973. throw ex;
  4974. }
  4975. finally
  4976. {
  4977. if (conn != null &&
  4978. conn.ConnState == ConnectionState.Open)
  4979. {
  4980. conn.Disconnect();
  4981. }
  4982. }
  4983. }
  4984. /// <summary>
  4985. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  4986. /// </summary>
  4987. /// <param name="user">登录用户信息</param>
  4988. /// <param name="se">查询条件</param>
  4989. /// <returns>查询结果</returns>
  4990. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  4991. {
  4992. IDBTransaction conn = null;
  4993. try
  4994. {
  4995. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4996. conn.Connect();
  4997. OracleParameter[] parameters = new OracleParameter[]
  4998. {
  4999. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5000. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5001. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5002. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5003. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5004. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5005. };
  5006. DataSet data = null;
  5007. if (se.IsShowG)
  5008. {
  5009. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5010. }
  5011. else
  5012. {
  5013. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5014. }
  5015. ServiceResultEntity sre = new ServiceResultEntity();
  5016. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5017. {
  5018. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5019. return sre;
  5020. }
  5021. conn.Commit();
  5022. sre.Data = data;
  5023. return sre;
  5024. }
  5025. catch (Exception ex)
  5026. {
  5027. throw ex;
  5028. }
  5029. finally
  5030. {
  5031. if (conn != null &&
  5032. conn.ConnState == ConnectionState.Open)
  5033. {
  5034. conn.Disconnect();
  5035. }
  5036. }
  5037. }
  5038. #endregion 分析报表
  5039. #region 汇总报表
  5040. /// <summary>
  5041. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5042. /// </summary>
  5043. /// <param name="user">登录用户信息</param>
  5044. /// <param name="se">查询条件</param>
  5045. /// <returns>查询结果</returns>
  5046. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5047. {
  5048. IDBConnection conn = null;
  5049. try
  5050. {
  5051. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5052. List<OracleParameter> parameters = new List<OracleParameter>();
  5053. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5054. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5055. ServiceResultEntity sre = new ServiceResultEntity();
  5056. if (data == null || data.Rows.Count == 0)
  5057. {
  5058. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5059. return sre;
  5060. }
  5061. sre.Data = new DataSet();
  5062. sre.Data.Tables.Add(data);
  5063. return sre;
  5064. }
  5065. catch (Exception ex)
  5066. {
  5067. throw ex;
  5068. }
  5069. finally
  5070. {
  5071. if (conn != null &&
  5072. conn.ConnState == ConnectionState.Open)
  5073. {
  5074. conn.Close();
  5075. }
  5076. }
  5077. }
  5078. /// <summary>
  5079. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5080. /// </summary>
  5081. /// <returns>sql</returns>
  5082. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5083. {
  5084. //string selSql = "";
  5085. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5086. /*
  5087. selSql = selSql +
  5088. "select " +
  5089. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5090. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5091. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5092. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5093. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5094. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5095. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5096. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5097. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5098. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5099. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5100. " t.产量 " +
  5101. "from " +
  5102. "( " +
  5103. " select " +
  5104. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5105. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5106. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5107. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5108. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5109. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5110. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5111. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5112. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5113. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5114. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5115. " count(BarCode) as 产量 " +
  5116. " from TP_PM_ProductionData " +
  5117. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5118. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5119. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5120. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5121. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5122. // 公坯、干补不算交坯工序的质量。
  5123. (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" : "") +
  5124. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5125. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5126. {
  5127. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5128. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5129. }
  5130. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5131. {
  5132. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5133. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5134. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5135. }
  5136. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5137. {
  5138. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5139. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5140. }
  5141. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5142. {
  5143. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5144. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5145. }
  5146. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5147. {
  5148. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5149. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5150. }
  5151. if (se.AccountDateStart.HasValue)
  5152. {
  5153. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5154. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5155. }
  5156. if (se.AccountDateEnd.HasValue)
  5157. {
  5158. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5159. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5160. }
  5161. selSql = selSql +
  5162. "group by " +
  5163. " rollup(TP_MST_Organization.OrganizationName, " +
  5164. " TP_PM_ProductionData.ProductionLineName, " +
  5165. " TP_PM_ProductionData.Procedureid, " +
  5166. " TP_PM_ProductionData.ProcedureName, " +
  5167. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5168. " TP_PM_ProductionData.GoodsCode, " +
  5169. " TP_PM_ProductionData.GoodsId, " +
  5170. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5171. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5172. " order by " +
  5173. " TP_MST_Organization.OrganizationName, " +
  5174. " TP_PM_ProductionData.ProductionLineName, " +
  5175. " TP_PM_ProductionData.Procedureid, " +
  5176. " TP_PM_ProductionData.ProcedureName, " +
  5177. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5178. ") t \n" +
  5179. // 增加 产品型号
  5180. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5181. "where 1=1 " +
  5182. "and (t.DICTIONARYVALUE!='--' ) " +
  5183. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5184. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5185. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5186. */
  5187. string selSql =
  5188. "select t.gid\n" +
  5189. " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
  5190. " ,t.OrganizationID\n" +
  5191. " --,t.OrganizationCode\n" +
  5192. " ,decode(t.gid\n" +
  5193. " ,7\n" +
  5194. " ,'合计[' || t.OrganizationName || ']'\n" +
  5195. " ,15\n" +
  5196. " ,'--'\n" +
  5197. " ,t.OrganizationName) OrganizationName\n" +
  5198. " ,t.Procedureid\n" +
  5199. " ,decode(t.gid\n" +
  5200. " ,3\n" +
  5201. " ,'小计[' || t.ProcedureName || ']'\n" +
  5202. " ,0\n" +
  5203. " ,t.ProcedureName\n" +
  5204. " ,1\n" +
  5205. " ,t.ProcedureName\n" +
  5206. " ,'--') ProcedureName\n" +
  5207. " ,t.GoodsTypeID\n" +
  5208. " ,decode(t.gid\n" +
  5209. " ,1\n" +
  5210. " ,'小计[' || t.GoodsTypeName || ']'\n" +
  5211. " ,0\n" +
  5212. " ,t.GoodsTypeName\n" +
  5213. " ,'--') GoodsTypeName\n" +
  5214. " --,t.GoodsId\n" +
  5215. " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
  5216. " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
  5217. " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5218. " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
  5219. " ,t.pfcount as 产量\n" +
  5220. " from (select grouping_id(org.OrganizationID\n" +
  5221. " ,p.Procedureid\n" +
  5222. " ,gt.goodstypeid\n" +
  5223. " ,g.GoodsId) as gid\n" +
  5224. " ,pd.ProductionLineName\n" +
  5225. " ,org.OrganizationID\n" +
  5226. " --,org.OrganizationCode\n" +
  5227. " ,org.OrganizationName\n" +
  5228. " ,p.Procedureid\n" +
  5229. " ,p.ProcedureName\n" +
  5230. " ,gt.GoodsTypeID\n" +
  5231. " ,gt.GoodsTypeName\n" +
  5232. " ,g.GoodsId\n" +
  5233. " ,g.GoodsCode\n" +
  5234. " ,g.GOODSSPECIFICATION\n" +
  5235. " ,d.Dictionaryvalue\n" +
  5236. " ,count(BarCode) as pfcount" +
  5237. " from TP_PM_ProductionData pd\n" +
  5238. " inner join tp_pc_Procedure p\n" +
  5239. " on p.Procedureid = pd.Procedureid\n" +
  5240. " inner join TP_MST_Goods g\n" +
  5241. " on g.GoodsID = pd.GoodsID\n" +
  5242. " inner join TP_MST_GoodsType gt\n" +
  5243. " on gt.GoodsTypeID = g.GoodsTypeID\n" +
  5244. " inner join TP_MST_Organization org\n" +
  5245. " on org.OrganizationID = pd.OrganizationID\n" +
  5246. " inner join TP_MST_DATADICTIONARY d\n" +
  5247. " on d.DICTIONARYID = g.GLAZETYPEID\n" +
  5248. " where pd.ValueFlag = '1'\n" +
  5249. " and pd.AccountID = :AccountID\n";
  5250. // 公坯、干补不算交坯工序的质量。
  5251. if (se.ProductionFlag == "1")
  5252. {
  5253. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5254. }
  5255. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5256. {
  5257. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5258. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5259. }
  5260. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5261. {
  5262. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5263. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5264. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5265. }
  5266. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5267. {
  5268. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5269. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5270. }
  5271. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5272. {
  5273. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5274. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5275. }
  5276. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5277. {
  5278. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5279. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5280. }
  5281. if (se.AccountDateStart.HasValue)
  5282. {
  5283. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5284. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5285. }
  5286. if (se.AccountDateEnd.HasValue)
  5287. {
  5288. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5289. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5290. }
  5291. selSql +=
  5292. " 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" +
  5293. " order by org.organizationcode\n" +
  5294. " ,p.displayno\n" +
  5295. " ,gt.goodstypecode\n" +
  5296. " ,g.goodscode) t";
  5297. return selSql;
  5298. }
  5299. /// <summary>
  5300. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5301. /// </summary>
  5302. /// <param name="user">登录用户信息</param>
  5303. /// <param name="se">查询条件</param>
  5304. /// <returns>查询结果</returns>
  5305. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5306. {
  5307. IDBConnection conn = null;
  5308. try
  5309. {
  5310. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5311. List<OracleParameter> parameters = new List<OracleParameter>();
  5312. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5313. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5314. ServiceResultEntity sre = new ServiceResultEntity();
  5315. if (data == null || data.Rows.Count == 0)
  5316. {
  5317. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5318. return sre;
  5319. }
  5320. sre.Data = new DataSet();
  5321. sre.Data.Tables.Add(data);
  5322. return sre;
  5323. }
  5324. catch (Exception ex)
  5325. {
  5326. throw ex;
  5327. }
  5328. finally
  5329. {
  5330. if (conn != null &&
  5331. conn.ConnState == ConnectionState.Open)
  5332. {
  5333. conn.Close();
  5334. }
  5335. }
  5336. }
  5337. /// <summary>
  5338. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5339. /// </summary>
  5340. /// <returns>sql</returns>
  5341. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5342. {
  5343. //string selSql = "";
  5344. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5345. /*
  5346. selSql = selSql +
  5347. "select " +
  5348. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5349. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5350. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5351. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5352. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5353. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5354. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5355. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5356. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5357. "产量, " +
  5358. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5359. "from " +
  5360. "( " +
  5361. " select " +
  5362. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5363. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5364. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5365. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5366. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5367. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5368. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5369. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5370. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5371. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5372. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5373. " count(BarCode) as 产量 " +
  5374. " from TP_PM_ProductionData " +
  5375. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5376. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5377. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5378. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5379. " Where 1=1 " +
  5380. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5381. // 公坯、干补不算交坯工序的质量。
  5382. " 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" +
  5383. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5384. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5385. {
  5386. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5387. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5388. }
  5389. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5390. {
  5391. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5392. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5393. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5394. }
  5395. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5396. {
  5397. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5398. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5399. }
  5400. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5401. {
  5402. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5403. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5404. }
  5405. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5406. {
  5407. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5408. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5409. }
  5410. if (se.AccountDateStart.HasValue)
  5411. {
  5412. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5413. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5414. }
  5415. if (se.AccountDateEnd.HasValue)
  5416. {
  5417. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5418. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5419. }
  5420. selSql = selSql +
  5421. "group by " +
  5422. " rollup(TP_MST_Organization.OrganizationName, " +
  5423. " TP_PM_ProductionData.ProductionLineName, " +
  5424. " TP_PM_ProductionData.ProcedureName, " +
  5425. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5426. " TP_PM_ProductionData.GoodsCode, " +
  5427. " TP_PM_ProductionData.BarCode, " +
  5428. " TP_PM_ProductionData.UserCode, " +
  5429. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5430. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5431. " ) " +
  5432. " order by " +
  5433. " TP_MST_Organization.OrganizationName, " +
  5434. " TP_PM_ProductionData.ProductionLineName, " +
  5435. " TP_PM_ProductionData.ProcedureName, " +
  5436. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5437. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5438. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5439. "where 1=1 " +
  5440. "and (temp.DICTIONARYVALUE!='--') " +
  5441. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5442. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5443. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5444. */
  5445. string selSql =
  5446. " select " +
  5447. " TP_MST_Organization.OrganizationName, " +
  5448. " TP_PM_ProductionData.ProductionLineName, " +
  5449. " TP_PM_ProductionData.ProcedureName, " +
  5450. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5451. " TP_PM_ProductionData.GoodsCode, " +
  5452. " TP_MST_Goods.GoodsName, " +
  5453. " TP_MST_Goods.GoodsModel, " +
  5454. " TP_PM_ProductionData.BarCode, " +
  5455. " TP_PM_ProductionData.UserCode, " +
  5456. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5457. " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
  5458. " TP_PM_ProductionData.CREATETIME, " +
  5459. " TP_PM_ProductionData.KILNcarCODE, " +
  5460. " TP_PM_ProductionData.KILNCODE, " +
  5461. " cu.usercode createusercode, " +
  5462. " cu.username CreateUserName, " +
  5463. " gdd.glazingroom," +
  5464. " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
  5465. " from TP_PM_ProductionData " +
  5466. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5467. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5468. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5469. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5470. " left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
  5471. " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
  5472. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5473. " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
  5474. " Where TP_PM_ProductionData.ValueFlag = '1' " +
  5475. // 公坯、干补不算交坯工序的质量。
  5476. " 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" +
  5477. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5478. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5479. {
  5480. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5481. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5482. }
  5483. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5484. {
  5485. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5486. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5487. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5488. }
  5489. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5490. {
  5491. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5492. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5493. }
  5494. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5495. {
  5496. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5497. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5498. }
  5499. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5500. {
  5501. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5502. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5503. }
  5504. if (se.AccountDateStart.HasValue)
  5505. {
  5506. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5507. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5508. }
  5509. if (se.AccountDateEnd.HasValue)
  5510. {
  5511. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5512. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5513. }
  5514. return selSql;
  5515. }
  5516. /// <summary>
  5517. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5518. /// </summary>
  5519. /// <param name="user">登录用户信息</param>
  5520. /// <param name="se">查询条件</param>
  5521. /// <returns>查询结果</returns>
  5522. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5523. {
  5524. IDBConnection conn = null;
  5525. try
  5526. {
  5527. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5528. List<OracleParameter> parameters = new List<OracleParameter>();
  5529. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5530. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5531. ServiceResultEntity sre = new ServiceResultEntity();
  5532. if (data == null || data.Rows.Count == 0)
  5533. {
  5534. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5535. return sre;
  5536. }
  5537. sre.Data = new DataSet();
  5538. sre.Data.Tables.Add(data);
  5539. return sre;
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. throw ex;
  5544. }
  5545. finally
  5546. {
  5547. if (conn != null &&
  5548. conn.ConnState == ConnectionState.Open)
  5549. {
  5550. conn.Close();
  5551. }
  5552. }
  5553. }
  5554. /// <summary>
  5555. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5556. /// </summary>
  5557. /// <returns>sql</returns>
  5558. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5559. {
  5560. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5561. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5562. string sqlString = "SELECT decode(ts.gid,\n" +
  5563. " 7,\n" +
  5564. " '总计',\n" +
  5565. " 3,\n" +
  5566. " '合计【' || ts.zrprocedurename || '】',\n" +
  5567. " 0,\n" +
  5568. " ts.zrprocedurename,\n" +
  5569. " '--') zrprocedurename\n" +
  5570. " ,decode(ts.gid,\n" +
  5571. " 1,\n" +
  5572. " '小计【' || ts.goodstypename2 || '】',\n" +
  5573. " 0,\n" +
  5574. " ts.goodstypename2,\n" +
  5575. " '--') goodstypename2\n" +
  5576. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5577. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5578. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5579. " ,ts.productionlineid\n" +
  5580. " ,ts.zrprocedureid\n" +
  5581. " ,ts.goodstypecode2\n" +
  5582. " ,ts.zruserid\n" +
  5583. " ,ts.goodsid\n" +
  5584. " ,ts.barcount\n" +
  5585. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5586. " ,t.productionlineid\n" +
  5587. " ,t.productionlinename\n" +
  5588. " ,t.displayno\n" +
  5589. " ,t.zrprocedureid\n" +
  5590. " ,t.zrprocedurename\n" +
  5591. " ,t.goodstypecode2\n" +
  5592. " ,t.goodstypename2\n" +
  5593. " ,t.zruserid\n" +
  5594. " ,t.zrusercode\n" +
  5595. " ,t.goodsid\n" +
  5596. " ,t.goodscode\n" +
  5597. " ,t.GOODSMODEL\n" +
  5598. " ,COUNT(t.barcode) barcount\n" +
  5599. " FROM (SELECT sp.productionlineid\n" +
  5600. " ,pline.productionlinename\n" +
  5601. " ,nvl(zp.displayno, -1) displayno\n" +
  5602. " ,zp.procedureid zrprocedureid\n" +
  5603. " ,zp.procedurename zrprocedurename\n" +
  5604. " ,sr.userid zruserid\n" +
  5605. " ,sr.usercode zrusercode\n" +
  5606. " ,gt2.goodstypecode goodstypecode2\n" +
  5607. " ,gt2.goodstypename goodstypename2\n" +
  5608. " ,g.goodsid\n" +
  5609. " ,g.goodscode\n" +
  5610. " ,g.GOODSMODEL\n" +
  5611. " ,sp.barcode\n" +
  5612. " FROM tp_pm_scrapproduct sp\n" +
  5613. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5614. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5615. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5616. " ,t.ResponProcedureID\n" +
  5617. " ,t.userid\n" +
  5618. " ,t.usercode\n" +
  5619. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5620. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5621. // wangx 2016-06-20
  5622. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5623. " ON rp.barcode = gdd.barcode\n" +
  5624. // wangx 2016-06-20 end
  5625. " LEFT JOIN tp_pc_productionline pline\n" +
  5626. " ON pline.productionlineid = sp.productionlineid\n" +
  5627. " LEFT JOIN tp_pc_procedure zp\n" +
  5628. " ON zp.procedureid = rp.procedureid\n" +
  5629. " LEFT JOIN tp_mst_user cu\n" +
  5630. " ON cu.userid = sp.createuserid\n" +
  5631. " LEFT JOIN tp_mst_user au\n" +
  5632. " ON au.userid = sp.auditor\n" +
  5633. " LEFT JOIN tp_mst_goods g\n" +
  5634. " ON g.goodsid = sp.goodsid\n" +
  5635. " LEFT JOIN tp_mst_goodstype gt\n" +
  5636. " ON gt.goodstypeid = g.goodstypeid\n" +
  5637. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5638. " ON gt2.accountid = gt.accountid\n" +
  5639. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5640. " WHERE sp.valueflag = '1'\n" +
  5641. " AND sp.AuditStatus = '1'\n" +
  5642. // 生产线
  5643. //" 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))" +
  5644. // 完成工序
  5645. //" 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))" +
  5646. // 责任工序
  5647. //" 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)))" +
  5648. " AND sp.accountid = :AccountID\n" +
  5649. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5650. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5651. " AND sp.ScrapType = '0'\n" +
  5652. " AND (:ProductionLineID IS NULL OR\n" +
  5653. " sp.ProductionLineID = :ProductionLineID)\n" +
  5654. " AND (:GoodsTypeCode IS NULL OR\n" +
  5655. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5656. " AND (:GoodsCode IS NULL OR\n" +
  5657. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5658. " AND (:ProcedureIDS IS NULL OR\n" +
  5659. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5660. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5661. " instr(:ResponProcedureIDS,\n" +
  5662. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5663. " AND (:ResponUserIDS IS NULL OR\n" +
  5664. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5665. // 损坯时间
  5666. " AND (:ScrapDateStart IS NULL OR\n" +
  5667. " sp.CreateTime >= :ScrapDateStart)\n" +
  5668. " AND (:ScrapDateEnd IS NULL OR\n" +
  5669. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5670. // 审核时间
  5671. " AND (:AuditDateStart IS NULL OR\n" +
  5672. " sp.AuditDate >= :AuditDateStart)\n" +
  5673. " AND (:AuditDateEnd IS NULL OR\n" +
  5674. " sp.AuditDate <= :AuditDateEnd)\n" +
  5675. // 完成时间
  5676. " AND (:CTimeStart IS NULL OR\n" +
  5677. " sp.CreateTime >= :CTimeStart)\n" +
  5678. " AND (:CTimeEnd IS NULL OR\n" +
  5679. " sp.CreateTime <= :CTimeEnd)\n" +
  5680. // 交坯时间
  5681. " AND (:DTimeStart IS NULL OR\n" +
  5682. " gdd.DeliverTime >= :DTimeStart)\n" +
  5683. " AND (:DTimeEnd IS NULL OR\n" +
  5684. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5685. // 注浆时间
  5686. " AND (:GTimeStart IS NULL OR\n" +
  5687. " gdd.GroutingDate >= :GTimeStart)\n" +
  5688. " AND (:GTimeEnd IS NULL OR\n" +
  5689. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5690. " AND (:CreatUser IS NULL OR\n" +
  5691. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5692. " AND (:AuditUser IS NULL OR\n" +
  5693. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5694. " 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" +
  5695. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5696. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5697. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5698. {
  5699. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5700. }
  5701. else
  5702. {
  5703. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5704. }
  5705. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5706. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5707. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5708. {
  5709. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5710. }
  5711. else
  5712. {
  5713. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5714. }
  5715. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5716. {
  5717. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5718. }
  5719. else
  5720. {
  5721. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5722. }
  5723. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5724. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5725. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5726. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5727. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5728. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5729. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5730. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5731. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5732. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5733. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5734. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5735. return sqlString;
  5736. }
  5737. /// <summary>
  5738. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5739. /// </summary>
  5740. /// <param name="user">登录用户信息</param>
  5741. /// <param name="se">查询条件</param>
  5742. /// <returns>查询结果</returns>
  5743. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5744. {
  5745. IDBConnection conn = null;
  5746. try
  5747. {
  5748. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5749. List<OracleParameter> parameters = new List<OracleParameter>();
  5750. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5751. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5752. ServiceResultEntity sre = new ServiceResultEntity();
  5753. if (data == null || data.Rows.Count == 0)
  5754. {
  5755. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5756. return sre;
  5757. }
  5758. sre.Data = new DataSet();
  5759. sre.Data.Tables.Add(data);
  5760. return sre;
  5761. }
  5762. catch (Exception ex)
  5763. {
  5764. throw ex;
  5765. }
  5766. finally
  5767. {
  5768. if (conn != null &&
  5769. conn.ConnState == ConnectionState.Open)
  5770. {
  5771. conn.Close();
  5772. }
  5773. }
  5774. }
  5775. /// <summary>
  5776. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5777. /// </summary>
  5778. /// <returns>sql</returns>
  5779. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5780. {
  5781. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5782. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5783. string sqlString =
  5784. "SELECT pline.productionlinename\n" +
  5785. " ,p.procedurename\n" +
  5786. " ,zp.procedurename zrprocedurename\n" +
  5787. " ,sr.usercode zrusercode\n" +
  5788. " ,sr.StaffNames zrStaffNames\n" +
  5789. " ,gt2.goodstypecode goodstypecode2\n" +
  5790. " ,gt2.goodstypename goodstypename2\n" +
  5791. " ,gt.goodstypename\n" +
  5792. " ,g.goodscode\n" +
  5793. " ,g.GOODSMODEL\n" +
  5794. " ,sp.barcode\n" +
  5795. " ,sp.createtime Scrapdate\n" +
  5796. " ,sp.Rreason\n" +
  5797. " ,sp.GroutingUserCode\n" +
  5798. " ,sp.GroutingLineCode\n" +
  5799. " ,sp.GroutingMouldCode\n" +
  5800. " ,sp.GroutingDate\n" +
  5801. " ,sp.GroutingNum\n" +
  5802. " ,cu.usercode CreateUserCode\n" +
  5803. " ,au.usercode AuditorCode\n" +
  5804. " ,sp.auditdate\n" +
  5805. " ,gdd.DeliverTime\n" +
  5806. " ,gdd.ISPUBLICBODY\n" +
  5807. " ,gdd.SPECIALREPAIRFLAG\n" +
  5808. " ,lg.logoname\n" +
  5809. " ,sp.CreateTime\n" +
  5810. " ,sp.Remarks\n" +
  5811. " FROM tp_pm_scrapproduct sp\n" +
  5812. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5813. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5814. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5815. " ,t.ResponProcedureID\n" +
  5816. " ,t.userid\n" +
  5817. " ,t.usercode\n" +
  5818. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5819. " FROM TP_PM_ScrapResponsible t\n" +
  5820. " LEFT JOIN TP_HR_Staff s \n" +
  5821. " ON s.StaffID = t.StaffID \n" +
  5822. " ) sr\n" +
  5823. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5824. // wangx 2016-06-20
  5825. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5826. " ON sp.barcode = gdd.barcode\n" +
  5827. // wangx 2016-06-20 end
  5828. " LEFT JOIN TP_mst_logo lg\n" +
  5829. " ON lg.logoid = gdd.logoid\n" +
  5830. " LEFT JOIN tp_pc_productionline pline\n" +
  5831. " ON pline.productionlineid = sp.productionlineid\n" +
  5832. " LEFT JOIN tp_pc_procedure p\n" +
  5833. " ON p.procedureid = sp.procedureid\n" +
  5834. " LEFT JOIN tp_pc_procedure zp\n" +
  5835. " ON zp.procedureid = rp.procedureid\n" +
  5836. " LEFT JOIN tp_mst_user cu\n" +
  5837. " ON cu.userid = sp.createuserid\n" +
  5838. " LEFT JOIN tp_mst_user au\n" +
  5839. " ON au.userid = sp.auditor\n" +
  5840. " LEFT JOIN tp_mst_goods g\n" +
  5841. " ON g.goodsid = sp.goodsid\n" +
  5842. " LEFT JOIN tp_mst_goodstype gt\n" +
  5843. " ON gt.goodstypeid = g.goodstypeid\n" +
  5844. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5845. " ON gt2.accountid = gt.accountid\n" +
  5846. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5847. " WHERE sp.valueflag = '1'\n" +
  5848. " AND sp.AuditStatus = '1'\n" +
  5849. " AND sp.accountid = :accountid\n" +
  5850. // 生产线
  5851. //" 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))" +
  5852. // 完成工序
  5853. //" 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))" +
  5854. // 责任工序
  5855. //" 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)))" +
  5856. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  5857. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5858. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5859. " AND sp.ScrapType = '0'\n" +
  5860. " AND (:ProductionLineID IS NULL OR\n" +
  5861. " sp.ProductionLineID = :ProductionLineID)\n" +
  5862. " AND (:GoodsTypeCode IS NULL OR\n" +
  5863. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5864. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5865. " AND (:ProcedureIDS IS NULL OR\n" +
  5866. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5867. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5868. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  5869. " AND (:ResponUserIDS IS NULL OR\n" +
  5870. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5871. // 损坯时间
  5872. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  5873. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  5874. // 审核时间
  5875. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  5876. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  5877. // 完成时间
  5878. " AND (:CTimeStart IS NULL OR\n" +
  5879. " sp.CreateTime >= :CTimeStart)\n" +
  5880. " AND (:CTimeEnd IS NULL OR\n" +
  5881. " sp.CreateTime <= :CTimeEnd)\n" +
  5882. // 交坯时间
  5883. " AND (:DTimeStart IS NULL OR\n" +
  5884. " gdd.DeliverTime >= :DTimeStart)\n" +
  5885. " AND (:DTimeEnd IS NULL OR\n" +
  5886. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5887. // 注浆时间
  5888. " AND (:GTimeStart IS NULL OR\n" +
  5889. " gdd.GroutingDate >= :GTimeStart)\n" +
  5890. " AND (:GTimeEnd IS NULL OR\n" +
  5891. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5892. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  5893. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  5894. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  5895. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  5896. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  5897. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  5898. " AND (:RUF = 1 OR sr.userid is null)\n" +
  5899. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  5900. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5901. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5902. {
  5903. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5904. }
  5905. else
  5906. {
  5907. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5908. }
  5909. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5910. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5911. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5912. {
  5913. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5914. }
  5915. else
  5916. {
  5917. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5918. }
  5919. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5920. {
  5921. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5922. }
  5923. else
  5924. {
  5925. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5926. }
  5927. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5928. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5929. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5930. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5931. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5932. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5933. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5934. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5935. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5936. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5937. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5938. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5939. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  5940. if (se.ResponProcedureID == "")
  5941. {
  5942. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5943. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  5944. }
  5945. else
  5946. {
  5947. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5948. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  5949. }
  5950. if (se.ResponUserID == "")
  5951. {
  5952. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5953. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  5954. }
  5955. else
  5956. {
  5957. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5958. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  5959. }
  5960. return sqlString;
  5961. }
  5962. /// <summary>
  5963. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  5964. /// </summary>
  5965. /// <param name="user">登录用户信息</param>
  5966. /// <param name="se">查询条件</param>
  5967. /// <returns>查询结果</returns>
  5968. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  5969. {
  5970. IDBConnection conn = null;
  5971. try
  5972. {
  5973. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5974. List<OracleParameter> parameters = new List<OracleParameter>();
  5975. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  5976. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  5977. ServiceResultEntity sre = new ServiceResultEntity();
  5978. if (data == null || data.Rows.Count == 0)
  5979. {
  5980. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5981. return sre;
  5982. }
  5983. sre.Data = new DataSet();
  5984. sre.Data.Tables.Add(data);
  5985. return sre;
  5986. }
  5987. catch (Exception ex)
  5988. {
  5989. throw ex;
  5990. }
  5991. finally
  5992. {
  5993. if (conn != null &&
  5994. conn.ConnState == ConnectionState.Open)
  5995. {
  5996. conn.Close();
  5997. }
  5998. }
  5999. }
  6000. /// <summary>
  6001. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6002. /// </summary>
  6003. /// <returns>sql</returns>
  6004. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6005. {
  6006. string selSql = "";
  6007. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6008. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6009. selSql = selSql +
  6010. "SELECT pdata.Procedureid Procedureid " +
  6011. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6012. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6013. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6014. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6015. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6016. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6017. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6018. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6019. " ,OutKilnCount " +
  6020. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6021. " pdata.Userid ) gid " +
  6022. " ,pdata.Procedureid " +
  6023. " ,pdata.Procedurename " +
  6024. " ,pdata.Userid " +
  6025. " ,pdata.Usercode " +
  6026. " ,pdata.Kilnid " +
  6027. " ,pdata.Kilncode " +
  6028. " ,pdata.goodstypename " +
  6029. " ,pdata.Goodsid " +
  6030. " ,pdata.Goodscode " +
  6031. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6032. " FROM (SELECT DISTINCT " +
  6033. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6034. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6035. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6036. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6037. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6038. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6039. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6040. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6041. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6042. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6043. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6044. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6045. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6046. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6047. " from TP_PM_ProductionData " +
  6048. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6049. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6050. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6051. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6052. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6053. " inner join " +
  6054. " ( " +
  6055. " 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 " +
  6056. " from TP_PM_ProductionData " +
  6057. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6058. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6059. {
  6060. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6061. }
  6062. selSql +=
  6063. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6064. " and TP_PM_ProductionData.Valueflag='1' " +
  6065. // 数据重复 modify by chenxy begin
  6066. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6067. // 数据重复 modify by chenxy end
  6068. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6069. //if (se.CreateTimeStart.HasValue)
  6070. //{
  6071. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6072. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6073. //}
  6074. //if (se.CreateTimeEnd.HasValue)
  6075. //{
  6076. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6077. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6078. //}
  6079. if (se.OutTimeStart.HasValue)
  6080. {
  6081. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6082. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6083. }
  6084. if (se.OutTimeEnd.HasValue)
  6085. {
  6086. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6087. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6088. }
  6089. if (se.GTimeStart.HasValue)
  6090. {
  6091. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6092. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6093. }
  6094. if (se.GTimeEnd.HasValue)
  6095. {
  6096. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6097. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6098. }
  6099. if (se.DTimeStart.HasValue)
  6100. {
  6101. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6102. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6103. }
  6104. if (se.DTimeEnd.HasValue)
  6105. {
  6106. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6107. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6108. }
  6109. if (se.Specialrepairflag)
  6110. {
  6111. selSql = selSql +
  6112. " ) temp " +
  6113. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6114. " " +
  6115. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6116. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6117. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6118. " FROM TP_PM_ProductionData pp\n" +
  6119. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6120. " AND pp.createtime < temp.createtime\n" +
  6121. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6122. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6123. " where " +
  6124. // 公坯、干补不算交坯工序的质量。
  6125. // " 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" +
  6126. // modify wangx 2015-12-3
  6127. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6128. " and TP_PM_ProductionData.Valueflag='1' " +
  6129. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6130. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6131. }
  6132. else
  6133. {
  6134. selSql = selSql +
  6135. " ) temp " +
  6136. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6137. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6138. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6139. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6140. " FROM TP_PM_ProductionData pp\n" +
  6141. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6142. " AND pp.createtime < temp.createtime\n" +
  6143. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6144. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6145. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6146. " and TP_PM_ProductionData.Valueflag='1' ";
  6147. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6148. }
  6149. if (se.CreateTimeStart.HasValue)
  6150. {
  6151. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6152. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6153. }
  6154. if (se.CreateTimeEnd.HasValue)
  6155. {
  6156. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6157. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6158. }
  6159. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6160. {
  6161. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6162. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6163. }
  6164. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6165. {
  6166. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6167. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6168. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6169. }
  6170. if (se.ProductionLineID.HasValue)
  6171. {
  6172. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6173. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6174. }
  6175. //else
  6176. //{
  6177. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6178. //}
  6179. 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))";
  6180. 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))";
  6181. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6182. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6183. {
  6184. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6185. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6186. }
  6187. if (!string.IsNullOrEmpty(se.UserIDS))
  6188. {
  6189. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6190. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6191. }
  6192. if (se.KilnID.HasValue)
  6193. {
  6194. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6195. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6196. }
  6197. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6198. {
  6199. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6200. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6201. }
  6202. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6203. " 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),()) " +
  6204. ") pdata"
  6205. ;
  6206. return selSql;
  6207. }
  6208. /// <summary>
  6209. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6210. /// </summary>
  6211. /// <param name="user">登录用户信息</param>
  6212. /// <param name="se">查询条件</param>
  6213. /// <returns>查询结果</returns>
  6214. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6215. {
  6216. IDBConnection conn = null;
  6217. try
  6218. {
  6219. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6220. List<OracleParameter> parameters = new List<OracleParameter>();
  6221. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6222. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6223. ServiceResultEntity sre = new ServiceResultEntity();
  6224. if (data == null || data.Rows.Count == 0)
  6225. {
  6226. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6227. return sre;
  6228. }
  6229. sre.Data = new DataSet();
  6230. sre.Data.Tables.Add(data);
  6231. return sre;
  6232. }
  6233. catch (Exception ex)
  6234. {
  6235. throw ex;
  6236. }
  6237. finally
  6238. {
  6239. if (conn != null &&
  6240. conn.ConnState == ConnectionState.Open)
  6241. {
  6242. conn.Close();
  6243. }
  6244. }
  6245. }
  6246. /// <summary>
  6247. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6248. /// </summary>
  6249. /// <returns>sql</returns>
  6250. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6251. {
  6252. string selSql = "";
  6253. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6254. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6255. selSql = selSql +
  6256. "select distinct " +
  6257. "TP_PM_ProductionData.Barcode, " +
  6258. //"TP_PM_ProductionData.UserCode, " +
  6259. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6260. "pcp.ProcedureName, " +
  6261. "tp_mst_goodstype.goodstypename, " +
  6262. "TP_PM_ProductionData.Goodscode, " +
  6263. "TP_PM_ProductionData.GroutingUserCode, " +
  6264. "TP_PM_ProductionData.GroutingLineCode, " +
  6265. "TP_PM_ProductionData.GroutingMouldCode, " +
  6266. // 多次干补 重复条码
  6267. //"TP_PM_ProductionData.Createtime OverDate, " +
  6268. "temp.Kilnid, " +
  6269. "temp.Kilncode, " +
  6270. "temp.Kilncarcode, " +
  6271. "temp.Createtime, " +
  6272. "temp.DELIVERTIME DDate, " +
  6273. "temp.GROUTINGDATE GDate, " +
  6274. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6275. "from TP_PM_ProductionData " +
  6276. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6277. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6278. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6279. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6280. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6281. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6282. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6283. "inner join " +
  6284. "( " +
  6285. " select " +
  6286. " TP_PM_ProductionData.Barcode, " +
  6287. " TP_PM_ProductionData.Kilncode, " +
  6288. " TP_PM_ProductionData.Kilncarcode, " +
  6289. " TP_PM_ProductionData.Createtime, " +
  6290. " TP_PM_ProductionData.KilnID " +
  6291. " ,gdd.DELIVERTIME " +
  6292. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6293. " ,TP_PM_ProductionData.KilnCarID " +
  6294. " from TP_PM_ProductionData " +
  6295. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6296. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6297. //{
  6298. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6299. //}
  6300. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6301. // selSql +=
  6302. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6303. " and TP_PM_ProductionData.Valueflag='1' " +
  6304. // 数据重复 modify by chenxy begin
  6305. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6306. // 数据重复 modify by chenxy end
  6307. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6308. if (se.OutTimeStart.HasValue)
  6309. {
  6310. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6311. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6312. }
  6313. if (se.OutTimeEnd.HasValue)
  6314. {
  6315. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6316. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6317. }
  6318. if (se.GTimeStart.HasValue)
  6319. {
  6320. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6321. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6322. }
  6323. if (se.GTimeEnd.HasValue)
  6324. {
  6325. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6326. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6327. }
  6328. if (se.DTimeStart.HasValue)
  6329. {
  6330. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6331. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6332. }
  6333. if (se.DTimeEnd.HasValue)
  6334. {
  6335. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6336. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6337. }
  6338. if (se.Specialrepairflag)
  6339. {
  6340. selSql = selSql +
  6341. ") temp " +
  6342. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6343. " " +
  6344. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6345. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6346. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6347. " FROM TP_PM_ProductionData pp\n" +
  6348. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6349. " AND pp.createtime < temp.createtime\n" +
  6350. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6351. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6352. "where " + // 公坯、干补不算交坯工序的质量。
  6353. //" 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" +
  6354. // modify wangx 2015-12-3
  6355. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6356. " and TP_PM_ProductionData.Valueflag='1' " +
  6357. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6358. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6359. }
  6360. else
  6361. {
  6362. selSql = selSql +
  6363. ") temp " +
  6364. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6365. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6366. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6367. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6368. " FROM TP_PM_ProductionData pp\n" +
  6369. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6370. " AND pp.createtime < temp.createtime\n" +
  6371. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6372. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6373. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6374. " and TP_PM_ProductionData.Valueflag='1' ";
  6375. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6376. }
  6377. if (se.CreateTimeStart.HasValue)
  6378. {
  6379. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6380. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6381. }
  6382. if (se.CreateTimeEnd.HasValue)
  6383. {
  6384. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6385. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6386. }
  6387. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6388. {
  6389. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6390. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6391. }
  6392. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6393. {
  6394. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6395. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6396. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6397. }
  6398. if (se.ProductionLineID.HasValue)
  6399. {
  6400. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6401. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6402. }
  6403. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6404. {
  6405. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6406. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6407. }
  6408. if (!string.IsNullOrEmpty(se.UserIDS))
  6409. {
  6410. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6411. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6412. }
  6413. if (se.KilnID.HasValue)
  6414. {
  6415. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6416. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6417. }
  6418. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6419. {
  6420. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6421. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6422. }
  6423. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6424. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6425. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6426. return selSql;
  6427. }
  6428. /// <summary>
  6429. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6430. /// </summary>
  6431. /// <param name="user">登录用户信息</param>
  6432. /// <param name="se">查询条件</param>
  6433. /// <returns>查询结果</returns>
  6434. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6435. {
  6436. IDBConnection conn = null;
  6437. try
  6438. {
  6439. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6440. List<OracleParameter> parameters = new List<OracleParameter>();
  6441. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6442. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6443. ServiceResultEntity sre = new ServiceResultEntity();
  6444. if (data == null || data.Rows.Count == 0)
  6445. {
  6446. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6447. return sre;
  6448. }
  6449. sre.Data = new DataSet();
  6450. sre.Data.Tables.Add(data);
  6451. return sre;
  6452. }
  6453. catch (Exception ex)
  6454. {
  6455. throw ex;
  6456. }
  6457. finally
  6458. {
  6459. if (conn != null &&
  6460. conn.ConnState == ConnectionState.Open)
  6461. {
  6462. conn.Close();
  6463. }
  6464. }
  6465. }
  6466. /// <summary>
  6467. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6468. /// </summary>
  6469. /// <returns>sql</returns>
  6470. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6471. {
  6472. string selSql = "";
  6473. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6474. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6475. selSql = "select " +
  6476. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6477. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6478. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6479. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6480. "Kilncarcode, " +
  6481. "Remarks, " +
  6482. "KilnCarCount " +
  6483. " from " +
  6484. " ( " +
  6485. " select " +
  6486. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6487. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6488. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6489. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6490. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6491. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6492. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6493. " from " +
  6494. " ( " +
  6495. " select " +
  6496. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6497. " TP_PM_KilnCarData.Modeltype, " +
  6498. " TP_PM_KilnCarData.Kilncarid, " +
  6499. " TP_PM_KilnCarData.Kilnid, " +
  6500. " TP_PM_KilnCarData.Userid, " +
  6501. " TP_PM_KilnCarData.Remarks, " +
  6502. " TP_PM_KilnCarData.Accountid, " +
  6503. " TP_PM_KilnCarData.Usercode " +
  6504. " from TP_PM_KilnCarData " +
  6505. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6506. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6507. " and TP_PM_KilnCarData.Valueflag=1 " +
  6508. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6509. if (se.KilnID.HasValue)
  6510. {
  6511. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6512. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6513. }
  6514. //if (se.KilnCarID.HasValue)
  6515. //{
  6516. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6517. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6518. //}
  6519. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6520. {
  6521. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6522. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6523. }
  6524. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6525. {
  6526. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6527. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6528. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6529. }
  6530. else
  6531. {
  6532. if (se.KilnCarNumBegin.HasValue)
  6533. {
  6534. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6535. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6536. }
  6537. if (se.KilnCarNumEnd.HasValue)
  6538. {
  6539. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6540. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6541. }
  6542. }
  6543. if (se.CreateTimeStart.HasValue)
  6544. {
  6545. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6546. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6547. }
  6548. if (se.CreateTimeEnd.HasValue)
  6549. {
  6550. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6551. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6552. }
  6553. selSql = selSql +
  6554. " ) TP_PM_KilnCarData " +
  6555. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6556. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6557. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6558. "where 1=1";
  6559. if (!string.IsNullOrEmpty(se.UserIDS))
  6560. {
  6561. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6562. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6563. }
  6564. selSql = selSql + "group by rollup( " +
  6565. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6566. " TP_MST_Kiln.Kilncode, " +
  6567. " TP_PM_KilnCarData.Usercode, " +
  6568. " TP_PM_KilnCarData.Createtime, " +
  6569. " TP_PM_KilnCarData.Remarks, " +
  6570. " TP_MST_KilnCar.Kilncarcode " +
  6571. " ) " +
  6572. " ) temp " +
  6573. " where (Kilncarcode !='--' ) " +
  6574. " or " +
  6575. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6576. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6577. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6578. return selSql;
  6579. }
  6580. /// <summary>
  6581. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6582. /// </summary>
  6583. /// <param name="user">登录用户信息</param>
  6584. /// <param name="se">查询条件</param>
  6585. /// <returns>查询结果</returns>
  6586. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6587. {
  6588. IDBConnection conn = null;
  6589. try
  6590. {
  6591. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6592. List<OracleParameter> parameters = new List<OracleParameter>();
  6593. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6594. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6595. ServiceResultEntity sre = new ServiceResultEntity();
  6596. if (data == null || data.Rows.Count == 0)
  6597. {
  6598. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6599. return sre;
  6600. }
  6601. sre.Data = new DataSet();
  6602. sre.Data.Tables.Add(data);
  6603. return sre;
  6604. }
  6605. catch (Exception ex)
  6606. {
  6607. throw ex;
  6608. }
  6609. finally
  6610. {
  6611. if (conn != null &&
  6612. conn.ConnState == ConnectionState.Open)
  6613. {
  6614. conn.Close();
  6615. }
  6616. }
  6617. }
  6618. /// <summary>
  6619. /// 获取查询sql
  6620. /// </summary>
  6621. /// <returns>sql</returns>
  6622. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6623. {
  6624. string selSql = "";
  6625. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6626. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6627. selSql = selSql +
  6628. "SELECT " +
  6629. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6630. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6631. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6632. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6633. "decode(goodscode,'--','--',createtime) createtime, " +
  6634. "GOODSTYPENAME, " +
  6635. "Goodscode, " +
  6636. "GOODSSPECIFICATION, " +
  6637. "GoodsCount " +
  6638. "from " +
  6639. "( " +
  6640. " SELECT " +
  6641. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6642. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6643. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6644. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6645. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6646. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6647. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6648. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6649. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6650. " from " +
  6651. " ( " +
  6652. " SELECT TP_PM_ProductionData.Modeltype, " +
  6653. " TP_PM_ProductionData.Goodsid, " +
  6654. " TP_PM_ProductionData.KilnCarID, " +
  6655. " TP_PM_ProductionData.Kilncode, " +
  6656. //" TP_PM_ProductionData.Usercode, " +
  6657. " kcd.Usercode, " +
  6658. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6659. " from TP_PM_ProductionData " +
  6660. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6661. " where " +
  6662. " TP_PM_ProductionData.Accountid=:AccountID " +
  6663. " and TP_PM_ProductionData.Valueflag=1 " +
  6664. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6665. if (se.KilnID.HasValue)
  6666. {
  6667. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6668. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6669. }
  6670. //if (se.KilnCarID.HasValue)
  6671. //{
  6672. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6673. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6674. //}
  6675. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6676. {
  6677. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6678. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6679. }
  6680. if (!string.IsNullOrEmpty(se.UserIDS))
  6681. {
  6682. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6683. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6684. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6685. }
  6686. if (se.CreateTimeStart.HasValue)
  6687. {
  6688. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6689. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6690. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6691. }
  6692. if (se.CreateTimeEnd.HasValue)
  6693. {
  6694. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6695. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6696. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6697. }
  6698. selSql = selSql +
  6699. " ) TP_PM_ProductionData " +
  6700. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6701. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6702. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6703. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6704. " where 1=1 ";
  6705. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6706. {
  6707. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6708. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6709. }
  6710. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6711. {
  6712. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6713. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6714. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6715. }
  6716. else
  6717. {
  6718. if (se.KilnCarNumBegin.HasValue)
  6719. {
  6720. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6721. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6722. }
  6723. if (se.KilnCarNumEnd.HasValue)
  6724. {
  6725. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6726. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6727. }
  6728. }
  6729. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6730. {
  6731. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6732. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6733. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6734. }
  6735. selSql = selSql +
  6736. " group by rollup( " +
  6737. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6738. " TP_PM_ProductionData.Kilncode, " +
  6739. " TP_PM_ProductionData.Usercode, " +
  6740. " TP_MST_KilnCar.Kilncarcode, " +
  6741. " TP_PM_ProductionData.CreateTime, " +
  6742. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6743. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6744. " TP_MST_Goods.Goodscode " +
  6745. " ) " +
  6746. ") temp " +
  6747. "where 1=1 and " +
  6748. " (Goodscode !='--' ) or " +
  6749. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6750. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6751. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6752. return selSql;
  6753. }
  6754. /// <summary>
  6755. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6756. /// </summary>
  6757. /// <param name="user">登录用户信息</param>
  6758. /// <param name="se">查询条件</param>
  6759. /// <returns>查询结果</returns>
  6760. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6761. {
  6762. IDBConnection conn = null;
  6763. try
  6764. {
  6765. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6766. List<OracleParameter> parameters = new List<OracleParameter>();
  6767. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6768. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6769. ServiceResultEntity sre = new ServiceResultEntity();
  6770. if (data == null || data.Rows.Count == 0)
  6771. {
  6772. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6773. return sre;
  6774. }
  6775. sre.Data = new DataSet();
  6776. sre.Data.Tables.Add(data);
  6777. return sre;
  6778. }
  6779. catch (Exception ex)
  6780. {
  6781. throw ex;
  6782. }
  6783. finally
  6784. {
  6785. if (conn != null &&
  6786. conn.ConnState == ConnectionState.Open)
  6787. {
  6788. conn.Close();
  6789. }
  6790. }
  6791. }
  6792. /// <summary>
  6793. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6794. /// </summary>
  6795. /// <returns>sql</returns>
  6796. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6797. {
  6798. string selSql = "";
  6799. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6800. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6801. selSql = selSql +
  6802. "select " +
  6803. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6804. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6805. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6806. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6807. "decode(goodscode,'--','--',createtime) createtime, " +
  6808. "GOODSTYPENAME, " +
  6809. "Goodscode, " +
  6810. "GOODSSPECIFICATION, " +
  6811. "Barcode, " +
  6812. "BarcodeCount, " +
  6813. "LogoCodeName " +
  6814. "from " +
  6815. " ( " +
  6816. " select " +
  6817. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6818. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6819. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6820. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6821. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6822. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6823. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6824. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6825. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6826. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6827. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6828. " from " +
  6829. " ( " +
  6830. " select TP_PM_ProductionData.logoid," +
  6831. " TP_PM_ProductionData.Modeltype, " +
  6832. " TP_PM_ProductionData.Goodsid, " +
  6833. " TP_PM_ProductionData.KilnCarID, " +
  6834. " TP_PM_ProductionData.Kilncode, " +
  6835. " TP_PM_ProductionData.Barcode, " +
  6836. " TP_PM_ProductionData.Usercode, " +
  6837. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6838. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6839. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6840. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6841. " where " +
  6842. " TP_PM_ProductionData.Accountid=:AccountID " +
  6843. " and TP_PM_ProductionData.Valueflag=1 " +
  6844. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6845. if (se.KilnID.HasValue)
  6846. {
  6847. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6848. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6849. }
  6850. //if (se.KilnCarID.HasValue)
  6851. //{
  6852. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  6853. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6854. //}
  6855. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6856. {
  6857. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6858. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6859. }
  6860. if (!string.IsNullOrEmpty(se.UserIDS))
  6861. {
  6862. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6863. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6864. }
  6865. if (se.CreateTimeStart.HasValue)
  6866. {
  6867. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6868. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6869. }
  6870. if (se.CreateTimeEnd.HasValue)
  6871. {
  6872. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6873. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6874. }
  6875. selSql = selSql +
  6876. " ) TP_PM_ProductionData " +
  6877. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6878. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6879. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6880. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6881. " where 1=1";
  6882. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6883. {
  6884. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6885. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6886. }
  6887. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6888. {
  6889. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6890. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6891. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6892. }
  6893. else
  6894. {
  6895. if (se.KilnCarNumBegin.HasValue)
  6896. {
  6897. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6898. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6899. }
  6900. if (se.KilnCarNumEnd.HasValue)
  6901. {
  6902. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6903. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6904. }
  6905. }
  6906. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6907. {
  6908. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6909. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  6910. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6911. }
  6912. selSql = selSql +
  6913. " group by rollup( " +
  6914. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6915. " TP_PM_ProductionData.Kilncode, " +
  6916. " TP_PM_ProductionData.Usercode, " +
  6917. " TP_MST_KilnCar.Kilncarcode, " +
  6918. " TP_PM_ProductionData.CreateTime, " +
  6919. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6920. " TP_MST_Goods.Goodscode, " +
  6921. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6922. " TP_PM_ProductionData.Barcode, " +
  6923. " TP_PM_ProductionData.LogoCodeName " +
  6924. " ) " +
  6925. " ) temp " +
  6926. "where 1=1 and " +
  6927. "(Barcode !='--' and LogoCodeName!='--') or " +
  6928. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  6929. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  6930. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  6931. return selSql;
  6932. }
  6933. #region 工序交接数量汇总表
  6934. /// <summary>
  6935. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  6936. /// </summary>
  6937. /// <param name="user">登录用户信息</param>
  6938. /// <param name="se">查询条件</param>
  6939. /// <returns>查询结果</returns>
  6940. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  6941. {
  6942. IDBConnection conn = null;
  6943. try
  6944. {
  6945. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6946. List<OracleParameter> parameters = new List<OracleParameter>();
  6947. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  6948. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6949. ServiceResultEntity sre = new ServiceResultEntity();
  6950. if (data == null || data.Rows.Count == 0)
  6951. {
  6952. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6953. return sre;
  6954. }
  6955. sre.Data = new DataSet();
  6956. sre.Data.Tables.Add(data);
  6957. return sre;
  6958. }
  6959. catch (Exception ex)
  6960. {
  6961. throw ex;
  6962. }
  6963. finally
  6964. {
  6965. if (conn != null &&
  6966. conn.ConnState == ConnectionState.Open)
  6967. {
  6968. conn.Close();
  6969. }
  6970. }
  6971. }
  6972. /// <summary>
  6973. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  6974. /// </summary>
  6975. /// <returns>sql</returns>
  6976. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  6977. {
  6978. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6979. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  6980. string sqlString =
  6981. "SELECT p.procedureid\n" +
  6982. " ,decode(gid,\n" +
  6983. " 7,\n" +
  6984. " '总计',\n" +
  6985. " 3,\n" +
  6986. " '合计【' || p.procedurename || '】',\n" +
  6987. " 1,\n" +
  6988. " '--',\n" +
  6989. " p.procedurename) procedurename\n" +
  6990. " ,decode(gid,\n" +
  6991. " 7,\n" +
  6992. " '--',\n" +
  6993. " 3,\n" +
  6994. " '--',\n" +
  6995. " 1,\n" +
  6996. " '小计【' || p.goodstypename2 || '】',\n" +
  6997. " p.goodstypename2) goodstypename2\n" +
  6998. " ,p.goodstypecode2 \n" +
  6999. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7000. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7001. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7002. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7003. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7004. " ,p.overcount\n" +
  7005. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7006. " ,pdata.productionlineid\n" +
  7007. " ,pdata.procedureid\n" +
  7008. " ,to_char(pdata.procedurename) procedurename\n" +
  7009. " ,to_char(pdata.userid) userid\n" +
  7010. " ,pdata.usercode\n" +
  7011. " ,to_char(pdata.goodsid) goodsid\n" +
  7012. " ,pdata.goodscode\n" +
  7013. " ,pdata.goodstypename\n" +
  7014. " ,pdata.goodstypecode2\n" +
  7015. " ,pdata.goodstypename2\n" +
  7016. " ,COUNT(pdata.barcode) overcount\n" +
  7017. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7018. " ,pd.productionlineid\n" +
  7019. " ,pd.procedureid\n" +
  7020. " ,pcp.procedurename\n" +
  7021. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7022. //" ,pd.userid\n" +
  7023. //" ,pd.usercode\n" +
  7024. " ,t_over.goodsid\n" +
  7025. " ,t_over.goodscode\n" +
  7026. " ,t_over.goodstypename\n" +
  7027. " ,t_over.goodstypecode2\n" +
  7028. " ,t_over.goodstypename2\n" +
  7029. " FROM tp_pm_productiondata pd\n" +
  7030. " LEFT JOIN tp_pc_procedure pcp\n" +
  7031. " ON pcp.procedureid = pd.procedureid\n" +
  7032. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7033. " ,pd.productiondataid\n" +
  7034. " ,goods.goodsid\n" +
  7035. " ,goods.goodscode\n" +
  7036. " ,gt.goodstypename\n" +
  7037. " ,gt2.goodstypename goodstypename2\n" +
  7038. " ,gt2.goodstypecode goodstypecode2\n" +
  7039. " FROM tp_pm_productiondata pd\n" +
  7040. " LEFT JOIN tp_mst_goods goods\n" +
  7041. " ON goods.goodsid = pd.goodsid\n" +
  7042. " LEFT JOIN tp_mst_goodstype gt\n" +
  7043. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7044. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7045. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7046. " AND gt2.accountid = gt.accountid\n" +
  7047. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7048. " -- ON pcp.procedureid = pd.procedureid\n" +
  7049. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7050. " WHERE pd.valueflag = '1'\n" +
  7051. " 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))" +
  7052. " AND pd.accountid = :AccountID\n";
  7053. // 生产线
  7054. if (se.ProductionLineID.HasValue)
  7055. {
  7056. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7057. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7058. }
  7059. // 成型工号
  7060. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7061. {
  7062. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7063. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7064. }
  7065. // 产品型号
  7066. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7067. {
  7068. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7069. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7070. }
  7071. // 产品编码
  7072. if (!string.IsNullOrEmpty(se.GoodsCode))
  7073. {
  7074. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7075. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7076. }
  7077. // 交接工序
  7078. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7079. {
  7080. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7081. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7082. }
  7083. // 交接工号
  7084. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7085. {
  7086. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7087. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7088. }
  7089. // 交接时间
  7090. if (se.OverTimeStart.HasValue)
  7091. {
  7092. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7093. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7094. }
  7095. if (se.OverTimeEnd.HasValue)
  7096. {
  7097. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7098. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7099. }
  7100. // 注浆时间
  7101. if (se.GTimeStart.HasValue)
  7102. {
  7103. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7104. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7105. }
  7106. if (se.GTimeEnd.HasValue)
  7107. {
  7108. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7109. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7110. }
  7111. // 交坯时间
  7112. if (se.DTimeStart.HasValue)
  7113. {
  7114. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7115. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7116. }
  7117. if (se.DTimeEnd.HasValue)
  7118. {
  7119. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7120. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7121. }
  7122. sqlString = sqlString +
  7123. " ) t_over\n" +
  7124. " ON pd.barcode = t_over.barcode\n" +
  7125. // 交接工序在生产工序后
  7126. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7127. " WHERE pd.valueflag = '1'\n" +
  7128. " AND pd.accountid = :AccountID\n" +
  7129. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7130. " 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))";
  7131. // 生产工序
  7132. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7133. {
  7134. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7135. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7136. }
  7137. // 生产工号
  7138. if (!string.IsNullOrEmpty(se.UserIDS))
  7139. {
  7140. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7141. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7142. }
  7143. // 生产时间
  7144. if (se.PTimeStart.HasValue)
  7145. {
  7146. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7147. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7148. }
  7149. if (se.PTimeEnd.HasValue)
  7150. {
  7151. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7152. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7153. }
  7154. sqlString = sqlString +
  7155. "\n ) pdata\n" +
  7156. " 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" +
  7157. " ORDER BY pdata.displayno\n" +
  7158. " ,pdata.goodstypename2\n" +
  7159. " ,pdata.usercode\n" +
  7160. " ,pdata.goodstypename\n" +
  7161. " ,pdata.goodscode) p";
  7162. return sqlString;
  7163. }
  7164. /// <summary>
  7165. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7166. /// </summary>
  7167. /// <param name="user">登录用户信息</param>
  7168. /// <param name="se">查询条件</param>
  7169. /// <returns>查询结果</returns>
  7170. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7171. {
  7172. IDBConnection conn = null;
  7173. try
  7174. {
  7175. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7176. List<OracleParameter> parameters = new List<OracleParameter>();
  7177. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7178. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7179. ServiceResultEntity sre = new ServiceResultEntity();
  7180. if (data == null || data.Rows.Count == 0)
  7181. {
  7182. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7183. return sre;
  7184. }
  7185. sre.Data = new DataSet();
  7186. sre.Data.Tables.Add(data);
  7187. return sre;
  7188. }
  7189. catch (Exception ex)
  7190. {
  7191. throw ex;
  7192. }
  7193. finally
  7194. {
  7195. if (conn != null &&
  7196. conn.ConnState == ConnectionState.Open)
  7197. {
  7198. conn.Close();
  7199. }
  7200. }
  7201. }
  7202. /// <summary>
  7203. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7204. /// </summary>
  7205. /// <returns>sql</returns>
  7206. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7207. {
  7208. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7209. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7210. string sqlString =
  7211. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7212. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7213. //" ,pd.usercode\n" +
  7214. " ,t_over.barcode\n" +
  7215. " ,t_over.goodscode\n" +
  7216. " ,t_over.goodstypename\n" +
  7217. " ,t_over.goodstypename2\n" +
  7218. //" ,pd.createtime ptime\n" +
  7219. //" ,t_over.overprocedurename\n" +
  7220. //" ,t_over.overusercode\n" +
  7221. //" ,t_over.overtime\n" +
  7222. " ,t_over.groutingusercode\n" +
  7223. " ,pd.groutinglinecode\n" +
  7224. " ,pd.groutingmouldcode\n" +
  7225. " ,t_over.groutingdate Gdate\n" +
  7226. " ,t_over.DELIVERTIME Ddate\n" +
  7227. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7228. " FROM tp_pm_productiondata pd\n" +
  7229. " LEFT JOIN tp_pc_procedure pcp\n" +
  7230. " ON pcp.procedureid = pd.procedureid\n" +
  7231. " LEFT JOIN TP_MST_logo logo\n" +
  7232. " ON logo.logoid = pd.logoid\n" +
  7233. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7234. " ,pd.productiondataid\n" +
  7235. " ,goods.goodsid\n" +
  7236. " ,goods.goodscode\n" +
  7237. " ,gt.goodstypename\n" +
  7238. " ,gt2.goodstypename goodstypename2\n" +
  7239. //" ,pcp.procedurename overprocedurename\n" +
  7240. //" ,pd.usercode overusercode\n" +
  7241. //" ,pd.createtime overtime\n" +
  7242. " ,pd.groutingusercode\n" +
  7243. " ,pd.groutingdate\n" +
  7244. " ,gdd.DELIVERTIME\n" +
  7245. " FROM tp_pm_productiondata pd\n" +
  7246. " LEFT JOIN tp_mst_goods goods\n" +
  7247. " ON goods.goodsid = pd.goodsid\n" +
  7248. " LEFT JOIN tp_mst_goodstype gt\n" +
  7249. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7250. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7251. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7252. " AND gt2.accountid = gt.accountid\n" +
  7253. " LEFT JOIN tp_pc_procedure pcp\n" +
  7254. " ON pcp.procedureid = pd.procedureid\n" +
  7255. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7256. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7257. " WHERE pd.valueflag = '1'\n" +
  7258. " 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))" +
  7259. " AND pd.accountid = :AccountID\n";
  7260. // 生产线
  7261. if (se.ProductionLineID.HasValue)
  7262. {
  7263. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7264. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7265. }
  7266. // 成型工号
  7267. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7268. {
  7269. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7270. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7271. }
  7272. // 产品型号
  7273. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7274. {
  7275. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7276. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7277. }
  7278. if (!string.IsNullOrEmpty(se.GoodsID))
  7279. {
  7280. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7281. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7282. }
  7283. // 产品编码
  7284. if (!string.IsNullOrEmpty(se.GoodsCode))
  7285. {
  7286. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7287. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7288. }
  7289. // 交接工序
  7290. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7291. {
  7292. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7293. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7294. }
  7295. // 交接工号
  7296. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7297. {
  7298. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7299. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7300. }
  7301. // 交接时间
  7302. if (se.OverTimeStart.HasValue)
  7303. {
  7304. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7305. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7306. }
  7307. if (se.OverTimeEnd.HasValue)
  7308. {
  7309. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7310. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7311. }
  7312. // 注浆时间
  7313. if (se.GTimeStart.HasValue)
  7314. {
  7315. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7316. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7317. }
  7318. if (se.GTimeEnd.HasValue)
  7319. {
  7320. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7321. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7322. }
  7323. // 交坯时间
  7324. if (se.DTimeStart.HasValue)
  7325. {
  7326. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7327. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7328. }
  7329. if (se.DTimeEnd.HasValue)
  7330. {
  7331. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7332. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7333. }
  7334. sqlString = sqlString +
  7335. " ) t_over\n" +
  7336. " ON pd.barcode = t_over.barcode\n" +
  7337. // 交接工序在生产工序后
  7338. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7339. " WHERE pd.valueflag = '1'\n" +
  7340. " AND pd.accountid = :AccountID\n" +
  7341. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7342. " 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))";
  7343. // 生产工序
  7344. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7345. {
  7346. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7347. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7348. }
  7349. // 生产工号
  7350. if (!string.IsNullOrEmpty(se.UserIDS))
  7351. {
  7352. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7353. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7354. }
  7355. // 生产时间
  7356. if (se.PTimeStart.HasValue)
  7357. {
  7358. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7359. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7360. }
  7361. if (se.PTimeEnd.HasValue)
  7362. {
  7363. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7364. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7365. }
  7366. sqlString = sqlString +
  7367. "\n ORDER BY pcp.displayno\n" +
  7368. " ,t_over.goodstypename2\n" +
  7369. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7370. " ,t_over.goodstypename\n" +
  7371. " ,t_over.goodscode\n";
  7372. return sqlString;
  7373. }
  7374. #endregion
  7375. /// <summary>
  7376. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7377. /// </summary>
  7378. /// <param name="user">登录用户信息</param>
  7379. /// <param name="se">查询条件</param>
  7380. /// <returns>查询结果</returns>
  7381. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7382. {
  7383. IDBConnection conn = null;
  7384. try
  7385. {
  7386. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7387. List<OracleParameter> parameters = new List<OracleParameter>();
  7388. string sqlString = "SELECT decode(g.gid,\n" +
  7389. " 7,\n" +
  7390. " '总计',\n" +
  7391. " 3,\n" +
  7392. " '合计【' || g.goodstypename2 || '】',\n" +
  7393. " 0,\n" +
  7394. " g.goodstypename2,\n" +
  7395. " '--') goodstypename2\n" +
  7396. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7397. " ,decode(g.gid,\n" +
  7398. " 1,\n" +
  7399. " '小计【' || g.goodscode || '】',\n" +
  7400. " 0,\n" +
  7401. " g.goodscode,\n" +
  7402. " '--') goodscode\n" +
  7403. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7404. " ,g.groutingcount\n" +
  7405. " ,g.barcodecount\n" +
  7406. " ,g.scrapcount\n" +
  7407. " ,g.barscrapcount\n" +
  7408. " ,g.delivercount\n" +
  7409. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7410. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7411. " ,gdd.goodstypename2\n" +
  7412. " ,gdd.goodstypename\n" +
  7413. " ,gdd.goodscode\n" +
  7414. " ,gdd.usercode\n" +
  7415. " ,SUM(groutingcount) groutingcount\n" +
  7416. " ,SUM(barcodecount) barcodecount\n" +
  7417. " ,SUM(scrapcount) scrapcount\n" +
  7418. " ,SUM(barscrapcount) barscrapcount\n" +
  7419. " ,SUM(delivercount) delivercount\n" +
  7420. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7421. " ,gdd.usercode\n" +
  7422. " ,goods.goodscode\n" +
  7423. " ,gt.goodstypename\n" +
  7424. " , CASE\n" +
  7425. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7426. " gdd.groutingdate <= :gdataend THEN\n" +
  7427. " 1\n" +
  7428. " ELSE\n" +
  7429. " 0\n" +
  7430. " END groutingcount\n" +
  7431. " , CASE\n" +
  7432. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7433. " gdd.groutingdate <= :gdataend AND\n" +
  7434. " gdd.barcode IS NOT NULL THEN\n" +
  7435. " 1\n" +
  7436. " ELSE\n" +
  7437. " 0\n" +
  7438. " END barcodecount\n" +
  7439. " , CASE\n" +
  7440. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7441. " gdd.scraptime <= :sdataend AND\n" +
  7442. " gdd.scrapflag = '1' THEN\n" +
  7443. " 1\n" +
  7444. " ELSE\n" +
  7445. " 0\n" +
  7446. " END scrapcount\n" +
  7447. " , CASE\n" +
  7448. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7449. " gdd.scraptime <= :sdataend AND\n" +
  7450. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7451. " 1\n" +
  7452. " ELSE\n" +
  7453. " 0\n" +
  7454. " END barscrapcount\n" +
  7455. " , CASE\n" +
  7456. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7457. " gdd.delivertime <= :ddataend AND\n" +
  7458. " gdd.deliverflag = '1' THEN\n" +
  7459. " 1\n" +
  7460. " ELSE\n" +
  7461. " 0\n" +
  7462. " END delivercount\n" +
  7463. " FROM tp_pm_groutingdailydetail gdd\n" +
  7464. " LEFT JOIN tp_mst_goods goods\n" +
  7465. " ON goods.goodsid = gdd.goodsid\n" +
  7466. " LEFT JOIN tp_mst_goodstype gt\n" +
  7467. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7468. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7469. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7470. " AND gt2.accountid = gt.accountid\n" +
  7471. " WHERE gdd.valueflag = '1'\n" +
  7472. " AND gdd.groutingflag = '1'\n" +
  7473. " AND gdd.accountid = :accountid\n" +
  7474. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7475. " gdd.groutingdate <= :gdataend) OR\n" +
  7476. " (gdd.scraptime >= :sdatabegin AND\n" +
  7477. " gdd.scraptime <= :sdataend) OR\n" +
  7478. " (gdd.delivertime >= :ddatabegin AND\n" +
  7479. " gdd.delivertime <= :ddataend))\n" +
  7480. " AND (:usercode IS NULL OR\n" +
  7481. " instr(gdd.usercode, :usercode) > 0)\n" +
  7482. " AND (:GoodsCode IS NULL OR\n" +
  7483. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7484. " AND (:goodstypecode IS NULL OR\n" +
  7485. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7486. " ORDER BY gt2.goodstypename\n" +
  7487. " ,gt.goodstypename\n" +
  7488. " ,goods.goodscode\n" +
  7489. " ,gdd.usercode) gdd\n" +
  7490. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7491. " ORDER BY gdd.goodstypename2\n" +
  7492. " ,gdd.goodstypename\n" +
  7493. " ,gdd.goodscode\n" +
  7494. " ,gdd.usercode) g";
  7495. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7496. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7497. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7498. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7499. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7500. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7501. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7502. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7503. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7504. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7505. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7506. ServiceResultEntity sre = new ServiceResultEntity();
  7507. if (data == null || data.Rows.Count == 0)
  7508. {
  7509. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7510. return sre;
  7511. }
  7512. sre.Data = new DataSet();
  7513. sre.Data.Tables.Add(data);
  7514. return sre;
  7515. }
  7516. catch (Exception ex)
  7517. {
  7518. throw ex;
  7519. }
  7520. finally
  7521. {
  7522. if (conn != null &&
  7523. conn.ConnState == ConnectionState.Open)
  7524. {
  7525. conn.Close();
  7526. }
  7527. }
  7528. }
  7529. #region 撤销产品汇总表
  7530. /// <summary>
  7531. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7532. /// </summary>
  7533. /// <param name="user">登录用户信息</param>
  7534. /// <param name="se">查询条件</param>
  7535. /// <returns>查询结果</returns>
  7536. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7537. {
  7538. IDBConnection conn = null;
  7539. try
  7540. {
  7541. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7542. List<OracleParameter> parameters = new List<OracleParameter>();
  7543. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7544. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7545. ServiceResultEntity sre = new ServiceResultEntity();
  7546. if (data == null || data.Rows.Count == 0)
  7547. {
  7548. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7549. return sre;
  7550. }
  7551. sre.Data = new DataSet();
  7552. sre.Data.Tables.Add(data);
  7553. return sre;
  7554. }
  7555. catch (Exception ex)
  7556. {
  7557. throw ex;
  7558. }
  7559. finally
  7560. {
  7561. if (conn != null &&
  7562. conn.ConnState == ConnectionState.Open)
  7563. {
  7564. conn.Close();
  7565. }
  7566. }
  7567. }
  7568. /// <summary>
  7569. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7570. /// </summary>
  7571. /// <returns>sql</returns>
  7572. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7573. {
  7574. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7575. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7576. string sqlString =
  7577. "SELECT decode(p.gid,\n" +
  7578. " 7,\n" +
  7579. " '总计',\n" +
  7580. " 3,\n" +
  7581. " '合计【' || p.procedurename || '】',\n" +
  7582. " 0,\n" +
  7583. " p.procedurename,\n" +
  7584. " '--') procedurename\n" +
  7585. " ,decode(p.gid,\n" +
  7586. " 1,\n" +
  7587. " '小计【' || p.goodstypename2 || '】',\n" +
  7588. " 0,\n" +
  7589. " p.goodstypename2,\n" +
  7590. " '--') goodstypename2\n" +
  7591. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7592. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7593. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7594. " ,p.codecount\n" +
  7595. " ,p.productionlineid\n" +
  7596. " ,p.procedureid\n" +
  7597. " ,p.goodstypecode2\n" +
  7598. " ,p.goodsid\n" +
  7599. " ,p.userid\n" +
  7600. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7601. " ,pd.productionlineid\n" +
  7602. " ,pd.procedureid\n" +
  7603. " ,p.procedurename\n" +
  7604. " ,p.displayno\n" +
  7605. " ,gt2.goodstypecode goodstypecode2\n" +
  7606. " ,gt2.goodstypename goodstypename2\n" +
  7607. " ,gt.goodstypecode\n" +
  7608. " ,gt.goodstypename\n" +
  7609. " ,goods.goodsid\n" +
  7610. " ,goods.goodscode\n" +
  7611. " ,pd.userid\n" +
  7612. " ,pd.usercode\n" +
  7613. " ,COUNT(*) codecount\n" +
  7614. " FROM tp_pm_productiondata pd\n" +
  7615. " LEFT JOIN tp_pc_procedure p\n" +
  7616. " ON p.procedureid = pd.procedureid\n" +
  7617. " LEFT JOIN tp_mst_goods goods\n" +
  7618. " ON goods.goodsid = pd.goodsid\n" +
  7619. " LEFT JOIN tp_mst_goodstype gt\n" +
  7620. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7621. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7622. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7623. " AND gt2.accountid = gt.accountid\n" +
  7624. " WHERE pd.valueflag = '0'\n" +
  7625. " AND pd.accountid = :accountid\n" +
  7626. " 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))" +
  7627. " 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))" +
  7628. " AND (:productionlineid IS NULL OR\n" +
  7629. " pd.productionlineid = :productionlineid)\n" +
  7630. " AND (:procedureids IS NULL OR\n" +
  7631. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7632. " AND (:goodstypecode IS NULL OR\n" +
  7633. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7634. " AND (:goodscode IS NULL OR\n" +
  7635. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7636. " AND (:PUserIDS IS NULL OR\n" +
  7637. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7638. " AND (:backusercode IS NULL OR\n" +
  7639. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7640. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7641. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7642. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7643. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7644. " 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" +
  7645. " ORDER BY p.displayno\n" +
  7646. " ,gt2.goodstypecode\n" +
  7647. " ,gt.goodstypecode\n" +
  7648. " ,goods.goodscode\n" +
  7649. " ,pd.usercode) p";
  7650. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7651. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7652. {
  7653. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7654. }
  7655. else
  7656. {
  7657. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7658. }
  7659. if (string.IsNullOrEmpty(se.UserIDS))
  7660. {
  7661. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7662. }
  7663. else
  7664. {
  7665. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7666. }
  7667. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7668. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7669. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7670. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7671. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7672. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7673. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7674. return sqlString;
  7675. }
  7676. /// <summary>
  7677. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7678. /// </summary>
  7679. /// <param name="user">登录用户信息</param>
  7680. /// <param name="se">查询条件</param>
  7681. /// <returns>查询结果</returns>
  7682. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7683. {
  7684. IDBConnection conn = null;
  7685. try
  7686. {
  7687. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7688. List<OracleParameter> parameters = new List<OracleParameter>();
  7689. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7690. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7691. ServiceResultEntity sre = new ServiceResultEntity();
  7692. if (data == null || data.Rows.Count == 0)
  7693. {
  7694. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7695. return sre;
  7696. }
  7697. sre.Data = new DataSet();
  7698. sre.Data.Tables.Add(data);
  7699. return sre;
  7700. }
  7701. catch (Exception ex)
  7702. {
  7703. throw ex;
  7704. }
  7705. finally
  7706. {
  7707. if (conn != null &&
  7708. conn.ConnState == ConnectionState.Open)
  7709. {
  7710. conn.Close();
  7711. }
  7712. }
  7713. }
  7714. /// <summary>
  7715. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7716. /// </summary>
  7717. /// <returns>sql</returns>
  7718. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7719. {
  7720. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7721. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7722. string sqlString =
  7723. "SELECT p.procedurename\n" +
  7724. " ,gt2.goodstypename goodstypename2\n" +
  7725. " ,gt.goodstypename\n" +
  7726. " ,goods.goodscode\n" +
  7727. " ,pd.barcode\n" +
  7728. " ,pd.usercode\n" +
  7729. " ,pd.createtime ptime\n" +
  7730. " ,pd.backoutusercode busercode\n" +
  7731. " ,pd.backouttime btime\n" +
  7732. " ,pd.groutingusercode\n" +
  7733. " ,pd.groutinglinecode\n" +
  7734. " ,pd.groutingmouldcode\n" +
  7735. " ,pd.groutingdate GDate\n" +
  7736. " FROM tp_pm_productiondata pd\n" +
  7737. " LEFT JOIN tp_pc_procedure p\n" +
  7738. " ON p.procedureid = pd.procedureid\n" +
  7739. " LEFT JOIN tp_mst_goods goods\n" +
  7740. " ON goods.goodsid = pd.goodsid\n" +
  7741. " LEFT JOIN tp_mst_goodstype gt\n" +
  7742. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7743. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7744. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7745. " AND gt2.accountid = gt.accountid\n" +
  7746. " WHERE pd.valueflag = '0'\n" +
  7747. " AND pd.accountid = :accountid\n" +
  7748. " 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))" +
  7749. " 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))" +
  7750. " AND (:productionlineid IS NULL OR\n" +
  7751. " pd.productionlineid = :productionlineid)\n" +
  7752. " AND (:procedureids IS NULL OR\n" +
  7753. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7754. " AND (:goodstypecode IS NULL OR\n" +
  7755. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7756. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7757. " AND (:PUserIDS IS NULL OR\n" +
  7758. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7759. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7760. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7761. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7762. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7763. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7764. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7765. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7766. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7767. " ORDER BY p.displayno\n" +
  7768. " ,gt2.goodstypename\n" +
  7769. " ,gt.goodstypename\n" +
  7770. " ,goods.goodscode\n" +
  7771. " ,pd.usercode\n" +
  7772. " ,pd.barcode\n" +
  7773. " ,pd.backoutusercode\n" +
  7774. " ,pd.backouttime";
  7775. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7776. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7777. {
  7778. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7779. }
  7780. else
  7781. {
  7782. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7783. }
  7784. if (string.IsNullOrEmpty(se.UserIDS))
  7785. {
  7786. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7787. }
  7788. else
  7789. {
  7790. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7791. }
  7792. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7793. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7794. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7795. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7796. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7797. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7798. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7799. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7800. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7801. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7802. return sqlString;
  7803. }
  7804. #endregion
  7805. /// <summary>
  7806. /// 工序收发存汇总表(初始化数据)
  7807. /// </summary>
  7808. /// <param name="user"></param>
  7809. /// <returns></returns>
  7810. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7811. {
  7812. IDBConnection conn = null;
  7813. try
  7814. {
  7815. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7816. OracleParameter[] parameters = new OracleParameter[]
  7817. {
  7818. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7819. };
  7820. string sqlString =
  7821. "SELECT t.ptid, t.name\n" +
  7822. " FROM tp_mst_rpt_transfer t\n" +
  7823. " WHERE t.AccountID = :AccountID\n" +
  7824. " AND t.valueflag = '1'\n" +
  7825. " ORDER BY t.displayno desc";
  7826. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7827. ServiceResultEntity sre = new ServiceResultEntity();
  7828. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7829. //{
  7830. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7831. // return sre;
  7832. //}
  7833. sre.Data = data;
  7834. return sre;
  7835. }
  7836. catch (Exception ex)
  7837. {
  7838. throw ex;
  7839. }
  7840. finally
  7841. {
  7842. if (conn != null &&
  7843. conn.ConnState == ConnectionState.Open)
  7844. {
  7845. conn.Close();
  7846. }
  7847. }
  7848. }
  7849. /// <summary>
  7850. /// 工序收发存汇总表
  7851. /// </summary>
  7852. /// <param name="user"></param>
  7853. /// <param name="se"></param>
  7854. /// <returns></returns>
  7855. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  7856. {
  7857. IDBTransaction conn = null;
  7858. try
  7859. {
  7860. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  7861. conn.Connect();
  7862. OracleParameter[] parameters = new OracleParameter[]
  7863. {
  7864. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7865. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  7866. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  7867. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  7868. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  7869. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  7870. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  7871. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  7872. };
  7873. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  7874. ServiceResultEntity sre = new ServiceResultEntity();
  7875. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7876. {
  7877. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7878. return sre;
  7879. }
  7880. //StringBuilder intdids = new StringBuilder();
  7881. //foreach (DataRow row in data.Tables[0].Rows)
  7882. //{
  7883. // if (intdids.Length > 0)
  7884. // {
  7885. // intdids.Append(", ");
  7886. // }
  7887. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  7888. //}
  7889. //string sqlString =
  7890. // "WITH ttm AS\n" +
  7891. // " (SELECT *\n" +
  7892. // " FROM TMP_RPT_TECDEP_D\n" +
  7893. // " pivot(SUM(m)\n" +
  7894. // " FOR intdid IN(" + intdids + ")))\n" +
  7895. // "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" +
  7896. // " FROM TMP_RPT_TECDEP_T t\n" +
  7897. // " LEFT JOIN ttm m\n" +
  7898. // " ON m.goodsid = t.goodsid\n" +
  7899. // " AND m.outtdid = t.tecdepid\n" +
  7900. // " ORDER BY t.goodscode, t.displayno";
  7901. //data = conn.GetSqlResultToDs(sqlString);
  7902. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7903. //{
  7904. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7905. // return sre;
  7906. //}
  7907. conn.Commit();
  7908. sre.Data = data;
  7909. return sre;
  7910. }
  7911. catch (Exception ex)
  7912. {
  7913. throw ex;
  7914. }
  7915. finally
  7916. {
  7917. if (conn != null &&
  7918. conn.ConnState == ConnectionState.Open)
  7919. {
  7920. conn.Disconnect();
  7921. }
  7922. }
  7923. }
  7924. #endregion 汇总报表
  7925. #region 公共函数
  7926. /// <summary>
  7927. /// 取得报表的查询数据源统计工序数据
  7928. /// </summary>
  7929. /// <param name="user">登录用户信息</param>
  7930. /// <param name="se">查询条件</param>
  7931. /// <returns>查询结果</returns>
  7932. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  7933. {
  7934. IDBConnection conn = null;
  7935. try
  7936. {
  7937. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7938. OracleParameter[] paras = new OracleParameter[]{
  7939. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  7940. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  7941. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  7942. };
  7943. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  7944. ServiceResultEntity sre = new ServiceResultEntity();
  7945. if (data == null || data.Tables.Count == 0)
  7946. {
  7947. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7948. return sre;
  7949. }
  7950. sre.Data = new DataSet();
  7951. sre.Data = data;
  7952. return sre;
  7953. }
  7954. catch (Exception ex)
  7955. {
  7956. throw ex;
  7957. }
  7958. finally
  7959. {
  7960. if (conn != null &&
  7961. conn.ConnState == ConnectionState.Open)
  7962. {
  7963. conn.Close();
  7964. }
  7965. }
  7966. }
  7967. /// <summary>
  7968. /// 取得报表数据源数据
  7969. /// </summary>
  7970. /// <param name="user">登录用户信息</param>
  7971. /// <returns>查询结果</returns>
  7972. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  7973. {
  7974. IDBConnection conn = null;
  7975. try
  7976. {
  7977. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7978. string selSql = " select "
  7979. + " TP_MST_RptProcedure.Rptprocedureid,"
  7980. + " TP_MST_RptProcedure.Rptprocedurecode,"
  7981. + " TP_MST_RptProcedure.Rptprocedurename,"
  7982. + " TP_MST_RptProcedure.Rptproceduretype,"
  7983. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  7984. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  7985. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  7986. + " TP_MST_RptProcedure.Optimestamp "
  7987. + " from TP_MST_RptProcedure "
  7988. + " where TP_MST_RptProcedure.ValueFlag=1 "
  7989. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  7990. List<OracleParameter> parameters = new List<OracleParameter>();
  7991. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7992. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  7993. ServiceResultEntity sre = new ServiceResultEntity();
  7994. if (data == null || data.Rows.Count == 0)
  7995. {
  7996. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7997. return sre;
  7998. }
  7999. sre.Data = new DataSet();
  8000. sre.Data.Tables.Add(data);
  8001. return sre;
  8002. }
  8003. catch (Exception ex)
  8004. {
  8005. throw ex;
  8006. }
  8007. finally
  8008. {
  8009. if (conn != null &&
  8010. conn.ConnState == ConnectionState.Open)
  8011. {
  8012. conn.Close();
  8013. }
  8014. }
  8015. }
  8016. /// <summary>
  8017. /// 取得窑炉数据
  8018. /// </summary>
  8019. /// <param name="user">登录用户信息</param>
  8020. /// <param name="pValue">使用标识条件</param>
  8021. /// <returns>查询结果</returns>
  8022. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8023. {
  8024. IDBConnection conn = null;
  8025. try
  8026. {
  8027. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8028. string selSql = string.Empty;
  8029. List<OracleParameter> parameters = new List<OracleParameter>();
  8030. //根据帐套查询数据
  8031. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8032. {
  8033. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8034. + "from TP_MST_Kiln where AccountID = :AccountID";
  8035. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8036. }
  8037. //根据帐套和标识查询数据
  8038. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8039. {
  8040. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8041. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8042. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8043. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8044. }
  8045. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8046. ServiceResultEntity sre = new ServiceResultEntity();
  8047. if (data == null || data.Rows.Count == 0)
  8048. {
  8049. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8050. return sre;
  8051. }
  8052. sre.Data = new DataSet();
  8053. sre.Data.Tables.Add(data);
  8054. return sre;
  8055. }
  8056. catch (Exception ex)
  8057. {
  8058. throw ex;
  8059. }
  8060. finally
  8061. {
  8062. if (conn != null &&
  8063. conn.ConnState == ConnectionState.Open)
  8064. {
  8065. conn.Close();
  8066. }
  8067. }
  8068. }
  8069. /// <summary>
  8070. /// 取得窑车数据
  8071. /// </summary>
  8072. /// <param name="user">登录用户信息</param>
  8073. /// <returns>查询结果</returns>
  8074. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8075. {
  8076. IDBConnection conn = null;
  8077. try
  8078. {
  8079. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8080. string selSql = String.Empty;
  8081. List<OracleParameter> parameters = new List<OracleParameter>();
  8082. //获取窑车管理的数据
  8083. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8084. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8085. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8086. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8087. ServiceResultEntity sre = new ServiceResultEntity();
  8088. if (data == null || data.Rows.Count == 0)
  8089. {
  8090. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8091. return sre;
  8092. }
  8093. sre.Data = new DataSet();
  8094. sre.Data.Tables.Add(data);
  8095. return sre;
  8096. }
  8097. catch (Exception ex)
  8098. {
  8099. throw ex;
  8100. }
  8101. finally
  8102. {
  8103. if (conn != null &&
  8104. conn.ConnState == ConnectionState.Open)
  8105. {
  8106. conn.Close();
  8107. }
  8108. }
  8109. }
  8110. /// <summary>
  8111. /// 取得生产线所有的工序
  8112. /// </summary>
  8113. /// <param name="user">登录用户信息</param>
  8114. /// <returns>查询结果</returns>
  8115. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8116. {
  8117. IDBConnection conn = null;
  8118. try
  8119. {
  8120. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8121. string selSql = "select "
  8122. + " tp_pc_procedure.procedureid, "
  8123. + " tp_pc_procedure.Procedurename "
  8124. + " from "
  8125. + " ( "
  8126. + " select TP_PM_ProductionData.Procedureid "
  8127. + " from TP_PM_ProductionData "
  8128. + " where TP_PM_ProductionData.accountid = :accountID "
  8129. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8130. + " group by TP_PM_ProductionData.Procedureid "
  8131. + " order by TP_PM_ProductionData.Procedureid "
  8132. + " )temp left join tp_pc_procedure "
  8133. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8134. List<OracleParameter> parameters = new List<OracleParameter>();
  8135. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8136. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8137. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8138. ServiceResultEntity sre = new ServiceResultEntity();
  8139. if (data == null || data.Rows.Count == 0)
  8140. {
  8141. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8142. return sre;
  8143. }
  8144. sre.Data = new DataSet();
  8145. sre.Data.Tables.Add(data);
  8146. return sre;
  8147. }
  8148. catch (Exception ex)
  8149. {
  8150. throw ex;
  8151. }
  8152. finally
  8153. {
  8154. if (conn != null &&
  8155. conn.ConnState == ConnectionState.Open)
  8156. {
  8157. conn.Close();
  8158. }
  8159. }
  8160. }
  8161. /// <summary>
  8162. /// 取得数据字典数据
  8163. /// </summary>
  8164. /// <param name="Pvalue">显示停用标识</param>
  8165. /// <param name="dictionaryType">字典类别</param>
  8166. /// <param name="user">登录用户信息</param>
  8167. /// <returns>查询结果</returns>
  8168. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8169. {
  8170. IDBConnection conn = null;
  8171. try
  8172. {
  8173. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8174. string selSql = String.Empty;
  8175. List<OracleParameter> parameters = new List<OracleParameter>();
  8176. //根据帐套获得数据字典管理的数据
  8177. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8178. {
  8179. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8180. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8181. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8182. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8183. }
  8184. //根据帐套,标识获得数据字典管理的数据
  8185. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8186. {
  8187. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8188. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8189. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8190. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8191. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8192. }
  8193. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8194. ServiceResultEntity sre = new ServiceResultEntity();
  8195. if (data == null || data.Rows.Count == 0)
  8196. {
  8197. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8198. return sre;
  8199. }
  8200. sre.Data = new DataSet();
  8201. sre.Data.Tables.Add(data);
  8202. return sre;
  8203. }
  8204. catch (Exception ex)
  8205. {
  8206. throw ex;
  8207. }
  8208. finally
  8209. {
  8210. if (conn != null &&
  8211. conn.ConnState == ConnectionState.Open)
  8212. {
  8213. conn.Close();
  8214. }
  8215. }
  8216. }
  8217. #endregion 公共函数
  8218. #endregion 统一使用Se模式rviceResultEntity类
  8219. /// <summary>
  8220. /// 获取注浆次数报表
  8221. /// </summary>
  8222. /// <param name="groutingLineEntity"></param>
  8223. /// <param name="user"></param>
  8224. /// <returns></returns>
  8225. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8226. {
  8227. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8228. try
  8229. {
  8230. con.Open();
  8231. OracleParameter[] paras = new OracleParameter[]{
  8232. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8233. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8234. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8235. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8236. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8237. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8238. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8239. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8240. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8241. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8242. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8243. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8244. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8245. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8246. new OracleParameter("AccountID",OracleDbType.Int32,
  8247. user.AccountID,ParameterDirection.Input),
  8248. new OracleParameter("UserId",OracleDbType.Int32,
  8249. user.UserID,ParameterDirection.Input),
  8250. new OracleParameter("PurviewType",OracleDbType.Int32,
  8251. groutingLineEntity.Purview,ParameterDirection.Input),
  8252. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8253. ParameterDirection.Output),
  8254. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8255. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8256. };
  8257. //调用获取符合条件的成型线信息
  8258. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8259. ServiceResultEntity sre = new ServiceResultEntity();
  8260. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8261. {
  8262. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8263. return sre;
  8264. }
  8265. sre.Data = new DataSet();
  8266. //DataTable dt=ds.Tables[0];
  8267. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8268. return sre;
  8269. }
  8270. catch (Exception ex)
  8271. {
  8272. throw ex;
  8273. }
  8274. finally
  8275. {
  8276. if (con.ConnState == ConnectionState.Open)
  8277. {
  8278. con.Close();
  8279. }
  8280. }
  8281. }
  8282. #region 在产产品汇总表
  8283. /// <summary>
  8284. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8285. /// </summary>
  8286. /// <param name="user">登录用户信息</param>
  8287. /// <param name="se">查询条件</param>
  8288. /// <returns>查询结果</returns>
  8289. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8290. {
  8291. IDBConnection conn = null;
  8292. try
  8293. {
  8294. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8295. List<OracleParameter> parameters = new List<OracleParameter>();
  8296. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8297. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8298. ServiceResultEntity sre = new ServiceResultEntity();
  8299. if (data == null || data.Rows.Count == 0)
  8300. {
  8301. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8302. return sre;
  8303. }
  8304. sre.Data = new DataSet();
  8305. sre.Data.Tables.Add(data);
  8306. return sre;
  8307. }
  8308. catch (Exception ex)
  8309. {
  8310. throw ex;
  8311. }
  8312. finally
  8313. {
  8314. if (conn != null &&
  8315. conn.ConnState == ConnectionState.Open)
  8316. {
  8317. conn.Close();
  8318. }
  8319. }
  8320. }
  8321. /// <summary>
  8322. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8323. /// </summary>
  8324. /// <returns>sql</returns>
  8325. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8326. {
  8327. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8328. //"select " +
  8329. //" ProcedureID," +
  8330. //" procedurecode, " +
  8331. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8332. //" productionlineid, " +
  8333. //" productionlinecode, " +
  8334. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8335. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8336. //" subGoodsTypecode, " +
  8337. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8338. //" Goodstypename, " +
  8339. //" InCount " +
  8340. #region
  8341. /*
  8342. "select " +
  8343. " ProcedureID," +
  8344. " procedurecode, " +
  8345. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8346. " productionlineid, " +
  8347. " productionlinecode, " +
  8348. " productionlinename, " +
  8349. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8350. " decode(productionlinename, '--', null, UserID) UserID, " +
  8351. " subGoodsTypecode, " +
  8352. " Goodsid," +
  8353. " Goodscode, " +
  8354. " Goodstypename, " +
  8355. " InCount from (" +
  8356. "select " +
  8357. " ProcedureID," +
  8358. " procedurecode, " +
  8359. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8360. " productionlineid, " +
  8361. " productionlinecode, " +
  8362. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8363. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8364. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8365. " subGoodsTypecode, " +
  8366. " Goodsid," +
  8367. " Goodscode, " +
  8368. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8369. " InCount " +
  8370. "from " +
  8371. "(" +
  8372. " select " +
  8373. " ProcedureID, " +
  8374. " procedurecode, " +
  8375. " procedurename, " +
  8376. " productionlineid, " +
  8377. " productionlinecode, " +
  8378. " productionlinename, " +
  8379. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8380. " decode(procedurecode,'--',null,Userid) Userid, " +
  8381. " subGoodsTypecode," +
  8382. " Goodsid," +
  8383. " Goodscode," +
  8384. " Goodstypename, " +
  8385. " InCount " +
  8386. " from ( select " +
  8387. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8388. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8389. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8390. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8391. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8392. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8393. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8394. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8395. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8396. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8397. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8398. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8399. " count(barcode) as InCount " +
  8400. " from tp_pm_inproduction " +
  8401. " left join tp_pc_procedure" +
  8402. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8403. " 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" +
  8404. " Where 1=1 " +
  8405. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8406. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8407. {
  8408. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8409. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8410. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8411. }
  8412. if (!string.IsNullOrEmpty(se.LineIDS))
  8413. {
  8414. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8415. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8416. }
  8417. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8418. {
  8419. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8420. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8421. }
  8422. if (!string.IsNullOrEmpty(se.GoodsCode))
  8423. {
  8424. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8425. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8426. }
  8427. selSql = selSql +
  8428. "group by " +
  8429. " rollup(tp_pc_procedure.ProcedureID, " +
  8430. " tp_pc_procedure.procedurecode, " +
  8431. " tp_pc_procedure.procedurename, " +
  8432. " tp_pm_inproduction.productionlineid, " +
  8433. " tp_pm_inproduction.productionlinecode, " +
  8434. " tp_pm_inproduction.productionlinename, " +
  8435. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8436. " TP_MST_User.Usercode," +
  8437. " TP_MST_Goods.Goodscode, " +
  8438. " TP_MST_User.UserID," +
  8439. " TP_MST_Goods.GoodsID, " +
  8440. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8441. "where 1=1 " +
  8442. "and (Goodstypename!='--')" +
  8443. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8444. "or (Goodstypename='--' and UserCode='合计') " +
  8445. "or (Goodstypename='--' and UserCode='总计') )";
  8446. */
  8447. #endregion
  8448. string sqlString = "select t.productionlineid\n" +
  8449. " ,t.productionlinecode\n" +
  8450. " ,decode(gid\n" +
  8451. " ,15\n" +
  8452. " ,'总计【' || t.productionlinename || '】'\n" +
  8453. " ,t.productionlinename) productionlinename\n" +
  8454. " ,t.ProcedureID\n" +
  8455. " ,t.procedurecode\n" +
  8456. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8457. " ,t.Goodstypeid2\n" +
  8458. " ,t.Goodstypecode2\n" +
  8459. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8460. " ,t.Goodsid\n" +
  8461. " ,t.Goodscode\n" +
  8462. " ,t.InCount\n" +
  8463. " from (select grouping_id(inp.productionlineid\n" +
  8464. " ,inp.ProcedureID\n" +
  8465. " ,gt2.Goodstypeid\n" +
  8466. " ,inp.Goodsid) gid\n" +
  8467. " ,inp.productionlineid\n" +
  8468. " ,pline.productionlinecode\n" +
  8469. " ,pline.productionlinename\n" +
  8470. " ,inp.ProcedureID\n" +
  8471. " ,p.procedurecode\n" +
  8472. " ,p.procedurename\n" +
  8473. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8474. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8475. " ,gt2.Goodstypename Goodstypename2\n" +
  8476. " ,inp.Goodsid\n" +
  8477. " ,g.Goodscode\n" +
  8478. " ,count(barcode) as InCount\n" +
  8479. " from tp_pm_inproduction inp\n" +
  8480. " inner join tp_pc_procedure p\n" +
  8481. " on inp.ProcedureID = p.ProcedureID\n" +
  8482. " inner join tp_pc_productionline pline\n" +
  8483. " on pline.productionlineid = inp.productionlineid\n" +
  8484. " inner join TP_MST_User u\n" +
  8485. " on inp.userid = u.Userid\n" +
  8486. " inner join TP_MST_Goods g\n" +
  8487. " on inp.goodsid = g.Goodsid\n" +
  8488. " inner join TP_MST_GoodsType gt\n" +
  8489. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8490. " inner join TP_MST_GoodsType gt2\n" +
  8491. " on gt.accountid = gt2.accountid\n" +
  8492. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8493. " where inp.AccountID = 1\n" +
  8494. " and inp.valueflag = '1'\n";
  8495. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8496. {
  8497. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8498. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8499. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8500. }
  8501. if (!string.IsNullOrEmpty(se.LineIDS))
  8502. {
  8503. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8504. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8505. }
  8506. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8507. {
  8508. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8509. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8510. }
  8511. if (!string.IsNullOrEmpty(se.GoodsCode))
  8512. {
  8513. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8514. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8515. }
  8516. sqlString += " group by grouping sets((inp.productionlineid, pline.productionlinecode, pline.productionlinename, inp.ProcedureID, p.procedurecode, p.procedurename, gt2.Goodstypeid, gt2.Goodstypecode, gt2.Goodstypename, inp.Goodsid, g.Goodscode),(inp.productionlineid, pline.productionlinecode, pline.productionlinename, inp.ProcedureID, p.procedurecode, p.procedurename, gt2.Goodstypeid, gt2.Goodstypecode, gt2.Goodstypename),(inp.productionlineid, pline.productionlinecode, pline.productionlinename, inp.ProcedureID, p.procedurecode, p.procedurename),())) t";
  8517. return sqlString;
  8518. }
  8519. /// <summary>
  8520. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8521. /// </summary>
  8522. /// <param name="user">登录用户信息</param>
  8523. /// <param name="se">查询条件</param>
  8524. /// <returns>查询结果</returns>
  8525. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8526. {
  8527. IDBConnection conn = null;
  8528. try
  8529. {
  8530. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8531. List<OracleParameter> parameters = new List<OracleParameter>();
  8532. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8533. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8534. if (se != null)
  8535. {
  8536. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8537. {
  8538. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8539. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8540. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8541. }
  8542. if (!string.IsNullOrEmpty(se.LineIDS))
  8543. {
  8544. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8545. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8546. }
  8547. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8548. {
  8549. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8550. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8551. }
  8552. if (!string.IsNullOrEmpty(se.GoodsCode))
  8553. {
  8554. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8555. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8556. }
  8557. // 总单点击查询用
  8558. if (se.GoodsID.HasValue)
  8559. {
  8560. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8561. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8562. }
  8563. if (se.UserID.HasValue)
  8564. {
  8565. sql.Append(" AND A.userid = :userid ");
  8566. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8567. }
  8568. }
  8569. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8570. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8571. ServiceResultEntity sre = new ServiceResultEntity();
  8572. if (data == null || data.Rows.Count == 0)
  8573. {
  8574. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8575. return sre;
  8576. }
  8577. sre.Data = new DataSet();
  8578. sre.Data.Tables.Add(data);
  8579. return sre;
  8580. }
  8581. catch (Exception ex)
  8582. {
  8583. throw ex;
  8584. }
  8585. finally
  8586. {
  8587. if (conn != null &&
  8588. conn.ConnState == ConnectionState.Open)
  8589. {
  8590. conn.Close();
  8591. }
  8592. }
  8593. }
  8594. /// <summary>
  8595. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8596. /// </summary>
  8597. /// <returns>sql</returns>
  8598. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8599. {
  8600. string selSql =
  8601. "SELECT " +
  8602. " TP_PM_InProduction.BarCode, " +
  8603. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8604. " TP_PM_InProduction.GoodsName, " +
  8605. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8606. " TP_PM_InProduction.ProductionLineID, " +
  8607. " TP_PM_InProduction.ProductionLineCode, " +
  8608. " TP_PM_InProduction.ProductionLineName, " +
  8609. " TP_PM_InProduction.ModelType, " +
  8610. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8611. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8612. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8613. " TP_PM_InProduction.IsPublicBody, " +
  8614. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8615. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8616. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8617. " TP_PM_InProduction.GroutingDailyID, " +
  8618. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8619. " TP_PM_InProduction.GroutingDate, " +
  8620. " TP_PM_InProduction.GroutingLineID, " +
  8621. " TP_PM_InProduction.GroutingLineCode, " +
  8622. " TP_PM_InProduction.GroutingLineName, " +
  8623. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8624. " D.ProcedureName as CompleteProcedureName, " +
  8625. " TP_PM_InProduction.GMouldTypeID, " +
  8626. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8627. " TP_PM_InProduction.GroutingLineDetailID, " +
  8628. " TP_PM_InProduction.GroutingMouldCode, " +
  8629. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8630. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8631. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8632. " TP_PM_InProduction.Remarks, " +
  8633. " TP_PM_GroutingDailyDetail.glazingroom," +
  8634. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8635. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8636. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8637. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8638. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8639. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8640. "FROM TP_PM_InProduction " +
  8641. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8642. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8643. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8644. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8645. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8646. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8647. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8648. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8649. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8650. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8651. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8652. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8653. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8654. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8655. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8656. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8657. " and TP_PM_InProduction.AccountID=:AccountID ";
  8658. return selSql;
  8659. }
  8660. #endregion
  8661. /// <summary>
  8662. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8663. /// </summary>
  8664. /// <param name="user">登录用户信息</param>
  8665. /// <param name="se">查询条件</param>
  8666. /// <returns>查询结果</returns>
  8667. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8668. {
  8669. IDBConnection conn = null;
  8670. try
  8671. {
  8672. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8673. List<OracleParameter> parameters = new List<OracleParameter>();
  8674. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8675. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8676. ServiceResultEntity sre = new ServiceResultEntity();
  8677. if (data == null || data.Rows.Count == 0)
  8678. {
  8679. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8680. return sre;
  8681. }
  8682. sre.Data = new DataSet();
  8683. sre.Data.Tables.Add(data);
  8684. return sre;
  8685. }
  8686. catch (Exception ex)
  8687. {
  8688. throw ex;
  8689. }
  8690. finally
  8691. {
  8692. if (conn != null &&
  8693. conn.ConnState == ConnectionState.Open)
  8694. {
  8695. conn.Close();
  8696. }
  8697. }
  8698. }
  8699. /// <summary>
  8700. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8701. /// </summary>
  8702. /// <returns>sql</returns>
  8703. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8704. {
  8705. #region
  8706. //string selSql = "";
  8707. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8708. //selSql = selSql +
  8709. // "select " +
  8710. // " DefectProcedureID," +
  8711. // " DefectProcedureCode, " +
  8712. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8713. // " ProductionLineID, " +
  8714. // " ProductionLineCode," +
  8715. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8716. // " ProcedureID, " +
  8717. // " ProcedureCode," +
  8718. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8719. // " DefectCode, " +
  8720. // " DefectName, " +
  8721. // " DefectTypeName, " +
  8722. // " Userid," +
  8723. // " Usercode," +
  8724. // " Username," +
  8725. // " Goodstypename," +
  8726. // " Goodsid," +
  8727. // " Goodscode," +
  8728. // " Goodsname," +
  8729. // " InCount from (" +
  8730. // "select " +
  8731. // " DefectProcedureID," +
  8732. // " DefectProcedureCode, " +
  8733. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8734. // " ProductionLineID, " +
  8735. // " ProductionLineCode, " +
  8736. // " ProductionLineName, " +
  8737. // " ProcedureID, " +
  8738. // " ProcedureCode, " +
  8739. // " ProcedureName, " +
  8740. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8741. // " DefectName, " +
  8742. // " DefectTypeName, " +
  8743. // " Userid, " +
  8744. // " Usercode, " +
  8745. // " Username, " +
  8746. // " Goodstypename, " +
  8747. // " Goodsid, " +
  8748. // " Goodscode, " +
  8749. // " Goodsname, " +
  8750. // " InCount " +
  8751. // "from " +
  8752. // "(" +
  8753. // " select " +
  8754. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8755. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8756. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8757. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8758. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8759. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8760. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8761. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8762. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8763. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8764. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8765. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8766. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8767. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8768. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8769. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8770. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8771. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8772. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8773. // " count(TP_PM_Defect.barcode) as InCount " +
  8774. // " from TP_PM_Defect " +
  8775. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8776. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8777. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8778. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8779. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8780. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8781. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8782. // " and TP_PM_Defect.AccountID=:AccountID ";
  8783. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8784. //{
  8785. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8786. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8787. //}
  8788. //if (!string.IsNullOrEmpty(se.LineIDS))
  8789. //{
  8790. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8791. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8792. //}
  8793. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8794. //{
  8795. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8796. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8797. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8798. //}
  8799. //else
  8800. //{
  8801. // // modify by chenxy :没有选择时,应全查询出来。
  8802. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8803. //}
  8804. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8805. //{
  8806. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8807. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8808. //}
  8809. //if (!string.IsNullOrEmpty(se.KilnCode))
  8810. //{
  8811. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8812. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8813. //}
  8814. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8815. //{
  8816. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8817. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8818. //}
  8819. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8820. //{
  8821. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8822. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8823. //}
  8824. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8825. //{
  8826. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8827. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8828. //}
  8829. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8830. //{
  8831. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8832. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8833. //}
  8834. //if (!string.IsNullOrEmpty(se.DefectCode))
  8835. //{
  8836. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8837. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8838. //}
  8839. //if (!string.IsNullOrEmpty(se.DefectName))
  8840. //{
  8841. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  8842. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  8843. //}
  8844. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  8845. //{
  8846. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  8847. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  8848. //}
  8849. //if (se.CreateTimeStart.HasValue)
  8850. //{
  8851. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  8852. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  8853. //}
  8854. //if (se.CreateTimeEnd.HasValue)
  8855. //{
  8856. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  8857. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  8858. //}
  8859. //selSql = selSql +
  8860. // "group by " +
  8861. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  8862. // " TP_PM_Defect.DefectProcedureCode, " +
  8863. // " TP_PM_Defect.DefectProcedureName, " +
  8864. // " TP_PM_Defect.ProductionLineID, " +
  8865. // " TP_PM_Defect.ProductionLineCode, " +
  8866. // " TP_PM_Defect.ProductionLineName, " +
  8867. // " TP_PM_Defect.ProcedureID, " +
  8868. // " TP_PM_Defect.ProcedureCode," +
  8869. // " TP_PM_Defect.ProcedureName, " +
  8870. // " TP_PM_Defect.DefectCode, " +
  8871. // " TP_PM_Defect.DefectName, " +
  8872. // " TP_MST_DefectType.DefectTypeName, " +
  8873. // " TP_PM_Defect.Userid, " +
  8874. // " TP_PM_Defect.Usercode, " +
  8875. // " TP_PM_Defect.Username, " +
  8876. // " TP_MST_GoodsType.Goodstypename, " +
  8877. // " TP_PM_Defect.Goodsid, " +
  8878. // " TP_PM_Defect.Goodscode, " +
  8879. // " TP_PM_Defect.Goodsname " +
  8880. // " )) temp ) temp2 " +
  8881. // "where 1=1 " +
  8882. // "and ((Goodsname!='--' )" +
  8883. // "or (Goodsname='--' and defectcode='小计')" +
  8884. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  8885. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  8886. //////----------------------
  8887. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  8888. ////{
  8889. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  8890. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  8891. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  8892. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  8893. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  8894. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  8895. ////}
  8896. //////----------------------
  8897. //return selSql;
  8898. #endregion
  8899. string selSql =
  8900. "SELECT t.ProductionLineID\n" +
  8901. " ,t.ProductionLineCode\n" +
  8902. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  8903. " ,t.ProcedureID\n" +
  8904. " ,t.ProcedureCode\n" +
  8905. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  8906. " ,t.DefectProcedureID\n" +
  8907. " ,t.DefectProcedureCode\n" +
  8908. " ,decode(t.gid,\n" +
  8909. " 7,\n" +
  8910. " '合计【' || t.DefectProcedureName || '】',\n" +
  8911. " 0,\n" +
  8912. " t.DefectProcedureName,\n" +
  8913. " '--') DefectProcedureName\n" +
  8914. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  8915. " ,decode(t.gid,\n" +
  8916. " 3,\n" +
  8917. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  8918. " 0,\n" +
  8919. " t.DefectName,\n" +
  8920. " '--') DefectName\n" +
  8921. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  8922. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  8923. " ,t.Userid\n" +
  8924. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  8925. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  8926. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  8927. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  8928. " ,t.Goodsid\n" +
  8929. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  8930. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  8931. " ,t.InCount\n" +
  8932. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  8933. " pmd.DefectProcedureID,\n" +
  8934. " pmd.DefectCode,\n" +
  8935. " pmd.userid,\n" +
  8936. " pmd.goodsid) gid\n" +
  8937. " ,pmd.ProductionLineID\n" +
  8938. " ,pmd.ProductionLineCode\n" +
  8939. " ,pmd.ProductionLineName\n" +
  8940. " ,pmd.ProcedureID\n" +
  8941. " ,pmd.ProcedureCode\n" +
  8942. " ,pmd.ProcedureName\n" +
  8943. " ,pmd.DefectProcedureID\n" +
  8944. " ,pmd.DefectProcedureCode\n" +
  8945. " ,pmd.DefectProcedureName\n" +
  8946. " ,pmd.DefectCode\n" +
  8947. " ,pmd.DefectName\n" +
  8948. " ,dt.DefectTypeName\n" +
  8949. " ,pmd.Userid\n" +
  8950. " ,pmd.Usercode\n" +
  8951. " ,pmd.Username\n" +
  8952. " ,gt.Goodstypename\n" +
  8953. " ,pmd.Goodsid\n" +
  8954. " ,pmd.Goodscode\n" +
  8955. " ,pmd.Goodsname\n" +
  8956. " ,COUNT(pmd.barcode) InCount\n" +
  8957. " FROM tp_pm_defect pmd\n" +
  8958. " LEFT JOIN TP_MST_Goods g\n" +
  8959. " ON pmd.Goodsid = g.Goodsid\n" +
  8960. " LEFT JOIN TP_MST_GoodsType gt\n" +
  8961. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  8962. " LEFT JOIN TP_MST_Defect mstd\n" +
  8963. " ON pmd.DefectID = mstd.DefectID\n" +
  8964. " LEFT JOIN TP_MST_DefectType dt\n" +
  8965. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  8966. " INNER JOIN tp_pm_productiondata pd\n" +
  8967. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  8968. " -- 交接工序\n" +
  8969. " INNER JOIN tp_pm_productiondata hopd\n" +
  8970. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  8971. " AND hopd.valueflag = '1'\n" +
  8972. " AND hopd.barcode = pd.barcode\n" +
  8973. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  8974. " WHERE pmd.valueflag = '1'\n" +
  8975. " AND pd.ModelType = -1\n" +
  8976. " AND pmd.AccountID = :AccountID\n";
  8977. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8978. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  8979. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8980. {
  8981. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8982. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8983. }
  8984. if (!string.IsNullOrEmpty(se.LineIDS))
  8985. {
  8986. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  8987. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8988. }
  8989. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8990. {
  8991. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8992. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  8993. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8994. }
  8995. else
  8996. {
  8997. // modify by chenxy :没有选择时,应全查询出来。
  8998. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8999. }
  9000. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9001. {
  9002. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9003. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9004. }
  9005. if (!string.IsNullOrEmpty(se.KilnCode))
  9006. {
  9007. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9008. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9009. }
  9010. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9011. {
  9012. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9013. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9014. }
  9015. if (!string.IsNullOrEmpty(se.GoodsCode))
  9016. {
  9017. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9018. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9019. }
  9020. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9021. {
  9022. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9023. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9024. }
  9025. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9026. {
  9027. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9028. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9029. }
  9030. if (!string.IsNullOrEmpty(se.DefectCode))
  9031. {
  9032. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9033. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9034. }
  9035. if (!string.IsNullOrEmpty(se.DefectName))
  9036. {
  9037. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9038. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9039. }
  9040. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9041. {
  9042. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9043. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9044. }
  9045. if (se.CreateTimeStart.HasValue)
  9046. {
  9047. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9048. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9049. }
  9050. if (se.CreateTimeEnd.HasValue)
  9051. {
  9052. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9053. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9054. }
  9055. // 交接时间
  9056. if (se.HandOverTimeStart.HasValue)
  9057. {
  9058. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9059. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9060. }
  9061. if (se.HandOverTimeEnd.HasValue)
  9062. {
  9063. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9064. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9065. }
  9066. selSql = selSql +
  9067. " 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" +
  9068. " ORDER BY pmd.ProductionLineCode\n" +
  9069. " ,pmd.ProcedureCode\n" +
  9070. " ,pmd.DefectProcedureCode\n" +
  9071. " ,pmd.DefectCode\n" +
  9072. " ,pmd.Usercode\n" +
  9073. " ,pmd.Goodscode) t";
  9074. return selSql;
  9075. }
  9076. /// <summary>
  9077. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9078. /// </summary>
  9079. /// <param name="user">登录用户信息</param>
  9080. /// <param name="se">查询条件</param>
  9081. /// <returns>查询结果</returns>
  9082. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9083. {
  9084. IDBConnection conn = null;
  9085. try
  9086. {
  9087. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9088. List<OracleParameter> parameters = new List<OracleParameter>();
  9089. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9090. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9091. ServiceResultEntity sre = new ServiceResultEntity();
  9092. if (data == null || data.Rows.Count == 0)
  9093. {
  9094. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9095. return sre;
  9096. }
  9097. sre.Data = new DataSet();
  9098. sre.Data.Tables.Add(data);
  9099. return sre;
  9100. }
  9101. catch (Exception ex)
  9102. {
  9103. throw ex;
  9104. }
  9105. finally
  9106. {
  9107. if (conn != null &&
  9108. conn.ConnState == ConnectionState.Open)
  9109. {
  9110. conn.Close();
  9111. }
  9112. }
  9113. }
  9114. /// <summary>
  9115. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9116. /// </summary>
  9117. /// <returns>sql</returns>
  9118. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9119. {
  9120. // string selSql = @"select
  9121. // tp_pm_defect.productionlinename,
  9122. // tp_pm_defect.procedurename,
  9123. // tp_pm_defect.DefectProcedureCode,
  9124. // tp_pm_defect.DefectProcedureName,
  9125. // tp_pm_defect.DefectUserCode,
  9126. // tp_pm_defect.defectusername,
  9127. // tp_mst_defectType.DefectTypeName,
  9128. // TP_MST_Defect.Remarks DefectRemarks,
  9129. // tp_pm_defect.defectcode,
  9130. // tp_pm_defect.defectname,
  9131. // tp_pm_defect.UserCode,
  9132. // tp_pm_defect.username,
  9133. // tp_mst_goodstype.Goodstypename,
  9134. // tp_pm_defect.goodscode,
  9135. // tp_pm_defect.barcode,
  9136. // tp_pm_productiondata.groutingdate,
  9137. // tp_pm_productiondata.groutingnum,
  9138. // tp_pm_productiondata.groutingMouldCode,
  9139. // tp_pm_productiondata.KilnCarCode,
  9140. // tp_pm_productiondata.Procedureid,
  9141. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9142. // tp_pm_defect.DefectPositionCode,
  9143. // tp_pm_defect.DefectPositionName,
  9144. // tp_pm_productiondata.GroutingUserCode,
  9145. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9146. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9147. // ,TP_PM_Defect.CreateTime
  9148. // ,(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
  9149. // ,TP_MST_DefectFine.DefectFineCode
  9150. // ,TP_PM_Defect.DefectDeductionNum
  9151. // from tp_pm_defect
  9152. // left join TP_MST_Goods
  9153. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9154. // left join TP_MST_GoodsType
  9155. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9156. // left join TP_MST_Defect
  9157. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9158. // left join TP_MST_DefectType
  9159. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9160. // inner join tp_pm_productiondata
  9161. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9162. // left join TP_MST_DefectFine
  9163. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9164. // left join tp_mst_logo
  9165. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9166. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9167. // 追加交接时间,改判标识。
  9168. string selSql =
  9169. "SELECT pmd.productionlinename\n" +
  9170. " ,pmd.procedurename\n" +
  9171. " ,pmd.DefectProcedureCode\n" +
  9172. " ,pmd.DefectProcedureName\n" +
  9173. " ,pmd.DefectUserCode\n" +
  9174. " ,pmd.defectusername\n" +
  9175. " ,dt.DefectTypeName\n" +
  9176. " ,mstd.Remarks DefectRemarks\n" +
  9177. " ,pmd.defectcode\n" +
  9178. " ,d.alldefectcode\n" +
  9179. " ,pmd.defectname\n" +
  9180. " ,pmd.UserCode\n" +
  9181. " ,pmd.username\n" +
  9182. " ,gt.Goodstypename\n" +
  9183. " ,pmd.goodscode\n" +
  9184. " ,pmd.barcode\n" +
  9185. " ,pd.groutingdate\n" +
  9186. " ,pd.groutingnum\n" +
  9187. " ,pd.groutingMouldCode\n" +
  9188. " ,pd.groutingLineCode\n" +
  9189. " ,pd.KilnCarCode\n" +
  9190. " ,pd.Procedureid\n" +
  9191. " ,gl.goodslevelname Goodsleveltype\n" +
  9192. " ,pmd.DefectPositionCode\n" +
  9193. " ,pmd.DefectPositionName\n" +
  9194. " ,pd.GroutingUserCode\n" +
  9195. " , CASE\n" +
  9196. " WHEN logo.logoid IS NULL THEN\n" +
  9197. " NULL\n" +
  9198. " ELSE\n" +
  9199. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9200. " END AS LogoCodeName\n" +
  9201. " ,pmd.CreateTime\n" +
  9202. " ,mstdf.DefectFineCode\n" +
  9203. " ,pmd.DefectDeductionNum\n" +
  9204. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9205. " ,hopd.createtime handovertime\n" +
  9206. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9207. " FROM tp_pm_ProductionData pduc\n" +
  9208. " WHERE pduc.barcode = pmd.barcode\n" +
  9209. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9210. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9211. " FROM tp_pm_ProductionData pdcu\n" +
  9212. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9213. " WHERE pdcu.barcode = pmd.barcode\n" +
  9214. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9215. " , CASE\n" +
  9216. " WHEN EXISTS (SELECT 1\n" +
  9217. " FROM tp_pm_ProductionData pdud\n" +
  9218. " WHERE pdud.barcode = pmd.barcode\n" +
  9219. " AND pdud.modeltype = -1\n" +
  9220. " AND pdud.procedureid = pd.procedureid\n" +
  9221. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9222. " AND pdud.valueflag = '0') THEN\n" +
  9223. " 1\n" +
  9224. " ELSE\n" +
  9225. " 0\n" +
  9226. " END AS undoflag\n" +
  9227. " , CASE\n" +
  9228. " WHEN EXISTS (SELECT 1\n" +
  9229. " FROM tp_pm_semicheck sc\n" +
  9230. " WHERE sc.barcode = pmd.barcode\n" +
  9231. " AND sc.SEMICHECKTYPE = 1\n" +
  9232. " AND sc.valueflag = '1') THEN\n" +
  9233. " 1\n" +
  9234. " ELSE\n" +
  9235. " 0\n" +
  9236. " END reworkflag" +
  9237. " ,gdd.glazingroom" +
  9238. " FROM tp_pm_defect pmd\n" +
  9239. " LEFT JOIN TP_MST_Goods g\n" +
  9240. " ON pmd.Goodsid = g.Goodsid\n" +
  9241. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9242. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9243. " LEFT JOIN TP_MST_Defect mstd\n" +
  9244. " ON pmd.DefectID = mstd.DefectID\n" +
  9245. " LEFT JOIN TP_MST_DefectType dt\n" +
  9246. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9247. " INNER JOIN tp_pm_productiondata pd\n" +
  9248. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9249. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9250. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9251. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9252. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9253. "-- 交接工序\n" +
  9254. " INNER JOIN tp_pm_productiondata hopd\n" +
  9255. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9256. " AND hopd.barcode = pd.barcode\n" +
  9257. " AND hopd.valueflag = '1'\n" +
  9258. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9259. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9260. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9261. " LEFT JOIN tp_mst_logo logo\n" +
  9262. " ON pd.logoid = logo.logoid\n" +
  9263. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9264. " FROM tp_pm_defect def\n" +
  9265. " WHERE def.valueflag = '1'\n" +
  9266. //def.createtime
  9267. " group by def.barcode ) d\n" +
  9268. " ON d.barcode = pmd.barcode\n" +
  9269. " WHERE pmd.valueflag = '1' \n" +
  9270. " AND pd.ModelType = -1\n" +
  9271. " AND pmd.AccountID = :AccountID\n";
  9272. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9273. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9274. //selSql = selSql +
  9275. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9276. // " and TP_PM_Defect.AccountID=:AccountID ";
  9277. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9278. {
  9279. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9280. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9281. }
  9282. if (!string.IsNullOrEmpty(se.LineIDS))
  9283. {
  9284. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9285. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9286. }
  9287. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9288. {
  9289. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9290. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9291. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9292. }
  9293. else
  9294. {
  9295. // modify by chenxy :没有选择时,应全查询出来。
  9296. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9297. }
  9298. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9299. {
  9300. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9301. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9302. }
  9303. if (!string.IsNullOrEmpty(se.KilnCode))
  9304. {
  9305. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9306. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9307. }
  9308. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9309. {
  9310. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9311. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9312. }
  9313. if (!string.IsNullOrEmpty(se.GoodsCode))
  9314. {
  9315. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9316. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9317. }
  9318. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9319. {
  9320. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9321. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9322. }
  9323. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9324. {
  9325. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9326. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9327. }
  9328. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9329. {
  9330. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9331. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9332. }
  9333. if (!string.IsNullOrEmpty(se.DefectCode))
  9334. {
  9335. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9336. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9337. }
  9338. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9339. {
  9340. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9341. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9342. }
  9343. if (!string.IsNullOrEmpty(se.DefectName))
  9344. {
  9345. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9346. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9347. }
  9348. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9349. {
  9350. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9351. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9352. }
  9353. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9354. {
  9355. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9356. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9357. }
  9358. if (se.CreateTimeStart.HasValue)
  9359. {
  9360. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9361. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9362. }
  9363. if (se.CreateTimeEnd.HasValue)
  9364. {
  9365. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9366. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9367. }
  9368. // 交接时间
  9369. if (se.HandOverTimeStart.HasValue)
  9370. {
  9371. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9372. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9373. }
  9374. if (se.HandOverTimeEnd.HasValue)
  9375. {
  9376. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9377. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9378. }
  9379. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9380. //{
  9381. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9382. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9383. //}
  9384. ////----------------------
  9385. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9386. //{
  9387. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9388. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9389. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9390. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9391. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9392. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9393. //}
  9394. ////----------------------
  9395. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9396. return selSql;
  9397. }
  9398. /// <summary>
  9399. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9400. /// </summary>
  9401. /// <param name="user">登录用户信息</param>
  9402. /// <param name="se">查询条件</param>
  9403. /// <returns>查询结果</returns>
  9404. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9405. {
  9406. IDBConnection conn = null;
  9407. try
  9408. {
  9409. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9410. List<OracleParameter> parameters = new List<OracleParameter>();
  9411. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9412. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9413. ServiceResultEntity sre = new ServiceResultEntity();
  9414. if (data == null || data.Rows.Count == 0)
  9415. {
  9416. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9417. return sre;
  9418. }
  9419. sre.Data = new DataSet();
  9420. sre.Data.Tables.Add(data);
  9421. return sre;
  9422. }
  9423. catch (Exception ex)
  9424. {
  9425. throw ex;
  9426. }
  9427. finally
  9428. {
  9429. if (conn != null &&
  9430. conn.ConnState == ConnectionState.Open)
  9431. {
  9432. conn.Close();
  9433. }
  9434. }
  9435. }
  9436. /// <summary>
  9437. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9438. /// </summary>
  9439. /// <returns>sql</returns>
  9440. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9441. {
  9442. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9443. // 追加交接时间,改判标识。
  9444. string selSql =
  9445. "SELECT pmd.productionlinename\n" +
  9446. " ,pmd.procedurename\n" +
  9447. " ,pmd.DefectProcedureCode\n" +
  9448. " ,pmd.DefectProcedureName\n" +
  9449. " ,pmd.DefectUserCode\n" +
  9450. " ,pmd.defectusername\n" +
  9451. " ,jobs.jobsname defectjobsname\n" +
  9452. " ,dt.DefectTypeName\n" +
  9453. " ,mstd.Remarks DefectRemarks\n" +
  9454. " ,pd.Remarks barcodeRemarks\n" +
  9455. " ,pmd.defectcode\n" +
  9456. " ,d.alldefectcode\n" +
  9457. " ,pmd.defectname\n" +
  9458. " ,pmd.UserCode\n" +
  9459. " ,pmd.username\n" +
  9460. " ,gt.Goodstypename\n" +
  9461. " ,pmd.goodscode\n" +
  9462. " ,pmd.barcode\n" +
  9463. " ,pd.groutingdate\n" +
  9464. " ,pd.groutingnum\n" +
  9465. " ,pd.groutingMouldCode\n" +
  9466. " ,pd.GroutingLineCode\n" +
  9467. " ,pd.KilnCarCode\n" +
  9468. " ,pd.Procedureid\n" +
  9469. " ,gl.goodslevelname Goodsleveltype\n" +
  9470. " ,pmd.DefectPositionCode\n" +
  9471. " ,pmd.DefectPositionName\n" +
  9472. " ,pd.GroutingUserCode\n" +
  9473. " , CASE\n" +
  9474. " WHEN logo.logoid IS NULL THEN\n" +
  9475. " NULL\n" +
  9476. " ELSE\n" +
  9477. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9478. " END AS LogoCodeName\n" +
  9479. //" ,pmd.CreateTime\n" +
  9480. " ,pd.CheckTime pdchecktime\n" +
  9481. " ,pmd.CheckTime\n" +
  9482. " ,mstdf.DefectFineCode\n" +
  9483. " ,pmd.DefectDeductionNum\n" +
  9484. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9485. " ,hopd.createtime handovertime\n" +
  9486. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9487. " FROM tp_pm_ProductionData pduc\n" +
  9488. " WHERE pduc.barcode = pmd.barcode\n" +
  9489. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9490. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9491. " FROM tp_pm_ProductionData pdcu\n" +
  9492. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9493. " WHERE pdcu.barcode = pmd.barcode\n" +
  9494. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9495. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9496. " FROM TP_PM_DefectResponsible dr\n" +
  9497. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9498. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9499. " ) AS DefectStaffNames\n" +
  9500. " , CASE\n" +
  9501. " WHEN pd.isrefire <> '0' THEN\n" +
  9502. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9503. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9504. " from tp_pm_productiondata p\n" +
  9505. " inner join tp_pm_defect d\n" +
  9506. " on d.productiondataid = p.productiondataid\n" +
  9507. " where p.valueflag = '1'\n" +
  9508. " and d.valueflag = '1'\n" +
  9509. " and p.barcode = pd.barcode\n" +
  9510. " and p.modeltype = -1\n" +
  9511. " and p.isrefire = '0')\n" +
  9512. " ELSE\n" +
  9513. " null\n" +
  9514. " END AS bsqx\n" +
  9515. " , CASE\n" +
  9516. " WHEN EXISTS (SELECT 1\n" +
  9517. " FROM tp_pm_ProductionData pdud\n" +
  9518. " WHERE pdud.barcode = pmd.barcode\n" +
  9519. " AND pdud.modeltype = -1\n" +
  9520. " AND pdud.procedureid = pd.procedureid\n" +
  9521. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9522. " AND pdud.valueflag = '0') THEN\n" +
  9523. " 1\n" +
  9524. " ELSE\n" +
  9525. " 0\n" +
  9526. " END AS undoflag\n" +
  9527. " FROM tp_pm_defect pmd\n" +
  9528. " LEFT JOIN TP_PC_Procedure p\n" +
  9529. " ON p.procedureid = pmd.procedureid\n" +
  9530. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9531. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9532. " LEFT JOIN TP_MST_Goods g\n" +
  9533. " ON pmd.Goodsid = g.Goodsid\n" +
  9534. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9535. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9536. " LEFT JOIN TP_MST_Defect mstd\n" +
  9537. " ON pmd.DefectID = mstd.DefectID\n" +
  9538. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9539. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9540. " LEFT JOIN TP_MST_DefectType dt\n" +
  9541. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9542. " INNER JOIN tp_pm_productiondata pd\n" +
  9543. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9544. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9545. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9546. //"-- 交接工序\n" +
  9547. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9548. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9549. //" AND hopd.valueflag = '1'\n" +
  9550. //" AND hopd.barcode = pd.barcode\n" +
  9551. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9552. " INNER JOIN tp_pm_productiondata hopd\n" +
  9553. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9554. " AND hopd.barcode = pd.barcode\n" +
  9555. " AND hopd.valueflag = '1'\n" +
  9556. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9557. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9558. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9559. " LEFT JOIN tp_mst_logo logo\n" +
  9560. " ON pd.logoid = logo.logoid\n" +
  9561. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9562. " FROM tp_pm_defect def\n" +
  9563. " WHERE def.valueflag = '1'\n" +
  9564. //def.createtime
  9565. " group by def.barcode ) d\n" +
  9566. " ON d.barcode = pmd.barcode\n" +
  9567. " WHERE pmd.valueflag = '1' \n" +
  9568. " AND pd.ModelType = -1\n" +
  9569. " AND pmd.AccountID = :AccountID\n";
  9570. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9571. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9572. //selSql = selSql +
  9573. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9574. // " and TP_PM_Defect.AccountID=:AccountID ";
  9575. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9576. {
  9577. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9578. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9579. }
  9580. if (!string.IsNullOrEmpty(se.LineIDS))
  9581. {
  9582. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9583. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9584. }
  9585. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9586. {
  9587. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9588. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9589. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9590. }
  9591. else
  9592. {
  9593. // modify by chenxy :没有选择时,应全查询出来。
  9594. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9595. }
  9596. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9597. {
  9598. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9599. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9600. }
  9601. if (!string.IsNullOrEmpty(se.KilnCode))
  9602. {
  9603. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9604. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9605. }
  9606. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9607. {
  9608. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9609. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9610. }
  9611. if (!string.IsNullOrEmpty(se.GoodsCode))
  9612. {
  9613. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9614. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9615. }
  9616. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9617. {
  9618. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9619. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9620. }
  9621. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9622. {
  9623. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9624. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9625. }
  9626. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9627. {
  9628. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9629. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9630. }
  9631. if (!string.IsNullOrEmpty(se.DefectCode))
  9632. {
  9633. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9634. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9635. }
  9636. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9637. {
  9638. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9639. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9640. }
  9641. if (!string.IsNullOrEmpty(se.DefectName))
  9642. {
  9643. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9644. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9645. }
  9646. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9647. {
  9648. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9649. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9650. }
  9651. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9652. {
  9653. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9654. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9655. }
  9656. //if (se.CreateTimeStart.HasValue)
  9657. //{
  9658. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9659. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9660. //}
  9661. //if (se.CreateTimeEnd.HasValue)
  9662. //{
  9663. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9664. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9665. //}
  9666. // 成检登记时间
  9667. if (se.CreateTimeStart.HasValue)
  9668. {
  9669. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9670. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9671. }
  9672. if (se.CreateTimeEnd.HasValue)
  9673. {
  9674. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9675. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9676. }
  9677. // 缺陷登记时间
  9678. if (se.CheckTimeStart.HasValue)
  9679. {
  9680. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9681. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9682. }
  9683. if (se.CheckTimeEnd.HasValue)
  9684. {
  9685. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9686. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9687. }
  9688. // 交接时间
  9689. if (se.HandOverTimeStart.HasValue)
  9690. {
  9691. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9692. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9693. }
  9694. if (se.HandOverTimeEnd.HasValue)
  9695. {
  9696. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9697. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9698. }
  9699. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9700. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9701. return selSql;
  9702. }
  9703. /// <summary>
  9704. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9705. /// </summary>
  9706. /// <param name="user">登录用户信息</param>
  9707. /// <param name="se">查询条件</param>
  9708. /// <returns>查询结果</returns>
  9709. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9710. {
  9711. IDBConnection conn = null;
  9712. try
  9713. {
  9714. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9715. List<OracleParameter> parameters = new List<OracleParameter>();
  9716. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9717. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9718. ServiceResultEntity sre = new ServiceResultEntity();
  9719. if (data == null || data.Rows.Count == 0)
  9720. {
  9721. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9722. return sre;
  9723. }
  9724. sre.Data = new DataSet();
  9725. sre.Data.Tables.Add(data);
  9726. return sre;
  9727. }
  9728. catch (Exception ex)
  9729. {
  9730. throw ex;
  9731. }
  9732. finally
  9733. {
  9734. if (conn != null &&
  9735. conn.ConnState == ConnectionState.Open)
  9736. {
  9737. conn.Close();
  9738. }
  9739. }
  9740. }
  9741. /// <summary>
  9742. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9743. /// </summary>
  9744. /// <returns>sql</returns>
  9745. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9746. {
  9747. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9748. // 追加交接时间,改判标识。
  9749. string selSql =
  9750. //"SELECT pmd.productionlinename\n" +
  9751. //" ,pmd.procedurename\n" +
  9752. //" ,pmd.DefectProcedureCode\n" +
  9753. //" ,pmd.DefectProcedureName\n" +
  9754. //" ,pmd.DefectUserCode\n" +
  9755. //" ,pmd.defectusername\n" +
  9756. //" ,jobs.jobsname defectjobsname\n" +
  9757. //" ,dt.DefectTypeName\n" +
  9758. //" ,mstd.Remarks DefectRemarks\n" +
  9759. //" ,pd.Remarks barcodeRemarks\n" +
  9760. //" ,pmd.defectcode\n" +
  9761. //" ,d.alldefectcode\n" +
  9762. //" ,pmd.defectname\n" +
  9763. //" ,pmd.UserCode\n" +
  9764. //" ,pmd.username\n" +
  9765. //" ,gt.Goodstypename\n" +
  9766. //" ,pmd.goodscode\n" +
  9767. //" ,pmd.barcode\n" +
  9768. //" ,pd.groutingdate\n" +
  9769. //" ,pd.groutingnum\n" +
  9770. //" ,pd.groutingMouldCode\n" +
  9771. //" ,pd.GroutingLineCode\n" +
  9772. //" ,pd.KilnCarCode\n" +
  9773. //" ,pd.Procedureid\n" +
  9774. //" ,gl.goodslevelname Goodsleveltype\n" +
  9775. //" ,pmd.DefectPositionCode\n" +
  9776. //" ,pmd.DefectPositionName\n" +
  9777. //" ,pd.GroutingUserCode\n" +
  9778. //" , CASE\n" +
  9779. //" WHEN logo.logoid IS NULL THEN\n" +
  9780. //" NULL\n" +
  9781. //" ELSE\n" +
  9782. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9783. //" END AS LogoCodeName\n" +
  9784. ////" ,pmd.CreateTime\n" +
  9785. //" ,pd.CheckTime pdchecktime\n" +
  9786. //" ,pmd.CheckTime\n" +
  9787. //" ,mstdf.DefectFineCode\n" +
  9788. //" ,pmd.DefectDeductionNum\n" +
  9789. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9790. //" ,hopd.createtime handovertime\n" +
  9791. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9792. //" FROM tp_pm_ProductionData pduc\n" +
  9793. //" WHERE pduc.barcode = pmd.barcode\n" +
  9794. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9795. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9796. //" FROM tp_pm_ProductionData pdcu\n" +
  9797. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9798. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9799. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9800. //" , CASE\n" +
  9801. //" WHEN EXISTS (SELECT 1\n" +
  9802. //" FROM tp_pm_ProductionData pdud\n" +
  9803. //" WHERE pdud.barcode = pmd.barcode\n" +
  9804. //" AND pdud.modeltype = -1\n" +
  9805. //" AND pdud.procedureid = pd.procedureid\n" +
  9806. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9807. //" AND pdud.valueflag = '0') THEN\n" +
  9808. //" 1\n" +
  9809. //" ELSE\n" +
  9810. //" 0\n" +
  9811. //" END AS undoflag\n" +
  9812. "SELECT pmd.goodscode\n" +
  9813. " ,pmd.barcode\n" +
  9814. " ,pmd.defectcode\n" +
  9815. " ,pmd.defectname\n" +
  9816. " ,pmd.DefectPositionCode\n" +
  9817. " ,pmd.DefectPositionName\n" +
  9818. " ,gl.goodslevelname Goodsleveltype\n" +
  9819. " , CASE\n" +
  9820. " WHEN logo.logoid IS NULL THEN\n" +
  9821. " NULL\n" +
  9822. " ELSE\n" +
  9823. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9824. " END AS LogoCodeName\n" +
  9825. //" ,pmd.CreateTime\n" +
  9826. " ,pd.CheckTime pdchecktime\n" +
  9827. " ,pmd.CheckTime\n" +
  9828. " ,proddata.CheckTime protime\n" +
  9829. " ,proddata.UserCode prousercode\n" +
  9830. " ,proddata.PROCEDURENAME proname\n" +
  9831. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9832. " FROM tp_pm_defect pmd\n" +
  9833. " INNER JOIN tp_pm_productiondata proddata\n" +
  9834. " ON proddata.barcode = pmd.barcode\n " +
  9835. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  9836. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  9837. " AND proddata.valueflag = '1'\n" +
  9838. " INNER JOIN tp_pm_productiondata pd\n" +
  9839. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9840. " LEFT JOIN TP_PC_Procedure p\n" +
  9841. " ON p.procedureid = pmd.procedureid\n" +
  9842. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9843. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9844. " LEFT JOIN TP_MST_Goods g\n" +
  9845. " ON pmd.Goodsid = g.Goodsid\n" +
  9846. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9847. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9848. " LEFT JOIN TP_MST_Defect mstd\n" +
  9849. " ON pmd.DefectID = mstd.DefectID\n" +
  9850. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9851. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9852. " LEFT JOIN TP_MST_DefectType dt\n" +
  9853. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9854. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9855. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9856. "-- 交接工序\n" +
  9857. " INNER JOIN tp_pm_productiondata hopd\n" +
  9858. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9859. " AND hopd.barcode = pd.barcode\n" +
  9860. " AND hopd.valueflag = '1'\n" +
  9861. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9862. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9863. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9864. " LEFT JOIN tp_mst_logo logo\n" +
  9865. " ON pd.logoid = logo.logoid\n" +
  9866. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9867. //" FROM tp_pm_defect def\n" +
  9868. //" WHERE def.valueflag = '1'\n" +
  9869. ////def.createtime
  9870. //" group by def.barcode ) d\n" +
  9871. //" ON d.barcode = pmd.barcode\n" +
  9872. " WHERE pmd.valueflag = '1' \n" +
  9873. " AND pd.ModelType = -1\n" +
  9874. " AND pmd.AccountID = :AccountID\n";
  9875. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9876. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9877. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9878. //selSql = selSql +
  9879. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9880. // " and TP_PM_Defect.AccountID=:AccountID ";
  9881. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9882. {
  9883. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9884. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9885. }
  9886. if (!string.IsNullOrEmpty(se.LineIDS))
  9887. {
  9888. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9889. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9890. }
  9891. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9892. {
  9893. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9894. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9895. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9896. }
  9897. else
  9898. {
  9899. // modify by chenxy :没有选择时,应全查询出来。
  9900. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9901. }
  9902. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9903. {
  9904. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9905. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9906. }
  9907. if (!string.IsNullOrEmpty(se.KilnCode))
  9908. {
  9909. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9910. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9911. }
  9912. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9913. {
  9914. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9915. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9916. }
  9917. if (!string.IsNullOrEmpty(se.GoodsCode))
  9918. {
  9919. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9920. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9921. }
  9922. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9923. {
  9924. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9925. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9926. }
  9927. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9928. {
  9929. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9930. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9931. }
  9932. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9933. {
  9934. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9935. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9936. }
  9937. if (!string.IsNullOrEmpty(se.DefectCode))
  9938. {
  9939. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9940. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9941. }
  9942. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9943. {
  9944. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9945. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9946. }
  9947. if (!string.IsNullOrEmpty(se.DefectName))
  9948. {
  9949. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9950. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9951. }
  9952. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9953. {
  9954. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9955. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9956. }
  9957. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9958. {
  9959. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9960. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9961. }
  9962. //if (se.CreateTimeStart.HasValue)
  9963. //{
  9964. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9965. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9966. //}
  9967. //if (se.CreateTimeEnd.HasValue)
  9968. //{
  9969. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9970. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9971. //}
  9972. // 成检登记时间
  9973. if (se.CreateTimeStart.HasValue)
  9974. {
  9975. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9976. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9977. }
  9978. if (se.CreateTimeEnd.HasValue)
  9979. {
  9980. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9981. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9982. }
  9983. // 缺陷登记时间
  9984. if (se.CheckTimeStart.HasValue)
  9985. {
  9986. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9987. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9988. }
  9989. if (se.CheckTimeEnd.HasValue)
  9990. {
  9991. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9992. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9993. }
  9994. // 交接时间
  9995. if (se.HandOverTimeStart.HasValue)
  9996. {
  9997. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9998. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9999. }
  10000. if (se.HandOverTimeEnd.HasValue)
  10001. {
  10002. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10003. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10004. }
  10005. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10006. selSql = selSql + " order by proddata.CheckTime ";
  10007. return selSql;
  10008. }
  10009. /// <summary>
  10010. /// 窑车状态主表查询
  10011. /// </summary>
  10012. /// <param name="kilnCode">窑炉编码</param>
  10013. /// <param name="kilnCarCode">窑车编码</param>
  10014. /// <param name="sUserInfo">用户基本信息</param>
  10015. /// <returns></returns>
  10016. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10017. {
  10018. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10019. try
  10020. {
  10021. con.Open();
  10022. OracleParameter[] paras = new OracleParameter[]{
  10023. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10024. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10025. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10026. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10027. };
  10028. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10029. ServiceResultEntity sre = new ServiceResultEntity();
  10030. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10031. {
  10032. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10033. return sre;
  10034. }
  10035. sre.Data = new DataSet();
  10036. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10037. return sre;
  10038. }
  10039. catch (Exception ex)
  10040. {
  10041. throw ex;
  10042. }
  10043. finally
  10044. {
  10045. if (con != null &&
  10046. con.ConnState == ConnectionState.Open)
  10047. {
  10048. con.Close();
  10049. }
  10050. }
  10051. }
  10052. /// <summary>
  10053. /// 窑车状态明细表查询
  10054. /// </summary>
  10055. /// <param name="kilnCarCode">窑车编码</param>
  10056. /// <param name="sUserInfo">用户基本信息</param>
  10057. /// <returns></returns>
  10058. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10059. {
  10060. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10061. try
  10062. {
  10063. con.Open();
  10064. OracleParameter[] paras = new OracleParameter[]{
  10065. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10066. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10067. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10068. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10069. };
  10070. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10071. ServiceResultEntity sre = new ServiceResultEntity();
  10072. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10073. {
  10074. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10075. return sre;
  10076. }
  10077. sre.Data = new DataSet();
  10078. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10079. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10080. return sre;
  10081. }
  10082. catch (Exception ex)
  10083. {
  10084. throw ex;
  10085. }
  10086. finally
  10087. {
  10088. if (con != null &&
  10089. con.ConnState == ConnectionState.Open)
  10090. {
  10091. con.Close();
  10092. }
  10093. }
  10094. }
  10095. /// <summary>
  10096. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10097. /// </summary>
  10098. /// <param name="user">登录用户信息</param>
  10099. /// <param name="se">查询条件</param>
  10100. /// <returns>查询结果</returns>
  10101. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10102. {
  10103. IDBConnection conn = null;
  10104. try
  10105. {
  10106. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10107. List<OracleParameter> parameters = new List<OracleParameter>();
  10108. parameters.Clear();
  10109. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10110. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10111. ServiceResultEntity sre = new ServiceResultEntity();
  10112. if (data == null || data.Rows.Count == 0)
  10113. {
  10114. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10115. return sre;
  10116. }
  10117. sre.Data = new DataSet();
  10118. sre.Data.Tables.Add(data);
  10119. return sre;
  10120. }
  10121. catch (Exception ex)
  10122. {
  10123. throw ex;
  10124. }
  10125. finally
  10126. {
  10127. if (conn != null &&
  10128. conn.ConnState == ConnectionState.Open)
  10129. {
  10130. conn.Close();
  10131. }
  10132. }
  10133. }
  10134. /// <summary>
  10135. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10136. /// </summary>
  10137. /// <returns>sql</returns>
  10138. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10139. {
  10140. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10141. #region
  10142. #endregion
  10143. string sql = @"
  10144. select gd.groutinglinecode,
  10145. gd.groutingmouldcode,
  10146. gd.mouldcode,
  10147. gd.usercode,
  10148. gs.goodscode,
  10149. gs.goodsname,
  10150. gs.goodsspecification,
  10151. gms.gmouldstatusname, -- 模具状态
  10152. --gs.goodsmodel,
  10153. gd.groutingcount, -- 注浆次数
  10154. --gd.groutingnum,
  10155. gd.scrapnum, -- 开模损坯数
  10156. gd.deliverpnum, -- 交坯数
  10157. gd.mingroutingdate, -- 开始注浆时间
  10158. gd.maxgroutingdate, -- 最后注浆时间
  10159. gld.beginuseddate, -- 开始使用时间
  10160. gld.enduseddate, -- 结束使用时间
  10161. zl.OutKilnCount, -- 质量登记数
  10162. zl.GoodCount, -- 正品数
  10163. zl.SubstandardCount, -- 副品数
  10164. zl.ReFireCount, -- 重烧数
  10165. zl.BadCount -- 次品数
  10166. from (select gdd.groutinglinecode,
  10167. gdd.groutingmouldcode,
  10168. gdd.mouldcode,
  10169. gdd.goodsid,
  10170. gdd.groutinglinedetailid,
  10171. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10172. max(gdd.groutingcount) groutingcount,
  10173. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10174. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10175. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10176. min(gdd.groutingdate) mingroutingdate,
  10177. max(gdd.groutingdate) maxgroutingdate
  10178. from tp_pm_groutingdailydetail gdd
  10179. where gdd.groutingflag = '1'
  10180. and gdd.AccountID = :AccountID
  10181. ";
  10182. // 成型线编码
  10183. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10184. {
  10185. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10186. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10187. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10188. }
  10189. // 模具编码
  10190. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10191. {
  10192. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10193. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10194. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10195. }
  10196. sql = sql + @"
  10197. group by gdd.groutinglinecode,
  10198. gdd.groutingmouldcode,
  10199. gdd.mouldcode,
  10200. gdd.goodsid,
  10201. gdd.groutinglinedetailid) gd
  10202. left join (select pdbc.mouldcode,
  10203. sum(1) OutKilnCount,
  10204. sum(case
  10205. when defect.defectprocedureid is not null and
  10206. glt.goodsleveltypeid in (5, 6, 7) then
  10207. 0
  10208. else
  10209. 1
  10210. end) GoodCount,
  10211. sum(case
  10212. when defect.defectprocedureid is not null and
  10213. glt.goodsleveltypeid = 7 then
  10214. 1
  10215. else
  10216. 0
  10217. end) SubstandardCount,
  10218. sum(case
  10219. when defect.defectprocedureid is not null and
  10220. glt.goodsleveltypeid = 6 then
  10221. 1
  10222. else
  10223. 0
  10224. end) ReFireCount,
  10225. sum(case
  10226. when defect.defectprocedureid is not null and
  10227. glt.goodsleveltypeid = 5 then
  10228. 1
  10229. else
  10230. 0
  10231. end) BadCount
  10232. from (select distinct pd.barcode,
  10233. pd.mouldcode,
  10234. pd.kilncarbatchno
  10235. from tp_pm_productiondata pd
  10236. where pd.valueflag = '1'";
  10237. // 开始注浆--开始
  10238. if (se.beginCreateTime.HasValue)
  10239. {
  10240. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10241. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10242. }
  10243. //--and pd.createtime > 查询条件。开始注浆日期开始
  10244. // --and pd.procedureid = :in_rptSprocedureId
  10245. sql = sql + @"
  10246. and pd.procedureid = 11
  10247. and pd.AccountID = 1) pdbc
  10248. left join (select kcbc.barcode,
  10249. kcbc.kilncarbatchno,
  10250. kcbc.goodsleveltypeid,
  10251. kcbc.productiondataid
  10252. from (select pd.barcode,
  10253. pd.kilncarbatchno,
  10254. pd.goodsleveltypeid,
  10255. pd.productiondataid,
  10256. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10257. from tp_pm_productiondata pd
  10258. where pd.valueflag = '1'
  10259. --and pd.AccountID = :AccountID
  10260. and pd.AccountID = :AccountID";
  10261. //--and pd.createtime > 查询条件。开始注浆日期开始
  10262. // 开始注浆--开始
  10263. if (se.beginCreateTime.HasValue)
  10264. {
  10265. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10266. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10267. }
  10268. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10269. and pd.modeltype = -1) kcbc
  10270. where kcbc.dataid = 1) glt
  10271. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10272. and pdbc.barcode = glt.barcode
  10273. left join (select distinct productiondataid, defectprocedureid
  10274. from tp_pm_defect def
  10275. where def.valueflag = '1'";
  10276. //--and pd.createtime > 查询条件。开始注浆日期开始
  10277. // 开始注浆--开始
  10278. if (se.beginCreateTime.HasValue)
  10279. {
  10280. sql = sql + " and def.createtime>=:groutingDateStart ";
  10281. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10282. }
  10283. sql = sql + @"
  10284. and def.AccountID = :AccountID) defect
  10285. on defect.productiondataid = glt.productiondataid
  10286. group by pdbc.mouldcode) zl
  10287. on zl.mouldcode = gd.mouldcode
  10288. left join tp_mst_goods gs
  10289. on gs.goodsid = gd.goodsid
  10290. left join tp_pc_groutinglinedetail gld
  10291. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10292. and gld.mouldcode = gd.mouldcode
  10293. left join tp_sys_gmouldstatus gms
  10294. on gms.gmouldstatusid = gld.gmouldstatus
  10295. where 1=1
  10296. ";
  10297. // 产品编码
  10298. if (!string.IsNullOrEmpty(se.goodscode))
  10299. {
  10300. //sql = sql + " and gs.goodscode=:goodscode";
  10301. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10302. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10303. }
  10304. // 成型工号
  10305. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10306. {
  10307. //sql = sql + " and gd.usercode=:usercode";
  10308. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10309. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10310. }
  10311. // 开始注浆--开始
  10312. if (se.beginCreateTime.HasValue)
  10313. {
  10314. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10315. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10316. }
  10317. // 开始注浆--结束
  10318. if (se.endCreateTime.HasValue)
  10319. {
  10320. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10321. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10322. }
  10323. // 结束注浆--开始
  10324. if (se.beginCreateTime2.HasValue)
  10325. {
  10326. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10327. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10328. }
  10329. // 结束注浆--结束
  10330. if (se.endCreateTime2.HasValue)
  10331. {
  10332. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10333. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10334. }
  10335. // 模具状态
  10336. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10337. {
  10338. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10339. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10340. }
  10341. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10342. return sql;
  10343. }
  10344. #region 工资产量统计
  10345. /// <summary>
  10346. /// 取得RPT080102画面(成型工产量)的查询数据
  10347. /// </summary>
  10348. /// <param name="user">登录用户信息</param>
  10349. /// <param name="se">查询条件</param>
  10350. /// <returns>查询结果</returns>
  10351. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10352. {
  10353. IDBTransaction conn = null;
  10354. try
  10355. {
  10356. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10357. conn.Connect();
  10358. OracleParameter[] paras = new OracleParameter[]{
  10359. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10360. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10361. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10362. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10363. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10364. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10365. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10366. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10367. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10368. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10369. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10370. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10371. };
  10372. conn.IsCommandTimeout = false;
  10373. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10374. ServiceResultEntity sre = new ServiceResultEntity();
  10375. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10376. {
  10377. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10378. return sre;
  10379. }
  10380. sre.Data = new DataSet();
  10381. sre.Data = data;
  10382. conn.Commit();
  10383. return sre;
  10384. }
  10385. catch (Exception ex)
  10386. {
  10387. throw ex;
  10388. }
  10389. finally
  10390. {
  10391. if (conn != null &&
  10392. conn.ConnState == ConnectionState.Open)
  10393. {
  10394. conn.Disconnect();
  10395. }
  10396. }
  10397. }
  10398. /// <summary>
  10399. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10400. /// </summary>
  10401. /// <param name="user">登录用户信息</param>
  10402. /// <param name="se">查询条件</param>
  10403. /// <returns>查询结果</returns>
  10404. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10405. {
  10406. IDBTransaction conn = null;
  10407. try
  10408. {
  10409. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10410. conn.Connect();
  10411. OracleParameter[] paras = new OracleParameter[]{
  10412. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10413. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10414. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10415. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10416. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10417. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10418. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10419. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10420. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10421. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10422. };
  10423. conn.IsCommandTimeout = false;
  10424. //DataSet data = null;
  10425. //if (se.ProcedureIDS.Contains(","))
  10426. //{
  10427. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10428. //}
  10429. //else
  10430. //{
  10431. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10432. //}
  10433. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10434. ServiceResultEntity sre = new ServiceResultEntity();
  10435. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10436. {
  10437. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10438. return sre;
  10439. }
  10440. sre.Data = new DataSet();
  10441. sre.Data = data;
  10442. conn.Commit();
  10443. return sre;
  10444. }
  10445. catch (Exception ex)
  10446. {
  10447. throw ex;
  10448. }
  10449. finally
  10450. {
  10451. if (conn != null &&
  10452. conn.ConnState == ConnectionState.Open)
  10453. {
  10454. conn.Disconnect();
  10455. }
  10456. }
  10457. }
  10458. /// <summary>
  10459. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10460. /// </summary>
  10461. /// <param name="user">登录用户信息</param>
  10462. /// <param name="se">查询条件</param>
  10463. /// <returns>查询结果</returns>
  10464. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10465. {
  10466. IDBTransaction conn = null;
  10467. try
  10468. {
  10469. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10470. conn.Connect();
  10471. OracleParameter[] paras = new OracleParameter[]{
  10472. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10473. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10474. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10475. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10476. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10477. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10478. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10479. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10480. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10481. };
  10482. conn.IsCommandTimeout = false;
  10483. DataSet data = null;
  10484. if (se.ProcedureIDS.Contains(","))
  10485. {
  10486. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10487. }
  10488. else
  10489. {
  10490. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10491. }
  10492. ServiceResultEntity sre = new ServiceResultEntity();
  10493. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10494. {
  10495. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10496. return sre;
  10497. }
  10498. sre.Data = data;
  10499. //string sqlString =
  10500. //"SELECT kk.procedurename\n" +
  10501. //" ,kk.usercode\n" +
  10502. //" ,kk.kilncode\n" +
  10503. //" ,kk.kdate\n" +
  10504. //" ,COUNT(*) kcount\n" +
  10505. //" FROM (SELECT k.usercode\n" +
  10506. //" ,kiln.kilncode\n" +
  10507. //" ,p.procedurename\n" +
  10508. //" ,trunc(k.createtime) kdate\n" +
  10509. //" FROM tp_pm_kilncardata k\n" +
  10510. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10511. //" ON kiln.kilnid = k.kilnid\n" +
  10512. //" LEFT JOIN tp_pc_procedure p\n" +
  10513. //" ON p.procedureid = k.procedureid\n" +
  10514. //" WHERE k.valueflag = '1'\n" +
  10515. //" AND k.AccountID = :in_AccountID\n" +
  10516. //" AND k.createtime >= :in_BeginDate\n" +
  10517. //" AND k.createtime <= :in_EndDate\n" +
  10518. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10519. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10520. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10521. string sqlString = "WITH kilnData AS\n" +
  10522. " (SELECT k.usercode\n" +
  10523. " ,kiln.kilncode\n" +
  10524. " ,p.procedurename\n" +
  10525. " ,trunc(k.createtime) kdate\n" +
  10526. " ,k.userid\n" +
  10527. " ,k.procedureid\n" +
  10528. " ,k.kilnid\n" +
  10529. " ,k.KILNCARBATCHNO\n" +
  10530. " FROM tp_pm_kilncardata k\n" +
  10531. " LEFT JOIN tp_mst_kiln kiln\n" +
  10532. " ON kiln.kilnid = k.kilnid\n" +
  10533. " LEFT JOIN tp_pc_procedure p\n" +
  10534. " ON p.procedureid = k.procedureid\n" +
  10535. " WHERE k.valueflag = '1'\n" +
  10536. " AND k.AccountID = :in_AccountID\n" +
  10537. " AND k.createtime >= :in_BeginDate\n" +
  10538. " AND k.createtime <= :in_EndDate\n" +
  10539. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10540. "SELECT kd.procedurename\n" +
  10541. " ,kd.usercode\n" +
  10542. " ,kd.kilncode\n" +
  10543. " ,kd.kdate\n" +
  10544. " ,kd.kcount\n" +
  10545. " ,kpd.kpcount\n" +
  10546. " FROM (SELECT kk.procedurename\n" +
  10547. " ,kk.usercode\n" +
  10548. " ,kk.kilncode\n" +
  10549. " ,kk.kdate\n" +
  10550. " ,kk.procedureid\n" +
  10551. " ,kk.userid\n" +
  10552. " ,kk.kilnid\n" +
  10553. " ,COUNT(*) kcount\n" +
  10554. " FROM kilnData kk\n" +
  10555. " GROUP BY kk.procedurename\n" +
  10556. " ,kk.usercode\n" +
  10557. " ,kk.kilncode\n" +
  10558. " ,kk.kdate\n" +
  10559. " ,kk.procedureid\n" +
  10560. " ,kk.userid\n" +
  10561. " ,kk.kilnid) kd\n" +
  10562. " LEFT JOIN (SELECT kk.kdate\n" +
  10563. " ,kk.procedureid\n" +
  10564. " ,kk.userid\n" +
  10565. " ,kk.kilnid\n" +
  10566. " ,COUNT(*) kpcount\n" +
  10567. " FROM kilnData kk\n" +
  10568. " INNER JOIN tp_pm_productiondata pd\n" +
  10569. " ON pd.valueflag = '1'\n" +
  10570. " AND pd.procedureid = kk.procedureid\n" +
  10571. " AND pd.kilnid = kk.kilnid\n" +
  10572. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10573. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10574. " ON kpd.kdate = kd.kdate\n" +
  10575. " AND kpd.procedureid = kd.procedureid\n" +
  10576. " AND kpd.userid = kd.userid\n" +
  10577. " AND kpd.kilnid = kd.kilnid\n" +
  10578. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10579. OracleParameter[] parascount = new OracleParameter[]{
  10580. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10581. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10582. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10583. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10584. };
  10585. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10586. if (dt != null)
  10587. {
  10588. sre.Data.Tables.Add(dt);
  10589. }
  10590. conn.Commit();
  10591. return sre;
  10592. }
  10593. catch (Exception ex)
  10594. {
  10595. throw ex;
  10596. }
  10597. finally
  10598. {
  10599. if (conn != null &&
  10600. conn.ConnState == ConnectionState.Open)
  10601. {
  10602. conn.Disconnect();
  10603. }
  10604. }
  10605. }
  10606. #endregion
  10607. /// <summary>
  10608. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10609. /// </summary>
  10610. /// <param name="searchEntity">生产数据实体类</param>
  10611. /// <param name="user">用户基本信息</param>
  10612. /// <returns>DataTable</returns>
  10613. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10614. {
  10615. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10616. string procsql = "PRO_RPT_GetProductionData";
  10617. try
  10618. {
  10619. IDataParameter[] paras = new OracleParameter[]
  10620. {
  10621. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10622. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10623. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10624. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10625. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10626. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10627. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10628. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10629. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10630. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10631. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10632. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10633. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10634. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10635. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10636. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10637. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10638. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10639. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10640. };
  10641. oracleConn.Open();
  10642. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10643. if (returnDs != null && returnDs.Tables.Count > 0)
  10644. {
  10645. return returnDs.Tables[0];
  10646. }
  10647. else
  10648. {
  10649. return null;
  10650. }
  10651. }
  10652. catch (Exception ex)
  10653. {
  10654. throw ex;
  10655. }
  10656. finally
  10657. {
  10658. if (oracleConn.ConnState == ConnectionState.Open)
  10659. {
  10660. oracleConn.Close();
  10661. }
  10662. }
  10663. }
  10664. /// <summary>
  10665. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10666. /// </summary>
  10667. /// <param name="user">登录用户信息</param>
  10668. /// <param name="se">查询条件</param>
  10669. /// <returns>查询结果</returns>
  10670. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10671. {
  10672. IDBConnection conn = null;
  10673. try
  10674. {
  10675. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10676. List<OracleParameter> parameters = new List<OracleParameter>();
  10677. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10678. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10679. ServiceResultEntity sre = new ServiceResultEntity();
  10680. if (data == null || data.Rows.Count == 0)
  10681. {
  10682. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10683. return sre;
  10684. }
  10685. sre.Data = new DataSet();
  10686. sre.Data.Tables.Add(data);
  10687. return sre;
  10688. }
  10689. catch (Exception ex)
  10690. {
  10691. throw ex;
  10692. }
  10693. finally
  10694. {
  10695. if (conn != null &&
  10696. conn.ConnState == ConnectionState.Open)
  10697. {
  10698. conn.Close();
  10699. }
  10700. }
  10701. }
  10702. /// <summary>
  10703. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10704. /// </summary>
  10705. /// <returns>sql</returns>
  10706. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10707. {
  10708. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10709. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10710. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10711. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10712. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10713. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10714. {
  10715. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10716. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10717. }
  10718. if (!string.IsNullOrEmpty(se.Remarks))
  10719. {
  10720. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10721. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10722. }
  10723. if (se.RecordDate.HasValue)
  10724. {
  10725. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10726. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10727. }
  10728. if (se.RecordDateEnd.HasValue)
  10729. {
  10730. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10731. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10732. }
  10733. selSql +=
  10734. // 温湿计查看权限
  10735. " AND EXISTS (SELECT UP.PurviewID" +
  10736. " FROM TP_MST_UserPurview UP" +
  10737. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10738. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10739. " AND UP.UserId = :UPUserId)";
  10740. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10741. selSql = selSql + " order by RecordDate asc";
  10742. return selSql;
  10743. }
  10744. /// <summary>
  10745. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10746. /// </summary>
  10747. /// <param name="user">登录用户信息</param>
  10748. /// <param name="se">查询条件</param>
  10749. /// <returns>查询结果</returns>
  10750. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10751. {
  10752. IDBConnection conn = null;
  10753. try
  10754. {
  10755. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10756. List<OracleParameter> parameters = new List<OracleParameter>();
  10757. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10758. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10759. ServiceResultEntity sre = new ServiceResultEntity();
  10760. if (data == null || data.Rows.Count == 0)
  10761. {
  10762. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10763. return sre;
  10764. }
  10765. sre.Data = new DataSet();
  10766. sre.Data.Tables.Add(data);
  10767. return sre;
  10768. }
  10769. catch (Exception ex)
  10770. {
  10771. throw ex;
  10772. }
  10773. finally
  10774. {
  10775. if (conn != null &&
  10776. conn.ConnState == ConnectionState.Open)
  10777. {
  10778. conn.Close();
  10779. }
  10780. }
  10781. }
  10782. /// <summary>
  10783. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10784. /// </summary>
  10785. /// <returns>sql</returns>
  10786. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10787. {
  10788. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10789. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10790. #region
  10791. // string sqlString = @"
  10792. // SELECT t.reworkprocedureid -- 返工工序id
  10793. // ,decode(gid,
  10794. // 7,
  10795. // '总计',
  10796. // 3,
  10797. // '合计【' || t.reworkprocedurename || '】',
  10798. // 0,
  10799. // t.reworkprocedurename,
  10800. // '--') reworkprocedurename -- 返工工序
  10801. // ,t.goodstypecode2 -- 产品二级类别
  10802. // ,decode(gid,
  10803. // 1,
  10804. // '小计【' || t.goodstypename2 || '】',
  10805. // 0,
  10806. // t.goodstypename2,
  10807. // '--') goodstypename2 -- 产品二级类别
  10808. // ,t.reworkuserid -- 返工工号id
  10809. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10810. // ,t.goodsid -- 产品id
  10811. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10812. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10813. // ,t.reworkcount -- 返工数
  10814. // ,t.badcount -- 不合格数
  10815. // ,t.regoodcount -- 复检合格数
  10816. // ,t.rebadcount -- 复检不合格数
  10817. // ,t.renocount -- 未复检
  10818. // --,t.renocountsum -- 待返工
  10819. // ,(SELECT COUNT(*)
  10820. // FROM tp_pm_semicheck sci
  10821. // WHERE sci.valueflag = '1'
  10822. // AND sci.backoutflag = '0'
  10823. // AND sci.semichecktype = 1
  10824. // AND sci.resemichecktype = 0
  10825. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10826. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10827. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10828. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10829. // ,sc.reworkprocedureid
  10830. // ,rp.procedurename reworkprocedurename
  10831. // ,gt2.goodstypecode goodstypecode2
  10832. // ,gt2.goodstypename goodstypename2
  10833. // ,sc.reworkuserid
  10834. // ,sc.reworkusercode
  10835. // ,g.goodsid
  10836. // ,g.goodscode
  10837. // ,gt.goodstypename
  10838. // , SUM(CASE
  10839. // WHEN sc.semichecktype = 1 THEN
  10840. // 1
  10841. // ELSE
  10842. // 0
  10843. // END) reworkcount
  10844. // , SUM(CASE
  10845. // WHEN sc.semichecktype = 2 THEN
  10846. // 1
  10847. // ELSE
  10848. // 0
  10849. // END) badcount
  10850. // , SUM(CASE
  10851. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  10852. // 1
  10853. // ELSE
  10854. // 0
  10855. // END) renocount
  10856. // , SUM(CASE
  10857. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  10858. // 1
  10859. // ELSE
  10860. // 0
  10861. // END) regoodcount
  10862. // , SUM(CASE
  10863. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  10864. // 1
  10865. // ELSE
  10866. // 0
  10867. // END) rebadcount
  10868. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  10869. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  10870. // --FROM tp_pm_semicheck sc
  10871. // FROM (SELECT semicheckid
  10872. // ,barcode
  10873. // ,productionlineid
  10874. // ,procedureid
  10875. // ,proceduretime
  10876. // ,proceduremodel
  10877. // ,modeltype
  10878. // ,organizationid
  10879. // ,goodsid
  10880. // ,goodscode
  10881. // ,userid
  10882. // ,usercode
  10883. // ,productiondataid
  10884. // ,logoid
  10885. // ,ispublicbody
  10886. // ,specialrepairflag
  10887. // ,goodslevelid
  10888. // ,goodsleveltypeid
  10889. // ,groutingdailyid
  10890. // ,groutingdailydetailid
  10891. // ,groutinglineid
  10892. // ,groutinglinecode
  10893. // ,groutinglinename
  10894. // ,gmouldtypeid
  10895. // ,canmanytimes
  10896. // ,groutinglinedetailid
  10897. // ,groutingdate
  10898. // ,groutingmouldcode
  10899. // ,mouldcode
  10900. // ,groutinguserid
  10901. // ,groutingusercode
  10902. // ,groutingnum
  10903. // ,semichecktype
  10904. // ,semicheckuserid
  10905. // ,semicheckusercode
  10906. // ,semichecktime
  10907. // ,reworkprocedureid
  10908. // ,reworkprocedurecode
  10909. // ,reworkuserid
  10910. // ,reworkusercode
  10911. // ,resemichecktype
  10912. // ,resemicheckuserid
  10913. // ,resemicheckusercode
  10914. // ,resemichecktime
  10915. // ,backoutflag
  10916. // ,backouttime
  10917. // ,backoutuserid
  10918. // ,backoutusercode
  10919. // ,remarks
  10920. // ,createtime
  10921. // ,createuserid
  10922. // ,updateuserid
  10923. // FROM tp_pm_semicheck sc
  10924. // WHERE sc.accountid = :accountid
  10925. // AND sc.valueflag = '1'
  10926. // AND sc.semichecktype = 1
  10927. // AND sc.backoutflag = '0'
  10928. // UNION ALL
  10929. // SELECT DISTINCT sc.semicheckid
  10930. // ,sc.barcode
  10931. // ,sc.productionlineid
  10932. // ,sc.procedureid
  10933. // ,sc.proceduretime
  10934. // ,sc.proceduremodel
  10935. // ,sc.modeltype
  10936. // ,sc.organizationid
  10937. // ,sc.goodsid
  10938. // ,sc.goodscode
  10939. // ,sc.userid
  10940. // ,sc.usercode
  10941. // ,sc.productiondataid
  10942. // ,sc.logoid
  10943. // ,sc.ispublicbody
  10944. // ,sc.specialrepairflag
  10945. // ,sc.goodslevelid
  10946. // ,sc.goodsleveltypeid
  10947. // ,sc.groutingdailyid
  10948. // ,sc.groutingdailydetailid
  10949. // ,sc.groutinglineid
  10950. // ,sc.groutinglinecode
  10951. // ,sc.groutinglinename
  10952. // ,sc.gmouldtypeid
  10953. // ,sc.canmanytimes
  10954. // ,sc.groutinglinedetailid
  10955. // ,sc.groutingdate
  10956. // ,sc.groutingmouldcode
  10957. // ,sc.mouldcode
  10958. // ,sc.groutinguserid
  10959. // ,sc.groutingusercode
  10960. // ,sc.groutingnum
  10961. // ,sc.semichecktype
  10962. // ,sc.semicheckuserid
  10963. // ,sc.semicheckusercode
  10964. // ,sc.semichecktime
  10965. // --,sc.reworkprocedureid
  10966. // --,sc.reworkprocedurecode
  10967. // --,sc.reworkuserid
  10968. // --,sc.reworkusercode
  10969. // ,scd.defectprocedureid
  10970. // ,scdp.procedurename
  10971. // ,scd.defectuserid
  10972. // ,scd.defectusercode
  10973. // ,sc.resemichecktype
  10974. // ,sc.resemicheckuserid
  10975. // ,sc.resemicheckusercode
  10976. // ,sc.resemichecktime
  10977. // ,sc.backoutflag
  10978. // ,sc.backouttime
  10979. // ,sc.backoutuserid
  10980. // ,sc.backoutusercode
  10981. // ,sc.remarks
  10982. // ,sc.createtime
  10983. // ,sc.createuserid
  10984. // ,sc.updateuserid
  10985. // FROM tp_pm_semicheck sc
  10986. // LEFT JOIN TP_PM_SemiCheckDefect scd
  10987. // ON sc.semicheckid = scd.semicheckid
  10988. // LEFT JOIN tp_pc_procedure scdp
  10989. // ON scdp.procedureid = scd.defectprocedureid
  10990. // WHERE sc.accountid = :accountid
  10991. // AND sc.valueflag = '1'
  10992. // AND sc.semichecktype = 2
  10993. // AND sc.backoutflag = '0'
  10994. // ) sc
  10995. // LEFT JOIN tp_pc_procedure rp
  10996. // ON rp.procedureid = sc.reworkprocedureid
  10997. // INNER JOIN tp_mst_goods g
  10998. // ON g.goodsid = sc.goodsid
  10999. // INNER JOIN tp_mst_goodstype gt
  11000. // ON gt.goodstypeid = g.goodstypeid
  11001. // INNER JOIN tp_mst_goodstype gt2
  11002. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11003. // AND gt2.accountid = gt.accountid
  11004. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11005. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11006. // 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))";
  11007. #endregion
  11008. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11009. " ,decode(gid,\n" +
  11010. " 7,\n" +
  11011. " '总计',\n" +
  11012. " 3,\n" +
  11013. " '合计【' || t.reworkprocedurename || '】',\n" +
  11014. " 0,\n" +
  11015. " t.reworkprocedurename,\n" +
  11016. " '--') reworkprocedurename -- 返工工序\n" +
  11017. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11018. " ,decode(gid,\n" +
  11019. " 1,\n" +
  11020. " '小计【' || t.goodstypename2 || '】',\n" +
  11021. " 0,\n" +
  11022. " t.goodstypename2,\n" +
  11023. " '--') goodstypename2 -- 产品二级类别\n" +
  11024. " ,t.reworkuserid -- 返工工号id\n" +
  11025. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11026. " ,t.goodsid -- 产品id\n" +
  11027. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11028. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11029. " ,t.reworkcount -- 返工数\n" +
  11030. " ,t.badcount -- 不合格数\n" +
  11031. " ,t.regoodcount -- 复检合格数\n" +
  11032. " ,t.rebadcount -- 复检不合格数\n" +
  11033. " ,t.renocount -- 未复检\n" +
  11034. " ,t.renocountsum -- 待返工\n" +
  11035. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11036. " sct.goodstypecode2,\n" +
  11037. " sct.goodsid) gid\n" +
  11038. " ,sct.displayno\n" +
  11039. " ,sct.reworkprocedureid\n" +
  11040. " ,sct.reworkprocedurename\n" +
  11041. " ,sct.goodstypecode2\n" +
  11042. " ,sct.goodstypename2\n" +
  11043. " ,sct.reworkuserid\n" +
  11044. " ,sct.reworkusercode\n" +
  11045. " ,sct.goodsid\n" +
  11046. " ,sct.goodscode\n" +
  11047. " ,sct.goodstypename\n" +
  11048. " ,SUM(sct.reworkcount) reworkcount\n" +
  11049. " ,SUM(sct. badcount) badcount\n" +
  11050. " ,SUM(sct. renocount) renocount\n" +
  11051. " ,SUM(sct.regoodcount) regoodcount\n" +
  11052. " ,SUM(sct.rebadcount) rebadcount\n" +
  11053. " ,SUM(sct.renocountsum) renocountsum\n" +
  11054. " FROM (SELECT rp.displayno\n" +
  11055. " ,sc.reworkprocedureid\n" +
  11056. " ,rp.procedurename reworkprocedurename\n" +
  11057. " ,gt2.goodstypecode goodstypecode2\n" +
  11058. " ,gt2.goodstypename goodstypename2\n" +
  11059. " ,sc.reworkuserid\n" +
  11060. " ,sc.reworkusercode\n" +
  11061. " ,g.goodsid\n" +
  11062. " ,g.goodscode\n" +
  11063. " ,gt.goodstypename\n" +
  11064. " , SUM(CASE\n" +
  11065. " WHEN sc.semichecktype = 1 THEN\n" +
  11066. " 1\n" +
  11067. " ELSE\n" +
  11068. " 0\n" +
  11069. " END) reworkcount\n" +
  11070. " , SUM(CASE\n" +
  11071. " WHEN sc.semichecktype = 2 THEN\n" +
  11072. " 1\n" +
  11073. " ELSE\n" +
  11074. " 0\n" +
  11075. " END) badcount\n" +
  11076. " , SUM(CASE\n" +
  11077. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11078. " 1\n" +
  11079. " ELSE\n" +
  11080. " 0\n" +
  11081. " END) renocount\n" +
  11082. " , SUM(CASE\n" +
  11083. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11084. " 1\n" +
  11085. " ELSE\n" +
  11086. " 0\n" +
  11087. " END) regoodcount\n" +
  11088. " , SUM(CASE\n" +
  11089. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11090. " 1\n" +
  11091. " ELSE\n" +
  11092. " 0\n" +
  11093. " END) rebadcount\n" +
  11094. " ,(SELECT COUNT(*)\n" +
  11095. " FROM tp_pm_semicheck sci\n" +
  11096. " WHERE sci.valueflag = '1'\n" +
  11097. " AND sci.backoutflag = '0'\n" +
  11098. " AND sci.semichecktype = 1\n" +
  11099. " AND sci.resemichecktype = 0\n" +
  11100. " AND sci.accountid = :accountid\n" +
  11101. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11102. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11103. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11104. " FROM (SELECT semicheckid\n" +
  11105. " ,barcode\n" +
  11106. " ,productionlineid\n" +
  11107. " ,procedureid\n" +
  11108. " ,proceduretime\n" +
  11109. " ,proceduremodel\n" +
  11110. " ,modeltype\n" +
  11111. " ,organizationid\n" +
  11112. " ,goodsid\n" +
  11113. " ,goodscode\n" +
  11114. " ,userid\n" +
  11115. " ,usercode\n" +
  11116. " ,productiondataid\n" +
  11117. " ,logoid\n" +
  11118. " ,ispublicbody\n" +
  11119. " ,specialrepairflag\n" +
  11120. " ,goodslevelid\n" +
  11121. " ,goodsleveltypeid\n" +
  11122. " ,groutingdailyid\n" +
  11123. " ,groutingdailydetailid\n" +
  11124. " ,groutinglineid\n" +
  11125. " ,groutinglinecode\n" +
  11126. " ,groutinglinename\n" +
  11127. " ,gmouldtypeid\n" +
  11128. " ,canmanytimes\n" +
  11129. " ,groutinglinedetailid\n" +
  11130. " ,groutingdate\n" +
  11131. " ,groutingmouldcode\n" +
  11132. " ,mouldcode\n" +
  11133. " ,groutinguserid\n" +
  11134. " ,groutingusercode\n" +
  11135. " ,groutingnum\n" +
  11136. " ,semichecktype\n" +
  11137. " ,semicheckuserid\n" +
  11138. " ,semicheckusercode\n" +
  11139. " ,semichecktime\n" +
  11140. " ,reworkprocedureid\n" +
  11141. " ,reworkprocedurecode\n" +
  11142. " ,reworkuserid\n" +
  11143. " ,reworkusercode\n" +
  11144. " ,resemichecktype\n" +
  11145. " ,resemicheckuserid\n" +
  11146. " ,resemicheckusercode\n" +
  11147. " ,resemichecktime\n" +
  11148. " ,backoutflag\n" +
  11149. " ,backouttime\n" +
  11150. " ,backoutuserid\n" +
  11151. " ,backoutusercode\n" +
  11152. " ,remarks\n" +
  11153. " ,createtime\n" +
  11154. " ,createuserid\n" +
  11155. " ,updateuserid\n" +
  11156. " FROM tp_pm_semicheck sc\n" +
  11157. " WHERE sc.accountid = :accountid\n" +
  11158. " AND sc.valueflag = '1'\n" +
  11159. " AND sc.semichecktype = 1\n" +
  11160. " AND sc.backoutflag = '0'\n" +
  11161. " UNION ALL\n" +
  11162. " SELECT DISTINCT sc.semicheckid\n" +
  11163. " ,sc.barcode\n" +
  11164. " ,sc.productionlineid\n" +
  11165. " ,sc.procedureid\n" +
  11166. " ,sc.proceduretime\n" +
  11167. " ,sc.proceduremodel\n" +
  11168. " ,sc.modeltype\n" +
  11169. " ,sc.organizationid\n" +
  11170. " ,sc.goodsid\n" +
  11171. " ,sc.goodscode\n" +
  11172. " ,sc.userid\n" +
  11173. " ,sc.usercode\n" +
  11174. " ,sc.productiondataid\n" +
  11175. " ,sc.logoid\n" +
  11176. " ,sc.ispublicbody\n" +
  11177. " ,sc.specialrepairflag\n" +
  11178. " ,sc.goodslevelid\n" +
  11179. " ,sc.goodsleveltypeid\n" +
  11180. " ,sc.groutingdailyid\n" +
  11181. " ,sc.groutingdailydetailid\n" +
  11182. " ,sc.groutinglineid\n" +
  11183. " ,sc.groutinglinecode\n" +
  11184. " ,sc.groutinglinename\n" +
  11185. " ,sc.gmouldtypeid\n" +
  11186. " ,sc.canmanytimes\n" +
  11187. " ,sc.groutinglinedetailid\n" +
  11188. " ,sc.groutingdate\n" +
  11189. " ,sc.groutingmouldcode\n" +
  11190. " ,sc.mouldcode\n" +
  11191. " ,sc.groutinguserid\n" +
  11192. " ,sc.groutingusercode\n" +
  11193. " ,sc.groutingnum\n" +
  11194. " ,sc.semichecktype\n" +
  11195. " ,sc.semicheckuserid\n" +
  11196. " ,sc.semicheckusercode\n" +
  11197. " ,sc.semichecktime\n" +
  11198. " --,sc.reworkprocedureid\n" +
  11199. " --,sc.reworkprocedurecode\n" +
  11200. " --,sc.reworkuserid\n" +
  11201. " --,sc.reworkusercode\n" +
  11202. " ,scd.defectprocedureid\n" +
  11203. " ,scdp.procedurename\n" +
  11204. " ,scd.defectuserid\n" +
  11205. " ,scd.defectusercode\n" +
  11206. " ,sc.resemichecktype\n" +
  11207. " ,sc.resemicheckuserid\n" +
  11208. " ,sc.resemicheckusercode\n" +
  11209. " ,sc.resemichecktime\n" +
  11210. " ,sc.backoutflag\n" +
  11211. " ,sc.backouttime\n" +
  11212. " ,sc.backoutuserid\n" +
  11213. " ,sc.backoutusercode\n" +
  11214. " ,sc.remarks\n" +
  11215. " ,sc.createtime\n" +
  11216. " ,sc.createuserid\n" +
  11217. " ,sc.updateuserid\n" +
  11218. " FROM tp_pm_semicheck sc\n" +
  11219. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11220. " ON sc.semicheckid = scd.semicheckid\n" +
  11221. " AND scd.valueflag='1'\n" +
  11222. " LEFT JOIN tp_pc_procedure scdp\n" +
  11223. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11224. " WHERE sc.accountid = :accountid\n" +
  11225. " AND sc.valueflag = '1'\n" +
  11226. " AND sc.semichecktype = 2\n" +
  11227. " AND sc.backoutflag = '0') sc\n" +
  11228. " LEFT JOIN tp_pc_procedure rp\n" +
  11229. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11230. " INNER JOIN tp_mst_goods g\n" +
  11231. " ON g.goodsid = sc.goodsid\n" +
  11232. " INNER JOIN tp_mst_goodstype gt\n" +
  11233. " ON gt.goodstypeid = g.goodstypeid\n" +
  11234. " INNER JOIN tp_mst_goodstype gt2\n" +
  11235. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11236. " AND gt2.accountid = gt.accountid\n" +
  11237. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11238. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11239. " sc.GroutingDailyDetailID\n" //+
  11240. //" WHERE EXISTS (SELECT 1\n" +
  11241. //" FROM TP_MST_UserPurview up\n" +
  11242. //" WHERE up.PurviewType = 9\n" +
  11243. //" AND up.UserID = :UserID\n" +
  11244. //" AND (up.PurviewID = -1 OR\n" +
  11245. //" up.PurviewID = sc.procedureid))\n"
  11246. ;
  11247. // 完成工序集
  11248. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11249. {
  11250. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11251. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11252. }
  11253. // 完成时间起始
  11254. if (se.CDateTimeStart.HasValue)
  11255. {
  11256. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11257. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11258. }
  11259. // 完成时间结束
  11260. if (se.CDateTimeEnd.HasValue)
  11261. {
  11262. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11263. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11264. }
  11265. // 完成工号
  11266. if (!string.IsNullOrEmpty(se.CUserCode))
  11267. {
  11268. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11269. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11270. }
  11271. // 产品类别
  11272. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11273. {
  11274. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11275. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11276. }
  11277. // 产品编码
  11278. if (!string.IsNullOrEmpty(se.GoodsCode))
  11279. {
  11280. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11281. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11282. }
  11283. // 成型工号
  11284. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11285. {
  11286. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11287. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11288. }
  11289. // 注浆时间起始
  11290. if (se.GroutingDateTimeStart.HasValue)
  11291. {
  11292. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11293. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11294. }
  11295. // 注浆时间结束
  11296. if (se.GroutingDateTimeEnd.HasValue)
  11297. {
  11298. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11299. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11300. }
  11301. // 交坯时间起始
  11302. if (se.DeliveryDateTimeStart.HasValue)
  11303. {
  11304. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11305. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11306. }
  11307. // 交坯时间结束
  11308. if (se.DeliveryDateTimeEnd.HasValue)
  11309. {
  11310. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11311. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11312. }
  11313. // 半检状态
  11314. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11315. {
  11316. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11317. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11318. }
  11319. // 半检时间起始
  11320. if (se.SemiCheckDateTimeStart.HasValue)
  11321. {
  11322. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11323. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11324. }
  11325. // 半检时间结束
  11326. if (se.SemiCheckDateTimeEnd.HasValue)
  11327. {
  11328. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11329. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11330. }
  11331. // 半检工号
  11332. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11333. {
  11334. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11335. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11336. }
  11337. // 返工工序
  11338. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11339. {
  11340. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11341. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11342. }
  11343. // 返工工号
  11344. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11345. {
  11346. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11347. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11348. }
  11349. // 复检状态
  11350. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11351. {
  11352. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11353. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11354. }
  11355. // 复检时间起始
  11356. if (se.ReSemiCheckDateTimeStart.HasValue)
  11357. {
  11358. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11359. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11360. }
  11361. // 复检时间结束
  11362. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11363. {
  11364. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11365. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11366. }
  11367. // 复检工号
  11368. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11369. {
  11370. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11371. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11372. }
  11373. // 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),())
  11374. // ORDER BY rp.displayno
  11375. // ,gt2.goodstypename
  11376. // ,sc.reworkusercode
  11377. // ,g.goodscode
  11378. // ,gt.goodstypename, gid) t
  11379. // ";
  11380. sqlString = sqlString +
  11381. " GROUP BY rp.displayno\n" +
  11382. " ,sc.reworkprocedureid\n" +
  11383. " ,rp.procedurename\n" +
  11384. " ,gt2.goodstypecode\n" +
  11385. " ,gt2.goodstypename\n" +
  11386. " ,sc.reworkuserid\n" +
  11387. " ,sc.reworkusercode\n" +
  11388. " ,g.goodsid\n" +
  11389. " ,g.goodscode\n" +
  11390. " ,gt.goodstypename) sct\n" +
  11391. " 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" +
  11392. " ORDER BY sct.displayno\n" +
  11393. " ,sct.goodstypename\n" +
  11394. " ,sct.reworkusercode\n" +
  11395. " ,sct.goodscode\n" +
  11396. " ,sct.goodstypename\n" +
  11397. " ,gid) t";
  11398. return sqlString;
  11399. }
  11400. /// <summary>
  11401. /// 取得RPT080107(半检登记明细)的信息查询数据
  11402. /// </summary>
  11403. /// <param name="user">登录用户信息</param>
  11404. /// <param name="se">查询条件</param>
  11405. /// <returns>查询结果</returns>
  11406. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11407. {
  11408. IDBConnection conn = null;
  11409. try
  11410. {
  11411. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11412. List<OracleParameter> parameters = new List<OracleParameter>();
  11413. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11414. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11415. ServiceResultEntity sre = new ServiceResultEntity();
  11416. if (data == null || data.Rows.Count == 0)
  11417. {
  11418. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11419. return sre;
  11420. }
  11421. sre.Data = new DataSet();
  11422. sre.Data.Tables.Add(data);
  11423. return sre;
  11424. }
  11425. catch (Exception ex)
  11426. {
  11427. throw ex;
  11428. }
  11429. finally
  11430. {
  11431. if (conn != null &&
  11432. conn.ConnState == ConnectionState.Open)
  11433. {
  11434. conn.Close();
  11435. }
  11436. }
  11437. }
  11438. //xuwei add 2019-10-14
  11439. /// <summary>
  11440. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11441. /// </summary>
  11442. /// <param name="user">登录用户信息</param>
  11443. /// <param name="se">查询条件</param>
  11444. /// <returns>查询结果</returns>
  11445. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11446. {
  11447. IDBConnection conn = null;
  11448. try
  11449. {
  11450. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11451. List<OracleParameter> parameters = new List<OracleParameter>();
  11452. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11453. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11454. ServiceResultEntity sre = new ServiceResultEntity();
  11455. if (data == null || data.Rows.Count == 0)
  11456. {
  11457. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11458. return sre;
  11459. }
  11460. sre.Data = new DataSet();
  11461. sre.Data.Tables.Add(data);
  11462. return sre;
  11463. }
  11464. catch (Exception ex)
  11465. {
  11466. throw ex;
  11467. }
  11468. finally
  11469. {
  11470. if (conn != null &&
  11471. conn.ConnState == ConnectionState.Open)
  11472. {
  11473. conn.Close();
  11474. }
  11475. }
  11476. }
  11477. /// <summary>
  11478. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11479. /// </summary>
  11480. /// <returns>sql</returns>
  11481. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11482. {
  11483. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11484. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11485. string sqlString = @"
  11486. SELECT
  11487. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11488. p.PROCEDURECODE ,--AS 完成工序编码,
  11489. p.PROCEDURENAME ,--AS 完成工序,
  11490. sr.PROCEDURETIME ,--AS 完成时间,
  11491. sr.USERCODE ,--完成工号,
  11492. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11493. gt.GOODSTYPENAME ,--AS 产品类别,
  11494. g.GOODSCODE ,--AS 产品编码,
  11495. g.GOODSNAME,--AS 产品名称,
  11496. sr.BARCODE ,--AS 产品条码,
  11497. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11498. sr.SEMIREWORKTIME ,--AS 半检时间,
  11499. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11500. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11501. sr.BACKOUTFLAG ,--AS 撤销标识,
  11502. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11503. sr.BACKOUTTIME ,--AS 撤销时间,
  11504. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11505. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11506. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11507. sr.GROUTINGDATE ,--AS 注浆时间,
  11508. gd.DELIVERTIME ,--AS 交坯时间,
  11509. l.LOGONAME ,--AS 商标,
  11510. srd.DEFECTCODE ,--AS 缺陷编码,
  11511. srd.DEFECTNAME ,--AS 缺陷名称,
  11512. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11513. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11514. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11515. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11516. srd.DEFECTUSERCODE ,--AS 责任工号,
  11517. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11518. FROM
  11519. TP_PM_SEMIREWORK sr
  11520. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11521. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11522. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11523. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11524. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11525. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11526. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11527. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11528. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11529. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11530. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11531. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11532. WHERE
  11533. sr.VALUEFLAG = '1'
  11534. AND srd.VALUEFLAG = '1'
  11535. AND sr.AccountID=:AccountID
  11536. ";
  11537. //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))
  11538. // 完成工序
  11539. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11540. {
  11541. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11542. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11543. }
  11544. // 完成时间起始
  11545. if (se.CDateTimeStart.HasValue)
  11546. {
  11547. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11548. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11549. }
  11550. // 完成时间结束
  11551. if (se.CDateTimeEnd.HasValue)
  11552. {
  11553. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11554. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11555. }
  11556. // 完成工号
  11557. if (!string.IsNullOrEmpty(se.CUserCode))
  11558. {
  11559. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11560. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11561. }
  11562. // 产品类别
  11563. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11564. {
  11565. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11566. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11567. }
  11568. // 产品编码
  11569. if (!string.IsNullOrEmpty(se.GoodsCode))
  11570. {
  11571. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11572. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11573. }
  11574. // 成型工号
  11575. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11576. {
  11577. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11578. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11579. }
  11580. // 注浆时间起始
  11581. if (se.GroutingDateTimeStart.HasValue)
  11582. {
  11583. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11584. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11585. }
  11586. // 注浆时间结束
  11587. if (se.GroutingDateTimeEnd.HasValue)
  11588. {
  11589. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11590. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11591. }
  11592. // 交坯时间起始
  11593. if (se.DeliveryDateTimeStart.HasValue)
  11594. {
  11595. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11596. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11597. }
  11598. // 交坯时间结束
  11599. if (se.DeliveryDateTimeEnd.HasValue)
  11600. {
  11601. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11602. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11603. }
  11604. // 半检时间起始
  11605. if (se.SemiCheckDateTimeStart.HasValue)
  11606. {
  11607. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11608. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11609. }
  11610. // 半检时间结束
  11611. if (se.SemiCheckDateTimeEnd.HasValue)
  11612. {
  11613. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11614. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11615. }
  11616. // 半检工号
  11617. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11618. {
  11619. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11620. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11621. }
  11622. // 返修工序
  11623. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11624. {
  11625. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11626. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11627. }
  11628. // 返修工号
  11629. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11630. {
  11631. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11632. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11633. }
  11634. // 撤销标识
  11635. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11636. {
  11637. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11638. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11639. }
  11640. // 撤销时间起始
  11641. if (se.BackOutTimeStart.HasValue)
  11642. {
  11643. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11644. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11645. }
  11646. // 撤销时间结束
  11647. if (se.BackOutTimeEnd.HasValue)
  11648. {
  11649. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11650. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11651. }
  11652. // 撤销工号
  11653. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11654. {
  11655. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11656. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11657. }
  11658. // 产品条码
  11659. if (!string.IsNullOrEmpty(se.BarCode))
  11660. {
  11661. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11662. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11663. }
  11664. // 缺陷编码
  11665. if (!string.IsNullOrEmpty(se.DefectCode))
  11666. {
  11667. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11668. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11669. }
  11670. // 缺陷位置集
  11671. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11672. {
  11673. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11674. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11675. }
  11676. // 责任工序集
  11677. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11678. {
  11679. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11680. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11681. }
  11682. // 责任工号
  11683. if (!string.IsNullOrEmpty(se.DefectUser))
  11684. {
  11685. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11686. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11687. }
  11688. // 只显示最后一条半检记录
  11689. if (se.SemiCheckType == "1")
  11690. {
  11691. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11692. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11693. " from TP_PM_SEMIREWORK sw\n" +
  11694. " where sw.barcode = sr.barcode\n" +
  11695. " and sw.valueflag = '1'\n" +
  11696. " and (sw.backoutflag = '0')\n" +
  11697. " and sw.semireworkid > sr.semireworkid) )";
  11698. }
  11699. return sqlString;
  11700. }
  11701. //xuwei end
  11702. //xuwei add 2019-10-21
  11703. /// <summary>
  11704. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11705. /// </summary>
  11706. /// <param name="user">用户</param>
  11707. /// <param name="dataStr">统计日期</param>
  11708. /// <returns></returns>
  11709. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11710. {
  11711. IDBConnection conn = null;
  11712. try
  11713. {
  11714. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11715. string sqlStr = $@"
  11716. SELECT
  11717. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11718. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11719. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11720. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11721. FROM
  11722. TP_PM_SEMIREWORK sr
  11723. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11724. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11725. WHERE
  11726. sr.VALUEFLAG = '1'
  11727. AND sr.ACCOUNTID = '{user.AccountID}'
  11728. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11729. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11730. GROUP BY
  11731. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11732. ";
  11733. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11734. ServiceResultEntity sre = new ServiceResultEntity();
  11735. //if (data == null || data.Rows.Count == 0)
  11736. //{
  11737. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11738. // return sre;
  11739. //}
  11740. sre.Data = new DataSet();
  11741. sre.Data.Tables.Add(data);
  11742. return sre;
  11743. }
  11744. catch (Exception ex)
  11745. {
  11746. throw ex;
  11747. }
  11748. finally
  11749. {
  11750. if (conn != null &&
  11751. conn.ConnState == ConnectionState.Open)
  11752. {
  11753. conn.Close();
  11754. }
  11755. }
  11756. }
  11757. //xuwei end
  11758. /// <summary>
  11759. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11760. /// </summary>
  11761. /// <returns>sql</returns>
  11762. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11763. {
  11764. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11765. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11766. string sqlString = @"
  11767. select
  11768. SemiCheck.SemiCheckID,
  11769. CProcedure.ProcedureName as CProcedureName,
  11770. SemiCheck.ProcedureTime,
  11771. SemiCheck.UserCode,
  11772. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11773. GoodsType.GoodsTypeName,
  11774. Goods.GoodsCode,
  11775. SemiCheck.BarCode,
  11776. -- 复检后不显示半检状态
  11777. SemiCheckType.SemiCheckTypeName,
  11778. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11779. SemiCheck.SemiCheckUserCode,
  11780. SemiCheck.SemiCheckTime,
  11781. ReSemiCheckType.ReSemiCheckTypeName,
  11782. SemiCheck.ReSemiCheckUserCode,
  11783. SemiCheck.ReSemiCheckTime,
  11784. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11785. SemiCheck.BackOutUserCode,
  11786. SemiCheck.BackOutTime,
  11787. SemiCheck.GroutingUserCode,
  11788. SemiCheck.GroutingLineCode,
  11789. SemiCheck.GroutingMouldCode,
  11790. SemiCheck.GroutingDate,
  11791. GroutingDailyDetail.DeliverTime,
  11792. logo.logoName,
  11793. RProcedure.ProcedureName as RProcedureName,
  11794. SemiCheck.ReworkUserCode,
  11795. SemiCheckDefect.DefectCode,
  11796. SemiCheckDefect.DefectName as DefectName1,
  11797. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11798. SemiCheckDefect.DefectPositionName,
  11799. SemiCheckDefect.DefectPositionCode,
  11800. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11801. Procedure.ProcedureName,
  11802. inpp.ProcedureName CurrProcedureName,
  11803. DefectUser.username as DefectUser
  11804. from TP_PM_SemiCheck SemiCheck
  11805. left join TP_PC_Procedure CProcedure
  11806. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11807. left join TP_MST_Goods Goods
  11808. on SemiCheck.GoodsID=Goods.GoodsID
  11809. left join TP_MST_GoodsType GoodsType
  11810. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11811. left join TP_MST_GoodsType GoodsType2
  11812. on GoodsType2.accountid=GoodsType.accountid
  11813. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11814. left join TP_SYS_SemiCheckType SemiCheckType
  11815. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11816. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11817. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11818. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11819. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11820. left join TP_MST_Logo logo
  11821. on GroutingDailyDetail.LogoID=logo.LogoID
  11822. left join TP_PC_Procedure RProcedure
  11823. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11824. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11825. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11826. and SemiCheckDefect.ValueFlag='1'
  11827. left join TP_PC_Procedure Procedure
  11828. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11829. left join TP_MST_User DefectUser
  11830. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11831. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11832. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11833. where SemiCheck.AccountID=:AccountID
  11834. ";
  11835. //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))
  11836. // 完成工序
  11837. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11838. {
  11839. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  11840. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11841. }
  11842. // 完成时间起始
  11843. if (se.CDateTimeStart.HasValue)
  11844. {
  11845. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  11846. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11847. }
  11848. // 完成时间结束
  11849. if (se.CDateTimeEnd.HasValue)
  11850. {
  11851. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  11852. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11853. }
  11854. // 完成工号
  11855. if (!string.IsNullOrEmpty(se.CUserCode))
  11856. {
  11857. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  11858. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11859. }
  11860. // 产品类别
  11861. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11862. {
  11863. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11864. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11865. }
  11866. // 产品编码
  11867. if (!string.IsNullOrEmpty(se.GoodsCode))
  11868. {
  11869. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  11870. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11871. }
  11872. // 成型工号
  11873. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11874. {
  11875. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  11876. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11877. }
  11878. // 注浆时间起始
  11879. if (se.GroutingDateTimeStart.HasValue)
  11880. {
  11881. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  11882. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11883. }
  11884. // 注浆时间结束
  11885. if (se.GroutingDateTimeEnd.HasValue)
  11886. {
  11887. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  11888. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11889. }
  11890. // 交坯时间起始
  11891. if (se.DeliveryDateTimeStart.HasValue)
  11892. {
  11893. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11894. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11895. }
  11896. // 交坯时间结束
  11897. if (se.DeliveryDateTimeEnd.HasValue)
  11898. {
  11899. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11900. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11901. }
  11902. // 半检状态
  11903. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11904. {
  11905. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  11906. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11907. }
  11908. // 半检时间起始
  11909. if (se.SemiCheckDateTimeStart.HasValue)
  11910. {
  11911. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11912. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11913. }
  11914. // 半检时间结束
  11915. if (se.SemiCheckDateTimeEnd.HasValue)
  11916. {
  11917. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11918. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11919. }
  11920. // 半检工号
  11921. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11922. {
  11923. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11924. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11925. }
  11926. // 返工工序
  11927. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11928. {
  11929. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  11930. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11931. }
  11932. // 返工工号
  11933. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11934. {
  11935. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  11936. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11937. }
  11938. // 复检状态
  11939. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11940. {
  11941. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  11942. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11943. }
  11944. // 复检时间起始
  11945. if (se.ReSemiCheckDateTimeStart.HasValue)
  11946. {
  11947. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11948. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11949. }
  11950. // 复检时间结束
  11951. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11952. {
  11953. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11954. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11955. }
  11956. // 复检工号
  11957. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11958. {
  11959. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11960. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11961. }
  11962. // 撤销标识
  11963. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11964. {
  11965. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  11966. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11967. }
  11968. // 撤销时间起始
  11969. if (se.BackOutTimeStart.HasValue)
  11970. {
  11971. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  11972. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11973. }
  11974. // 撤销时间结束
  11975. if (se.BackOutTimeEnd.HasValue)
  11976. {
  11977. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  11978. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11979. }
  11980. // 撤销工号
  11981. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11982. {
  11983. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  11984. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11985. }
  11986. // 产品条码
  11987. if (!string.IsNullOrEmpty(se.BarCode))
  11988. {
  11989. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  11990. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11991. }
  11992. // 缺陷编码
  11993. if (!string.IsNullOrEmpty(se.DefectCode))
  11994. {
  11995. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  11996. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11997. }
  11998. // 缺陷位置集
  11999. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12000. {
  12001. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12002. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12003. }
  12004. // 责任工序集
  12005. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12006. {
  12007. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12008. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12009. }
  12010. // 责任工号
  12011. if (!string.IsNullOrEmpty(se.DefectUser))
  12012. {
  12013. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12014. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12015. }
  12016. return sqlString;
  12017. }
  12018. /// <summary>
  12019. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12020. /// </summary>
  12021. /// <param name="user">登录用户信息</param>
  12022. /// <param name="se">查询条件</param>
  12023. /// <returns>查询结果</returns>
  12024. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12025. {
  12026. IDBConnection conn = null;
  12027. try
  12028. {
  12029. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12030. List<OracleParameter> parameters = new List<OracleParameter>();
  12031. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12032. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12033. ServiceResultEntity sre = new ServiceResultEntity();
  12034. if (data == null || data.Rows.Count == 0)
  12035. {
  12036. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12037. return sre;
  12038. }
  12039. sre.Data = new DataSet();
  12040. sre.Data.Tables.Add(data);
  12041. return sre;
  12042. }
  12043. catch (Exception ex)
  12044. {
  12045. throw ex;
  12046. }
  12047. finally
  12048. {
  12049. if (conn != null &&
  12050. conn.ConnState == ConnectionState.Open)
  12051. {
  12052. conn.Close();
  12053. }
  12054. }
  12055. }
  12056. /// <summary>
  12057. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12058. /// </summary>
  12059. /// <returns>sql</returns>
  12060. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12061. {
  12062. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12063. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12064. string sqlString = @"SELECT ts.gid
  12065. ,logoid
  12066. ,decode(ts.gid,
  12067. '23',
  12068. '总计【' || orderno || '】',
  12069. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12070. ,decode(ts.gid,
  12071. '3',
  12072. '合计【' || logoname || '】',
  12073. decode(ts.gid, '1', '--', logoname)) AS logoname
  12074. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12075. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12076. ,GoodsSpecification
  12077. ,fhtime
  12078. ,COUNT
  12079. FROM (SELECT grouping_id(l.logoid,
  12080. o.orderno,
  12081. l.logoname,
  12082. g.goodscode,
  12083. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12084. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12085. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12086. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12087. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12088. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12089. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12090. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12091. 1,
  12092. '--',
  12093. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12094. ,COUNT(f.fhtime) AS COUNT
  12095. FROM tp_pm_finishedproduct F
  12096. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12097. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12098. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12099. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12100. where f.fhtime is not null and f.AccountID=:AccountID ";
  12101. // 交接时间起始
  12102. if (se.FHTimeStart.HasValue)
  12103. {
  12104. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12105. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12106. }
  12107. // 交接时间结束
  12108. if (se.FHTimeEnd.HasValue)
  12109. {
  12110. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12111. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12112. }
  12113. // 订单号
  12114. if (!string.IsNullOrEmpty(se.OrderNo))
  12115. {
  12116. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12117. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12118. }
  12119. // 产品类别编码
  12120. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12121. {
  12122. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12123. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12124. }
  12125. // 产品编码
  12126. if (!string.IsNullOrEmpty(se.GoodsCode))
  12127. {
  12128. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12129. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12130. }
  12131. // 产品型号
  12132. if (!string.IsNullOrEmpty(se.GoodsModel))
  12133. {
  12134. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12135. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12136. }
  12137. // 产品商标ID集
  12138. if (!string.IsNullOrEmpty(se.LogoIDS))
  12139. {
  12140. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12141. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12142. }
  12143. // 交接工号
  12144. if (!string.IsNullOrEmpty(se.FHUserCode))
  12145. {
  12146. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12147. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12148. }
  12149. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12150. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12151. )ts
  12152. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12153. or (goodscode!='--')
  12154. or(logoname!='')
  12155. or (orderno!='--') and ts.gid!='7'";
  12156. return sqlString;
  12157. }
  12158. /// <summary>
  12159. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12160. /// </summary>
  12161. /// <param name="user">登录用户信息</param>
  12162. /// <param name="se">查询条件</param>
  12163. /// <returns>查询结果</returns>
  12164. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12165. {
  12166. IDBConnection conn = null;
  12167. try
  12168. {
  12169. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12170. List<OracleParameter> parameters = new List<OracleParameter>();
  12171. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12172. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12173. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12174. " nvl2(l.logoname,\n" +
  12175. " o.orderno,\n" +
  12176. " to_char('合计[') || o.orderno ||\n" +
  12177. " to_char(']')),\n" +
  12178. " '总计') orderno\n" +
  12179. " ,nvl2(l.logoname,\n" +
  12180. " nvl2(g.goodscode,\n" +
  12181. " l.logoname,\n" +
  12182. " to_char('小计[' || l.logoname || ']')),\n" +
  12183. " '--') logoname\n" +
  12184. " ,nvl(g.goodscode, '--') goodscode" +
  12185. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12186. " ,nvl(gdd.materialcode, '--') mcode" +
  12187. " ,f.logoid" +
  12188. " ,f.goodsid" +
  12189. " ,f.fhorderid" +
  12190. " ,COUNT(*) count" +
  12191. " FROM tp_pm_finishedproduct f\n" +
  12192. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12193. " ON gdd.barcode = f.barcode\n" +
  12194. " LEFT JOIN tp_mst_logo l\n" +
  12195. " ON f.logoid = l.logoid\n" +
  12196. " LEFT JOIN TP_PM_Order O\n" +
  12197. " ON f.Fhorderid = O.Orderid\n" +
  12198. " LEFT JOIN tp_mst_goods G\n" +
  12199. " ON g.goodsid = f.goodsid\n" +
  12200. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12201. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12202. " WHERE f.fhtime IS NOT NULL\n" +
  12203. " AND f.AccountID = :AccountID\n";
  12204. // 交接时间起始
  12205. if (cre.Properties["FHTimeStart"] != null)
  12206. {
  12207. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12208. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12209. }
  12210. // 交接时间结束
  12211. if (cre.Properties["FHTimeEnd"] != null)
  12212. {
  12213. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12214. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12215. }
  12216. // 订单号
  12217. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12218. {
  12219. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12220. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12221. }
  12222. // 产品类别编码
  12223. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12224. {
  12225. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12226. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12227. }
  12228. // 产品编码
  12229. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12230. {
  12231. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12232. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12233. }
  12234. // 产品型号
  12235. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12236. {
  12237. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12238. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12239. }
  12240. // 产品商标ID集
  12241. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12242. {
  12243. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12244. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12245. }
  12246. // 交接工号
  12247. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12248. {
  12249. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12250. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12251. }
  12252. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12253. 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),())";
  12254. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12255. ServiceResultEntity sre = new ServiceResultEntity();
  12256. if (data == null || data.Rows.Count == 0)
  12257. {
  12258. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12259. return sre;
  12260. }
  12261. sre.Data = new DataSet();
  12262. sre.Data.Tables.Add(data);
  12263. return sre;
  12264. }
  12265. catch (Exception ex)
  12266. {
  12267. throw ex;
  12268. }
  12269. finally
  12270. {
  12271. if (conn != null &&
  12272. conn.ConnState == ConnectionState.Open)
  12273. {
  12274. conn.Close();
  12275. }
  12276. }
  12277. }
  12278. /// <summary>
  12279. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12280. /// </summary>
  12281. /// <param name="user">登录用户信息</param>
  12282. /// <param name="se">查询条件</param>
  12283. /// <returns>查询结果</returns>
  12284. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12285. {
  12286. IDBConnection conn = null;
  12287. try
  12288. {
  12289. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12290. List<OracleParameter> parameters = new List<OracleParameter>();
  12291. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12292. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12293. ServiceResultEntity sre = new ServiceResultEntity();
  12294. if (data == null || data.Rows.Count == 0)
  12295. {
  12296. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12297. return sre;
  12298. }
  12299. sre.Data = new DataSet();
  12300. sre.Data.Tables.Add(data);
  12301. return sre;
  12302. }
  12303. catch (Exception ex)
  12304. {
  12305. throw ex;
  12306. }
  12307. finally
  12308. {
  12309. if (conn != null &&
  12310. conn.ConnState == ConnectionState.Open)
  12311. {
  12312. conn.Close();
  12313. }
  12314. }
  12315. }
  12316. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12317. {
  12318. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12319. string sqlString = "SELECT O.ORDERNO,\n" +
  12320. " F.FHTIME,\n" +
  12321. " F.FHUSERCODE,\n" +
  12322. " F.BARCODE,\n" +
  12323. " F.GOODSCODE,\n" +
  12324. " L.LOGONAME,\n" +
  12325. " F.GROUTINGUSERCODE,\n" +
  12326. " F.GROUTINGLINECODE,\n" +
  12327. " F.GROUTINGMOULDCODE,\n" +
  12328. " F.GROUTINGDATE,\n" +
  12329. " G.DELIVERTIME,\n" +
  12330. " GOODS.goodsmodel,\n" +
  12331. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12332. //" 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" +
  12333. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12334. " G.MATERIALCODE AS mcode,\n" +
  12335. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12336. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12337. " LEFT JOIN TP_PM_ORDER O\n" +
  12338. " ON F.FHORDERID = O.ORDERID\n" +
  12339. " LEFT JOIN TP_MST_LOGO L\n" +
  12340. " ON F.LOGOID = L.LOGOID\n" +
  12341. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12342. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12343. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12344. " ON F.GOODSID = GOODS.GOODSID\n" +
  12345. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12346. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12347. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12348. " AND F.FHTIME IS NOT NULL";
  12349. // 交接时间起始
  12350. if (se.FHTimeStart.HasValue)
  12351. {
  12352. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12353. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12354. }
  12355. // 交接时间结束
  12356. if (se.FHTimeEnd.HasValue)
  12357. {
  12358. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12359. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12360. }
  12361. // 订单号
  12362. if (!string.IsNullOrEmpty(se.OrderNo))
  12363. {
  12364. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12365. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12366. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12367. }
  12368. // 产品类别编码
  12369. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12370. {
  12371. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12372. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12373. }
  12374. // 产品编码
  12375. if (!string.IsNullOrEmpty(se.GoodsCode))
  12376. {
  12377. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12378. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12379. }
  12380. // 产品型号
  12381. if (!string.IsNullOrEmpty(se.GoodsModel))
  12382. {
  12383. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12384. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12385. }
  12386. // 产品商标ID集
  12387. if (!string.IsNullOrEmpty(se.LogoIDS))
  12388. {
  12389. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12390. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12391. }
  12392. // 交接工号
  12393. if (!string.IsNullOrEmpty(se.FHUserCode))
  12394. {
  12395. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12396. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12397. }
  12398. if (se.OrderID != null)
  12399. {
  12400. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12401. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12402. }
  12403. if (se.GoodsID != null)
  12404. {
  12405. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12406. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12407. }
  12408. if (se.LogoID != null)
  12409. {
  12410. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12411. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12412. }
  12413. return sqlString;
  12414. }
  12415. /// <summary>
  12416. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12417. /// </summary>
  12418. /// <param name="user">登录用户信息</param>
  12419. /// <param name="se">查询条件</param>
  12420. /// <returns>查询结果</returns>
  12421. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12422. {
  12423. IDBConnection conn = null;
  12424. try
  12425. {
  12426. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12427. List<OracleParameter> parameters = new List<OracleParameter>();
  12428. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12429. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12430. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12431. " nvl2(l.logoname,\n" +
  12432. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12433. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12434. " to_char(']')),\n" +
  12435. " '总计') fhtime\n" +
  12436. " ,nvl2(l.logoname,\n" +
  12437. " nvl2(g.goodscode,\n" +
  12438. " l.logoname,\n" +
  12439. " to_char('小计[' || l.logoname || ']')),\n" +
  12440. " '--') logoname\n" +
  12441. " ,nvl(g.goodscode, '--') goodscode" +
  12442. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12443. " ,nvl(gdd.materialcode, '--') mcode" +
  12444. " ,COUNT(*) goodscount" +
  12445. " FROM tp_pm_finishedproduct f\n" +
  12446. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12447. " ON gdd.barcode = f.barcode\n" +
  12448. " LEFT JOIN tp_mst_logo l\n" +
  12449. " ON f.logoid = l.logoid\n" +
  12450. " LEFT JOIN TP_PM_Order O\n" +
  12451. " ON f.Fhorderid = O.Orderid\n" +
  12452. " LEFT JOIN tp_mst_goods G\n" +
  12453. " ON g.goodsid = f.goodsid\n" +
  12454. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12455. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12456. " WHERE f.fhtime IS NOT NULL\n" +
  12457. " AND f.AccountID = :AccountID\n";
  12458. // 交接时间起始
  12459. if (cre.Properties["FHTimeStart"] != null)
  12460. {
  12461. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12462. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12463. }
  12464. // 交接时间结束
  12465. if (cre.Properties["FHTimeEnd"] != null)
  12466. {
  12467. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12468. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12469. }
  12470. // 订单号
  12471. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12472. {
  12473. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12474. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12475. }
  12476. // 产品类别编码
  12477. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12478. {
  12479. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12480. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12481. }
  12482. // 产品编码
  12483. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12484. {
  12485. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12486. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12487. }
  12488. // 产品型号
  12489. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12490. {
  12491. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12492. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12493. }
  12494. // 产品商标ID集
  12495. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12496. {
  12497. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12498. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12499. }
  12500. // 交接工号
  12501. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12502. {
  12503. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12504. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12505. }
  12506. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12507. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12508. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12509. ServiceResultEntity sre = new ServiceResultEntity();
  12510. if (data == null || data.Rows.Count == 0)
  12511. {
  12512. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12513. return sre;
  12514. }
  12515. sre.Data = new DataSet();
  12516. sre.Data.Tables.Add(data);
  12517. return sre;
  12518. }
  12519. catch (Exception ex)
  12520. {
  12521. throw ex;
  12522. }
  12523. finally
  12524. {
  12525. if (conn != null &&
  12526. conn.ConnState == ConnectionState.Open)
  12527. {
  12528. conn.Close();
  12529. }
  12530. }
  12531. }
  12532. /// <summary>
  12533. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12534. /// </summary>
  12535. /// <param name="user">登录用户信息</param>
  12536. /// <param name="se">查询条件</param>
  12537. /// <returns>查询结果</returns>
  12538. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12539. {
  12540. IDBConnection conn = null;
  12541. try
  12542. {
  12543. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12544. List<OracleParameter> parameters = new List<OracleParameter>();
  12545. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12546. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12547. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12548. //" nvl2(l.logoname,\n" +
  12549. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12550. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12551. //" to_char(']')),\n" +
  12552. //" '总计') fhtime\n" +
  12553. //" ,nvl2(l.logoname,\n" +
  12554. //" nvl2(g.goodscode,\n" +
  12555. //" l.logoname,\n" +
  12556. //" to_char('小计[' || l.logoname || ']')),\n" +
  12557. //" '--') logoname\n" +
  12558. " nvl(g.goodscode, '合计') goodscode" +
  12559. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12560. " ,nvl(gdd.materialcode, '--') mcode" +
  12561. " ,COUNT(*) goodscount" +
  12562. " FROM tp_pm_finishedproduct f\n" +
  12563. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12564. " ON gdd.barcode = f.barcode\n" +
  12565. " LEFT JOIN tp_mst_logo l\n" +
  12566. " ON f.logoid = l.logoid\n" +
  12567. " LEFT JOIN TP_PM_Order O\n" +
  12568. " ON f.Fhorderid = O.Orderid\n" +
  12569. " LEFT JOIN tp_mst_goods G\n" +
  12570. " ON g.goodsid = f.goodsid\n" +
  12571. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12572. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12573. " WHERE f.fhtime IS NOT NULL\n" +
  12574. " AND f.AccountID = :AccountID\n";
  12575. // 交接时间起始
  12576. if (cre.Properties["FHTimeStart"] != null)
  12577. {
  12578. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12579. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12580. }
  12581. // 交接时间结束
  12582. if (cre.Properties["FHTimeEnd"] != null)
  12583. {
  12584. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12585. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12586. }
  12587. // 订单号
  12588. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12589. {
  12590. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12591. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12592. }
  12593. // 产品类别编码
  12594. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12595. {
  12596. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12597. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12598. }
  12599. // 产品编码
  12600. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12601. {
  12602. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12603. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12604. }
  12605. // 产品型号
  12606. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12607. {
  12608. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12609. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12610. }
  12611. // 产品商标ID集
  12612. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12613. {
  12614. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12615. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12616. }
  12617. // 交接工号
  12618. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12619. {
  12620. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12621. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12622. }
  12623. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12624. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12625. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12626. ServiceResultEntity sre = new ServiceResultEntity();
  12627. if (data == null || data.Rows.Count == 0)
  12628. {
  12629. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12630. return sre;
  12631. }
  12632. sre.Data = new DataSet();
  12633. sre.Data.Tables.Add(data);
  12634. return sre;
  12635. }
  12636. catch (Exception ex)
  12637. {
  12638. throw ex;
  12639. }
  12640. finally
  12641. {
  12642. if (conn != null &&
  12643. conn.ConnState == ConnectionState.Open)
  12644. {
  12645. conn.Close();
  12646. }
  12647. }
  12648. }
  12649. /// <summary>
  12650. /// 取得PDA(产成品交接汇总表)的交接数量
  12651. /// </summary>
  12652. /// <param name="user">登录用户信息</param>
  12653. /// <param name="se">查询条件</param>
  12654. /// <returns>查询结果</returns>
  12655. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12656. {
  12657. IDBConnection conn = null;
  12658. try
  12659. {
  12660. DateTime dateStart = date;
  12661. DateTime dateEnd = dateStart.AddDays(1);
  12662. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12663. List<OracleParameter> parameters = new List<OracleParameter>();
  12664. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12665. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12666. " FROM tp_pm_finishedproduct f\n" +
  12667. " LEFT JOIN TP_PM_Order O\n" +
  12668. " ON f.Fhorderid = O.Orderid\n" +
  12669. " LEFT JOIN tp_mst_goods G\n" +
  12670. " ON g.goodsid = f.goodsid\n" +
  12671. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12672. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12673. " WHERE f.fhtime IS NOT NULL\n" +
  12674. " AND f.AccountID = :AccountID\n";
  12675. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12676. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12677. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12678. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12679. // 产品型号
  12680. if (!string.IsNullOrEmpty(goodscode))
  12681. {
  12682. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12683. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12684. }
  12685. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12686. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12687. ServiceResultEntity sre = new ServiceResultEntity();
  12688. if (data == null || data.Rows.Count == 0)
  12689. {
  12690. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12691. return sre;
  12692. }
  12693. sre.Data = new DataSet();
  12694. sre.Data.Tables.Add(data);
  12695. return sre;
  12696. }
  12697. catch (Exception ex)
  12698. {
  12699. throw ex;
  12700. }
  12701. finally
  12702. {
  12703. if (conn != null &&
  12704. conn.ConnState == ConnectionState.Open)
  12705. {
  12706. conn.Close();
  12707. }
  12708. }
  12709. }
  12710. /// <summary>
  12711. /// 获取在产品备份表
  12712. /// </summary>
  12713. /// <param name="cre"></param>
  12714. /// <param name="sUserInfo"></param>
  12715. /// <returns></returns>
  12716. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12717. {
  12718. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12719. try
  12720. {
  12721. ServiceResultEntity sre = new ServiceResultEntity();
  12722. string sqlString = "SELECT inpb.BackupMonth\n" +
  12723. " ,gdd.BarCode\n" +
  12724. //" ,inpb.GoodsID\n" +
  12725. " ,inpb.GoodsCode\n" +
  12726. " ,inpb.GoodsName\n" +
  12727. //" ,inpb.Userid\n" +
  12728. " ,worker.USERNAME AS UserName\n" +
  12729. " ,worker.USERCode AS UserCode\n" +
  12730. //" ,inpb.ProductionLineID\n" +
  12731. " ,inpb.ProductionLineCode\n" +
  12732. " ,inpb.ProductionLineName\n" +
  12733. //" ,inpb.ModelType\n" +
  12734. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12735. " ,inpb.IsPublicBody\n" +
  12736. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12737. " ,inpb.IsReworkFlag\n" +
  12738. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12739. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12740. //" ,inpb.GroutingDailyID\n" +
  12741. //" ,inpb.GroutingDailyDetailID\n" +
  12742. " ,inpb.GroutingDate\n" +
  12743. //" ,inpb.GroutingLineID\n" +
  12744. " ,inpb.GroutingLineCode\n" +
  12745. " ,inpb.GroutingLineName\n" +
  12746. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12747. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12748. //" ,inpb.GMouldTypeID\n" +
  12749. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12750. //" ,inpb.GroutingLineDetailID\n" +
  12751. " ,inpb.GroutingMouldCode\n" +
  12752. " ,inpb.SPECIALREPAIRFLAG\n" +
  12753. " ,inpb.GROUTINGUSERCODE\n" +
  12754. " ,gdd.GROUTINGCOUNT\n" +
  12755. " ,gdd.delivertime\n" +
  12756. " ,inpb.proceduretime\n" +
  12757. " ,inpb.Remarks\n" +
  12758. //" ,inpb.GoodsLevelID\n" +
  12759. " ,mgl.GOODSLEVELNAME\n" +
  12760. //" ,inpb.GoodsLevelTypeID\n" +
  12761. " ,mglt.GOODSLEVELTYPENAME\n" +
  12762. " ,inpb.BackupTime\n" +
  12763. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12764. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12765. " ,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" +
  12766. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12767. " INNER JOIN TP_MST_User worker\n" +
  12768. " ON worker.UserID = inpb.Userid\n" +
  12769. " INNER JOIN TP_PC_Procedure pro\n" +
  12770. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12771. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12772. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12773. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12774. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12775. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12776. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12777. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12778. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12779. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12780. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12781. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12782. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12783. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12784. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12785. " LEFT JOIN TP_MST_Logo logo\n" +
  12786. " ON inpb.logoid = logo.logoid\n" +
  12787. " LEFT JOIN TP_MST_Goods Goods\n" +
  12788. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12789. " WHERE inpb.AccountID = :AccountID" +
  12790. " AND inpb.BackupMonth = :BackupMonth" +
  12791. " ORDER BY pro.displayno,inpb.proceduretime";
  12792. OracleParameter[] oracleParameter = new OracleParameter[]
  12793. {
  12794. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12795. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12796. };
  12797. oracleConn.Open();
  12798. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12799. oracleConn.Close();
  12800. sre.Data = result;
  12801. return sre;
  12802. }
  12803. catch (Exception ex)
  12804. {
  12805. if (oracleConn.ConnState == ConnectionState.Open)
  12806. {
  12807. oracleConn.Close();
  12808. }
  12809. throw ex;
  12810. }
  12811. }
  12812. /// <summary>
  12813. /// 产成品单值明细表
  12814. /// </summary>
  12815. /// <param name="cre"></param>
  12816. /// <param name="sUserInfo"></param>
  12817. /// <returns></returns>
  12818. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12819. {
  12820. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12821. try
  12822. {
  12823. string sql =
  12824. "SELECT up.id, up.NAME\n" +
  12825. " FROM tp_mst_unitprice up\n" +
  12826. " WHERE up.accountid = :AccountID\n" +
  12827. " AND up.valueflag = '1'\n" +
  12828. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12829. " ORDER BY up.displayno";
  12830. OracleParameter[] opara = new OracleParameter[]
  12831. {
  12832. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12833. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12834. };
  12835. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  12836. StringBuilder upNames = new StringBuilder();
  12837. StringBuilder upTotals = new StringBuilder();
  12838. StringBuilder upSUMs = new StringBuilder();
  12839. foreach (DataRow item in upTable.Rows)
  12840. {
  12841. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  12842. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  12843. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  12844. }
  12845. ServiceResultEntity sre = new ServiceResultEntity();
  12846. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  12847. " ,g.goodscode\n" +
  12848. " ,g.materialcode\n" +
  12849. " ,lg.logoname\n" +
  12850. " ,nvl(fpcount, 0) fpcount\n" +
  12851. // " ,u1 AS \"单值1\"\n" +
  12852. //" ,u2 AS \"单值2\"\n" +
  12853. upNames +
  12854. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  12855. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  12856. upTotals +
  12857. " FROM (SELECT up.goodsid\n" +
  12858. " ,up.logoid\n" +
  12859. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  12860. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  12861. upSUMs +
  12862. " FROM TP_MST_UnitPriceGoods up\n" +
  12863. " WHERE up.accountid = :AccountID\n" +
  12864. " GROUP BY up.goodsid, up.logoid) upg\n" +
  12865. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  12866. " FROM tp_pm_finishedproduct fp\n" +
  12867. " WHERE fp.accountid = :AccountID\n" +
  12868. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  12869. " AND (:GoodsCode IS NULL OR\n" +
  12870. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  12871. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  12872. " ON fpp.goodsid = upg.goodsid\n" +
  12873. " AND fpp.logoid = upg.logoid\n" +
  12874. " INNER JOIN tp_mst_logo lg\n" +
  12875. " ON lg.logoid = upg.logoid\n" +
  12876. " INNER JOIN tp_mst_goods g\n" +
  12877. " ON g.goodsid = upg.goodsid\n" +
  12878. " INNER JOIN tp_mst_goodstype gt\n" +
  12879. " ON gt.goodstypeid = g.goodstypeid\n" +
  12880. " INNER JOIN tp_mst_goodstype gt2\n" +
  12881. " ON gt2.accountid = :AccountID\n" +
  12882. " AND length(gt2.goodstypecode) = 6\n" +
  12883. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  12884. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  12885. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  12886. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  12887. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  12888. " ORDER BY g.goodscode, lg.displayno";
  12889. OracleParameter[] oracleParameter = new OracleParameter[]
  12890. {
  12891. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12892. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  12893. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  12894. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  12895. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  12896. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  12897. };
  12898. oracleConn.Open();
  12899. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12900. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  12901. {
  12902. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12903. }
  12904. sre.Data = result;
  12905. oracleConn.Close();
  12906. return sre;
  12907. }
  12908. catch (Exception ex)
  12909. {
  12910. if (oracleConn.ConnState == ConnectionState.Open)
  12911. {
  12912. oracleConn.Close();
  12913. }
  12914. throw ex;
  12915. }
  12916. }
  12917. /// <summary>
  12918. /// 产成品单值明细表-单值名管理
  12919. /// </summary>
  12920. /// <param name="cre"></param>
  12921. /// <param name="sUserInfo"></param>
  12922. /// <returns></returns>
  12923. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12924. {
  12925. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12926. try
  12927. {
  12928. ServiceResultEntity sre = new ServiceResultEntity();
  12929. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  12930. " FROM TP_MST_UnitPrice t\n" +
  12931. " WHERE t.accountid = :accountid\n" +
  12932. " ORDER BY t.id";
  12933. OracleParameter[] oracleParameter = new OracleParameter[]
  12934. {
  12935. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12936. };
  12937. oracleConn.Open();
  12938. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12939. oracleConn.Close();
  12940. return sre;
  12941. }
  12942. catch (Exception ex)
  12943. {
  12944. if (oracleConn.ConnState == ConnectionState.Open)
  12945. {
  12946. oracleConn.Close();
  12947. }
  12948. throw ex;
  12949. }
  12950. }
  12951. /// <summary>
  12952. /// 产成品单值明细表-单值名管理
  12953. /// </summary>
  12954. /// <param name="cre"></param>
  12955. /// <param name="sUserInfo"></param>
  12956. /// <returns></returns>
  12957. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12958. {
  12959. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12960. try
  12961. {
  12962. ServiceResultEntity sre = new ServiceResultEntity();
  12963. // 检验参数的有效性
  12964. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  12965. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  12966. {
  12967. return sre;
  12968. }
  12969. oracleTrConn.Connect();
  12970. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  12971. {
  12972. // 新建
  12973. if (dataRow.RowState == DataRowState.Added)
  12974. {
  12975. #region 新增
  12976. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  12977. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  12978. "VALUES\n" +
  12979. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  12980. OracleParameter[] oracleParameter = new OracleParameter[]
  12981. {
  12982. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  12983. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  12984. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  12985. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  12986. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  12987. };
  12988. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  12989. #endregion
  12990. }
  12991. else if (dataRow.RowState == DataRowState.Modified)
  12992. {
  12993. #region 更新
  12994. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  12995. + " Name = :Name,"
  12996. + " DisplayNo = :DisplayNo,"
  12997. + " ValueFlag = :ValueFlag,"
  12998. + " UpdateUserID = :UserID"
  12999. + " WHERE ID = :ID";
  13000. OracleParameter[] oracleParameter = new OracleParameter[]
  13001. {
  13002. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13003. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13004. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13005. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13006. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13007. };
  13008. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13009. #endregion
  13010. }
  13011. else if (dataRow.RowState == DataRowState.Deleted)
  13012. {
  13013. #region 删除
  13014. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13015. OracleParameter[] oracleParameter = new OracleParameter[]
  13016. {
  13017. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13018. };
  13019. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13020. #endregion
  13021. }
  13022. }
  13023. oracleTrConn.Commit();
  13024. oracleTrConn.Disconnect();
  13025. return sre;
  13026. }
  13027. catch (Exception ex)
  13028. {
  13029. if (oracleTrConn.ConnState == ConnectionState.Open)
  13030. {
  13031. oracleTrConn.Rollback();
  13032. oracleTrConn.Disconnect();
  13033. }
  13034. throw ex;
  13035. }
  13036. finally
  13037. {
  13038. if (oracleTrConn.ConnState == ConnectionState.Open)
  13039. {
  13040. oracleTrConn.Disconnect();
  13041. }
  13042. }
  13043. }
  13044. /// <summary>
  13045. /// 获取模具跟踪表
  13046. /// </summary>
  13047. /// <param name="cre"></param>
  13048. /// <param name="sUserInfo"></param>
  13049. /// <returns></returns>
  13050. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13051. {
  13052. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13053. try
  13054. {
  13055. ServiceResultEntity sre = new ServiceResultEntity();
  13056. OracleParameter[] oracleParameter = new OracleParameter[]
  13057. {
  13058. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13059. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13060. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13061. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13062. };
  13063. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13064. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13065. {
  13066. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13067. }
  13068. sre.Data = result;
  13069. return sre;
  13070. }
  13071. catch (Exception ex)
  13072. {
  13073. if (oracleConn.ConnState == ConnectionState.Open)
  13074. {
  13075. oracleConn.Close();
  13076. }
  13077. throw ex;
  13078. }
  13079. }
  13080. /// <summary>
  13081. /// 获取模具收发存汇总表
  13082. /// </summary>
  13083. /// <param name="cre"></param>
  13084. /// <param name="sUserInfo"></param>
  13085. /// <returns></returns>
  13086. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13087. {
  13088. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13089. try
  13090. {
  13091. ServiceResultEntity sre = new ServiceResultEntity();
  13092. OracleParameter[] oracleParameter = new OracleParameter[]
  13093. {
  13094. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13095. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13096. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13097. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13098. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13099. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13100. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13101. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13102. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13103. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13104. };
  13105. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13106. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13107. {
  13108. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13109. }
  13110. sre.Data = result;
  13111. oracleConn.Commit();
  13112. return sre;
  13113. }
  13114. catch (Exception ex)
  13115. {
  13116. if (oracleConn.ConnState == ConnectionState.Open)
  13117. {
  13118. oracleConn.Disconnect();
  13119. }
  13120. throw ex;
  13121. }
  13122. }
  13123. /// <summary>
  13124. /// 获取废弃产品汇总表
  13125. /// </summary>
  13126. /// <param name="cre"></param>
  13127. /// <param name="sUserInfo"></param>
  13128. /// <returns></returns>
  13129. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13130. {
  13131. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13132. try
  13133. {
  13134. ServiceResultEntity sre = new ServiceResultEntity();
  13135. OracleParameter[] oracleParameter = new OracleParameter[]
  13136. {
  13137. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13138. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13139. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13140. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13141. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13142. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13143. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13144. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13145. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13146. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13147. };
  13148. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13149. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13150. {
  13151. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13152. }
  13153. sre.Data = result;
  13154. oracleConn.Commit();
  13155. return sre;
  13156. }
  13157. catch (Exception ex)
  13158. {
  13159. if (oracleConn.ConnState == ConnectionState.Open)
  13160. {
  13161. oracleConn.Disconnect();
  13162. }
  13163. throw ex;
  13164. }
  13165. }
  13166. /// <summary>
  13167. /// 获取废品损失汇总表
  13168. /// </summary>
  13169. /// <param name="cre"></param>
  13170. /// <param name="sUserInfo"></param>
  13171. /// <returns></returns>
  13172. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13173. {
  13174. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13175. try
  13176. {
  13177. ServiceResultEntity sre = new ServiceResultEntity();
  13178. OracleParameter[] oracleParameter = new OracleParameter[]
  13179. {
  13180. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13181. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13182. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13183. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13184. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13185. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13186. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13187. };
  13188. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13189. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13190. {
  13191. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13192. }
  13193. sre.Data = result;
  13194. oracleConn.Commit();
  13195. return sre;
  13196. }
  13197. catch (Exception ex)
  13198. {
  13199. if (oracleConn.ConnState == ConnectionState.Open)
  13200. {
  13201. oracleConn.Disconnect();
  13202. }
  13203. throw ex;
  13204. }
  13205. }
  13206. /// <summary>
  13207. /// 获取废品损失汇总-明细表
  13208. /// </summary>
  13209. /// <param name="cre"></param>
  13210. /// <param name="sUserInfo"></param>
  13211. /// <returns></returns>
  13212. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13213. {
  13214. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13215. try
  13216. {
  13217. ServiceResultEntity sre = new ServiceResultEntity();
  13218. OracleParameter[] oracleParameter = new OracleParameter[]
  13219. {
  13220. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13221. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13222. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13223. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13224. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13225. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13226. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13227. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13228. };
  13229. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13230. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13231. {
  13232. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13233. }
  13234. sre.Data = result;
  13235. oracleConn.Commit();
  13236. return sre;
  13237. }
  13238. catch (Exception ex)
  13239. {
  13240. if (oracleConn.ConnState == ConnectionState.Open)
  13241. {
  13242. oracleConn.Disconnect();
  13243. }
  13244. throw ex;
  13245. }
  13246. }
  13247. /// <summary>
  13248. /// 获取废品损失汇总表-半成品损失汇总表
  13249. /// </summary>
  13250. /// <param name="cre"></param>
  13251. /// <param name="sUserInfo"></param>
  13252. /// <returns></returns>
  13253. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13254. {
  13255. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13256. try
  13257. {
  13258. ServiceResultEntity sre = new ServiceResultEntity();
  13259. OracleParameter[] oracleParameter = new OracleParameter[]
  13260. {
  13261. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13262. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13263. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13264. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13265. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13266. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13267. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13268. };
  13269. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13270. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13271. {
  13272. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13273. }
  13274. StringBuilder cols = new StringBuilder();
  13275. StringBuilder sumCols = new StringBuilder();
  13276. foreach (DataRow item in result.Tables[0].Rows)
  13277. {
  13278. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13279. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13280. }
  13281. string sqlString = "SELECT gid\n" +
  13282. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13283. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13284. " ,gg.gc\n" +
  13285. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13286. " ,d\n" +
  13287. " ,c\n" +
  13288. " ,d-c g\n" +
  13289. cols +
  13290. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13291. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13292. " ,t.tecdepname gt2name\n" +
  13293. " ,td2.name td2name\n" +
  13294. " ,td2.displayno td2displayno\n" +
  13295. " ,SUM(g.d) d\n" +
  13296. " ,SUM(g.c) c\n" +
  13297. sumCols +
  13298. " FROM TMP_RPT_TECDEP_G g\n" +
  13299. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13300. " ON g.goodsid = t.goodsid\n" +
  13301. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13302. " ON s1.procedureid = g.pid\n" +
  13303. " INNER JOIN tp_mst_tecdep td1\n" +
  13304. " ON td1.id = s1.intecdepid\n" +
  13305. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13306. " ON s2.procedureid = g.f\n" +
  13307. " LEFT JOIN tp_mst_tecdep td2\n" +
  13308. " ON td2.id = s2.intecdepid\n" +
  13309. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13310. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13311. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13312. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13313. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13314. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13315. " FROM tp_pm_groutingdailydetail gdd\n" +
  13316. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13317. " ON gdd.goodsid = t.goodsid\n" +
  13318. " WHERE gdd.accountid = :in_accountid\n" +
  13319. " AND gdd.valueflag = '1'\n" +
  13320. " AND gdd.groutingflag = '1'\n" +
  13321. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13322. " :in_datetimeend\n" +
  13323. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13324. " ON gg.gt2id = tt.gt2id\n" +
  13325. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13326. oracleParameter = new OracleParameter[]
  13327. {
  13328. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13329. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13330. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13331. };
  13332. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13333. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13334. {
  13335. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13336. }
  13337. sre.Data = result;
  13338. oracleConn.Commit();
  13339. return sre;
  13340. }
  13341. catch (Exception ex)
  13342. {
  13343. if (oracleConn.ConnState == ConnectionState.Open)
  13344. {
  13345. oracleConn.Disconnect();
  13346. }
  13347. throw ex;
  13348. }
  13349. }
  13350. /// <summary>
  13351. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13352. /// </summary>
  13353. /// <param name="cre"></param>
  13354. /// <param name="sUserInfo"></param>
  13355. /// <returns></returns>
  13356. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13357. {
  13358. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13359. try
  13360. {
  13361. ServiceResultEntity sre = new ServiceResultEntity();
  13362. /*
  13363. string sqlString =
  13364. "SELECT gdrd.goodsid\n" +
  13365. " ,gdrd.goodscode\n" +
  13366. //" ,gdrd.groutinglineid\n" +
  13367. //" ,gdrd.groutinglinecode\n" +
  13368. //" ,gdrd.userid\n" +
  13369. //" ,gdrd.usercode\n" +
  13370. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13371. " ,rdd.gldcount -- 模具数\n" +
  13372. " , CASE\n" +
  13373. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13374. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13375. " ELSE\n" +
  13376. " NULL\n" +
  13377. " END rddays -- 存坯天数\n" +
  13378. " ,gdrd.reserveddays -- 应存天数\n" +
  13379. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13380. " FROM (SELECT gdd.goodsid\n" +
  13381. " ,gdd.goodscode\n" +
  13382. //" ,gdd.groutinglineid\n" +
  13383. //" ,gdd.groutinglinecode\n" +
  13384. //" ,gdd.userid\n" +
  13385. //" ,gdd.usercode\n" +
  13386. " ,g.reserveddays\n" +
  13387. " ,COUNT(*) gddc\n" +
  13388. " FROM tp_pm_groutingdailydetail gdd\n" +
  13389. " INNER JOIN tp_mst_goods g\n" +
  13390. " ON g.goodsid = gdd.goodsid\n" +
  13391. " INNER JOIN tp_mst_goodstype gt\n" +
  13392. " ON g.goodstypeid = gt.goodstypeid\n" +
  13393. " WHERE gdd.accountid = :accountid\n" +
  13394. " AND gdd.valueflag = '1'\n" +
  13395. " AND gdd.groutingflag = '1'\n" +
  13396. " AND gdd.barcode IS NOT NULL\n" +
  13397. " AND gdd.scrapflag = '0'\n" +
  13398. " AND gdd.deliverflag = '0'\n" +
  13399. " AND (:LineCode IS NULL OR\n" +
  13400. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13401. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13402. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13403. " AND (:GoodsTypeCode IS NULL OR\n" +
  13404. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13405. " AND (:DateBegin IS NULL OR\n" +
  13406. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13407. " GROUP BY gdd.goodsid\n" +
  13408. " ,gdd.goodscode\n" +
  13409. //" ,gdd.groutinglineid\n" +
  13410. //" ,gdd.groutinglinecode\n" +
  13411. //" ,gdd.userid\n" +
  13412. //" ,gdd.usercode\n" +
  13413. " ,g.reserveddays) gdrd\n" +
  13414. " LEFT JOIN (SELECT gld.goodsid\n" +
  13415. //" ,gld.groutinglineid\n" +
  13416. " ,COUNT(*) gldcount\n" +
  13417. " FROM tp_pc_groutinglinedetail gld\n" +
  13418. " INNER JOIN tp_pc_groutingline gl\n" +
  13419. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13420. " WHERE gld.valueflag = '1'\n" +
  13421. " AND gld.gmouldstatus = 1\n" +
  13422. " AND gl.accountid = :accountid\n" +
  13423. " AND gl.valueflag = '1'\n" +
  13424. " AND gl.gmouldstatus = 1\n" +
  13425. " GROUP BY gld.goodsid\n" +
  13426. //" ,gld.groutinglineid\n" +
  13427. " ) rdd\n" +
  13428. " ON rdd.goodsid = gdrd.goodsid\n" +
  13429. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13430. " ORDER BY gdrd.goodscode\n" +
  13431. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13432. "";
  13433. */
  13434. string sqlString =
  13435. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13436. " ,t.goodstypecode2\n" +
  13437. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13438. " 3,\n" +
  13439. " '总计',\n" +
  13440. " 1,\n" +
  13441. " '合计[' || t.goodstypename2 || ']',\n" +
  13442. " t.goodstypename2) goodstypename2\n" +
  13443. " ,t.goodstypename\n" +
  13444. " ,t.goodsid\n" +
  13445. " ,t.goodscode\n" +
  13446. //" ,t.groutinglineid\n" +
  13447. //" ,t.groutinglinecode\n" +
  13448. //" ,t.userid\n" +
  13449. //" ,t.usercode\n" +
  13450. " ,SUM(t.rdcount) rdcount\n" +
  13451. " ,t.gldcount -- 模具数\n" +
  13452. " ,t.rddays -- 存坯天数\n" +
  13453. " ,t.reserveddays -- 应存天数\n" +
  13454. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13455. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13456. " ,gt2.goodstypename goodstypename2\n" +
  13457. " ,gdrd.goodsid\n" +
  13458. " ,gdrd.goodscode\n" +
  13459. " ,gdrd.goodstypename\n" +
  13460. //" ,gdrd.groutinglineid\n" +
  13461. //" ,gdrd.groutinglinecode\n" +
  13462. //" ,gdrd.userid\n" +
  13463. //" ,gdrd.usercode\n" +
  13464. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13465. " ,rdd.gldcount -- 模具数\n" +
  13466. " , CASE\n" +
  13467. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13468. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13469. " ELSE\n" +
  13470. " NULL\n" +
  13471. " END rddays -- 存坯天数\n" +
  13472. " ,gdrd.reserveddays -- 应存天数\n" +
  13473. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13474. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13475. " FROM (SELECT gdd.goodsid\n" +
  13476. " ,gdd.goodscode\n" +
  13477. //" ,gdd.groutinglineid\n" +
  13478. //" ,gdd.groutinglinecode\n" +
  13479. //" ,gdd.userid\n" +
  13480. //" ,gdd.usercode\n" +
  13481. " ,g.reserveddays\n" +
  13482. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13483. " ,gt.goodstypename\n" +
  13484. " ,COUNT(*) gddc\n" +
  13485. " FROM tp_pm_groutingdailydetail gdd\n" +
  13486. " INNER JOIN tp_mst_goods g\n" +
  13487. " ON g.goodsid = gdd.goodsid\n" +
  13488. " INNER JOIN tp_mst_goodstype gt\n" +
  13489. " ON g.goodstypeid = gt.goodstypeid\n" +
  13490. " WHERE gdd.accountid = :accountid\n" +
  13491. " AND gdd.valueflag = '1'\n" +
  13492. " AND gdd.groutingflag = '1'\n" +
  13493. " AND gdd.barcode IS NOT NULL\n" +
  13494. " AND gdd.scrapflag = '0'\n" +
  13495. " AND gdd.deliverflag = '0'\n" +
  13496. " AND (:LineCode IS NULL OR\n" +
  13497. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13498. " AND (:UserCode IS NULL OR\n" +
  13499. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13500. " AND (:GoodsCode IS NULL OR\n" +
  13501. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13502. " AND (:GoodsTypeCode IS NULL OR\n" +
  13503. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13504. " AND (:DateBegin IS NULL OR\n" +
  13505. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13506. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13507. " ,gdd.goodsid\n" +
  13508. " ,gdd.goodscode\n" +
  13509. //" ,gdd.groutinglineid\n" +
  13510. //" ,gdd.groutinglinecode\n" +
  13511. //" ,gdd.userid\n" +
  13512. //" ,gdd.usercode\n" +
  13513. " ,g.reserveddays) gdrd\n" +
  13514. " LEFT JOIN (SELECT gld.goodsid\n" +
  13515. //" ,gld.groutinglineid\n" +
  13516. " ,COUNT(*) gldcount\n" +
  13517. " FROM tp_pc_groutinglinedetail gld\n" +
  13518. " INNER JOIN tp_pc_groutingline gl\n" +
  13519. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13520. " WHERE gld.valueflag = '1'\n" +
  13521. " AND gld.gmouldstatus = 1\n" +
  13522. " AND gl.accountid = :accountid\n" +
  13523. " AND gl.valueflag = '1'\n" +
  13524. " AND gl.gmouldstatus = 1\n" +
  13525. " GROUP BY gld.goodsid\n" +
  13526. //" , gld.groutinglineid" +
  13527. " ) rdd\n" +
  13528. " ON rdd.goodsid = gdrd.goodsid\n" +
  13529. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13530. " INNER JOIN tp_mst_goodstype gt2\n" +
  13531. " ON gt2.accountid = :accountid\n" +
  13532. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13533. " ORDER BY gt2.goodstypecode\n" +
  13534. " ,gdrd.goodscode\n" +
  13535. //" ,gdrd.groutinglinecode\n" +
  13536. //" ,gdrd.usercode" +
  13537. " ) t\n" +
  13538. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13539. OracleParameter[] oracleParameter = new OracleParameter[]
  13540. {
  13541. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13542. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13543. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13544. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13545. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13546. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13547. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13548. };
  13549. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13550. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13551. {
  13552. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13553. }
  13554. sre.Data = result;
  13555. return sre;
  13556. }
  13557. catch (Exception ex)
  13558. {
  13559. if (oracleConn.ConnState == ConnectionState.Open)
  13560. {
  13561. oracleConn.Close();
  13562. }
  13563. throw ex;
  13564. }
  13565. }
  13566. /// <summary>
  13567. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13568. /// </summary>
  13569. /// <param name="cre"></param>
  13570. /// <param name="sUserInfo"></param>
  13571. /// <returns></returns>
  13572. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13573. {
  13574. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13575. try
  13576. {
  13577. ServiceResultEntity sre = new ServiceResultEntity();
  13578. /*
  13579. string sqlString =
  13580. "SELECT gdrd.goodsid\n" +
  13581. " ,gdrd.goodscode\n" +
  13582. " ,gdrd.groutinglineid\n" +
  13583. " ,gdrd.groutinglinecode\n" +
  13584. " ,gdrd.userid\n" +
  13585. " ,gdrd.usercode\n" +
  13586. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13587. " ,rdd.gldcount -- 模具数\n" +
  13588. " , CASE\n" +
  13589. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13590. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13591. " ELSE\n" +
  13592. " NULL\n" +
  13593. " END rddays -- 存坯天数\n" +
  13594. " ,gdrd.reserveddays -- 应存天数\n" +
  13595. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13596. " FROM (SELECT gdd.goodsid\n" +
  13597. " ,gdd.goodscode\n" +
  13598. " ,gdd.groutinglineid\n" +
  13599. " ,gdd.groutinglinecode\n" +
  13600. " ,gdd.userid\n" +
  13601. " ,gdd.usercode\n" +
  13602. " ,g.reserveddays\n" +
  13603. " ,COUNT(*) gddc\n" +
  13604. " FROM tp_pm_groutingdailydetail gdd\n" +
  13605. " INNER JOIN tp_mst_goods g\n" +
  13606. " ON g.goodsid = gdd.goodsid\n" +
  13607. " INNER JOIN tp_mst_goodstype gt\n" +
  13608. " ON g.goodstypeid = gt.goodstypeid\n" +
  13609. " WHERE gdd.accountid = :accountid\n" +
  13610. " AND gdd.valueflag = '1'\n" +
  13611. " AND gdd.groutingflag = '1'\n" +
  13612. " AND gdd.barcode IS NOT NULL\n" +
  13613. " AND gdd.scrapflag = '0'\n" +
  13614. " AND gdd.deliverflag = '0'\n" +
  13615. " AND (:LineCode IS NULL OR\n" +
  13616. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13617. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13618. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13619. " AND (:GoodsTypeCode IS NULL OR\n" +
  13620. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13621. " AND (:DateBegin IS NULL OR\n" +
  13622. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13623. " GROUP BY gdd.goodsid\n" +
  13624. " ,gdd.goodscode\n" +
  13625. " ,gdd.groutinglineid\n" +
  13626. " ,gdd.groutinglinecode\n" +
  13627. " ,gdd.userid\n" +
  13628. " ,gdd.usercode\n" +
  13629. " ,g.reserveddays) gdrd\n" +
  13630. " LEFT JOIN (SELECT gld.goodsid\n" +
  13631. " ,gld.groutinglineid\n" +
  13632. " ,COUNT(*) gldcount\n" +
  13633. " FROM tp_pc_groutinglinedetail gld\n" +
  13634. " INNER JOIN tp_pc_groutingline gl\n" +
  13635. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13636. " WHERE gld.valueflag = '1'\n" +
  13637. " AND gld.gmouldstatus = 1\n" +
  13638. " AND gl.accountid = :accountid\n" +
  13639. " AND gl.valueflag = '1'\n" +
  13640. " AND gl.gmouldstatus = 1\n" +
  13641. " GROUP BY gld.goodsid\n" +
  13642. " ,gld.groutinglineid\n" +
  13643. " ) rdd\n" +
  13644. " ON rdd.goodsid = gdrd.goodsid\n" +
  13645. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13646. " ORDER BY gdrd.goodscode\n" +
  13647. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13648. "";
  13649. */
  13650. string sqlString =
  13651. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13652. " ,t.goodstypecode2\n" +
  13653. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13654. " 3,\n" +
  13655. " '总计',\n" +
  13656. " 1,\n" +
  13657. " '合计[' || t.goodstypename2 || ']',\n" +
  13658. " t.goodstypename2) goodstypename2\n" +
  13659. " ,t.goodsid\n" +
  13660. " ,t.goodscode\n" +
  13661. " ,t.groutinglineid\n" +
  13662. " ,t.groutinglinecode\n" +
  13663. " ,t.userid\n" +
  13664. " ,t.usercode\n" +
  13665. " ,SUM(t.rdcount) rdcount\n" +
  13666. " ,t.gldcount -- 模具数\n" +
  13667. " ,t.rddays -- 存坯天数\n" +
  13668. " ,t.reserveddays -- 应存天数\n" +
  13669. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13670. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13671. " ,gt2.goodstypename goodstypename2\n" +
  13672. " ,gdrd.goodsid\n" +
  13673. " ,gdrd.goodscode\n" +
  13674. " ,gdrd.groutinglineid\n" +
  13675. " ,gdrd.groutinglinecode\n" +
  13676. " ,gdrd.userid\n" +
  13677. " ,gdrd.usercode\n" +
  13678. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13679. " ,rdd.gldcount -- 模具数\n" +
  13680. " , CASE\n" +
  13681. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13682. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13683. " ELSE\n" +
  13684. " NULL\n" +
  13685. " END rddays -- 存坯天数\n" +
  13686. " ,gdrd.reserveddays -- 应存天数\n" +
  13687. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13688. " FROM (SELECT gdd.goodsid\n" +
  13689. " ,gdd.goodscode\n" +
  13690. " ,gdd.groutinglineid\n" +
  13691. " ,gdd.groutinglinecode\n" +
  13692. " ,gdd.userid\n" +
  13693. " ,gdd.usercode\n" +
  13694. " ,g.reserveddays\n" +
  13695. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13696. " ,COUNT(*) gddc\n" +
  13697. " FROM tp_pm_groutingdailydetail gdd\n" +
  13698. " INNER JOIN tp_mst_goods g\n" +
  13699. " ON g.goodsid = gdd.goodsid\n" +
  13700. " INNER JOIN tp_mst_goodstype gt\n" +
  13701. " ON g.goodstypeid = gt.goodstypeid\n" +
  13702. " WHERE gdd.accountid = :accountid\n" +
  13703. " AND gdd.valueflag = '1'\n" +
  13704. " AND gdd.groutingflag = '1'\n" +
  13705. " AND gdd.barcode IS NOT NULL\n" +
  13706. " AND gdd.scrapflag = '0'\n" +
  13707. " AND gdd.deliverflag = '0'\n" +
  13708. " AND (:LineCode IS NULL OR\n" +
  13709. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13710. " AND (:UserCode IS NULL OR\n" +
  13711. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13712. " AND (:GoodsCode IS NULL OR\n" +
  13713. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13714. " AND (:GoodsTypeCode IS NULL OR\n" +
  13715. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13716. " AND (:DateBegin IS NULL OR\n" +
  13717. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13718. " GROUP BY gt.goodstypecode\n" +
  13719. " ,gdd.goodsid\n" +
  13720. " ,gdd.goodscode\n" +
  13721. " ,gdd.groutinglineid\n" +
  13722. " ,gdd.groutinglinecode\n" +
  13723. " ,gdd.userid\n" +
  13724. " ,gdd.usercode\n" +
  13725. " ,g.reserveddays) gdrd\n" +
  13726. " LEFT JOIN (SELECT gld.goodsid\n" +
  13727. " ,gld.groutinglineid\n" +
  13728. " ,COUNT(*) gldcount\n" +
  13729. " FROM tp_pc_groutinglinedetail gld\n" +
  13730. " INNER JOIN tp_pc_groutingline gl\n" +
  13731. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13732. " WHERE gld.valueflag = '1'\n" +
  13733. " AND gld.gmouldstatus = 1\n" +
  13734. " AND gl.accountid = :accountid\n" +
  13735. " AND gl.valueflag = '1'\n" +
  13736. " AND gl.gmouldstatus = 1\n" +
  13737. " GROUP BY gld.goodsid, gld.groutinglineid) rdd\n" +
  13738. " ON rdd.goodsid = gdrd.goodsid\n" +
  13739. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13740. " INNER JOIN tp_mst_goodstype gt2\n" +
  13741. " ON gt2.accountid = :accountid\n" +
  13742. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13743. " ORDER BY gt2.goodstypecode\n" +
  13744. " ,gdrd.goodscode\n" +
  13745. " ,gdrd.groutinglinecode\n" +
  13746. " ,gdrd.usercode) t\n" +
  13747. " 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),())";
  13748. OracleParameter[] oracleParameter = new OracleParameter[]
  13749. {
  13750. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13751. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13752. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13753. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13754. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13755. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13756. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13757. };
  13758. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13759. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13760. {
  13761. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13762. }
  13763. sre.Data = result;
  13764. return sre;
  13765. }
  13766. catch (Exception ex)
  13767. {
  13768. if (oracleConn.ConnState == ConnectionState.Open)
  13769. {
  13770. oracleConn.Close();
  13771. }
  13772. throw ex;
  13773. }
  13774. }
  13775. /// <summary>
  13776. /// 获取成型存坯汇总表-成型存坯明细表
  13777. /// </summary>
  13778. /// <param name="cre"></param>
  13779. /// <param name="sUserInfo"></param>
  13780. /// <returns></returns>
  13781. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13782. {
  13783. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13784. try
  13785. {
  13786. ServiceResultEntity sre = new ServiceResultEntity();
  13787. string sqlString = "SELECT gdd.barcode\n" +
  13788. //" ,gdd.groutinglineid\n" +
  13789. " ,gdd.groutinglinecode\n" +
  13790. " ,gdd.GroutingMouldCode\n" +
  13791. //" ,gdd.goodsid\n" +
  13792. " ,gdd.goodscode\n" +
  13793. //" ,gdd.userid\n" +
  13794. " ,gdd.usercode\n" +
  13795. " ,gdd.groutingdate\n" +
  13796. " FROM tp_pm_groutingdailydetail gdd\n" +
  13797. " INNER JOIN tp_mst_goods g\n" +
  13798. " ON g.goodsid = gdd.goodsid\n" +
  13799. " INNER JOIN tp_mst_goodstype gt\n" +
  13800. " ON g.goodstypeid = gt.goodstypeid\n" +
  13801. " WHERE gdd.accountid = :accountid\n" +
  13802. " AND gdd.valueflag = '1'\n" +
  13803. " AND gdd.groutingflag = '1'\n" +
  13804. " AND gdd.barcode IS NOT NULL\n" +
  13805. " AND gdd.scrapflag = '0'\n" +
  13806. " AND gdd.deliverflag = '0'\n" +
  13807. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13808. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13809. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13810. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13811. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13812. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13813. " AND (:GoodsTypeCode IS NULL OR\n" +
  13814. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13815. " AND (:DateBegin IS NULL OR\n" +
  13816. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13817. " ORDER BY gdd.barcode\n" +
  13818. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13819. "";
  13820. OracleParameter[] oracleParameter = new OracleParameter[]
  13821. {
  13822. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13823. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13824. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13825. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13826. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13827. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13828. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13829. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13830. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  13831. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  13832. };
  13833. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13834. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13835. {
  13836. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13837. }
  13838. sre.Data = result;
  13839. return sre;
  13840. }
  13841. catch (Exception ex)
  13842. {
  13843. if (oracleConn.ConnState == ConnectionState.Open)
  13844. {
  13845. oracleConn.Close();
  13846. }
  13847. throw ex;
  13848. }
  13849. }
  13850. /// <summary>
  13851. /// 年度各工序月产量统计表
  13852. /// </summary>
  13853. /// <param name="cre"></param>
  13854. /// <param name="sUserInfo"></param>
  13855. /// <returns></returns>
  13856. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13857. {
  13858. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13859. try
  13860. {
  13861. ServiceResultEntity sre = new ServiceResultEntity();
  13862. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  13863. string sqlString = "select gt2.goodstypecode\n" +
  13864. " ,nvl2(gt2.goodstypename\n" +
  13865. " ,nvl2(t.procedureid\n" +
  13866. " ,gt2.goodstypename\n" +
  13867. " ,'小计[' || gt2.goodstypename || ']')\n" +
  13868. " ,'总计') goodstypename\n" +
  13869. " ,p.displayno\n" +
  13870. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  13871. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  13872. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  13873. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  13874. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  13875. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  13876. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  13877. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  13878. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  13879. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  13880. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  13881. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  13882. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  13883. " ,sum(t.pcount) msum\n" +
  13884. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13885. " gt.goodstypecode\n" +
  13886. " ,0 procedureid\n" +
  13887. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  13888. " ,count(*) pcount\n" +
  13889. " from tp_pm_groutingdailydetail pd\n" +
  13890. " inner join tp_mst_goods g\n" +
  13891. " on g.goodsid = pd.goodsid\n" +
  13892. " inner join tp_mst_goodstype gt\n" +
  13893. " on gt.goodstypeid = g.goodstypeid\n" +
  13894. " where pd.accountid = :accountid\n" +
  13895. " and pd.groutingflag = '1'\n" +
  13896. " and pd.groutingdate >= :begindate\n" +
  13897. " and pd.groutingdate < :enddate\n" +
  13898. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13899. " gt.goodstypecode\n" +
  13900. " ,to_char(pd.groutingdate, 'mm')\n" +
  13901. " union all\n" +
  13902. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13903. " gt.goodstypecode\n" +
  13904. " ,pd.procedureid\n" +
  13905. " ,to_char(pd.createtime, 'mm') mm\n" +
  13906. " ,count(*) pcount\n" +
  13907. " from tp_pm_productiondata pd\n" +
  13908. " inner join tp_mst_goods g\n" +
  13909. " on g.goodsid = pd.goodsid\n" +
  13910. " inner join tp_mst_goodstype gt\n" +
  13911. " on gt.goodstypeid = g.goodstypeid\n" +
  13912. " where pd.accountid = :accountid\n" +
  13913. " and pd.createtime >= :begindate\n" +
  13914. " and pd.createtime < :enddate\n" +
  13915. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13916. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13917. " gt.goodstypecode\n" +
  13918. " ,pd.procedureid\n" +
  13919. " ,to_char(pd.createtime, 'mm')" +
  13920. " union all\n" +
  13921. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13922. " gt.goodstypecode\n" +
  13923. " ,pd.procedureid\n" +
  13924. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  13925. " ,count(*) pcount\n" +
  13926. " from tp_pm_productiondata pd\n" +
  13927. " inner join tp_mst_goods g\n" +
  13928. " on g.goodsid = pd.goodsid\n" +
  13929. " inner join tp_mst_goodstype gt\n" +
  13930. " on gt.goodstypeid = g.goodstypeid\n" +
  13931. " where pd.accountid = :accountid\n" +
  13932. " and pd.valueflag = '0'\n" +
  13933. " and pd.BACKOUTTIME >= :begindate\n" +
  13934. " and pd.BACKOUTTIME < :enddate\n" +
  13935. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13936. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13937. " gt.goodstypecode\n" +
  13938. " ,pd.procedureid\n" +
  13939. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  13940. " inner join tp_mst_goodstype gt2\n" +
  13941. " on gt2.accountid = 1\n" +
  13942. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  13943. " left join tp_pc_procedure p\n" +
  13944. " on p.procedureid = t.procedureid\n" +
  13945. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  13946. OracleParameter[] oracleParameter = new OracleParameter[]
  13947. {
  13948. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13949. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13950. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13951. };
  13952. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13953. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13954. {
  13955. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13956. }
  13957. sre.Data = result;
  13958. return sre;
  13959. }
  13960. catch (Exception ex)
  13961. {
  13962. throw ex;
  13963. }
  13964. finally
  13965. {
  13966. oracleConn?.Close();
  13967. }
  13968. }
  13969. /// <summary>
  13970. /// 半检返修缺陷汇总表
  13971. /// </summary>
  13972. /// <param name="cre"></param>
  13973. /// <param name="sUserInfo"></param>
  13974. /// <returns></returns>
  13975. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13976. {
  13977. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13978. try
  13979. {
  13980. ServiceResultEntity sre = new ServiceResultEntity();
  13981. string sqlString = "select dp.defectpositionid\n" +
  13982. " ,dp.defectpositioncode\n" +
  13983. " ,dp.defectpositionname\n" +
  13984. " ,'D_' || dp.defectpositionid colname\n" +
  13985. " from tp_mst_scdefectposition dp\n" +
  13986. " where dp.valueflag = '1'\n" +
  13987. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  13988. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  13989. {
  13990. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  13991. }
  13992. sqlString += " order by dp.displayno";
  13993. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  13994. if (scdTable == null || scdTable.Rows.Count == 0)
  13995. {
  13996. return sre;
  13997. }
  13998. List<string> pivotFor = new List<string>();
  13999. foreach (DataRow item in scdTable.Rows)
  14000. {
  14001. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14002. }
  14003. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14004. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14005. sqlString = "select *\n" +
  14006. " from (select srd.defectid\n" +
  14007. " ,scd.defectcode\n" +
  14008. " ,scd.defectname\n" +
  14009. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14010. " ,count(srd.semireworkdefectid) cc\n" +
  14011. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14012. " inner join TP_PM_SEMIREWORK sr\n" +
  14013. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14014. " left join tp_mst_semicheckdefect scd\n" +
  14015. " on scd.defectid = srd.defectid\n" +
  14016. " left join tp_mst_scdefectposition scdp\n" +
  14017. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14018. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14019. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14020. " where srd.valueflag = '1'\n" +
  14021. " and sr.BACKOUTFLAG = '0'\n" +
  14022. " and sr.valueflag = '1'\n" +
  14023. " and sr.accountid = :accountid\n";
  14024. // 半检日期
  14025. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14026. {
  14027. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14028. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14029. }
  14030. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14031. {
  14032. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14033. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14034. }
  14035. // 产品编码 GOODSCODE
  14036. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14037. {
  14038. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14039. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14040. }
  14041. // 成型工号 GROUTINGUSERCODE
  14042. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14043. {
  14044. //xuwei modify 2019-11-13
  14045. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14046. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14047. //xuwei end
  14048. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14049. }
  14050. // 半检工号 SEMIREWORKUSERCODE
  14051. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14052. {
  14053. //xuwei modify 2019-11-13
  14054. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14055. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14056. //xuwei end
  14057. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14058. }
  14059. // 缺陷位置 scdp.defectpositionname
  14060. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14061. {
  14062. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14063. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14064. }
  14065. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14066. {
  14067. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14068. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14069. }
  14070. // 缺陷名称 scd.defectname
  14071. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14072. {
  14073. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14074. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14075. }
  14076. // 缺陷编码 scd.defectcode
  14077. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14078. {
  14079. sqlString += " and scd.defectcode = :defectcode \n";
  14080. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14081. }
  14082. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14083. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14084. {
  14085. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14086. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14087. }
  14088. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14089. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14090. {
  14091. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14092. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14093. }
  14094. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14095. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14096. {
  14097. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14098. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14099. }
  14100. sqlString +=
  14101. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid))) t\n" +
  14102. "pivot(sum(cc)\n" +
  14103. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14104. " order by defectid";
  14105. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14106. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14107. {
  14108. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14109. return sre;
  14110. }
  14111. DataTable table = result.Tables[0];
  14112. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14113. dataRow["defectname"] = "合计";
  14114. foreach (DataRow item in scdTable.Rows)
  14115. {
  14116. string colname = item["colname"] + "";
  14117. if (table.Columns.Contains(colname))
  14118. {
  14119. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14120. {
  14121. table.Columns.Remove(colname);
  14122. }
  14123. else
  14124. {
  14125. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14126. }
  14127. }
  14128. }
  14129. table.Columns["D_0"].Caption = "合计";
  14130. sre.Data = result;
  14131. return sre;
  14132. }
  14133. catch (Exception ex)
  14134. {
  14135. throw ex;
  14136. }
  14137. finally
  14138. {
  14139. oracleConn?.Close();
  14140. }
  14141. }
  14142. /// <summary>
  14143. /// 模具注浆分析表
  14144. /// </summary>
  14145. /// <param name="cre"></param>
  14146. /// <param name="sUserInfo"></param>
  14147. /// <returns></returns>
  14148. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14149. {
  14150. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14151. try
  14152. {
  14153. ServiceResultEntity sre = new ServiceResultEntity();
  14154. OracleParameter[] oracleParameter = new OracleParameter[]
  14155. {
  14156. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14157. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14158. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14159. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14160. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14161. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14162. };
  14163. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14164. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14165. {
  14166. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14167. }
  14168. sre.Data = result;
  14169. oracleConn.Commit();
  14170. return sre;
  14171. }
  14172. catch (Exception ex)
  14173. {
  14174. if (oracleConn.ConnState == ConnectionState.Open)
  14175. {
  14176. oracleConn.Disconnect();
  14177. }
  14178. throw ex;
  14179. }
  14180. }
  14181. /// <summary>
  14182. /// 成检产品预算分析表
  14183. /// </summary>
  14184. /// <param name="cre"></param>
  14185. /// <param name="sUserInfo"></param>
  14186. /// <returns></returns>
  14187. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14188. {
  14189. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14190. try
  14191. {
  14192. ServiceResultEntity sre = new ServiceResultEntity();
  14193. OracleParameter[] oracleParameter = new OracleParameter[]
  14194. {
  14195. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14196. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14197. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14198. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14199. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14200. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14201. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14202. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14203. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14204. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14205. };
  14206. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14207. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14208. {
  14209. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14210. }
  14211. sre.Data = result;
  14212. oracleConn.Commit();
  14213. return sre;
  14214. }
  14215. catch (Exception ex)
  14216. {
  14217. if (oracleConn.ConnState == ConnectionState.Open)
  14218. {
  14219. oracleConn.Disconnect();
  14220. }
  14221. throw ex;
  14222. }
  14223. }
  14224. /// <summary>
  14225. /// 成检产品预算分析表-设置
  14226. /// </summary>
  14227. /// <param name="cre"></param>
  14228. /// <param name="sUserInfo"></param>
  14229. /// <returns></returns>
  14230. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14231. {
  14232. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14233. try
  14234. {
  14235. ServiceResultEntity sre = new ServiceResultEntity();
  14236. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14237. " FROM tp_qco_prosetting s\n" +
  14238. " LEFT JOIN tp_pc_procedure p\n" +
  14239. " ON s.procedureid = p.procedureid\n" +
  14240. " WHERE s.accountid = :accountid";
  14241. OracleParameter[] oracleParameter = new OracleParameter[]
  14242. {
  14243. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14244. };
  14245. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14246. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14247. " FROM tp_mst_kiln k\n" +
  14248. " WHERE k.accountid = :accountid\n" +
  14249. " AND k.valueflag = '1'";
  14250. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14251. result.Tables.Add(dt);
  14252. sre.Data = result;
  14253. return sre;
  14254. }
  14255. catch (Exception ex)
  14256. {
  14257. if (oracleConn.ConnState == ConnectionState.Open)
  14258. {
  14259. oracleConn.Close();
  14260. }
  14261. throw ex;
  14262. }
  14263. }
  14264. /// <summary>
  14265. /// 成检产品预算分析表-设置
  14266. /// </summary>
  14267. /// <param name="cre"></param>
  14268. /// <param name="sUserInfo"></param>
  14269. /// <returns></returns>
  14270. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14271. {
  14272. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14273. try
  14274. {
  14275. ServiceResultEntity sre = new ServiceResultEntity();
  14276. OracleParameter[] oracleParameter = null;
  14277. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14278. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14279. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14280. {
  14281. oracleParameter = new OracleParameter[]
  14282. {
  14283. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14284. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14285. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14286. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14287. };
  14288. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14289. }
  14290. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14291. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14292. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14293. {
  14294. oracleParameter = new OracleParameter[]
  14295. {
  14296. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14297. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14298. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14299. };
  14300. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14301. }
  14302. oracleConn.Commit();
  14303. return sre;
  14304. }
  14305. catch (Exception ex)
  14306. {
  14307. if (oracleConn.ConnState == ConnectionState.Open)
  14308. {
  14309. oracleConn.Disconnect();
  14310. }
  14311. throw ex;
  14312. }
  14313. }
  14314. /// <summary>
  14315. /// 各工序质量表-恒洁三水
  14316. /// </summary>
  14317. /// <param name="cre"></param>
  14318. /// <param name="sUserInfo"></param>
  14319. /// <returns></returns>
  14320. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14321. {
  14322. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14323. try
  14324. {
  14325. int p1ID = 11; // 成检交接工序
  14326. int p2ID = 12; // 成检登记工序
  14327. string gtcode2 = cre.Properties["gtcode2"] + "";
  14328. if (gtcode2 != "001001" && gtcode2 != "001002")
  14329. {
  14330. gtcode2 = "[ALL]";
  14331. }
  14332. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14333. // goodsleveltypeid 次品 7
  14334. string sqlString = "select t.*\n" +
  14335. " ,gt.goodstypename\n" +
  14336. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14337. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14338. " ,decode(nvl(outk.outkcount, 0)\n" +
  14339. " ,0\n" +
  14340. " ,to_number(null)\n" +
  14341. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14342. " nvl(outk.outkcount, 0)\n" +
  14343. " ,4)) ccp\n" +
  14344. " from (select 10 pcode\n" +
  14345. " ,'成型' pname\n" +
  14346. " ,gt2.goodstypecode gtcode2\n" +
  14347. " ,count(*) defectcount\n" +
  14348. " from tp_pm_defect dd\n" +
  14349. " inner join tp_pm_productiondata pd\n" +
  14350. " on dd.productiondataid = pd.productiondataid\n" +
  14351. " inner join tp_mst_goods g\n" +
  14352. " on dd.goodsid = g.goodsid\n" +
  14353. " inner join tp_mst_goodstype gt\n" +
  14354. " on gt.goodstypeid = g.goodstypeid\n" +
  14355. " inner join tp_mst_goodstype gt2\n" +
  14356. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14357. " where dd.valueflag = '1'\n" +
  14358. " and dd.accountid = :accountid\n" +
  14359. " and pd.goodsleveltypeid = 7\n" + // 次品
  14360. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14361. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14362. " and dd.procedureid = :p2ID\n" +
  14363. " and dd.checktime >= :timebegin\n" +
  14364. " and dd.checktime < :timeend\n" +
  14365. ////" -- 交坯、干补\n" +
  14366. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14367. " 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" +
  14368. " 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" +
  14369. " )\n" +
  14370. " group by gt2.goodstypecode\n" +
  14371. " union all\n" +
  14372. " select 20 pcode\n" +
  14373. " ,'改洗' pname\n" +
  14374. " ,gt2.goodstypecode gtcode2\n" +
  14375. " ,count(*) defectcount\n" +
  14376. " from tp_pm_defect dd\n" +
  14377. " inner join tp_pm_productiondata pd\n" +
  14378. " on dd.productiondataid = pd.productiondataid\n" +
  14379. " inner join tp_mst_goods g\n" +
  14380. " on dd.goodsid = g.goodsid\n" +
  14381. " inner join tp_mst_goodstype gt\n" +
  14382. " on gt.goodstypeid = g.goodstypeid\n" +
  14383. " inner join tp_mst_goodstype gt2\n" +
  14384. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14385. " where dd.valueflag = '1'\n" +
  14386. " and dd.accountid = :accountid\n" +
  14387. " and pd.goodsleveltypeid = 7\n" + // 次品
  14388. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14389. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14390. " and dd.procedureid = :p2ID\n" +
  14391. " and dd.checktime >= :timebegin\n" +
  14392. " and dd.checktime < :timeend\n" +
  14393. ////" -- 改洗、吹风\n" +
  14394. //" and dd.defectprocedureid in (2, 62)\n" +
  14395. ////" -- 除不平\n" +
  14396. //" and dd.defectid not in (91, 240)\n" +
  14397. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14398. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14399. " )\n" +
  14400. " group by gt2.goodstypecode\n" +
  14401. " union all\n" +
  14402. " select 30 pcode\n" +
  14403. " ,'二检' pname\n" +
  14404. " ,gt2.goodstypecode gtcode2\n" +
  14405. " ,count(*) defectcount\n" +
  14406. " from tp_pm_defect dd\n" +
  14407. " inner join tp_pm_productiondata pd\n" +
  14408. " on dd.productiondataid = pd.productiondataid\n" +
  14409. " inner join tp_mst_goods g\n" +
  14410. " on dd.goodsid = g.goodsid\n" +
  14411. " inner join tp_mst_goodstype gt\n" +
  14412. " on gt.goodstypeid = g.goodstypeid\n" +
  14413. " inner join tp_mst_goodstype gt2\n" +
  14414. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14415. " where dd.valueflag = '1'\n" +
  14416. " and dd.accountid = :accountid\n" +
  14417. " and pd.goodsleveltypeid = 7\n" + // 次品
  14418. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14419. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14420. " and dd.procedureid = :p2ID\n" +
  14421. " and dd.checktime >= :timebegin\n" +
  14422. " and dd.checktime < :timeend\n" +
  14423. ////" -- 二检\n" +
  14424. //" and dd.defectprocedureid in (61)\n" +
  14425. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14426. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14427. " )\n" +
  14428. " group by gt2.goodstypecode\n" +
  14429. " union all\n" +
  14430. " select 40 pcode\n" +
  14431. " ,'施釉' pname\n" +
  14432. " ,gt2.goodstypecode gtcode2\n" +
  14433. " ,count(*) defectcount\n" +
  14434. " from tp_pm_defect dd\n" +
  14435. " inner join tp_pm_productiondata pd\n" +
  14436. " on dd.productiondataid = pd.productiondataid\n" +
  14437. " inner join tp_mst_goods g\n" +
  14438. " on dd.goodsid = g.goodsid\n" +
  14439. " inner join tp_mst_goodstype gt\n" +
  14440. " on gt.goodstypeid = g.goodstypeid\n" +
  14441. " inner join tp_mst_goodstype gt2\n" +
  14442. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14443. " where dd.valueflag = '1'\n" +
  14444. " and dd.accountid = :accountid\n" +
  14445. " and pd.goodsleveltypeid = 7\n" + // 次品
  14446. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14447. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14448. " and dd.procedureid = :p2ID\n" +
  14449. " and dd.checktime >= :timebegin\n" +
  14450. " and dd.checktime < :timeend\n" +
  14451. ////" -- 施釉\n" +
  14452. //" and dd.defectprocedureid in (3, 4)\n" +
  14453. ////" -- 除铁、铜脏\n" +
  14454. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14455. " 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" +
  14456. " 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" +
  14457. " )\n" +
  14458. " group by gt2.goodstypecode\n" +
  14459. " union all\n" +
  14460. " select 50 pcode\n" +
  14461. " ,'刮登' pname\n" +
  14462. " ,gt2.goodstypecode gtcode2\n" +
  14463. " ,count(*) defectcount\n" +
  14464. " from tp_pm_defect dd\n" +
  14465. " inner join tp_pm_productiondata pd\n" +
  14466. " on dd.productiondataid = pd.productiondataid\n" +
  14467. " inner join tp_mst_goods g\n" +
  14468. " on dd.goodsid = g.goodsid\n" +
  14469. " inner join tp_mst_goodstype gt\n" +
  14470. " on gt.goodstypeid = g.goodstypeid\n" +
  14471. " inner join tp_mst_goodstype gt2\n" +
  14472. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14473. " where dd.valueflag = '1'\n" +
  14474. " and dd.accountid = :accountid\n" +
  14475. " and pd.goodsleveltypeid = 7\n" + // 次品
  14476. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14477. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14478. " and dd.procedureid = :p2ID\n" +
  14479. " and dd.checktime >= :timebegin\n" +
  14480. " and dd.checktime < :timeend\n" +
  14481. ////" -- 登窑、入窑、卸窑\n" +
  14482. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14483. " 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" +
  14484. " 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" +
  14485. " )\n" +
  14486. " group by gt2.goodstypecode\n" +
  14487. " union all\n" +
  14488. " select 60 pcode\n" +
  14489. " ,'烧成' pname\n" +
  14490. " ,gt2.goodstypecode gtcode2\n" +
  14491. " ,count(*) defectcount\n" +
  14492. " from tp_pm_defect dd\n" +
  14493. " inner join tp_pm_productiondata pd\n" +
  14494. " on dd.productiondataid = pd.productiondataid\n" +
  14495. " inner join tp_mst_goods g\n" +
  14496. " on dd.goodsid = g.goodsid\n" +
  14497. " inner join tp_mst_goodstype gt\n" +
  14498. " on gt.goodstypeid = g.goodstypeid\n" +
  14499. " inner join tp_mst_goodstype gt2\n" +
  14500. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14501. " where dd.valueflag = '1'\n" +
  14502. " and dd.accountid = :accountid\n" +
  14503. " and pd.goodsleveltypeid = 7\n" + // 次品
  14504. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14505. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14506. " and dd.procedureid = :p2ID\n" +
  14507. " and dd.checktime >= :timebegin\n" +
  14508. " and dd.checktime < :timeend\n" +
  14509. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14510. //" and dd.defectid in (385\n" +
  14511. //" ,203\n" +
  14512. //" ,836\n" +
  14513. //" ,234\n" +
  14514. //" ,384\n" +
  14515. //" ,202\n" +
  14516. //" ,835\n" +
  14517. //" ,390\n" +
  14518. //" ,818\n" +
  14519. //" ,389\n" +
  14520. //" ,204\n" +
  14521. //" ,814\n" +
  14522. //" ,837\n" +
  14523. //" ,387)\n" +
  14524. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14525. //" 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" +
  14526. //" 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" +
  14527. //" )\n" +
  14528. " group by gt2.goodstypecode\n" +
  14529. " union all\n" +
  14530. " select 70 pcode\n" +
  14531. " ,'杂锈点' pname\n" +
  14532. " ,gt2.goodstypecode gtcode2\n" +
  14533. " ,count(*) defectcount\n" +
  14534. " from tp_pm_defect dd\n" +
  14535. " inner join tp_pm_productiondata pd\n" +
  14536. " on dd.productiondataid = pd.productiondataid\n" +
  14537. " inner join tp_mst_goods g\n" +
  14538. " on dd.goodsid = g.goodsid\n" +
  14539. " inner join tp_mst_goodstype gt\n" +
  14540. " on gt.goodstypeid = g.goodstypeid\n" +
  14541. " inner join tp_mst_goodstype gt2\n" +
  14542. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14543. " where dd.valueflag = '1'\n" +
  14544. " and dd.accountid = :accountid\n" +
  14545. " and pd.goodsleveltypeid = 7\n" + // 次品
  14546. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14547. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14548. " and dd.procedureid = :p2ID\n" +
  14549. " and dd.checktime >= :timebegin\n" +
  14550. " and dd.checktime < :timeend\n" +
  14551. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14552. //" and dd.defectid in\n" +
  14553. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14554. " and dd.defectid in (170,389,398,399)\n" +
  14555. //" 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" +
  14556. //" 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" +
  14557. //" )\n" +
  14558. " group by gt2.goodstypecode\n" +
  14559. " union all\n" +
  14560. " select 80 pcode\n" +
  14561. " ,'其他' pname\n" +
  14562. " ,gt2.goodstypecode gtcode2\n" +
  14563. " ,count(*) defectcount\n" +
  14564. " from tp_pm_defect dd\n" +
  14565. " inner join tp_pm_productiondata pd\n" +
  14566. " on dd.productiondataid = pd.productiondataid\n" +
  14567. " inner join tp_mst_goods g\n" +
  14568. " on dd.goodsid = g.goodsid\n" +
  14569. " inner join tp_mst_goodstype gt\n" +
  14570. " on gt.goodstypeid = g.goodstypeid\n" +
  14571. " inner join tp_mst_goodstype gt2\n" +
  14572. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14573. " where dd.valueflag = '1'\n" +
  14574. " and dd.accountid = :accountid\n" +
  14575. " and pd.goodsleveltypeid = 7\n" + // 次品
  14576. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14577. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14578. " and dd.procedureid = :p2ID\n" +
  14579. " and dd.checktime >= :timebegin\n" +
  14580. " and dd.checktime < :timeend\n" +
  14581. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14582. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14583. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14584. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14585. " )\n" +
  14586. " group by gt2.goodstypecode) t\n" +
  14587. " left join (select gt2.goodstypecode gtcode2\n" +
  14588. " ,count(*) outkcount\n" +
  14589. " from tp_pm_productiondata pd\n" +
  14590. " inner join tp_mst_goods g\n" +
  14591. " on pd.goodsid = g.goodsid\n" +
  14592. " inner join tp_mst_goodstype gt\n" +
  14593. " on gt.goodstypeid = g.goodstypeid\n" +
  14594. " inner join tp_mst_goodstype gt2\n" +
  14595. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14596. " where pd.valueflag = '1'\n" +
  14597. " and pd.accountid = :accountid\n" +
  14598. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14599. " and pd.procedureid = :p1ID\n" +
  14600. " and pd.createtime >= :timebegin\n" +
  14601. " and pd.createtime < :timeend\n" +
  14602. " group by gt2.goodstypecode) outk\n" +
  14603. " on t.gtcode2 = outk.gtcode2\n" +
  14604. " inner join tp_mst_goodstype gt\n" +
  14605. " on gt.goodstypecode = t.gtcode2\n" +
  14606. " and gt.accountid = :accountid\n" +
  14607. " order by t.pcode, t.gtcode2";
  14608. OracleParameter[] oracleParameter = new OracleParameter[]
  14609. {
  14610. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14611. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14612. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14613. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14614. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14615. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14616. };
  14617. ServiceResultEntity sre = new ServiceResultEntity();
  14618. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14619. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14620. {
  14621. sre.Data.Tables[0].TableName = "S";
  14622. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14623. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14624. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14625. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14626. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14627. {
  14628. sre1.Data.Tables[0].TableName = "D";
  14629. sre.Data.Merge(sre1.Data.Tables[0]);
  14630. }
  14631. }
  14632. sqlString =
  14633. "select t.gtcode2\n" +
  14634. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14635. " ,sum(t.outk) outk\n" +
  14636. " ,sum(t.cipin) cipin\n" +
  14637. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14638. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14639. " from (select gt2.goodstypecode gtcode2\n" +
  14640. " ,gt2.goodstypename gtname2\n" +
  14641. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14642. " ,nvl(sum(case\n" +
  14643. " when pd.procedureid = :p2ID and\n" +
  14644. " pd.goodsleveltypeid in (6, 7) then\n" +
  14645. " 1\n" +
  14646. " else\n" +
  14647. " 0\n" +
  14648. " end)\n" +
  14649. " ,0) cipin\n" +
  14650. " from tp_pm_productiondata pd\n" +
  14651. " inner join tp_mst_goods g\n" +
  14652. " on pd.goodsid = g.goodsid\n" +
  14653. " inner join tp_mst_goodstype gt\n" +
  14654. " on g.goodstypeid = gt.goodstypeid\n" +
  14655. " inner join tp_mst_goodstype gt2\n" +
  14656. " on length(gt2.goodstypecode) = 6\n" +
  14657. " and gt2.accountid = gt.accountid\n" +
  14658. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14659. " where pd.valueflag = '1'\n" +
  14660. " and pd.accountid = :accountid\n" +
  14661. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14662. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14663. //" and pd.checktime > date '2018-01-01'\n" +
  14664. " and pd.checktime >= :timebegin\n" +
  14665. " and pd.checktime < :timeend\n" +
  14666. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14667. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14668. oracleParameter = new OracleParameter[]
  14669. {
  14670. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14671. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14672. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14673. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14674. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14675. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14676. };
  14677. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14678. alldata.TableName = "A";
  14679. DataTable data = sre.Data.Tables[0];
  14680. foreach (DataRow item in alldata.Rows)
  14681. {
  14682. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14683. }
  14684. return sre;
  14685. }
  14686. catch (Exception ex)
  14687. {
  14688. if (oracleConn.ConnState == ConnectionState.Open)
  14689. {
  14690. oracleConn.Close();
  14691. }
  14692. throw ex;
  14693. }
  14694. }
  14695. /// <summary>
  14696. /// 各工序质量表-缺陷明细-恒洁三水
  14697. /// </summary>
  14698. /// <param name="cre"></param>
  14699. /// <param name="sUserInfo"></param>
  14700. /// <returns></returns>
  14701. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14702. {
  14703. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14704. try
  14705. {
  14706. //int p1ID = 11; // 成检交接工序
  14707. int p2ID = 12; // 成检登记工序
  14708. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14709. string sqlString =
  14710. "select :pcode pcode\n" +
  14711. " ,:pname pname\n" +
  14712. " ,gt2.goodstypecode gtcode2\n" +
  14713. " ,gt2.goodstypename gtname2\n" +
  14714. " ,dd.defectcode\n" +
  14715. " ,dd.defectname\n" +
  14716. " ,count(*) defectcount\n" +
  14717. " from tp_pm_defect dd\n" +
  14718. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14719. " inner join tp_mst_goods g\n" +
  14720. " on dd.goodsid = g.goodsid\n" +
  14721. " inner join tp_pm_productiondata pd\n" +
  14722. " on dd.productiondataid = pd.productiondataid\n" +
  14723. " inner join tp_mst_goodstype gt\n" +
  14724. " on gt.goodstypeid = g.goodstypeid\n" +
  14725. " inner join tp_mst_goodstype gt2\n" +
  14726. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14727. " and gt2.accountid = :accountid\n" +
  14728. " where dd.valueflag = '1'\n" +
  14729. " and dd.accountid = :accountid\n" +
  14730. " and pd.goodsleveltypeid = 7\n" + // 次品
  14731. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14732. " and dd.procedureid = :p2ID\n" +
  14733. " and gt2.goodstypecode = :gtcode2\n" +
  14734. " and dd.checktime >= :timebegin\n" +
  14735. " and dd.checktime < :timeend\n";
  14736. switch (pcode)
  14737. {
  14738. case 10:
  14739. ////" -- 交坯、干补\n" +
  14740. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14741. sqlString +=
  14742. " 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" +
  14743. " 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" +
  14744. " )\n";
  14745. break;
  14746. case 20:
  14747. sqlString +=
  14748. ////" -- 改洗、吹风\n" +
  14749. //" and dd.defectprocedureid in (2, 62)\n" +
  14750. ////" -- 除不平\n" +
  14751. //" and dd.defectid not in (91, 240)\n";
  14752. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14753. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14754. " )\n";
  14755. break;
  14756. case 30:
  14757. sqlString +=
  14758. ////" -- 二检\n" +
  14759. //" and dd.defectprocedureid in (61)\n";
  14760. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14761. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14762. " )\n";
  14763. break;
  14764. case 40:
  14765. sqlString +=
  14766. ////" -- 施釉\n" +
  14767. //" and dd.defectprocedureid in (3, 4)\n" +
  14768. ////" -- 除铁、铜脏\n" +
  14769. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14770. " 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" +
  14771. " 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" +
  14772. " )\n";
  14773. break;
  14774. case 50:
  14775. sqlString +=
  14776. ////" -- 登窑、入窑、卸窑\n" +
  14777. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14778. " 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" +
  14779. " 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" +
  14780. " )\n";
  14781. break;
  14782. case 60:
  14783. sqlString +=
  14784. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14785. //" and dd.defectid in (385\n" +
  14786. //" ,203\n" +
  14787. //" ,836\n" +
  14788. //" ,234\n" +
  14789. //" ,384\n" +
  14790. //" ,202\n" +
  14791. //" ,835\n" +
  14792. //" ,390\n" +
  14793. //" ,818\n" +
  14794. //" ,389\n" +
  14795. //" ,204\n" +
  14796. //" ,814\n" +
  14797. //" ,837\n" +
  14798. //" ,387)\n";
  14799. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14800. break;
  14801. case 70:
  14802. sqlString +=
  14803. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14804. //" and dd.defectid in\n" +
  14805. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14806. " and dd.defectid in (170,389,398,399)\n";
  14807. break;
  14808. case 80:
  14809. sqlString +=
  14810. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14811. //" and dd.defectid in (393, 180, 394, 395)\n";
  14812. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14813. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14814. " )\n";
  14815. break;
  14816. default:
  14817. break;
  14818. }
  14819. sqlString +=
  14820. " group by gt2.goodstypecode\n" +
  14821. " ,gt2.goodstypename\n" +
  14822. " ,dd.defectcode\n" +
  14823. " ,dd.defectname\n" +
  14824. " order by dd.defectcode";
  14825. OracleParameter[] oracleParameter = new OracleParameter[]
  14826. {
  14827. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14828. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14829. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14830. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  14831. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  14832. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  14833. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14834. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14835. };
  14836. ServiceResultEntity sre = new ServiceResultEntity();
  14837. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14838. return sre;
  14839. }
  14840. catch (Exception ex)
  14841. {
  14842. if (oracleConn.ConnState == ConnectionState.Open)
  14843. {
  14844. oracleConn.Close();
  14845. }
  14846. throw ex;
  14847. }
  14848. }
  14849. /// <summary>
  14850. /// 综合合格率分析表-半成品报废率分析表
  14851. /// </summary>
  14852. /// <param name="cre"></param>
  14853. /// <param name="sUserInfo"></param>
  14854. /// <returns></returns>
  14855. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14856. {
  14857. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14858. try
  14859. {
  14860. ServiceResultEntity sre = new ServiceResultEntity();
  14861. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14862. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14863. string sqlString = "select g.goodscode\n" +
  14864. " ,tt.d_num\n" +
  14865. " ,tt.b_num\n" +
  14866. " ,tt.f_num\n" +
  14867. " ,tt.s_num\n" +
  14868. " ,decode(tt.d_num\n" +
  14869. " ,0\n" +
  14870. " ,to_number(null)\n" +
  14871. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  14872. " from (select t.goodsid\n" +
  14873. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  14874. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  14875. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  14876. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  14877. " from (select gdd.goodsid\n" +
  14878. " ,'A' numtype\n" +
  14879. " ,count(gdd.groutingdailydetailid) id_num\n" +
  14880. " from tp_pm_groutingdailydetail gdd\n" +
  14881. " where gdd.groutingflag = '1'\n" +
  14882. " and gdd.valueflag = '1'\n" +
  14883. " and gdd.accountid = :accountid\n" +
  14884. " and gdd.deliverflag = '1'\n" +
  14885. " and gdd.delivertime >= :datebegin\n" +
  14886. " and gdd.delivertime < :dateend\n" +
  14887. " group by gdd.goodsid\n" +
  14888. " union all\n" +
  14889. " -- 半检不合格数 复检不合格数 损坯数\n" +
  14890. " select sp.goodsid\n" +
  14891. " ,sp.SCRAPTYPE numtype\n" +
  14892. " ,count(sp.scrapproductid) id_num\n" +
  14893. " from tp_pm_scrapproduct sp\n" +
  14894. " where sp.valueflag = '1'\n" +
  14895. " and sp.accountid = :accountid\n" +
  14896. " and sp.auditstatus = 1\n" +
  14897. " and sp.KILNID is null\n" +
  14898. " and sp.SCRAPTYPE <> '1'\n" +
  14899. " and sp.AUDITDATE >= :datebegin\n" +
  14900. " and sp.AUDITDATE < :dateend\n" +
  14901. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  14902. " group by t.goodsid) tt\n" +
  14903. " inner join tp_mst_goods g\n" +
  14904. " on tt.goodsid = g.goodsid\n" +
  14905. " order by g.goodscode";
  14906. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14907. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14908. //// 产品编码 GOODSCODE
  14909. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14910. //{
  14911. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14912. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14913. //}
  14914. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14915. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14916. {
  14917. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14918. return sre;
  14919. }
  14920. sre.Data = result;
  14921. return sre;
  14922. }
  14923. catch (Exception ex)
  14924. {
  14925. throw ex;
  14926. }
  14927. finally
  14928. {
  14929. oracleConn?.Close();
  14930. }
  14931. }
  14932. /// <summary>
  14933. /// 综合合格率分析表-综合优等率分析表
  14934. /// </summary>
  14935. /// <param name="cre"></param>
  14936. /// <param name="sUserInfo"></param>
  14937. /// <returns></returns>
  14938. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14939. {
  14940. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14941. try
  14942. {
  14943. ServiceResultEntity sre = new ServiceResultEntity();
  14944. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14945. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14946. string sqlString = "\n" +
  14947. "select g.goodscode\n" +
  14948. " ,pp.b_out_num\n" +
  14949. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  14950. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  14951. " ,decode(pp.b_out_num\n" +
  14952. " ,0\n" +
  14953. " ,to_number(null)\n" +
  14954. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  14955. " pp.b_out_num,4)) zh_r\n" +
  14956. " from (select p.goodsid\n" +
  14957. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  14958. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  14959. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  14960. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  14961. " from tp_pm_productiondata p\n" +
  14962. " where p.valueflag = '1'\n" +
  14963. " and p.accountid = :accountid\n" +
  14964. " and (p.procedureid in (11, 58) or\n" +
  14965. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  14966. " and p.createtime >= :datebegin\n" +
  14967. " and p.createtime < :dateend\n" +
  14968. " group by p.goodsid) pp\n" +
  14969. " inner join tp_mst_goods g\n" +
  14970. " on g.goodsid = pp.goodsid\n" +
  14971. " order by g.goodscode";
  14972. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14973. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14974. //// 产品编码 GOODSCODE
  14975. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14976. //{
  14977. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14978. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14979. //}
  14980. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14981. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14982. {
  14983. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14984. return sre;
  14985. }
  14986. sre.Data = result;
  14987. return sre;
  14988. }
  14989. catch (Exception ex)
  14990. {
  14991. throw ex;
  14992. }
  14993. finally
  14994. {
  14995. oracleConn?.Close();
  14996. }
  14997. }
  14998. #region 产成品交接撤销汇总表
  14999. /// <summary>
  15000. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15001. /// </summary>
  15002. /// <param name="user">登录用户信息</param>
  15003. /// <param name="se">查询条件</param>
  15004. /// <returns>查询结果</returns>
  15005. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15006. {
  15007. IDBConnection conn = null;
  15008. try
  15009. {
  15010. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15011. string sqlString = "SELECT TS.GID,\n" +
  15012. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15013. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15014. " GOODSCOUNT\n" +
  15015. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15016. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15017. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15018. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15019. " FROM TP_PM_FHUNDO F\n" +
  15020. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15021. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15022. " LEFT JOIN TP_MST_GOODS G\n" +
  15023. " ON G.GOODSID = GDD.GOODSID\n" +
  15024. " WHERE F.ACCOUNTID = :AccountID\n";
  15025. List<OracleParameter> parameters = new List<OracleParameter>();
  15026. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15027. // 撤销时间
  15028. if (orderEntity.UndoTimeStart != null)
  15029. {
  15030. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15031. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15032. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15033. }
  15034. // 产品型号
  15035. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15036. {
  15037. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15038. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15039. }
  15040. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15041. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15042. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15043. ServiceResultEntity sre = new ServiceResultEntity();
  15044. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15045. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15046. {
  15047. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15048. }
  15049. sre.Data = result;
  15050. return sre;
  15051. }
  15052. catch (Exception ex)
  15053. {
  15054. throw ex;
  15055. }
  15056. finally
  15057. {
  15058. if (conn != null &&
  15059. conn.ConnState == ConnectionState.Open)
  15060. {
  15061. conn.Close();
  15062. }
  15063. }
  15064. }
  15065. /// <summary>
  15066. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15067. /// </summary>
  15068. /// <param name="user">登录用户信息</param>
  15069. /// <param name="se">查询条件</param>
  15070. /// <returns>查询结果</returns>
  15071. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15072. {
  15073. IDBConnection conn = null;
  15074. try
  15075. {
  15076. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15077. string sqlString = "SELECT O.ORDERNO,\n" +
  15078. " F.FHTIME,\n" +
  15079. " F.FHUSERCODE,\n" +
  15080. " GDD.BARCODE,\n" +
  15081. " GOODS.GOODSCODE,\n" +
  15082. " L.LOGONAME,\n" +
  15083. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15084. " GDD.GROUTINGLINECODE,\n" +
  15085. " GDD.GROUTINGMOULDCODE,\n" +
  15086. " GDD.GROUTINGDATE,\n" +
  15087. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15088. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15089. " 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" +
  15090. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15091. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15092. " FROM TP_PM_FHUNDO F\n" +
  15093. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15094. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15095. " LEFT JOIN TP_PM_ORDER O\n" +
  15096. " ON F.FHORDERID = O.ORDERID\n" +
  15097. " LEFT JOIN TP_MST_LOGO L\n" +
  15098. " ON GDD.LOGOID = L.LOGOID\n" +
  15099. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15100. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15101. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15102. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15103. " WHERE F.ACCOUNTID = :AccountID";
  15104. List<OracleParameter> parameters = new List<OracleParameter>();
  15105. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15106. // 撤销时间
  15107. if (orderEntity.UndoTimeStart != null)
  15108. {
  15109. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15110. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15111. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15112. }
  15113. // 产品型号
  15114. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15115. {
  15116. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15117. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15118. }
  15119. ServiceResultEntity sre = new ServiceResultEntity();
  15120. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15121. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15122. {
  15123. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15124. }
  15125. sre.Data = result;
  15126. return sre;
  15127. }
  15128. catch (Exception ex)
  15129. {
  15130. throw ex;
  15131. }
  15132. finally
  15133. {
  15134. if (conn != null &&
  15135. conn.ConnState == ConnectionState.Open)
  15136. {
  15137. conn.Close();
  15138. }
  15139. }
  15140. }
  15141. #endregion
  15142. }
  15143. }