ReportModuleLogic.cs 781 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016
  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||',',','||gdd.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||',',','||gdd.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(gdd.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 gdd.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 gdd.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(gdd.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 || ',' ,','||gdd.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 || ',' ,','||gdd.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(gdd.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 gdd.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 gdd.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(gdd.BarCode) > 0");
  221. }
  222. else
  223. {
  224. sql.Append(" AND (gdd.BarCode IS NULL OR LENGTH(gdd.BarCode) = 0)");
  225. }
  226. }
  227. // 交坯日期-开始
  228. if (se.DeliverTimeBegin.HasValue)
  229. {
  230. sql.Append(" AND gdd.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 gdd.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 gdd.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 gdd.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 gdd.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 gdd.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 gdd.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= gdd.GroutingLineID))");
  271. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  272. }
  273. sql.Append(" order by gdd.GroutingDate desc, ");
  274. sql.Append(" gdd.GroutingLineCode, ");
  275. sql.Append(" gdd.GroutingBatchNo, ");
  276. sql.Append(" gdd.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. " gdd.GroutingDate, " +
  310. " gdd.GroutingBatchNo, " +
  311. " gdd.GroutingLineCode, " +
  312. " TP_MST_GMouldType.Gmouldtypename, " +
  313. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  314. " gdd.GoodsCode, " +
  315. " TP_MST_GOODS.GOODSSPECIFICATION, " +
  316. " gdd.GroutingMouldCode, " +
  317. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  318. " gdd.Groutingcount, " +
  319. " gdd.Barcode, " +
  320. " tp_mst_user.UserCode CreateUserCode, " +
  321. " tp_mst_user.username CreateUserName, " +
  322. " gdd.UserCode, " +
  323. " gdd.SCRAPFLAG, " +
  324. " gdd.GoodsName, " +
  325. " gdd.GROUTINGFLAG, " +
  326. " gdd.GMOULDSTATUS, " +
  327. " gdd.DeliverTime, " +
  328. " gdd.DeliverFlag, " +
  329. " tp_sys_gmouldstatus.gmouldstatusname, " +
  330. " b.dictionaryvalue AS NoGroutingRreason, " +
  331. " gdd.SCRAPTIME, " +
  332. " gdd.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 gdd " +
  337. "inner join TP_PM_GroutingDaily gd on gd.GroutingDailyID = gdd.GroutingDailyID " +
  338. "left join tp_mst_user mu on mu.userid = gd.MONITORID " +
  339. "inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=gdd.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=gdd.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 gdd.gmouldstatus = tp_sys_gmouldstatus.gmouldstatusid " +
  345. "left join tp_mst_user on gdd.CreateUserID=tp_mst_user.userid " +
  346. "left join TP_MST_DataDictionary b on gdd.NoGroutingRreason=b.DictionaryID " +
  347. "left join TP_MST_logo on gdd.logoid=TP_MST_logo.logoid " +
  348. "Where 1=1 " +
  349. "and gdd.Valueflag=1 " +
  350. "and gdd.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. + " mu.username as MONITORName,"
  571. //--公坯标识
  572. + " pd.ISPUBLICBODY, "
  573. //--注浆次数
  574. + " gdd.GROUTINGCOUNT, "
  575. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  576. //--查油工号
  577. + " , uc.usercode check1 "
  578. //生产数据
  579. + "from TP_PM_PRODUCTIONDATA pd "
  580. // 成型线
  581. + " LEFT JOIN tp_pc_groutingline gl" +
  582. " ON gl.groutinglineid = pd.GroutingLineID" +
  583. // 成型班长
  584. " LEFT JOIN tp_mst_user mu" +
  585. " ON mu.userid = gl.MONITORID"
  586. //注浆明细
  587. + " inner join TP_PM_GROUTINGDAILYDETAIL gdd on pd.GROUTINGDAILYDETAILID=gdd.GROUTINGDAILYDETAILID "
  588. //模具类型
  589. + "inner join TP_MST_GMouldType gt "
  590. + "on pd.GMOULDTYPEID=gt.GMouldTypeID "
  591. //产品档案
  592. + "inner join TP_MST_Goods g "
  593. + "on pd.goodsid=g.goodsid "
  594. //数据字典,TPC002为釉色类别
  595. + "inner join TP_MST_DataDictionary dd "
  596. //
  597. + "on dd.DictionaryType = 'TPC002' "
  598. //
  599. + "and dd.dictionaryid= g.GlazeTypeID "
  600. //用户信息
  601. + "inner join tp_mst_user u "
  602. + "on pd.userid=u.userid "
  603. + "inner join tp_mst_user uc "
  604. + "on pd.createuserid=uc.userid "
  605. //
  606. + "inner join TP_MST_GoodsType gdt "
  607. + "on g.GoodsTypeID=gdt.GoodsTypeID "
  608. + "inner join TP_MST_logo "
  609. + "on gdd.logoid=TP_MST_logo.logoid "
  610. // 交坯
  611. + " WHERE pd.modeltype=5 "
  612. // 账套
  613. + " and pd.AccountID=:AccountID"
  614. + " and pd.ValueFlag='" + (int)Constant.ValueFlag.Effective + "'";
  615. //成型线查看权限
  616. //+ " and exists (select up.PurviewID "
  617. //+ " from TP_MST_UserPurview up where up.PurviewType='"
  618. //+ (int)Constant.PurviewType.ViewGroutingLine
  619. //+ "' and up.PurviewID=pd.GroutingLineID "
  620. //+ " and up.UserId=:UPUserId)";
  621. return selSql;
  622. }
  623. /// <summary>
  624. /// 取得RPT010105画面(成型线模具使用明细表)的查询数据
  625. /// </summary>
  626. /// <param name="user">登录用户信息</param>
  627. /// <param name="se">查询条件</param>
  628. /// <returns>查询结果</returns>
  629. public static ServiceResultEntity GetRPT010105SData(SUserInfo user, RPT010105_SE se)
  630. {
  631. IDBConnection conn = null;
  632. try
  633. {
  634. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  635. string sqlString =
  636. "SELECT t.groutinglinecode\n" +
  637. " ,gl.BuildingNo\n" +
  638. " ,gl.FloorNo\n" +
  639. " ,gl.GroutingLineNo\n" +
  640. " ,t.usercode\n" +
  641. " ,t.goodscode\n" +
  642. " ,t.GOODSSPECIFICATION\n" +
  643. " ,t.goodstypename\n" +
  644. " ,t.MouldQuantity\n" +
  645. " ,gld.groutingmouldcode\n" +
  646. " ,gms.gmouldstatusname\n" +
  647. " ,gld.beginuseddate\n" +
  648. " ,(SELECT MIN(ggg.groutingdate)\n" +
  649. " FROM tp_pm_groutingdailydetail ggg\n" +
  650. " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
  651. " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
  652. " ,SUM(t.groutingflag) sumgroutingcount\n" +
  653. " ,MAX(t.GroutingCount) maxGroutingCount\n" +
  654. " ,gld.groutingcount\n" +
  655. " FROM (SELECT gd.groutinglinecode\n" +
  656. " ,gd.usercode\n" +
  657. " ,gdd.goodsid\n" +
  658. " ,gd.MouldQuantity\n" +
  659. " ,gdd.groutinglinedetailid\n" +
  660. " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
  661. " ,gdd.GroutingCount\n" +
  662. " ,gt.goodstypename\n" +
  663. " ,g.goodscode\n" +
  664. " ,g.GOODSSPECIFICATION\n" +
  665. " FROM TP_PM_GroutingDaily gd\n" +
  666. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  667. " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  668. " INNER JOIN TP_MST_Goods g\n" +
  669. " ON g.goodsid = gdd.goodsid\n" +
  670. " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  671. " ON gt.goodstypeid = g.goodstypeid\n" +
  672. " WHERE gd.accountid = :AccountID\n" +
  673. " AND gd.groutingdate >= :GDateBegin\n" +
  674. " AND gd.groutingdate <= :GDateEnd\n" +
  675. " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  676. " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  677. " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  678. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  679. " ) t\n" +
  680. " INNER JOIN tp_pc_groutinglinedetail gld\n" +
  681. " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
  682. " INNER JOIN tp_pc_groutingline gl\n" +
  683. " ON gld.groutinglineid = gl.groutinglineid\n" +
  684. " INNER JOIN TP_SYS_GMouldStatus gms\n" +
  685. " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
  686. " GROUP BY t.groutinglinecode\n" +
  687. " ,gl.BuildingNo\n" +
  688. " ,gl.FloorNo\n" +
  689. " ,gl.GroutingLineNo\n" +
  690. " ,t.usercode\n" +
  691. " ,t.goodscode\n" +
  692. " ,t.GOODSSPECIFICATION\n" +
  693. " ,t.goodstypename\n" +
  694. " ,t.MouldQuantity\n" +
  695. " ,gld.groutingmouldcode\n" +
  696. " ,gms.gmouldstatusname\n" +
  697. " ,gld.beginuseddate\n" +
  698. " ,gld.groutingcount\n" +
  699. " ,t.groutinglinedetailid\n" +
  700. " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
  701. List<OracleParameter> parameters = new List<OracleParameter>();
  702. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  703. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  704. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  705. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  706. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  707. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  708. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  709. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  710. ServiceResultEntity sre = new ServiceResultEntity();
  711. if (data == null || data.Rows.Count == 0)
  712. {
  713. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  714. return sre;
  715. }
  716. sre.Data = new DataSet();
  717. sre.Data.Tables.Add(data);
  718. return sre;
  719. }
  720. catch (Exception ex)
  721. {
  722. throw ex;
  723. }
  724. finally
  725. {
  726. if (conn != null &&
  727. conn.ConnState == ConnectionState.Open)
  728. {
  729. conn.Close();
  730. }
  731. }
  732. }
  733. /// <summary>
  734. /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
  735. /// </summary>
  736. /// <param name="user">登录用户信息</param>
  737. /// <param name="se">查询条件</param>
  738. /// <returns>查询结果</returns>
  739. public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
  740. {
  741. IDBConnection conn = null;
  742. try
  743. {
  744. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  745. string sqlString =
  746. "SELECT gl.buildingno\n" +
  747. " ,gl.floorno\n" +
  748. " ,gl.groutinglineno\n" +
  749. " ,gl.groutinglinecode\n" +
  750. " ,gl.Remarks\n" +
  751. " ,decode(UserCount,\n" +
  752. " 1,\n" +
  753. " mu.usercode,\n" +
  754. " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
  755. " FROM tp_pc_groutinguser gu\n" +
  756. " INNER JOIN tp_mst_user gmu\n" +
  757. " ON gmu.userid = gu.userid\n" +
  758. " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
  759. // 成型班长
  760. " ,mnu.username as MONITORName" +
  761. " ,g.goodscode\n" +
  762. " ,g.goodsspecification\n" +
  763. " ,gt.goodstypename\n" +
  764. " --,gl.mouldquantity\n" +
  765. " ,gldd.mouldquantity\n" +
  766. " ,gmt.gmouldtypename\n" +
  767. " ,gms.gmouldstatusname\n" +
  768. " ,gldd.beginuseddate -- 上模日期\n" +
  769. " ,gldd.groutingdate -- 首次注浆日期\n" +
  770. " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
  771. " ,gldd.groutingcount -- 最大注浆次数\n" +
  772. " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
  773. " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
  774. " ,gldd.sumgroutingcount -- 总注浆次数\n" +
  775. " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
  776. " ,round(decode(gl.mouldquantity,\n" +
  777. " 0,\n" +
  778. " 0,\n" +
  779. " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
  780. " gl.mouldquantity),\n" +
  781. " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
  782. " FROM tp_pc_groutingline gl\n" +
  783. " INNER JOIN (SELECT gld.groutinglineid\n" +
  784. " ,gld.goodsid\n" +
  785. " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
  786. " ,MIN(gld.beginuseddate) beginuseddate\n" +
  787. " ,MIN(gddd.groutingdate) groutingdate\n" +
  788. " /* ,(SELECT MIN(gdd.groutingdate)\n" +
  789. " FROM tp_pm_groutingdailydetail gdd\n" +
  790. " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  791. " AND gdd.groutingflag = '1') groutingdate*/\n" +
  792. " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  793. " ,MAX(gld.groutingcount) groutingcount\n" +
  794. " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
  795. " ,SUM(gld.groutingcount) sumgroutingcount\n" +
  796. " FROM tp_pc_groutinglinedetail gld\n" +
  797. " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
  798. " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  799. " -- AND gdd.groutingflag = '1'\n" +
  800. " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
  801. " ,gdd.mouldcode\n" +
  802. " ,MIN(gdd.groutingdate) groutingdate\n" +
  803. " FROM tp_pm_groutingdailydetail gdd\n" +
  804. " WHERE gdd.accountid = :AccountID\n" +
  805. " AND gdd.groutingflag = '1'\n" +
  806. " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
  807. " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  808. " AND gddd.mouldcode = gld.mouldcode\n" +
  809. " WHERE gld.valueflag = '1'\n" +
  810. " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
  811. " ON gldd.groutinglineid = gl.groutinglineid\n" +
  812. " INNER JOIN tp_mst_goods g\n" +
  813. " ON g.goodsid = gldd.goodsid\n" +
  814. " INNER JOIN tp_mst_goodstype gt\n" +
  815. " ON gt.goodstypeid = g.goodstypeid\n" +
  816. " INNER JOIN tp_mst_gmouldtype gmt\n" +
  817. " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
  818. " INNER JOIN tp_sys_gmouldstatus gms\n" +
  819. " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
  820. " INNER JOIN tp_mst_user mu\n" +
  821. " ON mu.userid = gl.userid\n" +
  822. // 成型班长
  823. " LEFT JOIN tp_mst_user mnu" +
  824. " ON mnu.userid = gl.MONITORID" +
  825. " WHERE gl.accountid = :AccountID\n" +
  826. " AND gl.valueflag = '1'\n" +
  827. " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
  828. " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
  829. " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
  830. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  831. " ORDER BY gl.groutinglinecode, g.goodscode";
  832. List<OracleParameter> parameters = new List<OracleParameter>();
  833. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  834. parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
  835. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  836. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  837. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  838. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  839. ServiceResultEntity sre = new ServiceResultEntity();
  840. if (data == null || data.Rows.Count == 0)
  841. {
  842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  843. return sre;
  844. }
  845. sre.Data = new DataSet();
  846. sre.Data.Tables.Add(data);
  847. return sre;
  848. }
  849. catch (Exception ex)
  850. {
  851. throw ex;
  852. }
  853. finally
  854. {
  855. if (conn != null &&
  856. conn.ConnState == ConnectionState.Open)
  857. {
  858. conn.Close();
  859. }
  860. }
  861. }
  862. /// <summary>
  863. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  864. /// </summary>
  865. /// <param name="user">登录用户信息</param>
  866. /// <param name="se">查询条件</param>
  867. /// <returns>查询结果</returns>
  868. public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
  869. {
  870. IDBConnection conn = null;
  871. try
  872. {
  873. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  874. List<OracleParameter> parameters = new List<OracleParameter>();
  875. // 校验时间--开始
  876. if (se.beginCreateTime.HasValue)
  877. {
  878. parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  879. }
  880. // 校验时间--结束
  881. if (se.endCreateTime.HasValue)
  882. {
  883. parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  884. }
  885. conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
  886. parameters.Clear();
  887. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
  888. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  889. ServiceResultEntity sre = new ServiceResultEntity();
  890. if (data == null || data.Rows.Count == 0)
  891. {
  892. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  893. return sre;
  894. }
  895. sre.Data = new DataSet();
  896. sre.Data.Tables.Add(data);
  897. return sre;
  898. }
  899. catch (Exception ex)
  900. {
  901. throw ex;
  902. }
  903. finally
  904. {
  905. if (conn != null &&
  906. conn.ConnState == ConnectionState.Open)
  907. {
  908. conn.Close();
  909. }
  910. }
  911. }
  912. /// <summary>
  913. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  914. /// </summary>
  915. /// <returns>sql</returns>
  916. private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  917. {
  918. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  919. #region
  920. /*
  921. selSql = selSql +
  922. "select * from (" +
  923. "select " +
  924. "MissProcedureID, " +
  925. "MissProcedureCode, " +
  926. "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
  927. "MissProcedureName, " +
  928. "MissID, " +
  929. "BarCode, " +
  930. "OrganizationID, " +
  931. "OrganizationName, " +
  932. "OrganizationCode, " +
  933. "OrganizationFullName, " +
  934. "CompleteProcedureID, " +
  935. "CompleteProcedureCode, " +
  936. "CompleteProcedureName, " +
  937. "ProcedureID, " +
  938. "ProcedureCode, " +
  939. "ProcedureName, " +
  940. "GoodsID, " +
  941. "GoodsCode, " +
  942. "GoodsName, " +
  943. "result.GoodsTypeID, " +
  944. "result.CreateTime, " +
  945. "result.GoodsTypeName, " +
  946. "UserName, " +
  947. "MissUserCode, " +
  948. "barcodecount, seqno " +
  949. "from " +
  950. " ( " +
  951. " select " +
  952. " MissProcedureID, " +
  953. " MissProcedureCode, " +
  954. " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
  955. " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
  956. " MissID, " +
  957. " BarCode, " +
  958. " OrganizationID, " +
  959. " OrganizationName, " +
  960. " OrganizationCode, " +
  961. " OrganizationFullName, " +
  962. " CompleteProcedureID, " +
  963. " CompleteProcedureCode, " +
  964. " CompleteProcedureName, " +
  965. " ProcedureID, " +
  966. " ProcedureCode, " +
  967. " ProcedureName, " +
  968. " GoodsID, " +
  969. " GoodsCode, " +
  970. " GoodsName, " +
  971. " GoodsTypeID, " +
  972. " CreateTime, " +
  973. " GoodsTypeName, " +
  974. " UserName, " +
  975. " MissUserCode, " +
  976. " barcodecount,rownum seqno " +
  977. " from " +
  978. " ( " +
  979. " select " +
  980. " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
  981. " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
  982. " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
  983. " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
  984. " decode(grouping(MissID),1,'--',MissID) MissID, " +
  985. " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
  986. " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
  987. " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
  988. " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
  989. " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
  990. " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
  991. " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
  992. " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
  993. " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
  994. " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
  995. " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
  996. " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
  997. " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
  998. " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
  999. " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
  1000. " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
  1001. " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
  1002. " decode(grouping(UserName),1,'--',UserName) UserName, " +
  1003. " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
  1004. " count(barcode) barcodecount " +
  1005. " from " +
  1006. " ( " +
  1007. " select TP_PM_BarCodeMissing.MissProcedureID, " +
  1008. " TP_PM_BarCodeMissing.MissProcedureCode, " +
  1009. " TP_PM_BarCodeMissing.MissProcedureName, " +
  1010. " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
  1011. " TP_PM_BarCodeMissing.MissID, " +
  1012. " TP_PM_BarCodeMissing.BarCode, " +
  1013. " TP_PM_BarCodeMissing.OrganizationID, " +
  1014. " TP_PM_BarCodeMissing.OrganizationName, " +
  1015. " TP_PM_BarCodeMissing.OrganizationCode, " +
  1016. " TP_PM_BarCodeMissing.OrganizationFullName, " +
  1017. " TP_PM_BarCodeMissing.CompleteProcedureID, " +
  1018. " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
  1019. " TP_PM_BarCodeMissing.CompleteProcedureName, " +
  1020. " TP_PM_BarCodeMissing.ProcedureID, " +
  1021. " TP_PM_BarCodeMissing.ProcedureCode, " +
  1022. " TP_PM_BarCodeMissing.ProcedureName, " +
  1023. " TP_PM_BarCodeMissing.GoodsID, " +
  1024. " TP_PM_BarCodeMissing.GoodsCode, " +
  1025. " TP_PM_BarCodeMissing.GoodsName, " +
  1026. " TP_PM_BarCodeMissing.GoodsTypeID, " +
  1027. " TP_PM_BarCodeMissing.MissUserCode, " +
  1028. " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
  1029. " TP_MST_GoodsType.GoodsTypeName, " +
  1030. " TP_MST_USER.UserName " +
  1031. " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
  1032. " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
  1033. " left join TP_MST_USER " +
  1034. " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
  1035. " where TP_PM_BarCodeMissing.valueflag=1 " +
  1036. " and TP_PM_BarCodeMissing.accountid=:AccountID ";
  1037. // 产品条码
  1038. if (!string.IsNullOrEmpty(se.Barcode))
  1039. {
  1040. selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
  1041. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1042. }
  1043. // 组织结构
  1044. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1045. {
  1046. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
  1047. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1048. }
  1049. // 完成工序
  1050. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1051. {
  1052. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
  1053. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1054. }
  1055. // 校验工序
  1056. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1057. {
  1058. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
  1059. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1060. }
  1061. // 漏扫工序
  1062. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1063. {
  1064. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
  1065. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1066. }
  1067. // 产品IDS
  1068. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1069. {
  1070. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
  1071. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1072. }
  1073. // 产品IDS
  1074. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1075. {
  1076. selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
  1077. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1078. }
  1079. // 校验时间--开始
  1080. if (se.beginCreateTime.HasValue)
  1081. {
  1082. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
  1083. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1084. }
  1085. // 校验时间--结束
  1086. if (se.endCreateTime.HasValue)
  1087. {
  1088. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
  1089. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1090. }
  1091. selSql = selSql +
  1092. // " order by missprocedureid,username " +
  1093. " ) " +
  1094. " group by rollup( " +
  1095. " GoodsType, " +
  1096. " MissProcedureID, " +
  1097. " MissProcedureCode, " +
  1098. " MissProcedureName, " +
  1099. " MissID, " +
  1100. " BarCode, " +
  1101. " OrganizationID, " +
  1102. " OrganizationName, " +
  1103. " OrganizationCode, " +
  1104. " OrganizationFullName, " +
  1105. " CompleteProcedureID, " +
  1106. " CompleteProcedureCode, " +
  1107. " CompleteProcedureName, " +
  1108. " ProcedureID, " +
  1109. " ProcedureCode, " +
  1110. " ProcedureName, " +
  1111. " GoodsID, " +
  1112. " GoodsCode, " +
  1113. " GoodsName, " +
  1114. " GoodsTypeID, " +
  1115. " CreateTime, " +
  1116. " GoodsTypeName,MissUserCode, " +
  1117. " UserName ) " +
  1118. " ) " +
  1119. " where UserName!='--' or " +
  1120. " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
  1121. " or " +
  1122. " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
  1123. " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
  1124. + " ) order by seqno";
  1125. */
  1126. #endregion
  1127. string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
  1128. " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
  1129. " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
  1130. " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
  1131. " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
  1132. " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
  1133. " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
  1134. " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
  1135. " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
  1136. " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
  1137. " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
  1138. " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
  1139. " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
  1140. " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
  1141. " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
  1142. " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
  1143. " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
  1144. " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
  1145. " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
  1146. " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
  1147. " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
  1148. " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
  1149. " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
  1150. " decode(tt.gid, 0, tt.username, '--') username,\n" +
  1151. " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
  1152. " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
  1153. " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
  1154. " tt.barcodecount, --数量\n" +
  1155. " tt.LogoCodeName\n" +
  1156. " from (select grouping_id(t.goodstypename2, --产品大类\n" +
  1157. " --t.MissProcedureCode,\n" +
  1158. " t.MissProcedureName,\n" +
  1159. " t.MissID) gid,\n" +
  1160. " t.MissID, --漏扫ID\n" +
  1161. " t.BarCode, --产品条码\n" +
  1162. " --t.OrganizationID,\n" +
  1163. " --t.OrganizationCode,\n" +
  1164. " t.OrganizationName, --漏扫部门\n" +
  1165. " --t.OrganizationFullName,\n" +
  1166. " --t.CompleteProcedureID,\n" +
  1167. " --t.CompleteProcedureCode,\n" +
  1168. " t.CompleteProcedureName, --完成工序\n" +
  1169. " --t.ProcedureID,\n" +
  1170. " --t.ProcedureCode,\n" +
  1171. " t.ProcedureName, --校验工序\n" +
  1172. " --t.MissProcedureID,\n" +
  1173. " --t.MissProcedureCode,\n" +
  1174. " t.MissProcedureName, --漏扫工序\n" +
  1175. " t.GoodsID,\n" +
  1176. " t.GoodsCode, --产品编码\n" +
  1177. " t.GoodsName, --产品名称\n" +
  1178. " t.GoodsTypeID,\n" +
  1179. " t.MissUserID,\n" +
  1180. " t.MissUserCode, --漏扫工号\n" +
  1181. " t.CreateTime, --校验漏扫时间\n" +
  1182. " t.CreateUserID,\n" +
  1183. " t.username, --校验者\n" +
  1184. " t.repaircode, --补扫操作工号\n" +
  1185. " t.prepaircode, --补扫生产工号\n" +
  1186. " t.goodstypename2, --产品大类\n" +
  1187. " count(t.barcodecount) barcodecount, --数量\n" +
  1188. " t.LogoCodeName\n" +
  1189. " from (select bcm.MissID, --漏扫ID\n" +
  1190. " bcm.BarCode, --产品条码\n" +
  1191. " --bcm.OrganizationID,\n" +
  1192. " --bcm.OrganizationCode,\n" +
  1193. " bcm.OrganizationName, --漏扫部门\n" +
  1194. " --bcm.OrganizationFullName,\n" +
  1195. " --bcm.CompleteProcedureID,\n" +
  1196. " --bcm.CompleteProcedureCode,\n" +
  1197. " --bcm.CompleteProcedureName, --完成工序\n" +
  1198. " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
  1199. " --bcm.ProcedureID,\n" +
  1200. " --bcm.ProcedureCode,\n" +
  1201. " --bcm.ProcedureName, --校验工序\n" +
  1202. " cp.ProcedureName, --校验工序\n" +
  1203. " --bcm.MissProcedureID,\n" +
  1204. " --bcm.MissProcedureCode,\n" +
  1205. " --bcm.MissProcedureName, --漏扫工序\n" +
  1206. " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
  1207. " bcm.GoodsID,\n" +
  1208. " bcm.GoodsCode, --产品编码\n" +
  1209. " bcm.GoodsName, --产品名称\n" +
  1210. " bcm.GoodsTypeID,\n" +
  1211. " bcm.MissUserID,\n" +
  1212. " bcm.MissUserCode, --漏扫工号\n" +
  1213. " bcm.CreateTime, --校验漏扫时间\n" +
  1214. " bcm.CreateUserID,\n" +
  1215. " u.username, --校验者\n" +
  1216. //" MU.usercode repaircode, --补扫操作工号\n" +
  1217. //" MU.pusercode prepaircode, --补扫生产工号\n" +
  1218. " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
  1219. " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
  1220. " gt2.goodstypename goodstypename2, --产品大类\n" +
  1221. " 1 barcodecount, --数量\n" +
  1222. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
  1223. " from TP_PM_BarCodeMissing bcm\n" +
  1224. " left join TP_MST_User u\n" +
  1225. " on bcm.CreateUserID = u.userid\n" +
  1226. " left join TP_MST_GoodsType gt\n" +
  1227. " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
  1228. " left join TP_MST_GoodsType gt2\n" +
  1229. " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
  1230. " and gt.accountid = gt2.accountid\n" +
  1231. /*
  1232. //" left join TP_PM_ProductionData PD\n" +
  1233. //" on PD.BarCode = bcm.BarCode\n" +
  1234. //" and PD.ProcedureID = bcm.MissProcedureID\n" +
  1235. //" left join TP_MST_User MU\n" +
  1236. //" on MU.UserID = PD.CreateUserID\n" +
  1237. " left join (select pd.barcode,\n" +
  1238. " pd.procedureid,\n" +
  1239. " pd.usercode pusercode,\n" +
  1240. " mu.usercode,\n" +
  1241. //" pd.usercode,\n" +
  1242. " max(bm.missid) missid\n" +
  1243. //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
  1244. " from tp_pm_productiondata pd\n" +
  1245. " inner join tp_pm_barcodemissing bm\n" +
  1246. " on bm.barcode = pd.barcode\n" +
  1247. " and bm.missprocedureid = pd.procedureid\n" +
  1248. " and bm.createtime < pd.createtime\n" +
  1249. " and bm.valueflag ='1'\n" +
  1250. " inner join tp_mst_user mu\n" +
  1251. " on mu.userid = pd.createuserid\n" +
  1252. " where pd.valueflag = '1'\n" +
  1253. " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
  1254. " ) MU\n" +
  1255. " on MU.barcode = bcm.barcode\n" +
  1256. " and MU.procedureid = bcm.missprocedureid\n" +
  1257. " and MU.missid = bcm.missid" +
  1258. //" and MU.rnum = 1" +
  1259. */
  1260. " left join tp_pc_procedure cedp \n" +
  1261. " on cedp.procedureid = bcm.CompleteProcedureID\n" +
  1262. " left join tp_pc_procedure cp \n" +
  1263. " on cp.procedureid = bcm.ProcedureID\n" +
  1264. " left join tp_pc_procedure mp \n" +
  1265. " on mp.procedureid = bcm.MissProcedureID\n" +
  1266. " left join TP_PM_GroutingDailyDetail \n" +
  1267. " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
  1268. " left join tp_mst_logo \n" +
  1269. " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
  1270. " where bcm.valueflag='1' \n" +
  1271. " and bcm.accountid=:AccountID \n";
  1272. // 产品条码
  1273. if (!string.IsNullOrEmpty(se.Barcode))
  1274. {
  1275. selSql = selSql + " and bcm.barcode=:Barcode ";
  1276. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1277. }
  1278. // 组织结构
  1279. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1280. {
  1281. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
  1282. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1283. }
  1284. // 完成工序
  1285. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1286. {
  1287. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
  1288. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1289. }
  1290. // 校验工序
  1291. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1292. {
  1293. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
  1294. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1295. }
  1296. // 漏扫工序
  1297. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1298. {
  1299. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
  1300. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1301. }
  1302. // 产品IDS
  1303. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1304. {
  1305. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
  1306. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1307. }
  1308. // 产品IDS
  1309. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1310. {
  1311. //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
  1312. selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
  1313. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1314. }
  1315. // 校验时间--开始
  1316. if (se.beginCreateTime.HasValue)
  1317. {
  1318. selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
  1319. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1320. }
  1321. // 校验时间--结束
  1322. if (se.endCreateTime.HasValue)
  1323. {
  1324. selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
  1325. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1326. }
  1327. selSql += "\n" +
  1328. //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
  1329. //" --bcm.GoodsCode,\n" +
  1330. //" bcm.BarCode,\n" +
  1331. //" bcm.ProcedureCode,\n" +
  1332. //" bcm.CompleteProcedureCode\n" +
  1333. //" ) t\n" +
  1334. " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
  1335. " --bcm.GoodsCode,\n" +
  1336. " bcm.BarCode,\n" +
  1337. " cp.ProcedureName,\n" +
  1338. " cedp.ProcedureName\n" +
  1339. " ) t\n" +
  1340. " group by grouping sets((t.MissID, --漏扫ID\n" +
  1341. " t.BarCode, --产品条码\n" +
  1342. " t.goodstypename2, --产品大类\n" +
  1343. " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
  1344. " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
  1345. " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
  1346. " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
  1347. " t.GoodsID, t.GoodsCode, --产品编码\n" +
  1348. " t.GoodsName, --产品名称\n" +
  1349. " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
  1350. " t.CreateTime, --校验漏扫时间\n" +
  1351. " t.CreateUserID, t.username, --校验者\n" +
  1352. " t.repaircode, --补扫工号\n" +
  1353. " t.prepaircode, --补扫工号\n" +
  1354. " t.LogoCodeName --商标\n" +
  1355. " ),(t.goodstypename2, --产品大类\n" +
  1356. " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
  1357. " ),(t.goodstypename2 --产品大类\n" +
  1358. " ),())) tt";
  1359. return selSql;
  1360. }
  1361. /// <summary>
  1362. /// 取得RPT010301_1画面(条码变更明细表)的查询数据
  1363. /// </summary>
  1364. /// <param name="user">登录用户信息</param>
  1365. /// <param name="se">查询条件</param>
  1366. /// <returns>查询结果</returns>
  1367. public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
  1368. {
  1369. IDBConnection conn = null;
  1370. try
  1371. {
  1372. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1373. List<OracleParameter> parameters = new List<OracleParameter>();
  1374. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
  1375. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1376. if (se != null)
  1377. {
  1378. // 更换条码时间-开始
  1379. if (se.createTimeBegin.HasValue)
  1380. {
  1381. sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
  1382. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  1383. }
  1384. // 更换条码时间-结束
  1385. if (se.createTimeEnd.HasValue)
  1386. {
  1387. sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
  1388. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  1389. }
  1390. //成型线IDS
  1391. if (!string.IsNullOrEmpty(se.Barcode))
  1392. {
  1393. // 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 )");
  1394. 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 )");
  1395. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1396. }
  1397. }
  1398. sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
  1399. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1400. ServiceResultEntity sre = new ServiceResultEntity();
  1401. if (data == null || data.Rows.Count == 0)
  1402. {
  1403. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1404. return sre;
  1405. }
  1406. sre.Data = new DataSet();
  1407. sre.Data.Tables.Add(data);
  1408. return sre;
  1409. }
  1410. catch (Exception ex)
  1411. {
  1412. throw ex;
  1413. }
  1414. finally
  1415. {
  1416. if (conn != null &&
  1417. conn.ConnState == ConnectionState.Open)
  1418. {
  1419. conn.Close();
  1420. }
  1421. }
  1422. }
  1423. /// <summary>
  1424. /// 获取RPT010301_1画面(条码变更明细表)的查询sql
  1425. /// </summary>
  1426. /// <returns>sql</returns>
  1427. private static string GetRPT010301SSQL()
  1428. {
  1429. string selSql =
  1430. " SELECT "
  1431. + " TP_PM_BarCodeRecord.BarCode, "
  1432. + " TP_PM_BarCodeRecord.NewBarCode, "
  1433. + " TP_PM_BarCodeRecord.FirstBarCode, "
  1434. + " TP_PM_BarCodeRecord.FinalBarCode, "
  1435. + " TP_PM_BarCodeRecord.Createtime, "
  1436. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
  1437. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
  1438. + " TP_MST_GMouldType.Gmouldtypename, "
  1439. + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
  1440. + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
  1441. + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
  1442. + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
  1443. + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
  1444. + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
  1445. + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
  1446. + " TP_PC_PROCEDURE.PROCEDURECODE, "
  1447. + " TP_PC_PROCEDURE.PROCEDURENAME, "
  1448. // 成型班长
  1449. + " mu.username as MONITORName,"
  1450. + " TP_MST_USER.USERNAME, "
  1451. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  1452. + " from TP_PM_BarCodeRecord "
  1453. + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
  1454. + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
  1455. // 成型班长
  1456. + " LEFT JOIN tp_mst_user mu" +
  1457. " ON mu.userid = TP_PC_GroutingLine.MONITORID"
  1458. + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
  1459. + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
  1460. + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
  1461. + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
  1462. + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
  1463. return selSql;
  1464. }
  1465. /// <summary>
  1466. /// 取得RPT010401画面(在产品明细表)的查询数据
  1467. /// </summary>
  1468. /// <param name="user">登录用户信息</param>
  1469. /// <param name="se">查询条件</param>
  1470. /// <returns>查询结果</returns>
  1471. public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
  1472. {
  1473. IDBConnection conn = null;
  1474. try
  1475. {
  1476. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1477. List<OracleParameter> parameters = new List<OracleParameter>();
  1478. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
  1479. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1480. if (se != null)
  1481. {
  1482. // 条码
  1483. if (!string.IsNullOrEmpty(se.Barcode))
  1484. {
  1485. //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
  1486. sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
  1487. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1488. }
  1489. // 产品IDS
  1490. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1491. {
  1492. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
  1493. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1494. }
  1495. //生产线IDS
  1496. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1497. {
  1498. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  1499. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1500. }
  1501. //完成工序IDS
  1502. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1503. {
  1504. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  1505. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1506. }
  1507. //生产工号IDS
  1508. if (!string.IsNullOrEmpty(se.UserIDS))
  1509. {
  1510. sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
  1511. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  1512. }
  1513. // 成型线IDS
  1514. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1515. {
  1516. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
  1517. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1518. }
  1519. // 成型线类型IDS
  1520. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1521. {
  1522. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
  1523. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1524. }
  1525. // 交坯时间--开始
  1526. if (se.CreateTimeStart.HasValue)
  1527. {
  1528. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
  1529. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1530. }
  1531. // 交坯时间--结束
  1532. if (se.CreateTimeEnd.HasValue)
  1533. {
  1534. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
  1535. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1536. }
  1537. // 完成时间--开始
  1538. if (se.UpdateTimeStart.HasValue)
  1539. {
  1540. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  1541. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  1542. }
  1543. // 完成时间--结束
  1544. if (se.UpdateTimeEnd.HasValue)
  1545. {
  1546. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  1547. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  1548. }
  1549. if (se.inscrapflag != 2)
  1550. {
  1551. sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
  1552. parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
  1553. }
  1554. if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
  1555. {
  1556. sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
  1557. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1558. }
  1559. }
  1560. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  1561. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1562. ServiceResultEntity sre = new ServiceResultEntity();
  1563. if (data == null || data.Rows.Count == 0)
  1564. {
  1565. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1566. return sre;
  1567. }
  1568. sre.Data = new DataSet();
  1569. sre.Data.Tables.Add(data);
  1570. return sre;
  1571. }
  1572. catch (Exception ex)
  1573. {
  1574. throw ex;
  1575. }
  1576. finally
  1577. {
  1578. if (conn != null &&
  1579. conn.ConnState == ConnectionState.Open)
  1580. {
  1581. conn.Close();
  1582. }
  1583. }
  1584. }
  1585. /// <summary>
  1586. /// 获取RPT010401画面(在产品明细表)的查询sql
  1587. /// </summary>
  1588. /// <returns>sql</returns>
  1589. private static string GetRPT010401SSQL()
  1590. {
  1591. string selSql =
  1592. "SELECT " +
  1593. " TP_PM_InProduction.BarCode, " +
  1594. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  1595. " TP_PM_InProduction.GoodsName, gt.goodstypename," +
  1596. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  1597. " TP_PM_InProduction.ProductionLineID, " +
  1598. " TP_PM_InProduction.ProductionLineCode, " +
  1599. " TP_PM_InProduction.ProductionLineName, " +
  1600. " TP_PM_InProduction.ModelType, " +
  1601. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  1602. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1603. " TP_PM_InProduction.IsPublicBody, " +
  1604. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  1605. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  1606. " TP_PM_InProduction.IsReworkFlag, " +
  1607. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  1608. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  1609. " TP_PM_InProduction.GroutingDailyID, " +
  1610. " TP_PM_InProduction.GroutingDailyDetailID, " +
  1611. " TP_PM_InProduction.GroutingDate, " +
  1612. " TP_PM_InProduction.GroutingLineID, " +
  1613. " TP_PM_InProduction.GroutingLineCode, " +
  1614. " TP_PM_InProduction.GroutingLineName, " +
  1615. " TP_PM_InProduction.KILNCODE, " +
  1616. " TP_PM_InProduction.KILNCARCODE, " +
  1617. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  1618. " D.ProcedureName as CompleteProcedureName, " +
  1619. " TP_PM_InProduction.GMouldTypeID, " +
  1620. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1621. " TP_PM_InProduction.GroutingLineDetailID, " +
  1622. " TP_PM_InProduction.GroutingMouldCode, " +
  1623. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  1624. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  1625. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  1626. " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
  1627. " TP_PM_GroutingDailyDetail.delivertime, " +
  1628. " TP_PM_InProduction.proceduretime, " +
  1629. " TP_PM_InProduction.Remarks, " +
  1630. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1631. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1632. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  1633. " TP_PM_GroutingDailyDetail.glazingroom," +
  1634. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  1635. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  1636. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
  1637. //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1638. " 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 " +
  1639. "FROM TP_PM_InProduction " +
  1640. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  1641. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  1642. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  1643. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  1644. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  1645. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  1646. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  1647. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  1648. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  1649. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  1650. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  1651. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  1652. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  1653. " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
  1654. " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
  1655. " Where TP_PM_InProduction.ValueFlag = 1 " +
  1656. " and TP_PM_InProduction.AccountID=:AccountID ";
  1657. return selSql;
  1658. }
  1659. /// <summary>
  1660. /// 取得RPT010402画面(产成品明细表)的查询数据
  1661. /// </summary>
  1662. /// <param name="user">登录用户信息</param>
  1663. /// <param name="se">查询条件</param>
  1664. /// <returns>查询结果</returns>
  1665. public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
  1666. {
  1667. IDBConnection conn = null;
  1668. try
  1669. {
  1670. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1671. List<OracleParameter> parameters = new List<OracleParameter>();
  1672. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
  1673. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1674. if (se != null)
  1675. {
  1676. // 条码
  1677. if (!string.IsNullOrEmpty(se.Barcode))
  1678. {
  1679. //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
  1680. sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
  1681. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1682. }
  1683. // 产品IDS
  1684. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1685. {
  1686. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
  1687. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1688. }
  1689. // 生产线IDS
  1690. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1691. {
  1692. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
  1693. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1694. }
  1695. // 成型线ids
  1696. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1697. {
  1698. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
  1699. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1700. }
  1701. // 成型线类型ids
  1702. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1703. {
  1704. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
  1705. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1706. }
  1707. // 财务日期--开始
  1708. if (se.AccountDateStart.HasValue)
  1709. {
  1710. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
  1711. sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
  1712. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  1713. }
  1714. // 财务日期--结束
  1715. if (se.AccountDateEnd.HasValue)
  1716. {
  1717. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
  1718. sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
  1719. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  1720. }
  1721. // 注浆时间--开始
  1722. if (se.CreateTimeStart.HasValue)
  1723. {
  1724. sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
  1725. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1726. }
  1727. // 注浆时间--结束
  1728. if (se.CreateTimeEnd.HasValue)
  1729. {
  1730. sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
  1731. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1732. }
  1733. }
  1734. sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
  1735. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1736. ServiceResultEntity sre = new ServiceResultEntity();
  1737. if (data == null || data.Rows.Count == 0)
  1738. {
  1739. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1740. return sre;
  1741. }
  1742. sre.Data = new DataSet();
  1743. sre.Data.Tables.Add(data);
  1744. return sre;
  1745. }
  1746. catch (Exception ex)
  1747. {
  1748. throw ex;
  1749. }
  1750. finally
  1751. {
  1752. if (conn != null &&
  1753. conn.ConnState == ConnectionState.Open)
  1754. {
  1755. conn.Close();
  1756. }
  1757. }
  1758. }
  1759. /// <summary>
  1760. /// 获取RPT010402画面(产成品明细表)的查询sql
  1761. /// </summary>
  1762. /// <returns>sql</returns>
  1763. private static string GetRPT010402SSQL()
  1764. {
  1765. string selSql =
  1766. "SELECT " +
  1767. " TP_PM_FinishedProduct.BarCode, " +
  1768. " TP_PM_FinishedProduct.GoodsID, " +
  1769. " TP_PM_FinishedProduct.GoodsCode, " +
  1770. " TP_PM_FinishedProduct.GoodsName, " +
  1771. " TP_PM_FinishedProduct.ProductionLineID, " +
  1772. " TP_PM_FinishedProduct.ProductionLineCode, " +
  1773. " TP_PM_FinishedProduct.ProductionLineName, " +
  1774. //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1775. //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
  1776. " TP_PM_FinishedProduct.IsPublicBody, " +
  1777. " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
  1778. " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
  1779. " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
  1780. " TP_PM_FinishedProduct.GroutingDailyID, " +
  1781. " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
  1782. " TP_PM_FinishedProduct.GroutingDate, " +
  1783. " TP_PM_FinishedProduct.GroutingLineID, " +
  1784. " TP_PM_FinishedProduct.GroutingLineCode," +
  1785. " TP_PM_FinishedProduct.GroutingLineName, " +
  1786. " TP_PM_FinishedProduct.GMouldTypeID, " +
  1787. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1788. " TP_PM_FinishedProduct.GroutingLineDetailID, " +
  1789. " TP_PM_FinishedProduct.GroutingMouldCode," +
  1790. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
  1791. " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
  1792. " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
  1793. " TP_PM_FinishedProduct.KILNID," +
  1794. " TP_PM_FinishedProduct.KILNCODE," +
  1795. " TP_PM_FinishedProduct.KILNNAME," +
  1796. " TP_PM_FinishedProduct.KILNCARID," +
  1797. " TP_PM_FinishedProduct.KILNCARCODE," +
  1798. " TP_PM_FinishedProduct.KILNCARNAME," +
  1799. " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
  1800. " TP_PM_FinishedProduct.MouldCode, " +
  1801. " TP_PM_FinishedProduct.Remarks, " +
  1802. " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1803. " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
  1804. " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1805. " TP_PM_FinishedProduct.FHUSERCODE, " +
  1806. " TP_PM_FinishedProduct.FHTIME, " +
  1807. " odr.ORDERNO, " +
  1808. " TP_PM_FinishedProduct.AccountID, " +
  1809. " TP_PM_FinishedProduct.ValueFlag, " +
  1810. " TP_PM_FinishedProduct.AccountDate, " +
  1811. " TP_PM_FinishedProduct.CreateTime, " +
  1812. " TP_PM_FinishedProduct.CreateUserID, " +
  1813. " B.USERNAME as CreateUserName, " +
  1814. " TP_PM_FinishedProduct.UpdateTime, " +
  1815. " TP_PM_FinishedProduct.UpdateUserID, " +
  1816. " C.USERNAME as UpdateUserName, " +
  1817. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
  1818. " TP_PM_GroutingDailyDetail.Materialcode," +
  1819. //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1820. " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
  1821. " FROM TP_PM_FinishedProduct " +
  1822. " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
  1823. " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
  1824. " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
  1825. " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
  1826. " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
  1827. " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
  1828. " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
  1829. " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
  1830. " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
  1831. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
  1832. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
  1833. " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
  1834. " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
  1835. " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
  1836. " and TP_PM_FinishedProduct.AccountID=:AccountID ";
  1837. return selSql;
  1838. }
  1839. /// <summary>
  1840. /// 取得RPT010403画面(生产数据明细表)的查询数据
  1841. /// </summary>
  1842. /// <param name="user">登录用户信息</param>
  1843. /// <param name="se">查询条件</param>
  1844. /// <returns>查询结果</returns>
  1845. public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
  1846. {
  1847. IDBConnection conn = null;
  1848. try
  1849. {
  1850. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1851. List<OracleParameter> parameters = new List<OracleParameter>();
  1852. string sqlString =
  1853. "SELECT *\n" +
  1854. " FROM (SELECT pd.barcode\n" +
  1855. " ,gt2.goodstypename as goodstypename2\n" +
  1856. " ,gt.goodstypename\n" +
  1857. " ,g.goodscode\n" +
  1858. " ,PD.ProductionLineName\n" +
  1859. " ,to_char(p.ProcedureName) AS ProcedureName\n" +
  1860. " ,op.organizationfullname AS porgname\n" +
  1861. " ,pd.CreateTime\n" +
  1862. " ,PD.UserCode\n" +
  1863. " ,cu.Usercode AS CreateUsercode\n" +
  1864. " ,cu.Username AS CreateUserName\n" +
  1865. " ,co.organizationfullname corgname\n" +
  1866. " , CASE\n" +
  1867. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
  1868. " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
  1869. " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1870. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
  1871. " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
  1872. " ELSE\n" +
  1873. " to_char(GL.GOODSLEVELNAME)\n" +
  1874. " END || CASE\n" +
  1875. " WHEN pd.modeltype = 1 THEN\n" +
  1876. " '[' || to_char(pd.kilncarcode) || ']'\n" +
  1877. " ELSE\n" +
  1878. " ''\n" +
  1879. " END GOODSLEVELNAME\n" +
  1880. " ,gdd.glazingroom" +
  1881. " FROM TP_PM_ProductionData PD\n" +
  1882. " INNER JOIN tp_pc_procedure p\n" +
  1883. " ON p.procedureid = pd.procedureid\n" +
  1884. " LEFT JOIN tp_mst_goods g\n" +
  1885. " ON g.goodsid = pd.goodsid\n" +
  1886. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  1887. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  1888. " LEFT JOIN tp_mst_goodstype gt\n" +
  1889. " ON gt.goodstypeid = g.goodstypeid\n" +
  1890. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1891. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1892. " AND gt2.AccountID = :AccountID\n" +
  1893. " INNER JOIN tp_mst_organization op\n" +
  1894. " ON op.organizationid = p.organizationid\n" +
  1895. " INNER JOIN tp_mst_user cu\n" +
  1896. " ON cu.userid = PD.Createuserid\n" +
  1897. " INNER JOIN tp_mst_organization co\n" +
  1898. " ON co.organizationid = cu.organizationid\n" +
  1899. " LEFT JOIN tp_mst_user bu\n" +
  1900. " ON bu.userid = PD.Backoutuserid\n" +
  1901. " LEFT JOIN tp_mst_goodslevel GL\n" +
  1902. " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
  1903. " AND gl.AccountID = :AccountID\n" +
  1904. " WHERE PD.AccountID = :AccountID\n" +
  1905. " AND PD.Createtime >= :CreatetimeBegin\n" +
  1906. " AND PD.Createtime <= :CreatetimeEnd\n" +
  1907. " AND (:ProductionLineID IS NULL OR\n" +
  1908. " pd.productionlineid = :ProductionLineID)\n" +
  1909. " AND (:GoodsTypeCode IS NULL OR\n" +
  1910. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1911. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  1912. " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
  1913. " UNION ALL\n" +
  1914. " -- 报损\n" +
  1915. " SELECT sp.barcode\n" +
  1916. " ,gt2.goodstypename as goodstypename2\n" +
  1917. " ,gt.goodstypename\n" +
  1918. " ,g.goodscode\n" +
  1919. " ,sp.productionlinename\n" +
  1920. //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
  1921. //" to_char(p.procedurename) || '】' AS procedurename\n" +
  1922. " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
  1923. " WHEN rpp.procedureid IS NOT NULL THEN\n" +
  1924. " to_char(rpp.procedurename)\n" +
  1925. " ELSE\n" +
  1926. " '无'\n" +
  1927. " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
  1928. " to_char(sruser.Username) || '】-原因【' ||\n" +
  1929. " to_char(sp.rreason) || '】' AS procedurename" +
  1930. " ,NULL AS porgname\n" +
  1931. " ,sp.Createtime\n" +
  1932. " ,NULL AS Usercode\n" +
  1933. " ,u.Usercode AS CreateUsercode\n" +
  1934. " ,U.Username AS CreateUserName\n" +
  1935. " ,co.organizationfullname corgname\n" +
  1936. " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
  1937. " WHEN Length(AU.usercode) > 0 THEN\n" +
  1938. " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
  1939. " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1940. " ELSE\n" +
  1941. " ''\n" +
  1942. " END || CASE\n" +
  1943. " WHEN sp.valueflag = '0' THEN\n" +
  1944. " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
  1945. " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1946. " ELSE\n" +
  1947. " ''\n" +
  1948. " END AS GOODSLEVELNAME\n" +
  1949. " ,null glazingroom\n" +
  1950. " FROM tp_pm_scrapproduct sp\n" +
  1951. " LEFT JOIN tp_mst_goods g\n" +
  1952. " ON g.goodsid = sp.goodsid\n" +
  1953. " LEFT JOIN tp_mst_goodstype gt\n" +
  1954. " ON gt.goodstypeid = g.goodstypeid\n" +
  1955. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1956. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1957. " AND gt2.AccountID = :AccountID\n" +
  1958. " INNER JOIN tp_pc_procedure p\n" +
  1959. " ON p.procedureid = sp.procedureid\n" +
  1960. " --inner join tp_mst_organization op\n" +
  1961. " -- on op.organizationid = p.organizationid\n" +
  1962. " INNER JOIN tp_mst_user U\n" +
  1963. " ON U.userid = sp.CREATEUSERID\n" +
  1964. " INNER JOIN tp_mst_organization co\n" +
  1965. " ON co.organizationid = u.organizationid\n" +
  1966. " INNER JOIN tp_mst_user uu\n" +
  1967. " ON uu.userid = sp.Updateuserid\n" +
  1968. " INNER JOIN tp_sys_AuditStatus A\n" +
  1969. " ON A.AuditStatusid = sp.AuditStatus\n" +
  1970. " LEFT JOIN tp_mst_goodslevel gl\n" +
  1971. " ON gl.goodsleveltypeid = 8\n" +
  1972. " AND gl.accountid = 1\n" +
  1973. " LEFT JOIN tp_mst_user AU\n" +
  1974. " ON au.userid = sp.auditor\n" +
  1975. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  1976. " ON rp.scrapproductid = sp.scrapproductid\n" +
  1977. " LEFT JOIN tp_pc_procedure rpp\n" +
  1978. " ON rpp.procedureid = rp.procedureid\n" +
  1979. " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
  1980. " FROM TP_PM_ScrapResponsible sr\n" +
  1981. " WHERE sr.AccountID = :AccountID\n" +
  1982. " -- 编辑后 时间不一致\n" +
  1983. " --AND sr.Createtime >= :CreatetimeBegin\n" +
  1984. " --AND sr.Createtime <= :CreatetimeEnd\n" +
  1985. " ) sru\n" +
  1986. " ON sru.scrapproductid = sp.scrapproductid\n" +
  1987. " LEFT JOIN tp_mst_user sruser\n" +
  1988. " ON sruser.userid = sru.userid" +
  1989. " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
  1990. " AND sp.scraptype = '0'\n" +
  1991. " AND sp.AccountID = :AccountID\n" +
  1992. " AND sp.Createtime >= :CreatetimeBegin\n" +
  1993. " AND sp.Createtime <= :CreatetimeEnd\n" +
  1994. " AND (:ProductionLineID IS NULL OR\n" +
  1995. " sp.productionlineid = :ProductionLineID)\n" +
  1996. " AND (:GoodsTypeCode IS NULL OR\n" +
  1997. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1998. " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
  1999. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
  2000. " ORDER BY t.barcode, t.Createtime";
  2001. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2002. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2003. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2004. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  2005. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  2006. parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
  2007. parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
  2008. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2009. ServiceResultEntity sre = new ServiceResultEntity();
  2010. if (data == null || data.Rows.Count == 0)
  2011. {
  2012. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2013. return sre;
  2014. }
  2015. sre.Data = new DataSet();
  2016. sre.Data.Tables.Add(data);
  2017. return sre;
  2018. }
  2019. catch (Exception ex)
  2020. {
  2021. throw ex;
  2022. }
  2023. finally
  2024. {
  2025. if (conn != null &&
  2026. conn.ConnState == ConnectionState.Open)
  2027. {
  2028. conn.Close();
  2029. }
  2030. }
  2031. }
  2032. /// <summary>
  2033. /// 取得RPT010302画面(商标变更明细表)的查询数据
  2034. /// </summary>
  2035. /// <param name="user">登录用户信息</param>
  2036. /// <param name="se">查询条件</param>
  2037. /// <returns>查询结果</returns>
  2038. public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
  2039. {
  2040. IDBConnection conn = null;
  2041. try
  2042. {
  2043. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2044. List<OracleParameter> parameters = new List<OracleParameter>();
  2045. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
  2046. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2047. if (se != null)
  2048. {
  2049. // 更换条码时间-开始
  2050. if (se.createTimeBegin.HasValue)
  2051. {
  2052. sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
  2053. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  2054. }
  2055. // 更换条码时间-结束
  2056. if (se.createTimeEnd.HasValue)
  2057. {
  2058. sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
  2059. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  2060. }
  2061. //成型线IDS
  2062. if (!string.IsNullOrEmpty(se.Barcode))
  2063. {
  2064. // 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 )");
  2065. sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
  2066. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2067. }
  2068. }
  2069. sql.Append(" ORDER BY lcr.CREATETIME ");
  2070. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2071. ServiceResultEntity sre = new ServiceResultEntity();
  2072. if (data == null || data.Rows.Count == 0)
  2073. {
  2074. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2075. return sre;
  2076. }
  2077. sre.Data = new DataSet();
  2078. sre.Data.Tables.Add(data);
  2079. return sre;
  2080. }
  2081. catch (Exception ex)
  2082. {
  2083. throw ex;
  2084. }
  2085. finally
  2086. {
  2087. if (conn != null &&
  2088. conn.ConnState == ConnectionState.Open)
  2089. {
  2090. conn.Close();
  2091. }
  2092. }
  2093. }
  2094. /// <summary>
  2095. /// 获取RPT010302画面(商标变更明细表)的查询sql
  2096. /// </summary>
  2097. /// <returns>sql</returns>
  2098. private static string GetRPT010302SSQL()
  2099. {
  2100. string selSql =
  2101. "SELECT lcr.BarCode\n" +
  2102. " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
  2103. " '[]',\n" +
  2104. " '') AS oldLogoCodeName\n" +
  2105. " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
  2106. " '[]',\n" +
  2107. " '') AS newLogoCodeName\n" +
  2108. " ,lcr.Createtime\n" +
  2109. " ,gdd.GroutingLineCode\n" +
  2110. " ,gdd.GroutingLineName\n" +
  2111. " ,gdd.GroutingDate\n" +
  2112. " ,gdd.GroutingMouldCode\n" +
  2113. " ,gdd.MouldCode\n" +
  2114. " ,gdd.UserCode GroutingUserCode\n" +
  2115. " ,gdd.GroutingCount\n" +
  2116. " ,gdd.GoodsCode\n" +
  2117. " ,gdd.GoodsName\n" +
  2118. " ,p.PROCEDURECODE\n" +
  2119. " ,p.PROCEDURENAME\n" +
  2120. " ,u.USERCode\n" +
  2121. " ,u.USERNAME\n" +
  2122. " FROM TP_PM_LogoChangedRecord lcr\n" +
  2123. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
  2124. " ON lcr.barcode = gdd.Barcode\n" +
  2125. " LEFT JOIN TP_PC_PROCEDURE p\n" +
  2126. " ON lcr.Procedureid = p.PROCEDUREID\n" +
  2127. " LEFT JOIN TP_MST_USER u\n" +
  2128. " ON lcr.CreateUserID = u.USERID\n" +
  2129. " LEFT JOIN TP_MST_logo oldlogo\n" +
  2130. " ON lcr.oldlogoid = oldlogo.logoid\n" +
  2131. " LEFT JOIN TP_MST_logo newlogo\n" +
  2132. " ON lcr.newlogoid = newlogo.logoid\n" +
  2133. " WHERE lcr.ACCOUNTID = :AccountID";
  2134. return selSql;
  2135. }
  2136. #endregion 明细报表
  2137. #region 分析报表
  2138. /// <summary>
  2139. /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
  2140. /// </summary>
  2141. /// <param name="user">登录用户信息</param>
  2142. /// <param name="se">查询条件</param>
  2143. /// <returns>查询结果</returns>
  2144. public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
  2145. {
  2146. IDBConnection conn = null;
  2147. try
  2148. {
  2149. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2150. #region
  2151. /*
  2152. List<OracleParameter> parameters = new List<OracleParameter>();
  2153. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2154. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2155. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2156. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2157. parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2158. if (se != null)
  2159. {
  2160. // 成型线IDS
  2161. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2162. {
  2163. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  2164. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2165. }
  2166. // 成型工IDS
  2167. if (!string.IsNullOrEmpty(se.UserIDS))
  2168. {
  2169. sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
  2170. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2171. }
  2172. //产品类型IDS
  2173. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2174. {
  2175. sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
  2176. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2177. }
  2178. //产品IDS
  2179. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2180. {
  2181. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  2182. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2183. }
  2184. }
  2185. sql.Append(" group by ");
  2186. sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
  2187. sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
  2188. sql.Append(" line.GroutinglineCode, ");
  2189. sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
  2190. sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
  2191. sql.Append(" TP_MST_Goods.Goodsspecification, ");
  2192. sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
  2193. sql.Append(" MouldQuantity ");
  2194. sql.Append(" ) temp ");
  2195. sql.Append(" ) a ");
  2196. sql.Append(" group by rollup( ");
  2197. sql.Append(" UserCode, ");
  2198. sql.Append(" Groutinglinecode, ");
  2199. sql.Append(" GoodsTypeName, ");
  2200. sql.Append(" GoodsCode, ");
  2201. sql.Append(" Goodsspecification, ");
  2202. sql.Append(" DICTIONARYVALUE, ");
  2203. sql.Append(" MouldQuantity, ");
  2204. sql.Append(" 注浆量, ");
  2205. sql.Append(" 交坯量 ");
  2206. sql.Append(" ) ");
  2207. sql.Append(") Temp where 交坯量 is not null");
  2208. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2209. */
  2210. #endregion
  2211. List<OracleParameter> parameters = new List<OracleParameter>();
  2212. //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2213. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2214. //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2215. string sqlGroutingdate = null;
  2216. StringBuilder sql = new StringBuilder();
  2217. if (se != null)
  2218. {
  2219. // 成型线IDS
  2220. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2221. {
  2222. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
  2223. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2224. }
  2225. // 成型工IDS
  2226. if (!string.IsNullOrEmpty(se.UserIDS))
  2227. {
  2228. sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
  2229. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2230. }
  2231. //产品类型IDS
  2232. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2233. {
  2234. //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
  2235. sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
  2236. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2237. }
  2238. //产品IDS
  2239. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2240. {
  2241. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
  2242. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2243. }
  2244. if (se.GroutingDateStart.HasValue)
  2245. {
  2246. //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
  2247. //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
  2248. sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
  2249. + " and gdd.groutingdate <= :groutingDateEnd \n";
  2250. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2251. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2252. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2253. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2254. }
  2255. else if (se.GCTimeBegin.HasValue)
  2256. {
  2257. //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
  2258. //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
  2259. sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
  2260. + " and gdd.createtime <= :groutingDateEnd \n";
  2261. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  2262. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  2263. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2264. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2265. }
  2266. }
  2267. string sqlString =
  2268. "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
  2269. " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
  2270. " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
  2271. " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
  2272. " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
  2273. " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
  2274. " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
  2275. //" select gddata.usercode,\n" +
  2276. //" gddata.goodscode,\n" +
  2277. //" gddata.goodstypename,\n" +
  2278. //" gddata.goodsspecification,\n" +
  2279. //" gddata.GlazeType,\n" +
  2280. //" gddata.groutinglinecode,\n" +
  2281. //" gddata.MouldQuantity,\n" +
  2282. " gddata.GroutingNum,\n" +
  2283. " gddata.StrippingNum,\n" +
  2284. " gddata.DeliverNum,\n" +
  2285. " decode(gddata.GroutingNum,\n" +
  2286. " 0,\n" +
  2287. " '0.00%',\n" +
  2288. " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
  2289. " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
  2290. " decode(gddata.GroutingNum,\n" +
  2291. " 0,\n" +
  2292. " '0.00%',\n" +
  2293. " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
  2294. " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
  2295. " decode(gddata.StrippingNum,\n" +
  2296. " 0,\n" +
  2297. " '0.00%',\n" +
  2298. " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
  2299. " '9,990.00') || '%') SDPercent -- 成交比,\n" +
  2300. " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2301. //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2302. " gdd.usercode,\n" +
  2303. " gdd.goodscode,\n" +
  2304. " gdd.goodstypename,\n" +
  2305. " gdd.goodsspecification,\n" +
  2306. " gdd.GlazeType,\n" +
  2307. " gdd.groutinglinecode,\n" +
  2308. " gdd.MouldQuantity,\n" +
  2309. " sum(gdd.GroutingNum) GroutingNum,\n" +
  2310. " sum(gdd.StrippingNum) StrippingNum,\n" +
  2311. " sum(gdd.DeliverNum) DeliverNum\n" +
  2312. " from (select 1 flag,\n" +
  2313. //" select 1 flag,\n" +
  2314. " gddgroup.usercode,\n" +
  2315. " gddgroup.goodscode,\n" +
  2316. " gddgroup.goodstypename,\n" +
  2317. " gddgroup.goodsspecification,\n" +
  2318. " gddgroup.GlazeType,\n" +
  2319. " gddgroup.groutinglinecode,\n" +
  2320. " gddgroup.MouldQuantity,\n" +
  2321. " sum(gddgroup.GroutingNum) GroutingNum,\n" +
  2322. " sum(gddgroup.StrippingNum) StrippingNum,\n" +
  2323. " sum(gddgroup.DeliverNum) DeliverNum\n" +
  2324. " from (select --gdd.groutingdailydetailid,\n" +
  2325. " gd.groutinglinecode,\n" +
  2326. " gt.goodstypename,\n" +
  2327. " g.goodscode,\n" +
  2328. " g.goodsspecification,\n" +
  2329. " dd.dictionaryvalue GlazeType,\n" +
  2330. //" gdd.usercode,\n" +
  2331. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2332. " gd.MouldQuantity,\n" +
  2333. " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
  2334. " case\n" +
  2335. " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
  2336. " 1\n" +
  2337. " else\n" +
  2338. " 0\n" +
  2339. " end StrippingNum,\n" +
  2340. " 0 DeliverNum\n" +
  2341. " from tp_pm_groutingdaily gd\n" +
  2342. " inner join tp_pm_groutingdailydetail gdd\n" +
  2343. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2344. " left join tp_mst_user mu\n" +
  2345. " on mu.userid = gd.MonitorID\n" +
  2346. " inner join tp_mst_goods g\n" +
  2347. " on gdd.goodsid = g.goodsid\n" +
  2348. " inner join tp_mst_goodstype gt\n" +
  2349. " on g.goodstypeid = gt.goodstypeid\n" +
  2350. " inner join tp_mst_datadictionary dd\n" +
  2351. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2352. " where gd.valueflag = '1'\n" +
  2353. " and gd.accountid = :AccountID\n"
  2354. + sqlGroutingdate +
  2355. //" and gdd.groutingdate >= :groutingDateStart \n" +
  2356. //" and gdd.groutingdate <= :groutingDateEnd \n" +
  2357. sql +
  2358. " union all\n" +
  2359. " select --gdd.groutingdailydetailid,\n" +
  2360. " gd.groutinglinecode,\n" +
  2361. " gt.goodstypename,\n" +
  2362. " g.goodscode,\n" +
  2363. " g.goodsspecification,\n" +
  2364. " dd.dictionaryvalue GlazeType,\n" +
  2365. //" gdd.usercode,\n" +
  2366. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2367. " gd.MouldQuantity,\n" +
  2368. " 0 GroutingNum,\n" +
  2369. " 0 StrippingNum,\n" +
  2370. " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
  2371. " from tp_pm_groutingdaily gd\n" +
  2372. " inner join tp_pm_groutingdailydetail gdd\n" +
  2373. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2374. " left join tp_mst_user mu\n" +
  2375. " on mu.userid = gd.MonitorID\n" +
  2376. " inner join tp_mst_goods g\n" +
  2377. " on gdd.goodsid = g.goodsid\n" +
  2378. " inner join tp_mst_goodstype gt\n" +
  2379. " on g.goodstypeid = gt.goodstypeid\n" +
  2380. " inner join tp_mst_datadictionary dd\n" +
  2381. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2382. " where gd.valueflag = '1'\n" +
  2383. " and gd.accountid = :AccountID\n" +
  2384. " and gdd.DeliverTime >= :DeliverTimeStart \n" +
  2385. " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
  2386. " ) gddgroup\n" +
  2387. " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
  2388. " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
  2389. " ) gdd\n" +
  2390. " 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" +
  2391. //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
  2392. ") gddata";
  2393. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2394. ServiceResultEntity sre = new ServiceResultEntity();
  2395. if (data == null || data.Rows.Count == 0)
  2396. {
  2397. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2398. return sre;
  2399. }
  2400. sre.Data = new DataSet();
  2401. sre.Data.Tables.Add(data);
  2402. return sre;
  2403. }
  2404. catch (Exception ex)
  2405. {
  2406. throw ex;
  2407. }
  2408. finally
  2409. {
  2410. if (conn != null &&
  2411. conn.ConnState == ConnectionState.Open)
  2412. {
  2413. conn.Close();
  2414. }
  2415. }
  2416. }
  2417. /// <summary>
  2418. /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
  2419. /// </summary>
  2420. /// <returns>sql</returns>
  2421. private static string GetRPT040101SSQL()
  2422. {
  2423. string selSql =
  2424. "select " +
  2425. "UserCode, " +
  2426. "Groutinglinename, " +
  2427. "GoodsTypeName, " +
  2428. "GoodsCode, " +
  2429. "Goodsspecification, " +
  2430. "DICTIONARYVALUE, " +
  2431. "MouldQuantity, " +
  2432. "注浆量, " +
  2433. "交坯量, " +
  2434. "交坯率 " +
  2435. "from " +
  2436. "( " +
  2437. " select " +
  2438. " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
  2439. " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
  2440. " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
  2441. " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
  2442. " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
  2443. " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
  2444. " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
  2445. " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
  2446. " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
  2447. " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
  2448. " from " +
  2449. " ( " +
  2450. " select " +
  2451. " UserCode, " +
  2452. " Groutinglinecode, " +
  2453. " GoodsTypeName, " +
  2454. " GoodsCode, " +
  2455. " Goodsspecification, " +
  2456. " DICTIONARYVALUE, " +
  2457. " MouldQuantity, " +
  2458. " 注浆量, " +
  2459. " ( " +
  2460. " select count(TP_PM_ProductionData.Productiondataid) " +
  2461. " from TP_PM_ProductionData " +
  2462. " where " +
  2463. " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
  2464. " and TP_PM_ProductionData.Usercode=temp.UserCode " +
  2465. " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
  2466. //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
  2467. //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
  2468. //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
  2469. //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2470. //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2471. //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2472. //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2473. //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
  2474. //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
  2475. //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2476. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
  2477. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2478. " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
  2479. " ) as 交坯量 " +
  2480. " from " +
  2481. " ( " +
  2482. " select " +
  2483. " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
  2484. " TP_PM_GroutingDailyDetail.Groutinglineid, " +
  2485. " line.GroutinglineCode, " +
  2486. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  2487. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  2488. " TP_MST_Goods.Goodsspecification, " +
  2489. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  2490. " line.MouldQuantity, " +
  2491. " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
  2492. " from " +
  2493. " TP_PM_GroutingDailyDetail " +
  2494. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
  2495. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
  2496. " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
  2497. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
  2498. " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
  2499. " where " +
  2500. " TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2501. " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2502. " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2503. " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2504. " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
  2505. return selSql;
  2506. }
  2507. /// <summary>
  2508. /// 取得RPT040102_1画面(工序产量分析表)的查询数据
  2509. /// </summary>
  2510. /// <param name="user">登录用户信息</param>
  2511. /// <param name="se">查询条件</param>
  2512. /// <returns>查询结果</returns>
  2513. public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
  2514. {
  2515. IDBConnection conn = null;
  2516. try
  2517. {
  2518. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2519. //OracleParameter[] paras = new OracleParameter[]{
  2520. // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2521. // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2522. // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2523. // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
  2524. // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
  2525. // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2526. // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2527. //};
  2528. /*
  2529. OracleParameter[] paras = new OracleParameter[]{
  2530. new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2531. new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
  2532. new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2533. new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2534. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2535. new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
  2536. new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
  2537. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2538. };
  2539. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
  2540. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
  2541. ServiceResultEntity sre = new ServiceResultEntity();
  2542. if (data == null || data.Tables.Count == 0)
  2543. {
  2544. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2545. return sre;
  2546. }
  2547. sre.Data = new DataSet();
  2548. sre.Data = data;
  2549. return sre;
  2550. */
  2551. ServiceResultEntity sre = new ServiceResultEntity();
  2552. List<OracleParameter> parameters = new List<OracleParameter>();
  2553. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2554. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2555. string sqlString =
  2556. "select p.procedureid, p.procedurecode, p.procedurename\n" +
  2557. " from tp_pc_procedure p\n" +
  2558. " where p.valueflag = '1'\n" +
  2559. " and p.AccountID = :AccountID" +
  2560. " and p.productionlineid = :productionlineid\n";
  2561. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2562. {
  2563. sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
  2564. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2565. }
  2566. sqlString += "order by p.Displayno";
  2567. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2568. if (data == null || data.Rows.Count == 0)
  2569. {
  2570. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2571. return sre;
  2572. }
  2573. parameters.Clear();
  2574. StringBuilder sql1 = new StringBuilder();
  2575. StringBuilder sql2 = new StringBuilder();
  2576. StringBuilder sql3 = new StringBuilder();
  2577. foreach (DataRow item in data.Rows)
  2578. {
  2579. //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
  2580. //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2581. //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2582. sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
  2583. sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2584. sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2585. }
  2586. sqlString =
  2587. "select --pdg.gid,\n" +
  2588. " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
  2589. " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
  2590. " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
  2591. " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
  2592. " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
  2593. " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
  2594. sql3 +
  2595. " from ( select " +
  2596. " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
  2597. " pdata.productionlineid,\n" +
  2598. " pdata.goodstypename2,\n" +
  2599. " pdata.goodstypename,\n" +
  2600. " pdata.goodscode,\n" +
  2601. " pdata.goodsspecification,\n" +
  2602. " pdata.GOODSMODEL,\n" +
  2603. " pdata.GLAZETYPE\n" +
  2604. sql2 +
  2605. " from (" +
  2606. " select\n" +
  2607. " pd.productionlineid,\n" +
  2608. " gt2.goodstypename goodstypename2,\n" +
  2609. " gt.goodstypename,\n" +
  2610. " g.goodscode,\n" +
  2611. " g.goodsspecification,\n" +
  2612. " g.GOODSMODEL,\n" +
  2613. " dd.dictionaryvalue GLAZETYPE\n" +
  2614. sql1 +
  2615. " from tp_pm_productiondata pd\n" +
  2616. " inner join tp_mst_goods g\n" +
  2617. " on g.goodsid = pd.goodsid\n" +
  2618. " inner join tp_mst_goodstype gt\n" +
  2619. " on gt.goodstypeid = g.goodstypeid\n" +
  2620. " inner join tp_mst_goodstype gt2\n" +
  2621. " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  2622. " and gt2.accountid = gt.accountid\n" +
  2623. " inner join tp_mst_datadictionary dd\n" +
  2624. " on dd.dictionaryid = g.GLAZETYPEID\n" +
  2625. " where pd.valueflag = '1'\n" +
  2626. // 公坯、干补不算交坯工序的产量。
  2627. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2628. // modify wangx 2015-12-3
  2629. (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  2630. " and pd.accountid = :accountid\n" +
  2631. " and pd.productionlineid = :productionlineid\n" +
  2632. " and pd.createtime >= :createtimeStart\n" +
  2633. " and pd.createtime <= :createtimeEnd\n";
  2634. StringBuilder sql = new StringBuilder(sqlString);
  2635. if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
  2636. {
  2637. sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
  2638. parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2639. }
  2640. if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
  2641. {
  2642. //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
  2643. sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
  2644. parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2645. }
  2646. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2647. {
  2648. sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
  2649. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2650. }
  2651. 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))");
  2652. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2653. sqlString =
  2654. " group by \n" +
  2655. " pd.productionlineid,\n" +
  2656. " gt2.goodstypename,\n" +
  2657. " gt.goodstypename,\n" +
  2658. " g.goodscode,\n" +
  2659. " g.goodsspecification,\n" +
  2660. " g.GOODSMODEL,\n" +
  2661. " dd.dictionaryvalue\n" +
  2662. " order by gt2.goodstypename, g.goodscode" +
  2663. " ) pdata\n" +
  2664. " group by grouping sets((pdata.productionlineid,\n" +
  2665. " pdata.goodstypename2,\n" +
  2666. " pdata.goodstypename,\n" +
  2667. " pdata.goodsspecification,\n" +
  2668. " pdata.GOODSMODEL,\n" +
  2669. " pdata.GLAZETYPE,\n" +
  2670. " pdata.goodscode),\n" +
  2671. " (pdata.productionlineid,pdata.goodstypename2),\n" +
  2672. " pdata.productionlineid)\n" +
  2673. " ) pdg";
  2674. sql.Append(sqlString);
  2675. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2676. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  2677. parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
  2678. parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
  2679. DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2680. if (data1 == null || data1.Rows.Count == 0)
  2681. {
  2682. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2683. return sre;
  2684. }
  2685. sre.Data = new DataSet();
  2686. sre.Data.Tables.Add(data1);
  2687. return sre;
  2688. }
  2689. catch (Exception ex)
  2690. {
  2691. throw ex;
  2692. }
  2693. finally
  2694. {
  2695. if (conn != null &&
  2696. conn.ConnState == ConnectionState.Open)
  2697. {
  2698. conn.Close();
  2699. }
  2700. }
  2701. }
  2702. /// <summary>
  2703. /// 取得RPT040103画面(工序质量分析表)的查询数据
  2704. /// </summary>
  2705. /// <param name="user">登录用户信息</param>
  2706. /// <param name="se">查询条件</param>
  2707. /// <returns>查询结果</returns>
  2708. public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
  2709. {
  2710. IDBConnection conn = null;
  2711. try
  2712. {
  2713. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2714. List<OracleParameter> parameters = new List<OracleParameter>();
  2715. //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
  2716. string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
  2717. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  2718. ServiceResultEntity sre = new ServiceResultEntity();
  2719. if (data == null || data.Rows.Count == 0)
  2720. {
  2721. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2722. return sre;
  2723. }
  2724. sre.Data = new DataSet();
  2725. sre.Data.Tables.Add(data);
  2726. return sre;
  2727. }
  2728. catch (Exception ex)
  2729. {
  2730. throw ex;
  2731. }
  2732. finally
  2733. {
  2734. if (conn != null &&
  2735. conn.ConnState == ConnectionState.Open)
  2736. {
  2737. conn.Close();
  2738. }
  2739. }
  2740. }
  2741. /// <summary>
  2742. /// 获取RPT040103画面(工序质量分析表)的查询sql
  2743. /// </summary>
  2744. /// <returns>sql</returns>
  2745. private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2746. {
  2747. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2748. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2749. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2750. // 2015-06-16 modify by chenxy
  2751. string sqlString = "\n" +
  2752. "select qdgroup.gid,\n" +
  2753. " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  2754. " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
  2755. " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  2756. " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  2757. " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
  2758. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  2759. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  2760. " qdgroup.OutKilnCount,\n" +
  2761. " qdgroup.GoodCount,\n" +
  2762. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  2763. " qdgroup.SubstandardCount,\n" +
  2764. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  2765. " '990.00') || '%' SubstandardPercent,\n" +
  2766. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  2767. " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  2768. " '990.00') || '%' QualifiedPercent,\n" +
  2769. " qdgroup.BadCount,\n" +
  2770. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  2771. " qdgroup.ReFireCount,\n" +
  2772. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  2773. " '990.00') || '%' ReFirePercent\n" +
  2774. " from (select grouping_id(pcpl.productionlinename,\n" +
  2775. " pcp.procedurename,\n" +
  2776. " mstkiln.kilncode,\n" +
  2777. " mstgoodstype2.goodstypename,\n" +
  2778. " qd.usercode,\n" +
  2779. " --mstgoodstype.goodstypename,\n" +
  2780. " mstgoods.goodscode) gid,\n" +
  2781. " pcpl.productionlinename,\n" +
  2782. " pcp.procedurename,\n" +
  2783. " --qd.kilnid,\n" +
  2784. " mstkiln.kilncode,\n" +
  2785. " mstgoodstype2.goodstypename goodstypename2,\n" +
  2786. " qd.usercode,\n" +
  2787. " mstgoodstype.goodstypename,\n" +
  2788. " mstgoods.goodscode,\n" +
  2789. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  2790. " sum(qd.GoodCount) GoodCount,\n" +
  2791. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  2792. " sum(qd.BadCount) BadCount,\n" +
  2793. " sum(qd.ReFireCount) ReFireCount\n" +
  2794. " from (select --pdbc.barcode,\n" +
  2795. " pdbc.productionlineid,\n" +
  2796. " pdata.procedureid,\n" +
  2797. " pdata.usercode,\n" +
  2798. " pdbc.goodsid,\n" +
  2799. " pdbc.kilnid,\n" +
  2800. " --pdbc.kilncarid,\n" +
  2801. " --pdbc.kilncarbatchno,\n" +
  2802. " 1 OutKilnCount,\n" +
  2803. " case\n" +
  2804. " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
  2805. " 0\n" +
  2806. " else\n" +
  2807. " 1\n" +
  2808. " end GoodCount,\n" +
  2809. " case\n" +
  2810. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
  2811. " 1\n" +
  2812. " else\n" +
  2813. " 0\n" +
  2814. " end SubstandardCount,\n" +
  2815. " case\n" +
  2816. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
  2817. " 1\n" +
  2818. " else\n" +
  2819. " 0\n" +
  2820. " end ReFireCount,\n" +
  2821. " case\n" +
  2822. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
  2823. " 1\n" +
  2824. " else\n" +
  2825. " 0\n" +
  2826. " end BadCount\n" +
  2827. " from (select distinct pd.barcode,\n" +
  2828. " pd.productionlineid,\n" +
  2829. " pd.goodsid,\n" +
  2830. " pd.kilnid,\n" +
  2831. " --pd.kilncarid,\n" +
  2832. " pd.kilncarbatchno\n" +
  2833. " from tp_pm_productiondata pd\n" +
  2834. " where pd.valueflag = '1'\n" +
  2835. " and pd.procedureid = :in_rptSprocedureId \n" +
  2836. " and pd.AccountID = :AccountID\n ";
  2837. StringBuilder selSql = new StringBuilder(sqlString);
  2838. if (se.CreateTimeStart.HasValue)
  2839. {
  2840. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  2841. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2842. }
  2843. if (se.CreateTimeEnd.HasValue)
  2844. {
  2845. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  2846. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2847. }
  2848. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2849. {
  2850. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  2851. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2852. }
  2853. if (se.ProductionLineID.HasValue)
  2854. {
  2855. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  2856. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2857. }
  2858. //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))");
  2859. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2860. if (se.KilnID.HasValue)
  2861. {
  2862. selSql.Append(" AND pd.KilnID = :KilnID\n");
  2863. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  2864. }
  2865. sqlString =
  2866. " ) pdbc\n" + // 成检交接工序
  2867. " inner join (select distinct pd.barcode,\n" +
  2868. " pd.userid,\n" +
  2869. " pd.usercode,\n" +
  2870. " pd.procedureid\n" +
  2871. " from tp_pm_productiondata pd\n" +
  2872. " where pd.valueflag = '1'\n" +
  2873. " and pd.AccountID = :AccountID\n" +
  2874. // 公坯、干补不算交坯工序的质量。
  2875. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2876. // 干补不算交坯工序的质量。
  2877. " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
  2878. " and exists\n" +
  2879. " (select 1\n" +
  2880. " from tp_mst_rpttprocedure rptt\n" +
  2881. " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
  2882. selSql.Append(sqlString);
  2883. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  2884. {
  2885. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  2886. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  2887. }
  2888. //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))");
  2889. selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
  2890. if (!string.IsNullOrEmpty(se.UserIDS))
  2891. {
  2892. selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
  2893. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2894. }
  2895. sqlString =
  2896. " ) pdata\n" + // 生产工序
  2897. " on pdata.barcode = pdbc.barcode\n" +
  2898. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
  2899. " from (select pd.barcode,\n" +
  2900. " pd.kilncarbatchno,\n" +
  2901. " pd.goodsleveltypeid,\n" +
  2902. " pd.productiondataid,\n" +
  2903. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  2904. " from tp_pm_productiondata pd\n" +
  2905. " where pd.valueflag = '1'\n" +
  2906. " and pd.AccountID = :AccountID\n" +
  2907. " and length(pd.kilncarbatchno) > 0\n" +
  2908. " AND pd.createtime >= :CreateTimeStart\n" +
  2909. " and pd.modeltype = -1) kcbc\n" +
  2910. " where kcbc.dataid = 1) glt\n" +
  2911. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  2912. " and pdbc.barcode = glt.barcode\n" +
  2913. " left join (select distinct productiondataid, defectprocedureid" +
  2914. " from tp_pm_defect def " +
  2915. " where def.valueflag='1'" +
  2916. " and def.AccountID = :AccountID\n" +
  2917. " AND def.createtime >= :CreateTimeStart) defect\n" +
  2918. " on defect.productiondataid = glt.productiondataid\n" +
  2919. " and pdata.procedureid = defect.defectprocedureid\n" +
  2920. " ) qd\n" +
  2921. " inner join tp_pc_productionline pcpl\n" +
  2922. " on pcpl.productionlineid = qd.productionlineid\n" +
  2923. " inner join tp_pc_procedure pcp\n" +
  2924. " on pcp.procedureid = qd.procedureid\n" +
  2925. " inner join tp_mst_kiln mstkiln\n" +
  2926. " on mstkiln.kilnid = qd.kilnid\n" +
  2927. " inner join tp_mst_goods mstgoods\n" +
  2928. " on mstgoods.goodsid = qd.goodsid\n" +
  2929. " inner join tp_mst_goodstype mstgoodstype\n" +
  2930. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  2931. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  2932. " inner join tp_mst_goodstype mstgoodstype2\n" +
  2933. " on mstgoodstype2.goodstypecode =\n" +
  2934. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  2935. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  2936. " where 1=1\n";
  2937. selSql.Append(sqlString);
  2938. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2939. {
  2940. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
  2941. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  2942. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2943. }
  2944. sqlString =
  2945. " group by grouping sets((pcpl.productionlinename,\n" +
  2946. " pcp.procedurename,\n" +
  2947. " mstkiln.kilncode,\n" +
  2948. " mstgoodstype2.goodstypename,\n" +
  2949. " qd.usercode,\n" +
  2950. " mstgoodstype.goodstypename,\n" +
  2951. " mstgoods.goodscode),\n" +
  2952. " (pcpl.productionlinename,\n" +
  2953. " pcp.procedurename,\n" +
  2954. " mstkiln.kilncode,\n" +
  2955. " mstgoodstype2.goodstypename),\n" +
  2956. " (pcpl.productionlinename,\n" +
  2957. " pcp.procedurename,\n" +
  2958. " mstkiln.kilncode),\n" +
  2959. " (pcpl.productionlinename, pcp.procedurename))\n" +
  2960. " order by pcpl.productionlinename,\n" +
  2961. " pcp.procedurename,\n" +
  2962. " mstkiln.kilncode,\n" +
  2963. " mstgoodstype2.goodstypename,\n" +
  2964. " qd.usercode,\n" +
  2965. " mstgoodstype.goodstypename,\n" +
  2966. " mstgoods.goodscode\n" +
  2967. " ) qdgroup\n";
  2968. selSql.Append(sqlString);
  2969. return selSql.ToString();
  2970. }
  2971. /// <summary>
  2972. /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
  2973. /// </summary>
  2974. /// <returns>sql</returns>
  2975. private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2976. {
  2977. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2978. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2979. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2980. string sqlString = "select qdgroup.gid\n" +
  2981. " ,qdgroup.productionlinename\n" +
  2982. " ,decode(qdgroup.gid\n" +
  2983. " ,15\n" +
  2984. " ,'总计[' || qdgroup.procedurename || ']'\n" +
  2985. " ,qdgroup.procedurename) procedurename\n" +
  2986. " ,decode(qdgroup.gid\n" +
  2987. " ,7\n" +
  2988. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  2989. " ,15\n" +
  2990. " ,'--'\n" +
  2991. " ,qdgroup.kilncode) kilncode\n" +
  2992. " ,decode(qdgroup.gid\n" +
  2993. " ,3\n" +
  2994. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  2995. " ,15\n" +
  2996. " ,'--'\n" +
  2997. " ,7\n" +
  2998. " ,'--'\n" +
  2999. " ,qdgroup.goodstypename2) goodstypename2\n" +
  3000. " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
  3001. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3002. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3003. " ,qdgroup.OutKilnCount\n" +
  3004. " ,qdgroup.GoodCount\n" +
  3005. " ,decode(qdgroup.OutKilnCount\n" +
  3006. " ,0\n" +
  3007. " ,to_number(null)\n" +
  3008. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3009. " ,qdgroup.SubstandardCount\n" +
  3010. " ,decode(qdgroup.OutKilnCount\n" +
  3011. " ,0\n" +
  3012. " ,to_number(null)\n" +
  3013. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3014. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3015. " ,decode(qdgroup.OutKilnCount\n" +
  3016. " ,0\n" +
  3017. " ,to_number(null)\n" +
  3018. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3019. " qdgroup.OutKilnCount\n" +
  3020. " ,4)) QualifiedPercent\n" +
  3021. " ,qdgroup.BadCount\n" +
  3022. " ,decode(qdgroup.OutKilnCount\n" +
  3023. " ,0\n" +
  3024. " ,to_number(null)\n" +
  3025. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3026. " ,qdgroup.ReFireCount\n" +
  3027. " ,decode(qdgroup.OutKilnCount\n" +
  3028. " ,0\n" +
  3029. " ,to_number(null)\n" +
  3030. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3031. " from (select grouping_id(pcpl.productionlinename\n" +
  3032. " ,pcp.procedurename\n" +
  3033. " ,mstkiln.kilncode\n" +
  3034. " ,mstgoodstype2.goodstypecode\n" +
  3035. " ,pdata.usercode\n" +
  3036. " ,mstgoods.goodscode) gid\n" +
  3037. " ,pcpl.productionlinename\n" +
  3038. " ,pcp.procedurename\n" +
  3039. " ,mstkiln.kilncode\n" +
  3040. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3041. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3042. " ,pdata.usercode\n" +
  3043. " ,mstgoodstype.goodstypename\n" +
  3044. " ,mstgoods.goodscode\n" +
  3045. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3046. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3047. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3048. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3049. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3050. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3051. " ,pd.barcode\n" +
  3052. " ,pd.productionlineid\n" +
  3053. " ,pd.goodsid\n" +
  3054. " ,pd.kilnid\n" +
  3055. " ,pd.kilncarbatchno\n" +
  3056. " ,0 procedureid\n" +
  3057. " ,1 cc\n" +
  3058. " from tp_pm_productiondata pd\n" +
  3059. " where pd.valueflag = '1'\n" +
  3060. " and pd.procedureid = :in_rptSprocedureId\n" +
  3061. " and pd.accountid = :in_AccountID\n";
  3062. StringBuilder selSql = new StringBuilder(sqlString);
  3063. if (se.CreateTimeStart.HasValue)
  3064. {
  3065. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3066. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3067. }
  3068. if (se.CreateTimeEnd.HasValue)
  3069. {
  3070. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3071. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3072. }
  3073. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3074. {
  3075. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3076. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3077. }
  3078. if (se.ProductionLineID.HasValue)
  3079. {
  3080. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3081. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3082. }
  3083. if (se.KilnID.HasValue)
  3084. {
  3085. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3086. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3087. }
  3088. sqlString =
  3089. " union all\n" +
  3090. " select distinct ppd.goodsleveltypeid\n" +
  3091. " ,dd.barcode\n" +
  3092. " ,dd.productionlineid\n" +
  3093. " ,dd.goodsid\n" +
  3094. " ,ppd.kilnid\n" +
  3095. " ,ppd.kilncarbatchno\n" +
  3096. " ,dd.defectprocedureid procedureid\n" +
  3097. " ,1 cc\n" +
  3098. " from (select pd.productiondataid\n" +
  3099. " ,pd.goodsleveltypeid\n" +
  3100. " ,pd.kilnid\n" +
  3101. " ,pd.kilncarbatchno\n" +
  3102. " from tp_pm_productiondata pd\n" +
  3103. " where pd.valueflag = '1'\n" +
  3104. " and pd.AccountID = :in_AccountID\n" +
  3105. " and length(pd.kilncarbatchno) > 0\n" +
  3106. " and pd.modeltype = -1\n";
  3107. selSql.Append(sqlString);
  3108. if (se.CreateTimeStart.HasValue)
  3109. {
  3110. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3111. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3112. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3113. }
  3114. if (se.CreateTimeEnd.HasValue)
  3115. {
  3116. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3117. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3118. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3119. }
  3120. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3121. {
  3122. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3123. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3124. }
  3125. if (se.ProductionLineID.HasValue)
  3126. {
  3127. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3128. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3129. }
  3130. if (se.KilnID.HasValue)
  3131. {
  3132. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3133. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3134. }
  3135. sqlString =
  3136. " and exists\n" +
  3137. " (select 1\n" +
  3138. " from tp_pm_productiondata outpd\n" +
  3139. " where outpd.barcode = pd.barcode\n" +
  3140. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3141. " and outpd.valueflag = '1'\n" +
  3142. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3143. " inner join tp_pm_defect dd\n" +
  3144. " on dd.productiondataid = ppd.productiondataid\n" +
  3145. //" --and dd.checktime >= in_DateBegin\n" +
  3146. //" --and dd.checktime <= in_DateEnd\n" +
  3147. " ) ppcc\n" +
  3148. " inner join tp_pm_productiondata pdata\n" +
  3149. " on pdata.barcode = ppcc.barcode\n" +
  3150. // 干补不算交坯工序的质量。
  3151. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3152. " and exists\n" +
  3153. " (select 1\n" +
  3154. " from tp_mst_rpttprocedure rptt\n" +
  3155. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3156. selSql.Append(sqlString);
  3157. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3158. {
  3159. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3160. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3161. }
  3162. sqlString =
  3163. " and rptt.procedureid = pdata.procedureid)\n" +
  3164. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3165. selSql.Append(sqlString);
  3166. if (!string.IsNullOrEmpty(se.UserIDS))
  3167. {
  3168. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3169. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3170. }
  3171. sqlString =
  3172. " inner join tp_pc_productionline pcpl\n" +
  3173. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3174. " inner join tp_pc_procedure pcp\n" +
  3175. " on pcp.procedureid = pdata.procedureid\n" +
  3176. " inner join tp_mst_kiln mstkiln\n" +
  3177. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3178. " inner join tp_mst_goods mstgoods\n" +
  3179. " on mstgoods.goodsid = pdata.goodsid\n" +
  3180. " inner join tp_mst_goodstype mstgoodstype\n" +
  3181. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3182. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3183. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3184. " on mstgoodstype2.goodstypecode =\n" +
  3185. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3186. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3187. // 产品类别
  3188. selSql.Append(sqlString);
  3189. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3190. {
  3191. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3192. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3193. }
  3194. sqlString =
  3195. " 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" +
  3196. " order by pcpl.productionlinename\n" +
  3197. " ,pcp.displayno\n" +
  3198. " ,pcp.procedurename\n" +
  3199. " ,mstkiln.kilncode\n" +
  3200. " ,mstgoodstype2.goodstypecode\n" +
  3201. " ,pdata.usercode\n" +
  3202. " ,mstgoodstype.goodstypecode\n" +
  3203. " ,mstgoods.goodscode) qdgroup";
  3204. selSql.Append(sqlString);
  3205. return selSql.ToString();
  3206. }
  3207. /// <summary>
  3208. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3209. /// </summary>
  3210. /// <param name="user">登录用户信息</param>
  3211. /// <param name="se">查询条件</param>
  3212. /// <returns>查询结果</returns>
  3213. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3214. {
  3215. IDBConnection conn = null;
  3216. try
  3217. {
  3218. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3219. List<OracleParameter> parameters = new List<OracleParameter>();
  3220. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3221. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3222. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3223. ServiceResultEntity sre = new ServiceResultEntity();
  3224. if (data == null || data.Rows.Count == 0)
  3225. {
  3226. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3227. return sre;
  3228. }
  3229. sre.Data = new DataSet();
  3230. sre.Data.Tables.Add(data);
  3231. return sre;
  3232. }
  3233. catch (Exception ex)
  3234. {
  3235. throw ex;
  3236. }
  3237. finally
  3238. {
  3239. if (conn != null &&
  3240. conn.ConnState == ConnectionState.Open)
  3241. {
  3242. conn.Close();
  3243. }
  3244. }
  3245. }
  3246. /// <summary>
  3247. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3248. /// </summary>
  3249. /// <returns>sql</returns>
  3250. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3251. {
  3252. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3253. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3254. // 2015-06-16 modify by chenxy
  3255. string sqlString = "\n" +
  3256. "select qdgroup.gid,\n" +
  3257. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3258. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3259. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3260. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3261. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3262. " qdgroup.OutKilnCount,\n" +
  3263. " qdgroup.GoodCount,\n" +
  3264. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3265. " qdgroup.SubstandardCount,\n" +
  3266. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3267. " '990.00') || '%' SubstandardPercent,\n" +
  3268. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3269. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3270. " '990.00') || '%' QualifiedPercent,\n" +
  3271. " qdgroup.BadCount,\n" +
  3272. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3273. " qdgroup.ReFireCount,\n" +
  3274. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3275. " '990.00') || '%' ReFirePercent\n" +
  3276. " from (select grouping_id(pcpl.productionlinename,\n" +
  3277. " mstkiln.kilncode,\n" +
  3278. " mstgoodstype2.goodstypename,\n" +
  3279. " --mstgoodstype.goodstypename,\n" +
  3280. " mstgoods.goodscode) gid,\n" +
  3281. " pcpl.productionlinename,\n" +
  3282. " --qd.kilnid,\n" +
  3283. " mstkiln.kilncode,\n" +
  3284. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3285. " mstgoodstype.goodstypename,\n" +
  3286. " mstgoods.goodscode,\n" +
  3287. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3288. " sum(qd.GoodCount) GoodCount,\n" +
  3289. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3290. " sum(qd.BadCount) BadCount,\n" +
  3291. " sum(qd.ReFireCount) ReFireCount\n" +
  3292. " from (select --pdbc.barcode,\n" +
  3293. " pdbc.productionlineid,\n" +
  3294. " pdbc.goodsid,\n" +
  3295. " pdbc.kilnid,\n" +
  3296. " --pdbc.kilncarid,\n" +
  3297. " --pdbc.kilncarbatchno,\n" +
  3298. " 1 OutKilnCount,\n" +
  3299. " case\n" +
  3300. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3301. " 0\n" +
  3302. " else\n" +
  3303. " 1\n" +
  3304. " end GoodCount,\n" +
  3305. " case\n" +
  3306. " when glt.goodsleveltypeid = 7 then\n" +
  3307. " 1\n" +
  3308. " else\n" +
  3309. " 0\n" +
  3310. " end SubstandardCount,\n" +
  3311. " case\n" +
  3312. " when glt.goodsleveltypeid = 6 then\n" +
  3313. " 1\n" +
  3314. " else\n" +
  3315. " 0\n" +
  3316. " end ReFireCount,\n" +
  3317. " case\n" +
  3318. " when glt.goodsleveltypeid = 5 then\n" +
  3319. " 1\n" +
  3320. " else\n" +
  3321. " 0\n" +
  3322. " end BadCount\n" +
  3323. " from (select distinct pd.barcode,\n" +
  3324. " pd.productionlineid,\n" +
  3325. " pd.goodsid,\n" +
  3326. " pd.kilnid,\n" +
  3327. " --pd.kilncarid,\n" +
  3328. " pd.kilncarbatchno\n" +
  3329. " from tp_pm_productiondata pd\n" +
  3330. " where pd.valueflag = '1'\n" +
  3331. " and pd.procedureid = :in_rptSprocedureId \n" +
  3332. " and pd.AccountID = :AccountID\n";
  3333. StringBuilder selSql = new StringBuilder(sqlString);
  3334. if (se.CreateTimeStart.HasValue)
  3335. {
  3336. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3337. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3338. }
  3339. if (se.CreateTimeEnd.HasValue)
  3340. {
  3341. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3342. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3343. }
  3344. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3345. {
  3346. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3347. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3348. }
  3349. if (se.ProductionLineID.HasValue)
  3350. {
  3351. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3352. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3353. }
  3354. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3355. {
  3356. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3357. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3358. }
  3359. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3360. {
  3361. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3362. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3363. }
  3364. //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))");
  3365. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3366. if (se.KilnID.HasValue)
  3367. {
  3368. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3369. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3370. }
  3371. sqlString =
  3372. " ) pdbc\n" +
  3373. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3374. " from (select pd.barcode,\n" +
  3375. " pd.kilncarbatchno,\n" +
  3376. " pd.goodsleveltypeid,\n" +
  3377. " pd.productiondataid,\n" +
  3378. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3379. " from tp_pm_productiondata pd\n" +
  3380. " where pd.valueflag = '1'\n" +
  3381. " and pd.AccountID = :AccountID\n" +
  3382. " and length(pd.kilncarbatchno) > 0\n" +
  3383. " AND pd.createtime >= :CreateTimeStart\n" +
  3384. " and pd.modeltype = -1) kcbc\n" +
  3385. " where kcbc.dataid = 1) glt\n" +
  3386. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3387. " and pdbc.barcode = glt.barcode) qd\n" +
  3388. " inner join tp_pc_productionline pcpl\n" +
  3389. " on pcpl.productionlineid = qd.productionlineid\n" +
  3390. " inner join tp_mst_kiln mstkiln\n" +
  3391. " on mstkiln.kilnid = qd.kilnid\n" +
  3392. " inner join tp_mst_goods mstgoods\n" +
  3393. " on mstgoods.goodsid = qd.goodsid\n" +
  3394. " inner join tp_mst_goodstype mstgoodstype\n" +
  3395. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3396. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3397. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3398. " on mstgoodstype2.goodstypecode =\n" +
  3399. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3400. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3401. " where 1=1\n";
  3402. selSql.Append(sqlString);
  3403. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3404. {
  3405. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3406. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3407. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3408. }
  3409. sqlString =
  3410. " group by grouping sets((pcpl.productionlinename,\n" +
  3411. " mstkiln.kilncode,\n" +
  3412. " mstgoodstype2.goodstypename,\n" +
  3413. " mstgoodstype.goodstypename,\n" +
  3414. " mstgoods.goodscode),\n" +
  3415. " (pcpl.productionlinename,\n" +
  3416. " mstkiln.kilncode,\n" +
  3417. " mstgoodstype2.goodstypename),\n" +
  3418. " (pcpl.productionlinename,\n" +
  3419. " mstkiln.kilncode),\n" +
  3420. " pcpl.productionlinename)\n" +
  3421. " order by pcpl.productionlinename,\n" +
  3422. " mstkiln.kilncode,\n" +
  3423. " mstgoodstype2.goodstypename,\n" +
  3424. " mstgoodstype.goodstypename,\n" +
  3425. " mstgoods.goodscode\n" +
  3426. " ) qdgroup\n";
  3427. selSql.Append(sqlString);
  3428. return selSql.ToString();
  3429. }
  3430. /// <summary>
  3431. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3432. /// </summary>
  3433. /// <returns>sql</returns>
  3434. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3435. {
  3436. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3437. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3438. string sqlString = "select qdgroup.gid\n" +
  3439. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3440. " ,decode(qdgroup.gid\n" +
  3441. " ,3\n" +
  3442. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3443. " ,7\n" +
  3444. " ,'--'\n" +
  3445. " ,qdgroup.kilncode) kilncode\n" +
  3446. " ,decode(qdgroup.gid\n" +
  3447. " ,1\n" +
  3448. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3449. " ,0\n" +
  3450. " ,qdgroup.goodstypename2\n" +
  3451. " ,'--') goodstypename2\n" +
  3452. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3453. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3454. " ,qdgroup.OutKilnCount\n" +
  3455. " ,qdgroup.GoodCount\n" +
  3456. " ,decode(qdgroup.OutKilnCount\n" +
  3457. " ,0\n" +
  3458. " ,to_number(null)\n" +
  3459. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3460. " ,qdgroup.SubstandardCount\n" +
  3461. " ,decode(qdgroup.OutKilnCount\n" +
  3462. " ,0\n" +
  3463. " ,to_number(null)\n" +
  3464. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3465. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3466. " ,decode(qdgroup.OutKilnCount\n" +
  3467. " ,0\n" +
  3468. " ,to_number(null)\n" +
  3469. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3470. " qdgroup.OutKilnCount\n" +
  3471. " ,4)) QualifiedPercent\n" +
  3472. " ,qdgroup.BadCount\n" +
  3473. " ,decode(qdgroup.OutKilnCount\n" +
  3474. " ,0\n" +
  3475. " ,to_number(null)\n" +
  3476. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3477. " ,qdgroup.ReFireCount\n" +
  3478. " ,decode(qdgroup.OutKilnCount\n" +
  3479. " ,0\n" +
  3480. " ,to_number(null)\n" +
  3481. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3482. " from (select grouping_id(pcpl.productionlinename\n" +
  3483. " ,mstkiln.kilncode\n" +
  3484. " ,mstgoodstype2.goodstypecode\n" +
  3485. " ,mstgoods.goodscode) gid\n" +
  3486. " ,pcpl.productionlinename\n" +
  3487. " ,mstkiln.kilncode\n" +
  3488. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3489. " ,mstgoodstype.goodstypename\n" +
  3490. " ,mstgoods.goodscode\n" +
  3491. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3492. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3493. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3494. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3495. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3496. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3497. " ,pd.barcode\n" +
  3498. " ,pd.productionlineid\n" +
  3499. " ,pd.goodsid\n" +
  3500. " ,pd.kilnid\n" +
  3501. " ,pd.kilncarbatchno\n" +
  3502. " ,1 cc\n" +
  3503. " from tp_pm_productiondata pd\n" +
  3504. " where pd.valueflag = '1'\n" +
  3505. " and pd.procedureid = :in_rptSprocedureId\n" +
  3506. " and pd.accountid = :in_AccountID\n";
  3507. StringBuilder selSql = new StringBuilder(sqlString);
  3508. if (se.CreateTimeStart.HasValue)
  3509. {
  3510. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3511. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3512. }
  3513. if (se.CreateTimeEnd.HasValue)
  3514. {
  3515. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3516. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3517. }
  3518. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3519. {
  3520. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3521. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3522. }
  3523. if (se.ProductionLineID.HasValue)
  3524. {
  3525. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3526. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3527. }
  3528. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3529. {
  3530. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3531. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3532. }
  3533. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3534. {
  3535. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3536. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3537. }
  3538. if (se.KilnID.HasValue)
  3539. {
  3540. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3541. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3542. }
  3543. sqlString =
  3544. " union all\n" +
  3545. " select distinct pd.goodsleveltypeid\n" +
  3546. " ,pd.barcode\n" +
  3547. " ,pd.productionlineid\n" +
  3548. " ,pd.goodsid\n" +
  3549. " ,pd.kilnid\n" +
  3550. " ,pd.kilncarbatchno\n" +
  3551. " ,1 cc\n" +
  3552. " from tp_pm_productiondata pd\n" +
  3553. " where pd.valueflag = '1'\n" +
  3554. " and pd.modeltype = -1\n" +
  3555. " and pd.AccountID = :in_AccountID\n" +
  3556. " and length(pd.kilncarbatchno) > 0\n";
  3557. selSql.Append(sqlString);
  3558. if (se.CreateTimeStart.HasValue)
  3559. {
  3560. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3561. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3562. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3563. }
  3564. if (se.CreateTimeEnd.HasValue)
  3565. {
  3566. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3567. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3568. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3569. }
  3570. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3571. {
  3572. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3573. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3574. }
  3575. if (se.ProductionLineID.HasValue)
  3576. {
  3577. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3578. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3579. }
  3580. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3581. {
  3582. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3583. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3584. }
  3585. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3586. {
  3587. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3588. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3589. }
  3590. if (se.KilnID.HasValue)
  3591. {
  3592. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3593. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3594. }
  3595. sqlString =
  3596. " and exists\n" +
  3597. " (select 1\n" +
  3598. " from tp_pm_productiondata outpd\n" +
  3599. " where outpd.barcode = pd.barcode\n" +
  3600. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3601. " and outpd.valueflag = '1'\n" +
  3602. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  3603. " inner join tp_pc_productionline pcpl\n" +
  3604. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  3605. " inner join tp_mst_kiln mstkiln\n" +
  3606. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3607. " inner join tp_mst_goods mstgoods\n" +
  3608. " on mstgoods.goodsid = ppcc.goodsid\n" +
  3609. " inner join tp_mst_goodstype mstgoodstype\n" +
  3610. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3611. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3612. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3613. " on mstgoodstype2.goodstypecode =\n" +
  3614. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3615. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3616. // 产品类别
  3617. selSql.Append(sqlString);
  3618. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3619. {
  3620. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3621. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3622. }
  3623. sqlString =
  3624. " 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" +
  3625. " order by pcpl.productionlinename\n" +
  3626. " ,mstkiln.kilncode\n" +
  3627. " ,mstgoodstype2.goodstypecode\n" +
  3628. " ,mstgoodstype.goodstypecode\n" +
  3629. " ,mstgoods.goodscode) qdgroup\n";
  3630. selSql.Append(sqlString);
  3631. return selSql.ToString();
  3632. }
  3633. /// <summary>
  3634. /// 取得RPT040105画面(质量报表)的查询数据
  3635. /// </summary>
  3636. /// <param name="user">登录用户信息</param>
  3637. /// <param name="se">查询条件</param>
  3638. /// <returns>查询结果</returns>
  3639. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  3640. {
  3641. IDBConnection conn = null;
  3642. try
  3643. {
  3644. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3645. List<OracleParameter> parameters = new List<OracleParameter>();
  3646. string sqlString =
  3647. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  3648. " FROM tp_pm_groutingdailydetail gdd\n" +
  3649. " INNER JOIN tp_mst_goods g\n" +
  3650. " ON g.goodsid = gdd.goodsid\n" +
  3651. " INNER JOIN tp_mst_goodstype gt\n" +
  3652. " ON gt.goodstypeid = g.goodstypeid\n" +
  3653. " WHERE gdd.accountid = :accountid\n" +
  3654. " AND gdd.valueflag = '1'\n" +
  3655. " AND gdd.groutingdate >= :datebegin\n" +
  3656. " AND gdd.groutingdate <= :dateend\n" +
  3657. " AND gdd.groutingflag = '1'\n" +
  3658. " AND gdd.barcode IS NOT NULL\n" +
  3659. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  3660. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3661. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  3662. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  3663. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3664. parameters.Clear();
  3665. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  3666. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  3667. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3668. ServiceResultEntity sre = new ServiceResultEntity();
  3669. if (data == null || data.Rows.Count == 0)
  3670. {
  3671. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3672. return sre;
  3673. }
  3674. data.Columns.Add("GCount", typeof(int));
  3675. //data.Columns.Add("OutGCount", typeof(string));
  3676. //data.Columns.Add("GoodGCount", typeof(string));
  3677. data.Columns.Add("OutGCount", typeof(decimal));
  3678. data.Columns.Add("GoodGCount", typeof(decimal));
  3679. foreach (DataRow item in data.Rows)
  3680. {
  3681. int gid = Convert.ToInt32(item["gid"]);
  3682. if (gid < 2)
  3683. {
  3684. continue;
  3685. }
  3686. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  3687. int goodCount = Convert.ToInt32(item["Qualified"]);
  3688. DataRow[] drs = null;
  3689. if (gid == 2)
  3690. {
  3691. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  3692. }
  3693. else if (gid == 3)
  3694. {
  3695. drs = dataCount.Select("goodstypecode2 is null");
  3696. }
  3697. if (drs != null && drs.Length > 0)
  3698. {
  3699. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  3700. item["GCount"] = barcodecount;
  3701. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3702. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3703. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  3704. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  3705. }
  3706. else
  3707. {
  3708. item["GCount"] = 0;
  3709. //item["OutGCount"] = "#DIV/0!";
  3710. //item["GoodGCount"] = "#DIV/0!";
  3711. item["OutGCount"] = DBNull.Value;
  3712. item["GoodGCount"] = DBNull.Value;
  3713. }
  3714. }
  3715. sre.Data = new DataSet();
  3716. sre.Data.Tables.Add(data);
  3717. return sre;
  3718. }
  3719. catch (Exception ex)
  3720. {
  3721. throw ex;
  3722. }
  3723. finally
  3724. {
  3725. if (conn != null &&
  3726. conn.ConnState == ConnectionState.Open)
  3727. {
  3728. conn.Close();
  3729. }
  3730. }
  3731. }
  3732. /// <summary>
  3733. /// 获取RPT040105画面(质量报表)的查询sql
  3734. /// </summary>
  3735. /// <returns>sql</returns>
  3736. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3737. {
  3738. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3739. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3740. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3741. // 2015-06-16 modify by chenxy
  3742. string sqlString = "\n" +
  3743. "select qdgroup.gid,\n" +
  3744. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3745. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3746. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3747. " qdgroup.goodstypecode2,\n" +
  3748. " qdgroup.OutKilnCount,\n" +
  3749. " qdgroup.GoodCount,\n" +
  3750. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3751. " qdgroup.SubstandardCount,\n" +
  3752. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3753. " '990.00') || '%' SubstandardPercent,\n" +
  3754. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3755. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3756. " '990.00') || '%' QualifiedPercent,\n" +
  3757. " qdgroup.BadCount,\n" +
  3758. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3759. " qdgroup.ReFireCount,\n" +
  3760. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3761. " '990.00') || '%' ReFirePercent\n" +
  3762. " from (select grouping_id(pcpl.productionlinename,\n" +
  3763. " mstkiln.kilncode,\n" +
  3764. " mstgoodstype2.goodstypecode) gid,\n" +
  3765. " pcpl.productionlinename,\n" +
  3766. " mstkiln.kilncode,\n" +
  3767. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  3768. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3769. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3770. " sum(qd.GoodCount) GoodCount,\n" +
  3771. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3772. " sum(qd.BadCount) BadCount,\n" +
  3773. " sum(qd.ReFireCount) ReFireCount\n" +
  3774. " from (select --pdbc.barcode,\n" +
  3775. " pdbc.productionlineid,\n" +
  3776. " pdbc.goodsid,\n" +
  3777. " pdbc.kilnid,\n" +
  3778. " 1 OutKilnCount,\n" +
  3779. " case\n" +
  3780. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3781. " 0\n" +
  3782. " else\n" +
  3783. " 1\n" +
  3784. " end GoodCount,\n" +
  3785. " case\n" +
  3786. " when glt.goodsleveltypeid = 7 then\n" +
  3787. " 1\n" +
  3788. " else\n" +
  3789. " 0\n" +
  3790. " end SubstandardCount,\n" +
  3791. " case\n" +
  3792. " when glt.goodsleveltypeid = 6 then\n" +
  3793. " 1\n" +
  3794. " else\n" +
  3795. " 0\n" +
  3796. " end ReFireCount,\n" +
  3797. " case\n" +
  3798. " when glt.goodsleveltypeid = 5 then\n" +
  3799. " 1\n" +
  3800. " else\n" +
  3801. " 0\n" +
  3802. " end BadCount\n" +
  3803. " from (select distinct pd.barcode,\n" +
  3804. " pd.productionlineid,\n" +
  3805. " pd.goodsid,\n" +
  3806. " pd.kilnid,\n" +
  3807. " pd.kilncarbatchno\n" +
  3808. " from tp_pm_productiondata pd\n" +
  3809. " where pd.valueflag = '1'\n" +
  3810. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  3811. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  3812. " and pd.AccountID = :AccountID\n";
  3813. StringBuilder selSql = new StringBuilder(sqlString);
  3814. if (se.CreateTimeStart.HasValue)
  3815. {
  3816. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3817. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3818. }
  3819. if (se.CreateTimeEnd.HasValue)
  3820. {
  3821. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3822. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3823. }
  3824. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3825. {
  3826. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3827. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3828. }
  3829. if (se.ProductionLineID.HasValue)
  3830. {
  3831. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3832. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3833. }
  3834. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3835. {
  3836. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3837. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3838. }
  3839. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3840. {
  3841. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3842. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3843. }
  3844. // 不控制权限
  3845. //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))");
  3846. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3847. if (se.KilnID.HasValue)
  3848. {
  3849. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3850. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3851. }
  3852. sqlString =
  3853. " ) pdbc\n" +
  3854. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3855. " from (select pd.barcode,\n" +
  3856. " pd.kilncarbatchno,\n" +
  3857. " pd.goodsleveltypeid,\n" +
  3858. " pd.productiondataid,\n" +
  3859. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3860. " from tp_pm_productiondata pd\n" +
  3861. " where pd.valueflag = '1'\n" +
  3862. " and pd.AccountID = :AccountID\n" +
  3863. " and length(pd.kilncarbatchno) > 0\n" +
  3864. " AND pd.createtime >= :CreateTimeStart\n" +
  3865. " and pd.modeltype = -1) kcbc\n" +
  3866. " where kcbc.dataid = 1) glt\n" +
  3867. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3868. " and pdbc.barcode = glt.barcode) qd\n" +
  3869. " inner join tp_pc_productionline pcpl\n" +
  3870. " on pcpl.productionlineid = qd.productionlineid\n" +
  3871. " inner join tp_mst_kiln mstkiln\n" +
  3872. " on mstkiln.kilnid = qd.kilnid\n" +
  3873. " inner join tp_mst_goods mstgoods\n" +
  3874. " on mstgoods.goodsid = qd.goodsid\n" +
  3875. " inner join tp_mst_goodstype mstgoodstype\n" +
  3876. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3877. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3878. " on mstgoodstype2.goodstypecode =\n" +
  3879. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3880. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3881. " where 1=1\n";
  3882. selSql.Append(sqlString);
  3883. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3884. {
  3885. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  3886. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3887. }
  3888. sqlString =
  3889. " group by grouping sets((pcpl.productionlinename,\n" +
  3890. " mstkiln.kilncode,\n" +
  3891. " mstgoodstype2.goodstypecode,\n" +
  3892. " mstgoodstype2.goodstypename),\n" +
  3893. " (pcpl.productionlinename,\n" +
  3894. " mstgoodstype2.goodstypecode,\n" +
  3895. " mstgoodstype2.goodstypename),\n" +
  3896. " (pcpl.productionlinename,\n" +
  3897. " mstkiln.kilncode),\n" +
  3898. " pcpl.productionlinename)\n" +
  3899. " order by pcpl.productionlinename,\n" +
  3900. " mstkiln.kilncode,\n" +
  3901. " mstgoodstype2.goodstypename\n" +
  3902. " ) qdgroup\n";
  3903. selSql.Append(sqlString);
  3904. return selSql.ToString();
  3905. }
  3906. /// <summary>
  3907. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  3908. /// </summary>
  3909. /// <returns>sql</returns>
  3910. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3911. {
  3912. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3913. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3914. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3915. string sqlString = "select qdgroup.gid\n" +
  3916. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  3917. " ,decode(qdgroup.gid\n" +
  3918. " ,1\n" +
  3919. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3920. " ,0\n" +
  3921. " ,qdgroup.kilncode\n" +
  3922. " ,'--') kilncode\n" +
  3923. " ,decode(qdgroup.gid\n" +
  3924. " ,2\n" +
  3925. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  3926. " ,0\n" +
  3927. " ,qdgroup.goodstypename2\n" +
  3928. " ,'--') goodstypename2\n" +
  3929. " ,qdgroup.goodstypecode2\n" +
  3930. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3931. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3932. " ,qdgroup.OutKilnCount\n" +
  3933. " ,qdgroup.GoodCount\n" +
  3934. " ,decode(qdgroup.OutKilnCount\n" +
  3935. " ,0\n" +
  3936. " ,to_number(null)\n" +
  3937. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3938. " ,qdgroup.SubstandardCount\n" +
  3939. " ,decode(qdgroup.OutKilnCount\n" +
  3940. " ,0\n" +
  3941. " ,to_number(null)\n" +
  3942. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3943. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3944. " ,decode(qdgroup.OutKilnCount\n" +
  3945. " ,0\n" +
  3946. " ,to_number(null)\n" +
  3947. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3948. " qdgroup.OutKilnCount\n" +
  3949. " ,4)) QualifiedPercent\n" +
  3950. " ,qdgroup.BadCount\n" +
  3951. " ,decode(qdgroup.OutKilnCount\n" +
  3952. " ,0\n" +
  3953. " ,to_number(null)\n" +
  3954. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3955. " ,qdgroup.ReFireCount\n" +
  3956. " ,decode(qdgroup.OutKilnCount\n" +
  3957. " ,0\n" +
  3958. " ,to_number(null)\n" +
  3959. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3960. " from (select grouping_id(pcpl.productionlinename\n" +
  3961. " ,mstkiln.kilncode\n" +
  3962. " ,mstgoodstype2.goodstypecode) gid\n" +
  3963. " ,pcpl.productionlinename\n" +
  3964. " ,mstkiln.kilncode\n" +
  3965. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3966. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3967. //" ,mstgoodstype.goodstypename\n" +
  3968. //" ,mstgoods.goodscode\n" +
  3969. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3970. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3971. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3972. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3973. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3974. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3975. " ,pd.barcode\n" +
  3976. " ,pd.productionlineid\n" +
  3977. " ,pd.goodsid\n" +
  3978. " ,pd.kilnid\n" +
  3979. " ,pd.kilncarbatchno\n" +
  3980. " ,1 cc\n" +
  3981. " from tp_pm_productiondata pd\n" +
  3982. " where pd.valueflag = '1'\n" +
  3983. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  3984. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  3985. " and pd.accountid = :in_AccountID\n";
  3986. StringBuilder selSql = new StringBuilder(sqlString);
  3987. if (se.CreateTimeStart.HasValue)
  3988. {
  3989. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3990. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3991. }
  3992. if (se.CreateTimeEnd.HasValue)
  3993. {
  3994. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3995. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3996. }
  3997. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3998. {
  3999. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4000. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4001. }
  4002. if (se.ProductionLineID.HasValue)
  4003. {
  4004. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4005. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4006. }
  4007. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4008. {
  4009. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4010. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4011. }
  4012. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4013. {
  4014. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4015. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4016. }
  4017. if (se.KilnID.HasValue)
  4018. {
  4019. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4020. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4021. }
  4022. sqlString =
  4023. " union all\n" +
  4024. " select distinct pd.goodsleveltypeid\n" +
  4025. " ,pd.barcode\n" +
  4026. " ,pd.productionlineid\n" +
  4027. " ,pd.goodsid\n" +
  4028. " ,pd.kilnid\n" +
  4029. " ,pd.kilncarbatchno\n" +
  4030. " ,1 cc\n" +
  4031. " from tp_pm_productiondata pd\n" +
  4032. " where pd.valueflag = '1'\n" +
  4033. " and pd.modeltype = -1\n" +
  4034. " and pd.AccountID = :in_AccountID\n" +
  4035. " and length(pd.kilncarbatchno) > 0\n";
  4036. selSql.Append(sqlString);
  4037. if (se.CreateTimeStart.HasValue)
  4038. {
  4039. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4040. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  4041. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4042. }
  4043. if (se.CreateTimeEnd.HasValue)
  4044. {
  4045. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4046. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  4047. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4048. }
  4049. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4050. {
  4051. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4052. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4053. }
  4054. if (se.ProductionLineID.HasValue)
  4055. {
  4056. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4057. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4058. }
  4059. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4060. {
  4061. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4062. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4063. }
  4064. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4065. {
  4066. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4067. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4068. }
  4069. if (se.KilnID.HasValue)
  4070. {
  4071. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4072. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4073. }
  4074. sqlString =
  4075. " and exists\n" +
  4076. " (select 1\n" +
  4077. " from tp_pm_productiondata outpd\n" +
  4078. " where outpd.barcode = pd.barcode\n" +
  4079. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4080. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4081. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4082. " and outpd.valueflag = '1'\n" +
  4083. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4084. " inner join tp_pc_productionline pcpl\n" +
  4085. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4086. " inner join tp_mst_kiln mstkiln\n" +
  4087. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4088. " inner join tp_mst_goods mstgoods\n" +
  4089. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4090. " inner join tp_mst_goodstype mstgoodstype\n" +
  4091. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4092. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4093. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4094. " on mstgoodstype2.goodstypecode =\n" +
  4095. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4096. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4097. // 产品类别
  4098. selSql.Append(sqlString);
  4099. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4100. {
  4101. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4102. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4103. }
  4104. sqlString =
  4105. " 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" +
  4106. " order by pcpl.productionlinename\n" +
  4107. " ,mstkiln.kilncode\n" +
  4108. " ,mstgoodstype2.goodstypecode\n" +
  4109. " ) qdgroup\n";
  4110. selSql.Append(sqlString);
  4111. return selSql.ToString();
  4112. }
  4113. /// <summary>
  4114. /// 取得RPT040106画面(缺陷报表)的查询数据
  4115. /// </summary>
  4116. /// <param name="user">登录用户信息</param>
  4117. /// <param name="se">查询条件</param>
  4118. /// <returns>查询结果</returns>
  4119. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4120. {
  4121. IDBConnection conn = null;
  4122. try
  4123. {
  4124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4125. string sqlString = null;
  4126. OracleParameter[] parameters = null;
  4127. if (se.OutKilnNumByGoodsType)
  4128. {
  4129. sqlString = "SELECT Defect.productionlinename\n" +
  4130. " ,Defect.procedurename\n" +
  4131. " ,Defect.Defectcode\n" +
  4132. " ,Defect.Defectname\n" +
  4133. " ,Defect.goodstypename2\n" +
  4134. " ,Defect.DefectCount\n" +
  4135. " ,OUT.outNum OutKilnCount\n" +
  4136. " ,decode(OUT.outNum,\n" +
  4137. " 0,\n" +
  4138. " to_number(NULL),\n" +
  4139. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4140. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4141. " ,tp_pc_procedure.procedurename\n" +
  4142. " ,TP_MST_DefectType.Defecttypename\n" +
  4143. " ,TP_MST_Defect.Defectcode\n" +
  4144. " ,TP_MST_Defect.Defectname\n" +
  4145. " ,goodstype2.goodstypename goodstypename2\n" +
  4146. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4147. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4148. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4149. " FROM TP_PM_Defect\n" +
  4150. " LEFT JOIN tp_pc_procedure\n" +
  4151. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4152. " LEFT JOIN tp_pc_productionline\n" +
  4153. " ON TP_PM_Defect.Productionlineid =\n" +
  4154. " tp_pc_productionline.Productionlineid\n" +
  4155. " LEFT JOIN TP_MST_Goods\n" +
  4156. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4157. " LEFT JOIN TP_MST_GoodsType\n" +
  4158. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4159. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4160. " ON goodstype2.goodstypecode =\n" +
  4161. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4162. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4163. " LEFT JOIN TP_MST_Defect\n" +
  4164. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4165. " LEFT JOIN TP_MST_DefectType\n" +
  4166. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4167. " --LEFT JOIN TP_PM_ProductionData\n" +
  4168. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4169. " -- TP_PM_Defect.ProductionDataID\n" +
  4170. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4171. " --AND tp_pc_procedure.ModelType = -1\n" +
  4172. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4173. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4174. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4175. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4176. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4177. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4178. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4179. " ,tp_pc_procedure.procedurename\n" +
  4180. " ,TP_MST_DefectType.Defecttypename\n" +
  4181. " ,TP_MST_Defect.Defectcode\n" +
  4182. " ,TP_MST_Defect.Defectname\n" +
  4183. " ,goodstype2.goodstypecode\n" +
  4184. " ,goodstype2.goodstypename) Defect\n" +
  4185. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4186. " FROM tp_pm_productiondata pd\n" +
  4187. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4188. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4189. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4190. " WHERE pd.valueflag = '1'\n" +
  4191. " AND pd.procedureid = :procedureid\n" +
  4192. " AND pd.AccountID = :AccountID\n" +
  4193. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4194. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4195. " GROUP BY gt2.goodstypecode) OUT \n" +
  4196. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4197. parameters = new OracleParameter[]
  4198. {
  4199. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4200. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4201. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4202. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4203. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4204. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4205. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4206. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4207. };
  4208. }
  4209. else
  4210. {
  4211. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4212. " FROM tp_pm_productiondata pd\n" +
  4213. " WHERE pd.valueflag = '1'\n" +
  4214. " AND pd.procedureid = :procedureid\n" +
  4215. " AND pd.AccountID = :AccountID\n" +
  4216. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4217. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4218. parameters = new OracleParameter[]
  4219. {
  4220. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4221. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4222. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4223. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4224. };
  4225. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4226. sqlString = "SELECT Defect.productionlinename\n" +
  4227. " ,Defect.procedurename\n" +
  4228. " ,Defect.Defectcode\n" +
  4229. " ,Defect.Defectname\n" +
  4230. " ,Defect.goodstypename2\n" +
  4231. " ,Defect.DefectCount\n" +
  4232. " ,:OutKilnCount OutKilnCount\n" +
  4233. " ,decode(:OutKilnCount,\n" +
  4234. " 0,\n" +
  4235. " to_number(NULL),\n" +
  4236. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4237. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4238. " ,tp_pc_procedure.procedurename\n" +
  4239. " ,TP_MST_DefectType.Defecttypename\n" +
  4240. " ,TP_MST_Defect.Defectcode\n" +
  4241. " ,TP_MST_Defect.Defectname\n" +
  4242. " ,goodstype2.goodstypename goodstypename2\n" +
  4243. " ,:OutKilnCount OutKilnCount\n" +
  4244. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4245. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4246. " FROM TP_PM_Defect\n" +
  4247. " LEFT JOIN tp_pc_procedure\n" +
  4248. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4249. " LEFT JOIN tp_pc_productionline\n" +
  4250. " ON TP_PM_Defect.Productionlineid =\n" +
  4251. " tp_pc_productionline.Productionlineid\n" +
  4252. " LEFT JOIN TP_MST_Goods\n" +
  4253. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4254. " LEFT JOIN TP_MST_GoodsType\n" +
  4255. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4256. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4257. " ON goodstype2.goodstypecode =\n" +
  4258. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4259. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4260. " LEFT JOIN TP_MST_Defect\n" +
  4261. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4262. " LEFT JOIN TP_MST_DefectType\n" +
  4263. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4264. " --LEFT JOIN TP_PM_ProductionData\n" +
  4265. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4266. " -- TP_PM_Defect.ProductionDataID\n" +
  4267. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4268. " --AND tp_pc_procedure.ModelType = -1\n" +
  4269. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4270. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4271. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4272. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4273. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4274. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4275. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4276. " ,tp_pc_procedure.procedurename\n" +
  4277. " ,TP_MST_DefectType.Defecttypename\n" +
  4278. " ,TP_MST_Defect.Defectcode\n" +
  4279. " ,TP_MST_Defect.Defectname\n" +
  4280. " ,goodstype2.goodstypename) Defect";
  4281. parameters = new OracleParameter[]
  4282. {
  4283. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4284. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4285. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4286. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4287. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4288. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4289. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4290. };
  4291. }
  4292. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4293. ServiceResultEntity sre = new ServiceResultEntity();
  4294. if (data == null || data.Rows.Count == 0)
  4295. {
  4296. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4297. return sre;
  4298. }
  4299. sre.Data = new DataSet();
  4300. sre.Data.Tables.Add(data);
  4301. return sre;
  4302. }
  4303. catch (Exception ex)
  4304. {
  4305. throw ex;
  4306. }
  4307. finally
  4308. {
  4309. if (conn != null &&
  4310. conn.ConnState == ConnectionState.Open)
  4311. {
  4312. conn.Close();
  4313. }
  4314. }
  4315. }
  4316. /// <summary>
  4317. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4318. /// </summary>
  4319. /// <param name="user">登录用户信息</param>
  4320. /// <param name="se">查询条件</param>
  4321. /// <returns>查询结果</returns>
  4322. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4323. {
  4324. IDBConnection conn = null;
  4325. try
  4326. {
  4327. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4328. List<OracleParameter> parameters = new List<OracleParameter>();
  4329. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4330. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4331. string sqlString =
  4332. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4333. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4334. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4335. " p.procedurename || '\"',\n" +
  4336. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4337. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4338. " ,to_char(p.procedurename) procedurename\n" +
  4339. " ,p.displayno\n" +
  4340. " ,p.productionlineid plid\n" +
  4341. " ,p.procedureid pid\n" +
  4342. " FROM tp_pc_procedure p\n" +
  4343. " WHERE p.valueflag = '1'\n" +
  4344. " AND p.modeltype <> -1\n" +
  4345. " AND p.accountid = :AccountID\n" +
  4346. " UNION ALL\n" +
  4347. " SELECT to_char(p.procedureid) || 'S'\n" +
  4348. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4349. " ,p.displayno\n" +
  4350. " ,p.productionlineid plid\n" +
  4351. " ,p.procedureid pid\n" +
  4352. " FROM tp_pc_procedure p\n" +
  4353. " WHERE p.valueflag = '1'\n" +
  4354. " AND p.modeltype = -1\n" +
  4355. " AND p.accountid = :AccountID) p" +
  4356. " 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" +
  4357. " 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";
  4358. // 生产线
  4359. if (se.ProductionLineID.HasValue)
  4360. {
  4361. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4362. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4363. }
  4364. // 生产工序
  4365. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4366. {
  4367. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4368. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4369. }
  4370. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4371. ServiceResultEntity sre = new ServiceResultEntity();
  4372. if (cols == null || cols.Rows.Count == 0)
  4373. {
  4374. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4375. return sre;
  4376. }
  4377. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4378. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4379. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4380. {
  4381. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4382. return sre;
  4383. }
  4384. parameters.Clear();
  4385. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4386. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4387. sqlString =
  4388. "WITH pd_data AS\n" +
  4389. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4390. " ,pd.groutingdailydetailid\n" +
  4391. " ,decode(pd.MODELTYPE,\n" +
  4392. " -1,\n" +
  4393. " to_char(pd.procedureid) || 'S',\n" +
  4394. " to_char(pd.procedureid)) procedureid\n" +
  4395. " FROM tp_pm_productiondata pd\n" +
  4396. " LEFT JOIN tp_mst_goods goods\n" +
  4397. " ON goods.goodsid = pd.goodsid\n" +
  4398. " LEFT JOIN tp_mst_goodstype gt\n" +
  4399. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4400. " WHERE pd.valueflag = '1'\n" +
  4401. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4402. " AND pd.accountid = :AccountID\n" +
  4403. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4404. " 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" +
  4405. " 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";
  4406. // 生产线
  4407. if (se.ProductionLineID.HasValue)
  4408. {
  4409. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4410. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4411. }
  4412. // 生产工序
  4413. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4414. {
  4415. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4416. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4417. }
  4418. // 产品型号
  4419. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4420. {
  4421. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4422. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4423. }
  4424. // 产品编码
  4425. if (!string.IsNullOrEmpty(se.GoodsCode))
  4426. {
  4427. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4428. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4429. }
  4430. // 注浆时间
  4431. if (se.GTimeStart.HasValue)
  4432. {
  4433. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4434. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4435. }
  4436. if (se.GTimeEnd.HasValue)
  4437. {
  4438. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4439. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4440. }
  4441. sqlString +=
  4442. " ),\n" +
  4443. "pivot_data AS\n" +
  4444. " (SELECT *\n" +
  4445. " FROM pd_data\n" +
  4446. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4447. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4448. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4449. " 3,\n" +
  4450. " '合计',\n" +
  4451. " 1,\n" +
  4452. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4453. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4454. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4455. " 0,\n" +
  4456. " groutdetail.goodscode,\n" +
  4457. " '--') \"产品编码\"\n" +
  4458. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4459. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4460. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4461. " ," + groupsum + "\n" +
  4462. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4463. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4464. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4465. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4466. " FROM tp_pm_groutingdailydetail gdd\n" +
  4467. " LEFT JOIN tp_mst_goods goods\n" +
  4468. " ON goods.goodsid = gdd.goodsid\n" +
  4469. " LEFT JOIN tp_mst_goodstype gt\n" +
  4470. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4471. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4472. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4473. " AND gt2.accountid = gt.accountid\n" +
  4474. " WHERE gdd.valueflag = '1'\n" +
  4475. " AND gdd.accountid = :AccountID\n";
  4476. // 产品型号
  4477. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4478. {
  4479. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4480. }
  4481. // 产品编码
  4482. if (!string.IsNullOrEmpty(se.GoodsCode))
  4483. {
  4484. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4485. }
  4486. // 注浆时间
  4487. if (se.GTimeStart.HasValue)
  4488. {
  4489. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4490. }
  4491. if (se.GTimeEnd.HasValue)
  4492. {
  4493. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4494. }
  4495. sqlString +=
  4496. " AND gdd.groutingflag = '1'\n" +
  4497. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4498. " LEFT JOIN pivot_data pd\n" +
  4499. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4500. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4501. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4502. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4503. if (data == null || data.Rows.Count == 0)
  4504. {
  4505. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4506. return sre;
  4507. }
  4508. sre.Data = new DataSet();
  4509. sre.Data.Tables.Add(data);
  4510. return sre;
  4511. }
  4512. catch (Exception ex)
  4513. {
  4514. throw ex;
  4515. }
  4516. finally
  4517. {
  4518. if (conn != null &&
  4519. conn.ConnState == ConnectionState.Open)
  4520. {
  4521. conn.Close();
  4522. }
  4523. }
  4524. }
  4525. /// <summary>
  4526. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  4527. /// </summary>
  4528. /// <param name="user">登录用户信息</param>
  4529. /// <param name="se">查询条件</param>
  4530. /// <returns>查询结果</returns>
  4531. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  4532. {
  4533. IDBConnection conn = null;
  4534. try
  4535. {
  4536. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4537. //string sqlString =
  4538. // "SELECT t.groutinglinecode\n" +
  4539. // " ,t.BuildingNo\n" +
  4540. // " ,t.FloorNo\n" +
  4541. // " ,t.GroutingLineNo\n" +
  4542. // " ,t.usercode\n" +
  4543. // " ,t.goodscode\n" +
  4544. // " ,t.GOODSSPECIFICATION\n" +
  4545. // " ,t.goodstypename\n" +
  4546. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  4547. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  4548. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  4549. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  4550. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  4551. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  4552. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  4553. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  4554. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  4555. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  4556. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  4557. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  4558. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  4559. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  4560. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  4561. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  4562. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  4563. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  4564. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  4565. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  4566. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  4567. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  4568. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  4569. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  4570. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  4571. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  4572. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  4573. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  4574. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  4575. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  4576. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  4577. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  4578. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  4579. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  4580. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  4581. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  4582. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  4583. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  4584. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  4585. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  4586. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  4587. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  4588. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  4589. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  4590. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  4591. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  4592. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  4593. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  4594. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  4595. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  4596. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  4597. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  4598. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  4599. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  4600. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  4601. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  4602. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  4603. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  4604. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  4605. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  4606. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  4607. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  4608. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  4609. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  4610. // " FROM (SELECT gd.groutinglinecode\n" +
  4611. // " ,gl.BuildingNo\n" +
  4612. // " ,gl.FloorNo\n" +
  4613. // " ,gl.GroutingLineNo\n" +
  4614. // " ,gd.usercode\n" +
  4615. // " ,gdd.goodscode\n" +
  4616. // " ,g.GOODSSPECIFICATION\n" +
  4617. // " ,gt.goodstypename\n" +
  4618. // //" ,gd.MouldQuantity\n" +
  4619. // " ,gl.MouldQuantity\n" +
  4620. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  4621. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  4622. // " , CASE\n" +
  4623. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  4624. // " gd.groutingdate <= :GDateEnd AND\n" +
  4625. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  4626. // " 1\n" +
  4627. // " ELSE\n" +
  4628. // " 0\n" +
  4629. // " END c -- 成坯量\n" +
  4630. // " , CASE\n" +
  4631. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  4632. // " gdd.delivertime <= :GDateEnd AND\n" +
  4633. // " gdd.deliverflag = '1' THEN\n" +
  4634. // " 1\n" +
  4635. // " ELSE\n" +
  4636. // " 0\n" +
  4637. // " END d -- 交坯量\n" +
  4638. // " FROM TP_PM_GroutingDaily gd\n" +
  4639. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  4640. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  4641. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  4642. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  4643. // " INNER JOIN TP_MST_Goods g\n" +
  4644. // " ON g.goodsid = gdd.goodsid\n" +
  4645. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  4646. // " ON gt.goodstypeid = g.goodstypeid\n" +
  4647. // " WHERE gd.accountid = :AccountID\n" +
  4648. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  4649. // " gd.groutingdate <= :GDateEnd) OR\n" +
  4650. // " (gdd.delivertime >= :GDateBegin AND\n" +
  4651. // " gdd.delivertime <= :GDateEnd))\n" +
  4652. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4653. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4654. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4655. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  4656. // " ) t\n" +
  4657. // " GROUP BY t.groutinglinecode\n" +
  4658. // " ,t.BuildingNo\n" +
  4659. // " ,t.FloorNo\n" +
  4660. // " ,t.GroutingLineNo\n" +
  4661. // " ,t.usercode\n" +
  4662. // " ,t.goodscode\n" +
  4663. // " ,t.GOODSSPECIFICATION\n" +
  4664. // " ,t.goodstypename\n" +
  4665. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  4666. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  4667. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  4668. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  4669. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  4670. " ,nvl(t.usercode, '--') usercode\n" +
  4671. " ,nvl2(t.groutinglinecode\n" +
  4672. " ,t.goodscode\n" +
  4673. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  4674. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  4675. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  4676. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  4677. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  4678. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  4679. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  4680. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  4681. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  4682. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  4683. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  4684. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  4685. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  4686. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  4687. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  4688. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  4689. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  4690. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  4691. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  4692. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  4693. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  4694. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  4695. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  4696. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  4697. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  4698. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  4699. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  4700. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  4701. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  4702. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  4703. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  4704. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  4705. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  4706. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  4707. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  4708. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  4709. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  4710. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  4711. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  4712. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  4713. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  4714. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  4715. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  4716. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  4717. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  4718. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  4719. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  4720. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  4721. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  4722. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  4723. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  4724. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  4725. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  4726. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  4727. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  4728. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  4729. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  4730. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  4731. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  4732. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  4733. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  4734. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  4735. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  4736. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  4737. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  4738. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  4739. " from (select gd.groutinglinecode\n" +
  4740. " ,gl.BuildingNo\n" +
  4741. " ,gl.FloorNo\n" +
  4742. " ,gl.GroutingLineNo\n" +
  4743. " ,gd.usercode\n" +
  4744. " ,gdd.goodscode\n" +
  4745. " ,g.GOODSSPECIFICATION\n" +
  4746. " ,gt.goodstypename\n" +
  4747. " ,gl.MouldQuantity\n" +
  4748. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  4749. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  4750. " ,case\n" +
  4751. " when gd.groutingdate >= :GDateBegin and\n" +
  4752. " gd.groutingdate <= :GDateEnd and\n" +
  4753. " gdd.GroutingFlag = '1' and\n" +
  4754. " gdd.ScrapFlag = '0' then\n" +
  4755. " 1\n" +
  4756. " else\n" +
  4757. " 0\n" +
  4758. " end c -- 成坯量\n" +
  4759. " ,case\n" +
  4760. " when gdd.delivertime >= :GDateBegin and\n" +
  4761. " gdd.delivertime <= :GDateEnd and\n" +
  4762. " gdd.deliverflag = '1' then\n" +
  4763. " 1\n" +
  4764. " else\n" +
  4765. " 0\n" +
  4766. " end d -- 交坯量\n" +
  4767. " from TP_PM_GroutingDaily gd\n" +
  4768. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  4769. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  4770. " inner join TP_PC_GroutingLine gl\n" +
  4771. " on gl.groutinglineid = gd.groutinglineid\n" +
  4772. " inner join TP_MST_Goods g\n" +
  4773. " on g.goodsid = gdd.goodsid\n" +
  4774. " inner join TP_MST_GOODSTYPE gt\n" +
  4775. " on gt.goodstypeid = g.goodstypeid\n" +
  4776. " where gd.accountid = :AccountID\n" +
  4777. " and ((gd.groutingdate >= :GDateBegin and\n" +
  4778. " gd.groutingdate <= :GDateEnd) or\n" +
  4779. " (gdd.delivertime >= :GDateBegin and\n" +
  4780. " gdd.delivertime <= :GDateEnd))\n" +
  4781. " and (:groutinglinecode is null or\n" +
  4782. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4783. " and (:groutingusercode is null or\n" +
  4784. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4785. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4786. " and (:goodstypecode is null or\n" +
  4787. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  4788. " 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" +
  4789. " order by t.goodscode, t.groutinglinecode, t.usercode";
  4790. List<OracleParameter> parameters = new List<OracleParameter>();
  4791. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4792. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  4793. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  4794. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  4795. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  4796. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4797. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4798. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4799. ServiceResultEntity sre = new ServiceResultEntity();
  4800. if (data == null || data.Rows.Count == 0)
  4801. {
  4802. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4803. return sre;
  4804. }
  4805. sre.Data = new DataSet();
  4806. sre.Data.Tables.Add(data);
  4807. return sre;
  4808. }
  4809. catch (Exception ex)
  4810. {
  4811. throw ex;
  4812. }
  4813. finally
  4814. {
  4815. if (conn != null &&
  4816. conn.ConnState == ConnectionState.Open)
  4817. {
  4818. conn.Close();
  4819. }
  4820. }
  4821. }
  4822. /// <summary>
  4823. /// 取得RPT040109画面(整体质量分析表)的查询数据
  4824. /// </summary>
  4825. /// <param name="user">登录用户信息</param>
  4826. /// <param name="se">查询条件</param>
  4827. /// <returns>查询结果</returns>
  4828. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  4829. {
  4830. IDBTransaction conn = null;
  4831. try
  4832. {
  4833. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4834. conn.Connect();
  4835. OracleParameter[] parameters = new OracleParameter[]
  4836. {
  4837. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4838. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4839. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4840. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  4841. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  4842. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4843. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4844. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4845. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4846. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4847. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4848. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4849. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4850. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4851. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4852. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4853. new OracleParameter("in_HasUserGroup", OracleDbType.Int32, (se.HasUserGroup?1:0), ParameterDirection.Input),
  4854. };
  4855. //out_data1 -- 质量整体情况
  4856. //out_data2 -- 各缺陷类型成品率
  4857. //out_data3 -- 各缺陷类型缺陷率
  4858. //out_data4 -- 产品质量排行榜
  4859. //out_data21 -- 各缺陷类型成品率-总成品率
  4860. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4861. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4862. //out_table1 -- 缺陷类别
  4863. //out_table2 -- 工号分组
  4864. //out_table3 -- 缺陷扣罚
  4865. //out_table4 -- 缺陷
  4866. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4867. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityA_UserG", parameters);
  4868. ServiceResultEntity sre = new ServiceResultEntity();
  4869. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4870. {
  4871. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4872. return sre;
  4873. }
  4874. data.Tables[0].TableName = "TQ";
  4875. data.Tables[1].TableName = "FR";
  4876. data.Tables[2].TableName = "DR";
  4877. data.Tables[3].TableName = "DL";
  4878. data.Tables[4].TableName = "FR1";
  4879. data.Tables[5].TableName = "DR1";
  4880. data.Tables[6].TableName = "DR2";
  4881. data.Tables[7].TableName = "DT";
  4882. data.Tables[8].TableName = "WG";
  4883. data.Tables[9].TableName = "DF";
  4884. data.Tables[10].TableName = "D";
  4885. DataTable dtFR = data.Tables["FR"];
  4886. DataTable dtFRClone = dtFR.Clone();
  4887. for (int i = 0; i < dtFR.Columns.Count; i++)
  4888. {
  4889. dtFRClone.Columns[i].DataType = typeof(string);
  4890. }
  4891. foreach (DataRow item in dtFR.Rows)
  4892. {
  4893. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4894. dtFRClone.Rows.Add(item.ItemArray);
  4895. }
  4896. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  4897. //DataRow drFR = dtFRClone.NewRow();
  4898. //drFR["goodstypename2"] = "成品率(%)";
  4899. //foreach (DataRow row in data.Tables["FR1"].Rows)
  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. //dtFRClone.Rows.Add(drFR);
  4912. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  4913. foreach (DataRow row in data.Tables["FR1"].Rows)
  4914. {
  4915. string tcode = row["goodstypecode2"].ToString();
  4916. DataRow drFR = null;
  4917. if (drFRs.ContainsKey(tcode))
  4918. {
  4919. drFR = drFRs[tcode];
  4920. }
  4921. else
  4922. {
  4923. drFR = dtFRClone.NewRow();
  4924. drFRs.Add(tcode, drFR);
  4925. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  4926. }
  4927. string tid = row["tid"].ToString();
  4928. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4929. foreach (DataColumn col in dtFRClone.Columns)
  4930. {
  4931. if (col.ColumnName.StartsWith(tid))
  4932. {
  4933. drFR[col.ColumnName] = overRate;
  4934. }
  4935. }
  4936. }
  4937. foreach (DataRow item in drFRs.Values)
  4938. {
  4939. dtFRClone.Rows.Add(item);
  4940. }
  4941. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4942. data.Tables.Remove(dtFR);
  4943. data.Tables.Remove(data.Tables["FR1"]);
  4944. data.Tables.Add(dtFRClone);
  4945. DataTable dtDR = data.Tables["DR"];
  4946. DataTable dtDRClone = dtDR.Clone();
  4947. for (int i = 0; i < dtDR.Columns.Count; i++)
  4948. {
  4949. dtDRClone.Columns[i].DataType = typeof(string);
  4950. }
  4951. foreach (DataRow item in dtDR.Rows)
  4952. {
  4953. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4954. dtDRClone.Rows.Add(item.ItemArray);
  4955. }
  4956. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  4957. //DataRow drDR = dtDRClone.NewRow();
  4958. //drDR["goodstypename2"] = "缺陷率(%)";
  4959. //foreach (DataRow row in data.Tables["DR2"].Rows)
  4960. //{
  4961. // string tid = row["tdfid"].ToString();
  4962. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4963. // drDR[tid] = defectRate;
  4964. //}
  4965. //dtDRClone.Rows.Add(drDR);
  4966. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  4967. foreach (DataRow row in data.Tables["DR2"].Rows)
  4968. {
  4969. string tcode = row["goodstypecode2"].ToString();
  4970. DataRow drDR = null;
  4971. if (drDRs.ContainsKey(tcode))
  4972. {
  4973. drDR = drDRs[tcode];
  4974. }
  4975. else
  4976. {
  4977. drDR = dtDRClone.NewRow();
  4978. drDRs.Add(tcode, drDR);
  4979. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  4980. }
  4981. string tid = row["tdfid"].ToString();
  4982. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4983. drDR[tid] = defectRate;
  4984. }
  4985. foreach (DataRow item in drDRs.Values)
  4986. {
  4987. dtDRClone.Rows.Add(item);
  4988. }
  4989. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4990. data.Tables.Remove(dtDR);
  4991. data.Tables.Remove(data.Tables["DR2"]);
  4992. data.Tables.Add(dtDRClone);
  4993. conn.Commit();
  4994. sre.Data = data;
  4995. return sre;
  4996. }
  4997. catch (Exception ex)
  4998. {
  4999. throw ex;
  5000. }
  5001. finally
  5002. {
  5003. if (conn != null &&
  5004. conn.ConnState == ConnectionState.Open)
  5005. {
  5006. conn.Disconnect();
  5007. }
  5008. }
  5009. }
  5010. /// <summary>
  5011. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5012. /// </summary>
  5013. /// <param name="user">登录用户信息</param>
  5014. /// <param name="se">查询条件</param>
  5015. /// <returns>查询结果</returns>
  5016. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5017. {
  5018. IDBTransaction conn = null;
  5019. try
  5020. {
  5021. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5022. conn.Connect();
  5023. OracleParameter[] parameters = new OracleParameter[]
  5024. {
  5025. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5026. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5027. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5028. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5029. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5030. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5031. };
  5032. DataSet data = null;
  5033. if (se.IsShowG)
  5034. {
  5035. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5036. }
  5037. else
  5038. {
  5039. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5040. }
  5041. ServiceResultEntity sre = new ServiceResultEntity();
  5042. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5043. {
  5044. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5045. return sre;
  5046. }
  5047. conn.Commit();
  5048. sre.Data = data;
  5049. return sre;
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. throw ex;
  5054. }
  5055. finally
  5056. {
  5057. if (conn != null &&
  5058. conn.ConnState == ConnectionState.Open)
  5059. {
  5060. conn.Disconnect();
  5061. }
  5062. }
  5063. }
  5064. #endregion 分析报表
  5065. #region 汇总报表
  5066. /// <summary>
  5067. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5068. /// </summary>
  5069. /// <param name="user">登录用户信息</param>
  5070. /// <param name="se">查询条件</param>
  5071. /// <returns>查询结果</returns>
  5072. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5073. {
  5074. IDBConnection conn = null;
  5075. try
  5076. {
  5077. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5078. List<OracleParameter> parameters = new List<OracleParameter>();
  5079. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5080. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5081. ServiceResultEntity sre = new ServiceResultEntity();
  5082. if (data == null || data.Rows.Count == 0)
  5083. {
  5084. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5085. return sre;
  5086. }
  5087. sre.Data = new DataSet();
  5088. sre.Data.Tables.Add(data);
  5089. return sre;
  5090. }
  5091. catch (Exception ex)
  5092. {
  5093. throw ex;
  5094. }
  5095. finally
  5096. {
  5097. if (conn != null &&
  5098. conn.ConnState == ConnectionState.Open)
  5099. {
  5100. conn.Close();
  5101. }
  5102. }
  5103. }
  5104. /// <summary>
  5105. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5106. /// </summary>
  5107. /// <returns>sql</returns>
  5108. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5109. {
  5110. //string selSql = "";
  5111. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5112. /*
  5113. selSql = selSql +
  5114. "select " +
  5115. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5116. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5117. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5118. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5119. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5120. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5121. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5122. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5123. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5124. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5125. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5126. " t.产量 " +
  5127. "from " +
  5128. "( " +
  5129. " select " +
  5130. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5131. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5132. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5133. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5134. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5135. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5136. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5137. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5138. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5139. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5140. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5141. " count(BarCode) as 产量 " +
  5142. " from TP_PM_ProductionData " +
  5143. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5144. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5145. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5146. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5147. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5148. // 公坯、干补不算交坯工序的质量。
  5149. (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" : "") +
  5150. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5151. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5152. {
  5153. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5154. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5155. }
  5156. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5157. {
  5158. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5159. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5160. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5161. }
  5162. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5163. {
  5164. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5165. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5166. }
  5167. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5168. {
  5169. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5170. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5171. }
  5172. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5173. {
  5174. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5175. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5176. }
  5177. if (se.AccountDateStart.HasValue)
  5178. {
  5179. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5180. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5181. }
  5182. if (se.AccountDateEnd.HasValue)
  5183. {
  5184. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5185. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5186. }
  5187. selSql = selSql +
  5188. "group by " +
  5189. " rollup(TP_MST_Organization.OrganizationName, " +
  5190. " TP_PM_ProductionData.ProductionLineName, " +
  5191. " TP_PM_ProductionData.Procedureid, " +
  5192. " TP_PM_ProductionData.ProcedureName, " +
  5193. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5194. " TP_PM_ProductionData.GoodsCode, " +
  5195. " TP_PM_ProductionData.GoodsId, " +
  5196. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5197. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5198. " order by " +
  5199. " TP_MST_Organization.OrganizationName, " +
  5200. " TP_PM_ProductionData.ProductionLineName, " +
  5201. " TP_PM_ProductionData.Procedureid, " +
  5202. " TP_PM_ProductionData.ProcedureName, " +
  5203. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5204. ") t \n" +
  5205. // 增加 产品型号
  5206. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5207. "where 1=1 " +
  5208. "and (t.DICTIONARYVALUE!='--' ) " +
  5209. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5210. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5211. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5212. */
  5213. string selSql =
  5214. "select t.gid\n" +
  5215. " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
  5216. " ,t.OrganizationID\n" +
  5217. " --,t.OrganizationCode\n" +
  5218. " ,decode(t.gid\n" +
  5219. " ,7\n" +
  5220. " ,'合计[' || t.OrganizationName || ']'\n" +
  5221. " ,15\n" +
  5222. " ,'--'\n" +
  5223. " ,t.OrganizationName) OrganizationName\n" +
  5224. " ,t.Procedureid\n" +
  5225. " ,decode(t.gid\n" +
  5226. " ,3\n" +
  5227. " ,'小计[' || t.ProcedureName || ']'\n" +
  5228. " ,0\n" +
  5229. " ,t.ProcedureName\n" +
  5230. " ,1\n" +
  5231. " ,t.ProcedureName\n" +
  5232. " ,'--') ProcedureName\n" +
  5233. " ,t.GoodsTypeID\n" +
  5234. " ,decode(t.gid\n" +
  5235. " ,1\n" +
  5236. " ,'小计[' || t.GoodsTypeName || ']'\n" +
  5237. " ,0\n" +
  5238. " ,t.GoodsTypeName\n" +
  5239. " ,'--') GoodsTypeName\n" +
  5240. " --,t.GoodsId\n" +
  5241. " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
  5242. " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
  5243. " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5244. " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
  5245. " ,t.pfcount as 产量\n" +
  5246. " from (select grouping_id(org.OrganizationID\n" +
  5247. " ,p.Procedureid\n" +
  5248. " ,gt.goodstypeid\n" +
  5249. " ,g.GoodsId) as gid\n" +
  5250. " ,pd.ProductionLineName\n" +
  5251. " ,org.OrganizationID\n" +
  5252. " --,org.OrganizationCode\n" +
  5253. " ,org.OrganizationName\n" +
  5254. " ,p.Procedureid\n" +
  5255. " ,p.ProcedureName\n" +
  5256. " ,gt.GoodsTypeID\n" +
  5257. " ,gt.GoodsTypeName\n" +
  5258. " ,g.GoodsId\n" +
  5259. " ,g.GoodsCode\n" +
  5260. " ,g.GOODSSPECIFICATION\n" +
  5261. " ,d.Dictionaryvalue\n" +
  5262. " ,count(BarCode) as pfcount" +
  5263. " from TP_PM_ProductionData pd\n" +
  5264. " inner join tp_pc_Procedure p\n" +
  5265. " on p.Procedureid = pd.Procedureid\n" +
  5266. " inner join TP_MST_Goods g\n" +
  5267. " on g.GoodsID = pd.GoodsID\n" +
  5268. " inner join TP_MST_GoodsType gt\n" +
  5269. " on gt.GoodsTypeID = g.GoodsTypeID\n" +
  5270. " inner join TP_MST_Organization org\n" +
  5271. " on org.OrganizationID = pd.OrganizationID\n" +
  5272. " inner join TP_MST_DATADICTIONARY d\n" +
  5273. " on d.DICTIONARYID = g.GLAZETYPEID\n" +
  5274. " where pd.ValueFlag = '1'\n" +
  5275. " and pd.AccountID = :AccountID\n";
  5276. // 公坯、干补不算交坯工序的质量。
  5277. if (se.ProductionFlag == "1")
  5278. {
  5279. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5280. }
  5281. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5282. {
  5283. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5284. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5285. }
  5286. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5287. {
  5288. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5289. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5290. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5291. }
  5292. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5293. {
  5294. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5295. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5296. }
  5297. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5298. {
  5299. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5300. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5301. }
  5302. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5303. {
  5304. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5305. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5306. }
  5307. if (se.AccountDateStart.HasValue)
  5308. {
  5309. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5310. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5311. }
  5312. if (se.AccountDateEnd.HasValue)
  5313. {
  5314. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5315. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5316. }
  5317. selSql +=
  5318. " 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" +
  5319. " order by org.organizationcode\n" +
  5320. " ,p.displayno\n" +
  5321. " ,gt.goodstypecode\n" +
  5322. " ,g.goodscode) t";
  5323. return selSql;
  5324. }
  5325. /// <summary>
  5326. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5327. /// </summary>
  5328. /// <param name="user">登录用户信息</param>
  5329. /// <param name="se">查询条件</param>
  5330. /// <returns>查询结果</returns>
  5331. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5332. {
  5333. IDBConnection conn = null;
  5334. try
  5335. {
  5336. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5337. List<OracleParameter> parameters = new List<OracleParameter>();
  5338. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5339. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5340. ServiceResultEntity sre = new ServiceResultEntity();
  5341. if (data == null || data.Rows.Count == 0)
  5342. {
  5343. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5344. return sre;
  5345. }
  5346. sre.Data = new DataSet();
  5347. sre.Data.Tables.Add(data);
  5348. return sre;
  5349. }
  5350. catch (Exception ex)
  5351. {
  5352. throw ex;
  5353. }
  5354. finally
  5355. {
  5356. if (conn != null &&
  5357. conn.ConnState == ConnectionState.Open)
  5358. {
  5359. conn.Close();
  5360. }
  5361. }
  5362. }
  5363. /// <summary>
  5364. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5365. /// </summary>
  5366. /// <returns>sql</returns>
  5367. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5368. {
  5369. //string selSql = "";
  5370. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5371. /*
  5372. selSql = selSql +
  5373. "select " +
  5374. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5375. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5376. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5377. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5378. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5379. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5380. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5381. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5382. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5383. "产量, " +
  5384. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5385. "from " +
  5386. "( " +
  5387. " select " +
  5388. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5389. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5390. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5391. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5392. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5393. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5394. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5395. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5396. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5397. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5398. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5399. " count(BarCode) as 产量 " +
  5400. " from TP_PM_ProductionData " +
  5401. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5402. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5403. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5404. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5405. " Where 1=1 " +
  5406. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5407. // 公坯、干补不算交坯工序的质量。
  5408. " 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" +
  5409. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5410. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5411. {
  5412. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5413. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5414. }
  5415. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5416. {
  5417. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5418. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5419. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5420. }
  5421. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5422. {
  5423. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5424. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5425. }
  5426. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5427. {
  5428. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5429. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5430. }
  5431. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5432. {
  5433. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5434. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5435. }
  5436. if (se.AccountDateStart.HasValue)
  5437. {
  5438. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5439. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5440. }
  5441. if (se.AccountDateEnd.HasValue)
  5442. {
  5443. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5444. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5445. }
  5446. selSql = selSql +
  5447. "group by " +
  5448. " rollup(TP_MST_Organization.OrganizationName, " +
  5449. " TP_PM_ProductionData.ProductionLineName, " +
  5450. " TP_PM_ProductionData.ProcedureName, " +
  5451. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5452. " TP_PM_ProductionData.GoodsCode, " +
  5453. " TP_PM_ProductionData.BarCode, " +
  5454. " TP_PM_ProductionData.UserCode, " +
  5455. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5456. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5457. " ) " +
  5458. " order by " +
  5459. " TP_MST_Organization.OrganizationName, " +
  5460. " TP_PM_ProductionData.ProductionLineName, " +
  5461. " TP_PM_ProductionData.ProcedureName, " +
  5462. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5463. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5464. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5465. "where 1=1 " +
  5466. "and (temp.DICTIONARYVALUE!='--') " +
  5467. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5468. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5469. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5470. */
  5471. string selSql =
  5472. " select " +
  5473. " TP_MST_Organization.OrganizationName, " +
  5474. " TP_PM_ProductionData.ProductionLineName, " +
  5475. " TP_PM_ProductionData.ProcedureName, " +
  5476. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5477. " TP_PM_ProductionData.GoodsCode, " +
  5478. " TP_MST_Goods.GoodsName, " +
  5479. " TP_MST_Goods.GoodsModel, " +
  5480. " TP_PM_ProductionData.BarCode, " +
  5481. " TP_PM_ProductionData.UserCode, " +
  5482. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5483. " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
  5484. " TP_PM_ProductionData.CREATETIME, " +
  5485. " TP_PM_ProductionData.KILNcarCODE, " +
  5486. " TP_PM_ProductionData.KILNCODE, " +
  5487. " cu.usercode createusercode, " +
  5488. " cu.username CreateUserName, " +
  5489. " gdd.glazingroom," +
  5490. " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
  5491. " from TP_PM_ProductionData " +
  5492. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5493. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5494. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5495. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5496. " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
  5497. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5498. " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
  5499. // 2022年3月2日13:05:24 by feiy modify 都取注浆明细的商标,与追踪表保持一致
  5500. //" left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
  5501. " left join tp_mst_logo on gdd.logoid=tp_mst_logo.logoid " +
  5502. " Where TP_PM_ProductionData.ValueFlag = '1' " +
  5503. // 公坯、干补不算交坯工序的质量。
  5504. " 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" +
  5505. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5506. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5507. {
  5508. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5509. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5510. }
  5511. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5512. {
  5513. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5514. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5515. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5516. }
  5517. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5518. {
  5519. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5520. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5521. }
  5522. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5523. {
  5524. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5525. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5526. }
  5527. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5528. {
  5529. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5530. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5531. }
  5532. if (se.AccountDateStart.HasValue)
  5533. {
  5534. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5535. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5536. }
  5537. if (se.AccountDateEnd.HasValue)
  5538. {
  5539. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5540. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5541. }
  5542. return selSql;
  5543. }
  5544. /// <summary>
  5545. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5546. /// </summary>
  5547. /// <param name="user">登录用户信息</param>
  5548. /// <param name="se">查询条件</param>
  5549. /// <returns>查询结果</returns>
  5550. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5551. {
  5552. IDBConnection conn = null;
  5553. try
  5554. {
  5555. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5556. List<OracleParameter> parameters = new List<OracleParameter>();
  5557. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5558. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5559. ServiceResultEntity sre = new ServiceResultEntity();
  5560. if (data == null || data.Rows.Count == 0)
  5561. {
  5562. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5563. return sre;
  5564. }
  5565. sre.Data = new DataSet();
  5566. sre.Data.Tables.Add(data);
  5567. return sre;
  5568. }
  5569. catch (Exception ex)
  5570. {
  5571. throw ex;
  5572. }
  5573. finally
  5574. {
  5575. if (conn != null &&
  5576. conn.ConnState == ConnectionState.Open)
  5577. {
  5578. conn.Close();
  5579. }
  5580. }
  5581. }
  5582. /// <summary>
  5583. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5584. /// </summary>
  5585. /// <returns>sql</returns>
  5586. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5587. {
  5588. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5589. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5590. string sqlString = "SELECT decode(ts.gid,\n" +
  5591. " 7,\n" +
  5592. " '总计',\n" +
  5593. " 3,\n" +
  5594. " '合计【' || ts.zrprocedurename || '】',\n" +
  5595. " 0,\n" +
  5596. " ts.zrprocedurename,\n" +
  5597. " '--') zrprocedurename\n" +
  5598. " ,decode(ts.gid,\n" +
  5599. " 1,\n" +
  5600. " '小计【' || ts.goodstypename2 || '】',\n" +
  5601. " 0,\n" +
  5602. " ts.goodstypename2,\n" +
  5603. " '--') goodstypename2\n" +
  5604. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5605. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5606. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5607. " ,ts.productionlineid\n" +
  5608. " ,ts.zrprocedureid\n" +
  5609. " ,ts.goodstypecode2\n" +
  5610. " ,ts.zruserid\n" +
  5611. " ,ts.goodsid\n" +
  5612. " ,ts.barcount\n" +
  5613. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5614. " ,t.productionlineid\n" +
  5615. " ,t.productionlinename\n" +
  5616. " ,t.displayno\n" +
  5617. " ,t.zrprocedureid\n" +
  5618. " ,t.zrprocedurename\n" +
  5619. " ,t.goodstypecode2\n" +
  5620. " ,t.goodstypename2\n" +
  5621. " ,t.zruserid\n" +
  5622. " ,t.zrusercode\n" +
  5623. " ,t.goodsid\n" +
  5624. " ,t.goodscode\n" +
  5625. " ,t.GOODSMODEL\n" +
  5626. " ,COUNT(t.barcode) barcount\n" +
  5627. " FROM (SELECT sp.productionlineid\n" +
  5628. " ,pline.productionlinename\n" +
  5629. " ,nvl(zp.displayno, -1) displayno\n" +
  5630. " ,zp.procedureid zrprocedureid\n" +
  5631. " ,zp.procedurename zrprocedurename\n" +
  5632. " ,sr.userid zruserid\n" +
  5633. " ,sr.usercode zrusercode\n" +
  5634. " ,gt2.goodstypecode goodstypecode2\n" +
  5635. " ,gt2.goodstypename goodstypename2\n" +
  5636. " ,g.goodsid\n" +
  5637. " ,g.goodscode\n" +
  5638. " ,g.GOODSMODEL\n" +
  5639. " ,sp.barcode\n" +
  5640. " FROM tp_pm_scrapproduct sp\n" +
  5641. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5642. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5643. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5644. " ,t.ResponProcedureID\n" +
  5645. " ,t.userid\n" +
  5646. " ,t.usercode\n" +
  5647. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5648. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5649. // wangx 2016-06-20
  5650. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5651. " ON rp.barcode = gdd.barcode\n" +
  5652. // wangx 2016-06-20 end
  5653. " LEFT JOIN tp_pc_productionline pline\n" +
  5654. " ON pline.productionlineid = sp.productionlineid\n" +
  5655. " LEFT JOIN tp_pc_procedure zp\n" +
  5656. " ON zp.procedureid = rp.procedureid\n" +
  5657. " LEFT JOIN tp_mst_user cu\n" +
  5658. " ON cu.userid = sp.createuserid\n" +
  5659. " LEFT JOIN tp_mst_user au\n" +
  5660. " ON au.userid = sp.auditor\n" +
  5661. " LEFT JOIN tp_mst_goods g\n" +
  5662. " ON g.goodsid = sp.goodsid\n" +
  5663. " LEFT JOIN tp_mst_goodstype gt\n" +
  5664. " ON gt.goodstypeid = g.goodstypeid\n" +
  5665. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5666. " ON gt2.accountid = gt.accountid\n" +
  5667. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5668. " WHERE sp.valueflag = '1'\n" +
  5669. " AND sp.AuditStatus = '1'\n" +
  5670. // 生产线
  5671. //" 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))" +
  5672. // 完成工序
  5673. //" 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))" +
  5674. // 责任工序
  5675. //" 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)))" +
  5676. " AND sp.accountid = :AccountID\n" +
  5677. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5678. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5679. " AND sp.ScrapType = '0'\n" +
  5680. " AND (:ProductionLineID IS NULL OR\n" +
  5681. " sp.ProductionLineID = :ProductionLineID)\n" +
  5682. " AND (:GoodsTypeCode IS NULL OR\n" +
  5683. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5684. " AND (:GoodsCode IS NULL OR\n" +
  5685. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5686. " AND (:ProcedureIDS IS NULL OR\n" +
  5687. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5688. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5689. " instr(:ResponProcedureIDS,\n" +
  5690. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5691. " AND (:ResponUserIDS IS NULL OR\n" +
  5692. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5693. // 损坯时间
  5694. " AND (:ScrapDateStart IS NULL OR\n" +
  5695. " sp.CreateTime >= :ScrapDateStart)\n" +
  5696. " AND (:ScrapDateEnd IS NULL OR\n" +
  5697. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5698. // 审核时间
  5699. " AND (:AuditDateStart IS NULL OR\n" +
  5700. " sp.AuditDate >= :AuditDateStart)\n" +
  5701. " AND (:AuditDateEnd IS NULL OR\n" +
  5702. " sp.AuditDate <= :AuditDateEnd)\n" +
  5703. // 完成时间
  5704. " AND (:CTimeStart IS NULL OR\n" +
  5705. " sp.CreateTime >= :CTimeStart)\n" +
  5706. " AND (:CTimeEnd IS NULL OR\n" +
  5707. " sp.CreateTime <= :CTimeEnd)\n" +
  5708. // 交坯时间
  5709. " AND (:DTimeStart IS NULL OR\n" +
  5710. " gdd.DeliverTime >= :DTimeStart)\n" +
  5711. " AND (:DTimeEnd IS NULL OR\n" +
  5712. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5713. // 注浆时间
  5714. " AND (:GTimeStart IS NULL OR\n" +
  5715. " gdd.GroutingDate >= :GTimeStart)\n" +
  5716. " AND (:GTimeEnd IS NULL OR\n" +
  5717. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5718. " AND (:CreatUser IS NULL OR\n" +
  5719. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5720. " AND (:AuditUser IS NULL OR\n" +
  5721. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5722. " 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" +
  5723. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5724. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5725. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5726. {
  5727. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5728. }
  5729. else
  5730. {
  5731. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5732. }
  5733. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5734. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5735. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5736. {
  5737. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5738. }
  5739. else
  5740. {
  5741. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5742. }
  5743. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5744. {
  5745. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5746. }
  5747. else
  5748. {
  5749. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5750. }
  5751. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5752. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5753. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5754. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5755. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5756. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5757. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5758. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5759. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5760. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5761. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5762. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5763. return sqlString;
  5764. }
  5765. /// <summary>
  5766. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5767. /// </summary>
  5768. /// <param name="user">登录用户信息</param>
  5769. /// <param name="se">查询条件</param>
  5770. /// <returns>查询结果</returns>
  5771. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5772. {
  5773. IDBConnection conn = null;
  5774. try
  5775. {
  5776. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5777. List<OracleParameter> parameters = new List<OracleParameter>();
  5778. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5779. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5780. ServiceResultEntity sre = new ServiceResultEntity();
  5781. if (data == null || data.Rows.Count == 0)
  5782. {
  5783. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5784. return sre;
  5785. }
  5786. sre.Data = new DataSet();
  5787. sre.Data.Tables.Add(data);
  5788. return sre;
  5789. }
  5790. catch (Exception ex)
  5791. {
  5792. throw ex;
  5793. }
  5794. finally
  5795. {
  5796. if (conn != null &&
  5797. conn.ConnState == ConnectionState.Open)
  5798. {
  5799. conn.Close();
  5800. }
  5801. }
  5802. }
  5803. /// <summary>
  5804. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5805. /// </summary>
  5806. /// <returns>sql</returns>
  5807. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5808. {
  5809. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5810. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5811. string sqlString =
  5812. "SELECT pline.productionlinename\n" +
  5813. " ,p.procedurename\n" +
  5814. " ,zp.procedurename zrprocedurename\n" +
  5815. " ,sr.usercode zrusercode\n" +
  5816. " ,sr.StaffNames zrStaffNames\n" +
  5817. " ,gt2.goodstypecode goodstypecode2\n" +
  5818. " ,gt2.goodstypename goodstypename2\n" +
  5819. " ,gt.goodstypename\n" +
  5820. " ,g.goodscode\n" +
  5821. " ,g.GOODSMODEL\n" +
  5822. " ,sp.barcode\n" +
  5823. " ,sp.createtime Scrapdate\n" +
  5824. " ,sp.Rreason\n" +
  5825. " ,sp.GroutingUserCode\n" +
  5826. " ,sp.GroutingLineCode\n" +
  5827. " ,sp.GroutingMouldCode\n" +
  5828. " ,sp.GroutingDate\n" +
  5829. " ,sp.GroutingNum\n" +
  5830. " ,cu.usercode CreateUserCode\n" +
  5831. " ,au.usercode AuditorCode\n" +
  5832. " ,sp.auditdate\n" +
  5833. " ,gdd.DeliverTime\n" +
  5834. " ,gdd.ISPUBLICBODY\n" +
  5835. " ,gdd.SPECIALREPAIRFLAG\n" +
  5836. " ,lg.logoname\n" +
  5837. " ,sp.CreateTime\n" +
  5838. " ,sp.Remarks\n" +
  5839. " FROM tp_pm_scrapproduct sp\n" +
  5840. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5841. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5842. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5843. " ,t.ResponProcedureID\n" +
  5844. " ,t.userid\n" +
  5845. " ,t.usercode\n" +
  5846. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5847. " FROM TP_PM_ScrapResponsible t\n" +
  5848. " LEFT JOIN TP_HR_Staff s \n" +
  5849. " ON s.StaffID = t.StaffID \n" +
  5850. " ) sr\n" +
  5851. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5852. // wangx 2016-06-20
  5853. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5854. " ON sp.barcode = gdd.barcode\n" +
  5855. // wangx 2016-06-20 end
  5856. " LEFT JOIN TP_mst_logo lg\n" +
  5857. " ON lg.logoid = gdd.logoid\n" +
  5858. " LEFT JOIN tp_pc_productionline pline\n" +
  5859. " ON pline.productionlineid = sp.productionlineid\n" +
  5860. " LEFT JOIN tp_pc_procedure p\n" +
  5861. " ON p.procedureid = sp.procedureid\n" +
  5862. " LEFT JOIN tp_pc_procedure zp\n" +
  5863. " ON zp.procedureid = rp.procedureid\n" +
  5864. " LEFT JOIN tp_mst_user cu\n" +
  5865. " ON cu.userid = sp.createuserid\n" +
  5866. " LEFT JOIN tp_mst_user au\n" +
  5867. " ON au.userid = sp.auditor\n" +
  5868. " LEFT JOIN tp_mst_goods g\n" +
  5869. " ON g.goodsid = sp.goodsid\n" +
  5870. " LEFT JOIN tp_mst_goodstype gt\n" +
  5871. " ON gt.goodstypeid = g.goodstypeid\n" +
  5872. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5873. " ON gt2.accountid = gt.accountid\n" +
  5874. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5875. " WHERE sp.valueflag = '1'\n" +
  5876. " AND sp.AuditStatus = '1'\n" +
  5877. " AND sp.accountid = :accountid\n" +
  5878. // 生产线
  5879. //" 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))" +
  5880. // 完成工序
  5881. //" 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))" +
  5882. // 责任工序
  5883. //" 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)))" +
  5884. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  5885. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5886. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5887. " AND sp.ScrapType = '0'\n" +
  5888. " AND (:ProductionLineID IS NULL OR\n" +
  5889. " sp.ProductionLineID = :ProductionLineID)\n" +
  5890. " AND (:GoodsTypeCode IS NULL OR\n" +
  5891. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5892. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5893. " AND (:ProcedureIDS IS NULL OR\n" +
  5894. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5895. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5896. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  5897. " AND (:ResponUserIDS IS NULL OR\n" +
  5898. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5899. // 损坯时间
  5900. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  5901. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  5902. // 审核时间
  5903. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  5904. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  5905. // 完成时间
  5906. " AND (:CTimeStart IS NULL OR\n" +
  5907. " sp.CreateTime >= :CTimeStart)\n" +
  5908. " AND (:CTimeEnd IS NULL OR\n" +
  5909. " sp.CreateTime <= :CTimeEnd)\n" +
  5910. // 交坯时间
  5911. " AND (:DTimeStart IS NULL OR\n" +
  5912. " gdd.DeliverTime >= :DTimeStart)\n" +
  5913. " AND (:DTimeEnd IS NULL OR\n" +
  5914. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5915. // 注浆时间
  5916. " AND (:GTimeStart IS NULL OR\n" +
  5917. " gdd.GroutingDate >= :GTimeStart)\n" +
  5918. " AND (:GTimeEnd IS NULL OR\n" +
  5919. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5920. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  5921. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  5922. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  5923. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  5924. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  5925. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  5926. " AND (:RUF = 1 OR sr.userid is null)\n" +
  5927. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  5928. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5929. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5930. {
  5931. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5932. }
  5933. else
  5934. {
  5935. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5936. }
  5937. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5938. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5939. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5940. {
  5941. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5942. }
  5943. else
  5944. {
  5945. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5946. }
  5947. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5948. {
  5949. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5950. }
  5951. else
  5952. {
  5953. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5954. }
  5955. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5956. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5957. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5958. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5959. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5960. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5961. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5962. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5963. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5964. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5965. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5966. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5967. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  5968. if (se.ResponProcedureID == "")
  5969. {
  5970. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5971. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  5972. }
  5973. else
  5974. {
  5975. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5976. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  5977. }
  5978. if (se.ResponUserID == "")
  5979. {
  5980. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5981. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  5982. }
  5983. else
  5984. {
  5985. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5986. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  5987. }
  5988. return sqlString;
  5989. }
  5990. /// <summary>
  5991. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  5992. /// </summary>
  5993. /// <param name="user">登录用户信息</param>
  5994. /// <param name="se">查询条件</param>
  5995. /// <returns>查询结果</returns>
  5996. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  5997. {
  5998. IDBConnection conn = null;
  5999. try
  6000. {
  6001. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6002. List<OracleParameter> parameters = new List<OracleParameter>();
  6003. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  6004. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6005. ServiceResultEntity sre = new ServiceResultEntity();
  6006. if (data == null || data.Rows.Count == 0)
  6007. {
  6008. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6009. return sre;
  6010. }
  6011. sre.Data = new DataSet();
  6012. sre.Data.Tables.Add(data);
  6013. return sre;
  6014. }
  6015. catch (Exception ex)
  6016. {
  6017. throw ex;
  6018. }
  6019. finally
  6020. {
  6021. if (conn != null &&
  6022. conn.ConnState == ConnectionState.Open)
  6023. {
  6024. conn.Close();
  6025. }
  6026. }
  6027. }
  6028. /// <summary>
  6029. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6030. /// </summary>
  6031. /// <returns>sql</returns>
  6032. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6033. {
  6034. string selSql = "";
  6035. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6036. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6037. selSql = selSql +
  6038. "SELECT pdata.Procedureid Procedureid " +
  6039. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6040. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6041. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6042. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6043. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6044. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6045. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6046. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6047. " ,OutKilnCount " +
  6048. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6049. " pdata.Userid ) gid " +
  6050. " ,pdata.Procedureid " +
  6051. " ,pdata.Procedurename " +
  6052. " ,pdata.Userid " +
  6053. " ,pdata.Usercode " +
  6054. " ,pdata.Kilnid " +
  6055. " ,pdata.Kilncode " +
  6056. " ,pdata.goodstypename " +
  6057. " ,pdata.Goodsid " +
  6058. " ,pdata.Goodscode " +
  6059. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6060. " FROM (SELECT DISTINCT " +
  6061. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6062. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6063. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6064. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6065. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6066. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6067. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6068. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6069. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6070. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6071. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6072. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6073. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6074. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6075. " from TP_PM_ProductionData " +
  6076. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6077. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6078. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6079. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6080. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6081. " inner join " +
  6082. " ( " +
  6083. " 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 " +
  6084. " from TP_PM_ProductionData " +
  6085. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6086. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6087. {
  6088. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6089. }
  6090. selSql +=
  6091. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6092. " and TP_PM_ProductionData.Valueflag='1' " +
  6093. // 数据重复 modify by chenxy begin
  6094. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6095. // 数据重复 modify by chenxy end
  6096. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6097. //if (se.CreateTimeStart.HasValue)
  6098. //{
  6099. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6100. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6101. //}
  6102. //if (se.CreateTimeEnd.HasValue)
  6103. //{
  6104. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6105. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6106. //}
  6107. if (se.OutTimeStart.HasValue)
  6108. {
  6109. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6110. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6111. }
  6112. if (se.OutTimeEnd.HasValue)
  6113. {
  6114. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6115. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6116. }
  6117. if (se.GTimeStart.HasValue)
  6118. {
  6119. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6120. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6121. }
  6122. if (se.GTimeEnd.HasValue)
  6123. {
  6124. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6125. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6126. }
  6127. if (se.DTimeStart.HasValue)
  6128. {
  6129. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6130. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6131. }
  6132. if (se.DTimeEnd.HasValue)
  6133. {
  6134. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6135. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6136. }
  6137. if (se.Specialrepairflag)
  6138. {
  6139. selSql = selSql +
  6140. " ) temp " +
  6141. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6142. " " +
  6143. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6144. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6145. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6146. " FROM TP_PM_ProductionData pp\n" +
  6147. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6148. " AND pp.createtime < temp.createtime\n" +
  6149. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6150. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6151. " where " +
  6152. // 公坯、干补不算交坯工序的质量。
  6153. // " 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" +
  6154. // modify wangx 2015-12-3
  6155. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6156. " and TP_PM_ProductionData.Valueflag='1' " +
  6157. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6158. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6159. }
  6160. else
  6161. {
  6162. selSql = selSql +
  6163. " ) temp " +
  6164. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6165. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6166. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6167. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6168. " FROM TP_PM_ProductionData pp\n" +
  6169. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6170. " AND pp.createtime < temp.createtime\n" +
  6171. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6172. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6173. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6174. " and TP_PM_ProductionData.Valueflag='1' ";
  6175. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6176. }
  6177. if (se.CreateTimeStart.HasValue)
  6178. {
  6179. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6180. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6181. }
  6182. if (se.CreateTimeEnd.HasValue)
  6183. {
  6184. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6185. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6186. }
  6187. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6188. {
  6189. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6190. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6191. }
  6192. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6193. {
  6194. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6195. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6196. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6197. }
  6198. if (se.ProductionLineID.HasValue)
  6199. {
  6200. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6201. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6202. }
  6203. //else
  6204. //{
  6205. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6206. //}
  6207. 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))";
  6208. 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))";
  6209. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6210. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6211. {
  6212. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6213. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6214. }
  6215. if (!string.IsNullOrEmpty(se.UserIDS))
  6216. {
  6217. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6218. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6219. }
  6220. if (se.KilnID.HasValue)
  6221. {
  6222. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6223. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6224. }
  6225. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6226. {
  6227. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6228. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6229. }
  6230. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6231. " 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),()) " +
  6232. ") pdata"
  6233. ;
  6234. return selSql;
  6235. }
  6236. /// <summary>
  6237. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6238. /// </summary>
  6239. /// <param name="user">登录用户信息</param>
  6240. /// <param name="se">查询条件</param>
  6241. /// <returns>查询结果</returns>
  6242. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6243. {
  6244. IDBConnection conn = null;
  6245. try
  6246. {
  6247. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6248. List<OracleParameter> parameters = new List<OracleParameter>();
  6249. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6250. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6251. ServiceResultEntity sre = new ServiceResultEntity();
  6252. if (data == null || data.Rows.Count == 0)
  6253. {
  6254. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6255. return sre;
  6256. }
  6257. sre.Data = new DataSet();
  6258. sre.Data.Tables.Add(data);
  6259. return sre;
  6260. }
  6261. catch (Exception ex)
  6262. {
  6263. throw ex;
  6264. }
  6265. finally
  6266. {
  6267. if (conn != null &&
  6268. conn.ConnState == ConnectionState.Open)
  6269. {
  6270. conn.Close();
  6271. }
  6272. }
  6273. }
  6274. /// <summary>
  6275. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6276. /// </summary>
  6277. /// <returns>sql</returns>
  6278. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6279. {
  6280. string selSql = "";
  6281. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6282. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6283. selSql = selSql +
  6284. "select distinct " +
  6285. "TP_PM_ProductionData.Barcode, " +
  6286. //"TP_PM_ProductionData.UserCode, " +
  6287. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6288. "pcp.ProcedureName, " +
  6289. "tp_mst_goodstype.goodstypename, " +
  6290. "TP_PM_ProductionData.Goodscode, " +
  6291. "TP_PM_ProductionData.GroutingUserCode, " +
  6292. "TP_PM_ProductionData.GroutingLineCode, " +
  6293. "TP_PM_ProductionData.GroutingMouldCode, " +
  6294. // 多次干补 重复条码
  6295. //"TP_PM_ProductionData.Createtime OverDate, " +
  6296. "temp.Kilnid, " +
  6297. "temp.Kilncode, " +
  6298. "temp.Kilncarcode, " +
  6299. "temp.Createtime, " +
  6300. "temp.DELIVERTIME DDate, " +
  6301. "temp.GROUTINGDATE GDate, " +
  6302. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6303. "from TP_PM_ProductionData " +
  6304. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6305. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6306. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6307. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6308. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6309. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6310. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6311. "inner join " +
  6312. "( " +
  6313. " select " +
  6314. " TP_PM_ProductionData.Barcode, " +
  6315. " TP_PM_ProductionData.Kilncode, " +
  6316. " TP_PM_ProductionData.Kilncarcode, " +
  6317. " TP_PM_ProductionData.Createtime, " +
  6318. " TP_PM_ProductionData.KilnID " +
  6319. " ,gdd.DELIVERTIME " +
  6320. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6321. " ,TP_PM_ProductionData.KilnCarID " +
  6322. " from TP_PM_ProductionData " +
  6323. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6324. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6325. //{
  6326. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6327. //}
  6328. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6329. // selSql +=
  6330. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6331. " and TP_PM_ProductionData.Valueflag='1' " +
  6332. // 数据重复 modify by chenxy begin
  6333. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6334. // 数据重复 modify by chenxy end
  6335. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6336. if (se.OutTimeStart.HasValue)
  6337. {
  6338. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6339. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6340. }
  6341. if (se.OutTimeEnd.HasValue)
  6342. {
  6343. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6344. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6345. }
  6346. if (se.GTimeStart.HasValue)
  6347. {
  6348. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6349. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6350. }
  6351. if (se.GTimeEnd.HasValue)
  6352. {
  6353. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6354. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6355. }
  6356. if (se.DTimeStart.HasValue)
  6357. {
  6358. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6359. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6360. }
  6361. if (se.DTimeEnd.HasValue)
  6362. {
  6363. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6364. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6365. }
  6366. if (se.Specialrepairflag)
  6367. {
  6368. selSql = selSql +
  6369. ") temp " +
  6370. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6371. " " +
  6372. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6373. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6374. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6375. " FROM TP_PM_ProductionData pp\n" +
  6376. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6377. " AND pp.createtime < temp.createtime\n" +
  6378. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6379. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6380. "where " + // 公坯、干补不算交坯工序的质量。
  6381. //" 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" +
  6382. // modify wangx 2015-12-3
  6383. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6384. " and TP_PM_ProductionData.Valueflag='1' " +
  6385. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6386. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6387. }
  6388. else
  6389. {
  6390. selSql = selSql +
  6391. ") temp " +
  6392. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6393. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6394. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6395. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6396. " FROM TP_PM_ProductionData pp\n" +
  6397. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6398. " AND pp.createtime < temp.createtime\n" +
  6399. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6400. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6401. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6402. " and TP_PM_ProductionData.Valueflag='1' ";
  6403. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6404. }
  6405. if (se.CreateTimeStart.HasValue)
  6406. {
  6407. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6408. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6409. }
  6410. if (se.CreateTimeEnd.HasValue)
  6411. {
  6412. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6413. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6414. }
  6415. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6416. {
  6417. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6418. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6419. }
  6420. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6421. {
  6422. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6423. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6424. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6425. }
  6426. if (se.ProductionLineID.HasValue)
  6427. {
  6428. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6429. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6430. }
  6431. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6432. {
  6433. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6434. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6435. }
  6436. if (!string.IsNullOrEmpty(se.UserIDS))
  6437. {
  6438. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6439. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6440. }
  6441. if (se.KilnID.HasValue)
  6442. {
  6443. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6444. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6445. }
  6446. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6447. {
  6448. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6449. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6450. }
  6451. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6452. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6453. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6454. return selSql;
  6455. }
  6456. /// <summary>
  6457. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6458. /// </summary>
  6459. /// <param name="user">登录用户信息</param>
  6460. /// <param name="se">查询条件</param>
  6461. /// <returns>查询结果</returns>
  6462. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6463. {
  6464. IDBConnection conn = null;
  6465. try
  6466. {
  6467. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6468. List<OracleParameter> parameters = new List<OracleParameter>();
  6469. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6470. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6471. ServiceResultEntity sre = new ServiceResultEntity();
  6472. if (data == null || data.Rows.Count == 0)
  6473. {
  6474. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6475. return sre;
  6476. }
  6477. sre.Data = new DataSet();
  6478. sre.Data.Tables.Add(data);
  6479. return sre;
  6480. }
  6481. catch (Exception ex)
  6482. {
  6483. throw ex;
  6484. }
  6485. finally
  6486. {
  6487. if (conn != null &&
  6488. conn.ConnState == ConnectionState.Open)
  6489. {
  6490. conn.Close();
  6491. }
  6492. }
  6493. }
  6494. /// <summary>
  6495. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6496. /// </summary>
  6497. /// <returns>sql</returns>
  6498. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6499. {
  6500. string selSql = "";
  6501. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6502. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6503. selSql = "select " +
  6504. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6505. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6506. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6507. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6508. "Kilncarcode, " +
  6509. "Remarks, " +
  6510. "KilnCarCount " +
  6511. " from " +
  6512. " ( " +
  6513. " select " +
  6514. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6515. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6516. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6517. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6518. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6519. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6520. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6521. " from " +
  6522. " ( " +
  6523. " select " +
  6524. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6525. " TP_PM_KilnCarData.Modeltype, " +
  6526. " TP_PM_KilnCarData.Kilncarid, " +
  6527. " TP_PM_KilnCarData.Kilnid, " +
  6528. " TP_PM_KilnCarData.Userid, " +
  6529. " TP_PM_KilnCarData.Remarks, " +
  6530. " TP_PM_KilnCarData.Accountid, " +
  6531. " TP_PM_KilnCarData.Usercode " +
  6532. " from TP_PM_KilnCarData " +
  6533. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6534. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6535. " and TP_PM_KilnCarData.Valueflag=1 " +
  6536. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6537. if (se.KilnID.HasValue)
  6538. {
  6539. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6540. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6541. }
  6542. //if (se.KilnCarID.HasValue)
  6543. //{
  6544. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6545. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6546. //}
  6547. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6548. {
  6549. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6550. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6551. }
  6552. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6553. {
  6554. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6555. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6556. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6557. }
  6558. else
  6559. {
  6560. if (se.KilnCarNumBegin.HasValue)
  6561. {
  6562. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6563. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6564. }
  6565. if (se.KilnCarNumEnd.HasValue)
  6566. {
  6567. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6568. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6569. }
  6570. }
  6571. if (se.CreateTimeStart.HasValue)
  6572. {
  6573. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6574. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6575. }
  6576. if (se.CreateTimeEnd.HasValue)
  6577. {
  6578. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6579. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6580. }
  6581. selSql = selSql +
  6582. " ) TP_PM_KilnCarData " +
  6583. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6584. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6585. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6586. "where 1=1";
  6587. if (!string.IsNullOrEmpty(se.UserIDS))
  6588. {
  6589. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6590. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6591. }
  6592. selSql = selSql + "group by rollup( " +
  6593. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6594. " TP_MST_Kiln.Kilncode, " +
  6595. " TP_PM_KilnCarData.Usercode, " +
  6596. " TP_PM_KilnCarData.Createtime, " +
  6597. " TP_PM_KilnCarData.Remarks, " +
  6598. " TP_MST_KilnCar.Kilncarcode " +
  6599. " ) " +
  6600. " ) temp " +
  6601. " where (Kilncarcode !='--' ) " +
  6602. " or " +
  6603. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6604. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6605. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6606. return selSql;
  6607. }
  6608. /// <summary>
  6609. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6610. /// </summary>
  6611. /// <param name="user">登录用户信息</param>
  6612. /// <param name="se">查询条件</param>
  6613. /// <returns>查询结果</returns>
  6614. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6615. {
  6616. IDBConnection conn = null;
  6617. try
  6618. {
  6619. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6620. List<OracleParameter> parameters = new List<OracleParameter>();
  6621. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6622. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6623. ServiceResultEntity sre = new ServiceResultEntity();
  6624. if (data == null || data.Rows.Count == 0)
  6625. {
  6626. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6627. return sre;
  6628. }
  6629. sre.Data = new DataSet();
  6630. sre.Data.Tables.Add(data);
  6631. return sre;
  6632. }
  6633. catch (Exception ex)
  6634. {
  6635. throw ex;
  6636. }
  6637. finally
  6638. {
  6639. if (conn != null &&
  6640. conn.ConnState == ConnectionState.Open)
  6641. {
  6642. conn.Close();
  6643. }
  6644. }
  6645. }
  6646. /// <summary>
  6647. /// 获取查询sql
  6648. /// </summary>
  6649. /// <returns>sql</returns>
  6650. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6651. {
  6652. string selSql = "";
  6653. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6654. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6655. selSql = selSql +
  6656. "SELECT " +
  6657. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6658. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6659. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6660. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6661. "decode(goodscode,'--','--',createtime) createtime, " +
  6662. "GOODSTYPENAME, " +
  6663. "Goodscode, " +
  6664. "GOODSSPECIFICATION, " +
  6665. "GoodsCount " +
  6666. "from " +
  6667. "( " +
  6668. " SELECT " +
  6669. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6670. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6671. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6672. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6673. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6674. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6675. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6676. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6677. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6678. " from " +
  6679. " ( " +
  6680. " SELECT TP_PM_ProductionData.Modeltype, " +
  6681. " TP_PM_ProductionData.Goodsid, " +
  6682. " TP_PM_ProductionData.KilnCarID, " +
  6683. " TP_PM_ProductionData.Kilncode, " +
  6684. //" TP_PM_ProductionData.Usercode, " +
  6685. " kcd.Usercode, " +
  6686. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6687. " from TP_PM_ProductionData " +
  6688. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6689. " where " +
  6690. " TP_PM_ProductionData.Accountid=:AccountID " +
  6691. " and TP_PM_ProductionData.Valueflag=1 " +
  6692. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6693. if (se.KilnID.HasValue)
  6694. {
  6695. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6696. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6697. }
  6698. //if (se.KilnCarID.HasValue)
  6699. //{
  6700. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6701. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6702. //}
  6703. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6704. {
  6705. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6706. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6707. }
  6708. if (!string.IsNullOrEmpty(se.UserIDS))
  6709. {
  6710. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6711. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6712. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6713. }
  6714. if (se.CreateTimeStart.HasValue)
  6715. {
  6716. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6717. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6718. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6719. }
  6720. if (se.CreateTimeEnd.HasValue)
  6721. {
  6722. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6723. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6724. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6725. }
  6726. selSql = selSql +
  6727. " ) TP_PM_ProductionData " +
  6728. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6729. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6730. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6731. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6732. " where 1=1 ";
  6733. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6734. {
  6735. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6736. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6737. }
  6738. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6739. {
  6740. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6741. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6742. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6743. }
  6744. else
  6745. {
  6746. if (se.KilnCarNumBegin.HasValue)
  6747. {
  6748. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6749. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6750. }
  6751. if (se.KilnCarNumEnd.HasValue)
  6752. {
  6753. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6754. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6755. }
  6756. }
  6757. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6758. {
  6759. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6760. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6761. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6762. }
  6763. selSql = selSql +
  6764. " group by rollup( " +
  6765. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6766. " TP_PM_ProductionData.Kilncode, " +
  6767. " TP_PM_ProductionData.Usercode, " +
  6768. " TP_MST_KilnCar.Kilncarcode, " +
  6769. " TP_PM_ProductionData.CreateTime, " +
  6770. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6771. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6772. " TP_MST_Goods.Goodscode " +
  6773. " ) " +
  6774. ") temp " +
  6775. "where 1=1 and " +
  6776. " (Goodscode !='--' ) or " +
  6777. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6778. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6779. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6780. return selSql;
  6781. }
  6782. /// <summary>
  6783. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6784. /// </summary>
  6785. /// <param name="user">登录用户信息</param>
  6786. /// <param name="se">查询条件</param>
  6787. /// <returns>查询结果</returns>
  6788. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6789. {
  6790. IDBConnection conn = null;
  6791. try
  6792. {
  6793. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6794. List<OracleParameter> parameters = new List<OracleParameter>();
  6795. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6796. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6797. ServiceResultEntity sre = new ServiceResultEntity();
  6798. if (data == null || data.Rows.Count == 0)
  6799. {
  6800. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6801. return sre;
  6802. }
  6803. sre.Data = new DataSet();
  6804. sre.Data.Tables.Add(data);
  6805. return sre;
  6806. }
  6807. catch (Exception ex)
  6808. {
  6809. throw ex;
  6810. }
  6811. finally
  6812. {
  6813. if (conn != null &&
  6814. conn.ConnState == ConnectionState.Open)
  6815. {
  6816. conn.Close();
  6817. }
  6818. }
  6819. }
  6820. /// <summary>
  6821. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6822. /// </summary>
  6823. /// <returns>sql</returns>
  6824. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6825. {
  6826. string selSql = "";
  6827. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6828. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6829. selSql = selSql +
  6830. "select " +
  6831. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6832. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6833. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6834. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6835. "decode(goodscode,'--','--',createtime) createtime, " +
  6836. "GOODSTYPENAME, " +
  6837. "Goodscode, " +
  6838. "GOODSSPECIFICATION, " +
  6839. "Barcode, " +
  6840. "BarcodeCount, " +
  6841. "LogoCodeName " +
  6842. "from " +
  6843. " ( " +
  6844. " select " +
  6845. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6846. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6847. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6848. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6849. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6850. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6851. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6852. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6853. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6854. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6855. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6856. " from " +
  6857. " ( " +
  6858. " select TP_PM_ProductionData.logoid," +
  6859. " TP_PM_ProductionData.Modeltype, " +
  6860. " TP_PM_ProductionData.Goodsid, " +
  6861. " TP_PM_ProductionData.KilnCarID, " +
  6862. " TP_PM_ProductionData.Kilncode, " +
  6863. " TP_PM_ProductionData.Barcode, " +
  6864. " TP_PM_ProductionData.Usercode, " +
  6865. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6866. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6867. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6868. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6869. " where " +
  6870. " TP_PM_ProductionData.Accountid=:AccountID " +
  6871. " and TP_PM_ProductionData.Valueflag=1 " +
  6872. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6873. if (se.KilnID.HasValue)
  6874. {
  6875. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6876. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6877. }
  6878. //if (se.KilnCarID.HasValue)
  6879. //{
  6880. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  6881. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6882. //}
  6883. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6884. {
  6885. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6886. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6887. }
  6888. if (!string.IsNullOrEmpty(se.UserIDS))
  6889. {
  6890. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6891. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6892. }
  6893. if (se.CreateTimeStart.HasValue)
  6894. {
  6895. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6896. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6897. }
  6898. if (se.CreateTimeEnd.HasValue)
  6899. {
  6900. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6901. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6902. }
  6903. selSql = selSql +
  6904. " ) TP_PM_ProductionData " +
  6905. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6906. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6907. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6908. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6909. " where 1=1";
  6910. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6911. {
  6912. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6913. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6914. }
  6915. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6916. {
  6917. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6918. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6919. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6920. }
  6921. else
  6922. {
  6923. if (se.KilnCarNumBegin.HasValue)
  6924. {
  6925. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6926. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6927. }
  6928. if (se.KilnCarNumEnd.HasValue)
  6929. {
  6930. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6931. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6932. }
  6933. }
  6934. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6935. {
  6936. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6937. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  6938. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6939. }
  6940. selSql = selSql +
  6941. " group by rollup( " +
  6942. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6943. " TP_PM_ProductionData.Kilncode, " +
  6944. " TP_PM_ProductionData.Usercode, " +
  6945. " TP_MST_KilnCar.Kilncarcode, " +
  6946. " TP_PM_ProductionData.CreateTime, " +
  6947. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6948. " TP_MST_Goods.Goodscode, " +
  6949. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6950. " TP_PM_ProductionData.Barcode, " +
  6951. " TP_PM_ProductionData.LogoCodeName " +
  6952. " ) " +
  6953. " ) temp " +
  6954. "where 1=1 and " +
  6955. "(Barcode !='--' and LogoCodeName!='--') or " +
  6956. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  6957. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  6958. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  6959. return selSql;
  6960. }
  6961. #region 工序交接数量汇总表
  6962. /// <summary>
  6963. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  6964. /// </summary>
  6965. /// <param name="user">登录用户信息</param>
  6966. /// <param name="se">查询条件</param>
  6967. /// <returns>查询结果</returns>
  6968. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  6969. {
  6970. IDBConnection conn = null;
  6971. try
  6972. {
  6973. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6974. List<OracleParameter> parameters = new List<OracleParameter>();
  6975. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  6976. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6977. ServiceResultEntity sre = new ServiceResultEntity();
  6978. if (data == null || data.Rows.Count == 0)
  6979. {
  6980. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6981. return sre;
  6982. }
  6983. sre.Data = new DataSet();
  6984. sre.Data.Tables.Add(data);
  6985. return sre;
  6986. }
  6987. catch (Exception ex)
  6988. {
  6989. throw ex;
  6990. }
  6991. finally
  6992. {
  6993. if (conn != null &&
  6994. conn.ConnState == ConnectionState.Open)
  6995. {
  6996. conn.Close();
  6997. }
  6998. }
  6999. }
  7000. /// <summary>
  7001. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  7002. /// </summary>
  7003. /// <returns>sql</returns>
  7004. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7005. {
  7006. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7007. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7008. string sqlString =
  7009. "SELECT p.procedureid\n" +
  7010. " ,decode(gid,\n" +
  7011. " 7,\n" +
  7012. " '总计',\n" +
  7013. " 3,\n" +
  7014. " '合计【' || p.procedurename || '】',\n" +
  7015. " 1,\n" +
  7016. " '--',\n" +
  7017. " p.procedurename) procedurename\n" +
  7018. " ,decode(gid,\n" +
  7019. " 7,\n" +
  7020. " '--',\n" +
  7021. " 3,\n" +
  7022. " '--',\n" +
  7023. " 1,\n" +
  7024. " '小计【' || p.goodstypename2 || '】',\n" +
  7025. " p.goodstypename2) goodstypename2\n" +
  7026. " ,p.goodstypecode2 \n" +
  7027. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7028. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7029. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7030. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7031. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7032. " ,p.overcount\n" +
  7033. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7034. " ,pdata.productionlineid\n" +
  7035. " ,pdata.procedureid\n" +
  7036. " ,to_char(pdata.procedurename) procedurename\n" +
  7037. " ,to_char(pdata.userid) userid\n" +
  7038. " ,pdata.usercode\n" +
  7039. " ,to_char(pdata.goodsid) goodsid\n" +
  7040. " ,pdata.goodscode\n" +
  7041. " ,pdata.goodstypename\n" +
  7042. " ,pdata.goodstypecode2\n" +
  7043. " ,pdata.goodstypename2\n" +
  7044. " ,COUNT(pdata.barcode) overcount\n" +
  7045. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7046. " ,pd.productionlineid\n" +
  7047. " ,pd.procedureid\n" +
  7048. " ,pcp.procedurename\n" +
  7049. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7050. //" ,pd.userid\n" +
  7051. //" ,pd.usercode\n" +
  7052. " ,t_over.goodsid\n" +
  7053. " ,t_over.goodscode\n" +
  7054. " ,t_over.goodstypename\n" +
  7055. " ,t_over.goodstypecode2\n" +
  7056. " ,t_over.goodstypename2\n" +
  7057. " FROM tp_pm_productiondata pd\n" +
  7058. " LEFT JOIN tp_pc_procedure pcp\n" +
  7059. " ON pcp.procedureid = pd.procedureid\n" +
  7060. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7061. " ,pd.productiondataid\n" +
  7062. " ,goods.goodsid\n" +
  7063. " ,goods.goodscode\n" +
  7064. " ,gt.goodstypename\n" +
  7065. " ,gt2.goodstypename goodstypename2\n" +
  7066. " ,gt2.goodstypecode goodstypecode2\n" +
  7067. " FROM tp_pm_productiondata pd\n" +
  7068. " LEFT JOIN tp_mst_goods goods\n" +
  7069. " ON goods.goodsid = pd.goodsid\n" +
  7070. " LEFT JOIN tp_mst_goodstype gt\n" +
  7071. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7072. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7073. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7074. " AND gt2.accountid = gt.accountid\n" +
  7075. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7076. " -- ON pcp.procedureid = pd.procedureid\n" +
  7077. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7078. " WHERE pd.valueflag = '1'\n" +
  7079. " 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))" +
  7080. " AND pd.accountid = :AccountID\n";
  7081. // 生产线
  7082. if (se.ProductionLineID.HasValue)
  7083. {
  7084. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7085. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7086. }
  7087. // 成型工号
  7088. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7089. {
  7090. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7091. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7092. }
  7093. // 产品型号
  7094. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7095. {
  7096. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7097. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7098. }
  7099. // 产品编码
  7100. if (!string.IsNullOrEmpty(se.GoodsCode))
  7101. {
  7102. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7103. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7104. }
  7105. // 交接工序
  7106. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7107. {
  7108. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7109. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7110. }
  7111. // 交接工号
  7112. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7113. {
  7114. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7115. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7116. }
  7117. // 交接时间
  7118. if (se.OverTimeStart.HasValue)
  7119. {
  7120. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7121. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7122. }
  7123. if (se.OverTimeEnd.HasValue)
  7124. {
  7125. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7126. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7127. }
  7128. // 注浆时间
  7129. if (se.GTimeStart.HasValue)
  7130. {
  7131. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7132. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7133. }
  7134. if (se.GTimeEnd.HasValue)
  7135. {
  7136. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7137. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7138. }
  7139. // 交坯时间
  7140. if (se.DTimeStart.HasValue)
  7141. {
  7142. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7143. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7144. }
  7145. if (se.DTimeEnd.HasValue)
  7146. {
  7147. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7148. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7149. }
  7150. sqlString = sqlString +
  7151. " ) t_over\n" +
  7152. " ON pd.barcode = t_over.barcode\n" +
  7153. // 交接工序在生产工序后
  7154. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7155. " WHERE pd.valueflag = '1'\n" +
  7156. " AND pd.accountid = :AccountID\n" +
  7157. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7158. " 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))";
  7159. // 生产工序
  7160. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7161. {
  7162. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7163. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7164. }
  7165. // 生产工号
  7166. if (!string.IsNullOrEmpty(se.UserIDS))
  7167. {
  7168. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7169. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7170. }
  7171. // 生产时间
  7172. if (se.PTimeStart.HasValue)
  7173. {
  7174. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7175. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7176. }
  7177. if (se.PTimeEnd.HasValue)
  7178. {
  7179. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7180. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7181. }
  7182. sqlString = sqlString +
  7183. "\n ) pdata\n" +
  7184. " 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" +
  7185. " ORDER BY pdata.displayno\n" +
  7186. " ,pdata.goodstypename2\n" +
  7187. " ,pdata.usercode\n" +
  7188. " ,pdata.goodstypename\n" +
  7189. " ,pdata.goodscode) p";
  7190. return sqlString;
  7191. }
  7192. /// <summary>
  7193. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7194. /// </summary>
  7195. /// <param name="user">登录用户信息</param>
  7196. /// <param name="se">查询条件</param>
  7197. /// <returns>查询结果</returns>
  7198. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7199. {
  7200. IDBConnection conn = null;
  7201. try
  7202. {
  7203. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7204. List<OracleParameter> parameters = new List<OracleParameter>();
  7205. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7206. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7207. ServiceResultEntity sre = new ServiceResultEntity();
  7208. if (data == null || data.Rows.Count == 0)
  7209. {
  7210. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7211. return sre;
  7212. }
  7213. sre.Data = new DataSet();
  7214. sre.Data.Tables.Add(data);
  7215. return sre;
  7216. }
  7217. catch (Exception ex)
  7218. {
  7219. throw ex;
  7220. }
  7221. finally
  7222. {
  7223. if (conn != null &&
  7224. conn.ConnState == ConnectionState.Open)
  7225. {
  7226. conn.Close();
  7227. }
  7228. }
  7229. }
  7230. /// <summary>
  7231. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7232. /// </summary>
  7233. /// <returns>sql</returns>
  7234. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7235. {
  7236. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7237. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7238. string sqlString =
  7239. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7240. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7241. //" ,pd.usercode\n" +
  7242. " ,t_over.barcode\n" +
  7243. " ,t_over.goodscode\n" +
  7244. " ,t_over.goodstypename\n" +
  7245. " ,t_over.goodstypename2\n" +
  7246. //" ,pd.createtime ptime\n" +
  7247. //" ,t_over.overprocedurename\n" +
  7248. //" ,t_over.overusercode\n" +
  7249. //" ,t_over.overtime\n" +
  7250. " ,t_over.groutingusercode\n" +
  7251. " ,pd.groutinglinecode\n" +
  7252. " ,pd.groutingmouldcode\n" +
  7253. " ,t_over.groutingdate Gdate\n" +
  7254. " ,t_over.DELIVERTIME Ddate\n" +
  7255. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7256. " FROM tp_pm_productiondata pd\n" +
  7257. " LEFT JOIN tp_pc_procedure pcp\n" +
  7258. " ON pcp.procedureid = pd.procedureid\n" +
  7259. " LEFT JOIN TP_MST_logo logo\n" +
  7260. " ON logo.logoid = pd.logoid\n" +
  7261. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7262. " ,pd.productiondataid\n" +
  7263. " ,goods.goodsid\n" +
  7264. " ,goods.goodscode\n" +
  7265. " ,gt.goodstypename\n" +
  7266. " ,gt2.goodstypename goodstypename2\n" +
  7267. //" ,pcp.procedurename overprocedurename\n" +
  7268. //" ,pd.usercode overusercode\n" +
  7269. //" ,pd.createtime overtime\n" +
  7270. " ,pd.groutingusercode\n" +
  7271. " ,pd.groutingdate\n" +
  7272. " ,gdd.DELIVERTIME\n" +
  7273. " FROM tp_pm_productiondata pd\n" +
  7274. " LEFT JOIN tp_mst_goods goods\n" +
  7275. " ON goods.goodsid = pd.goodsid\n" +
  7276. " LEFT JOIN tp_mst_goodstype gt\n" +
  7277. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7278. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7279. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7280. " AND gt2.accountid = gt.accountid\n" +
  7281. " LEFT JOIN tp_pc_procedure pcp\n" +
  7282. " ON pcp.procedureid = pd.procedureid\n" +
  7283. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7284. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7285. " WHERE pd.valueflag = '1'\n" +
  7286. " 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))" +
  7287. " AND pd.accountid = :AccountID\n";
  7288. // 生产线
  7289. if (se.ProductionLineID.HasValue)
  7290. {
  7291. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7292. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7293. }
  7294. // 成型工号
  7295. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7296. {
  7297. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7298. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7299. }
  7300. // 产品型号
  7301. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7302. {
  7303. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7304. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7305. }
  7306. if (!string.IsNullOrEmpty(se.GoodsID))
  7307. {
  7308. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7309. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7310. }
  7311. // 产品编码
  7312. if (!string.IsNullOrEmpty(se.GoodsCode))
  7313. {
  7314. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7315. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7316. }
  7317. // 交接工序
  7318. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7319. {
  7320. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7321. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7322. }
  7323. // 交接工号
  7324. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7325. {
  7326. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7327. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7328. }
  7329. // 交接时间
  7330. if (se.OverTimeStart.HasValue)
  7331. {
  7332. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7333. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7334. }
  7335. if (se.OverTimeEnd.HasValue)
  7336. {
  7337. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7338. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7339. }
  7340. // 注浆时间
  7341. if (se.GTimeStart.HasValue)
  7342. {
  7343. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7344. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7345. }
  7346. if (se.GTimeEnd.HasValue)
  7347. {
  7348. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7349. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7350. }
  7351. // 交坯时间
  7352. if (se.DTimeStart.HasValue)
  7353. {
  7354. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7355. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7356. }
  7357. if (se.DTimeEnd.HasValue)
  7358. {
  7359. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7360. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7361. }
  7362. sqlString = sqlString +
  7363. " ) t_over\n" +
  7364. " ON pd.barcode = t_over.barcode\n" +
  7365. // 交接工序在生产工序后
  7366. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7367. " WHERE pd.valueflag = '1'\n" +
  7368. " AND pd.accountid = :AccountID\n" +
  7369. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7370. " 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))";
  7371. // 生产工序
  7372. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7373. {
  7374. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7375. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7376. }
  7377. // 生产工号
  7378. if (!string.IsNullOrEmpty(se.UserIDS))
  7379. {
  7380. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7381. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7382. }
  7383. // 生产时间
  7384. if (se.PTimeStart.HasValue)
  7385. {
  7386. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7387. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7388. }
  7389. if (se.PTimeEnd.HasValue)
  7390. {
  7391. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7392. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7393. }
  7394. sqlString = sqlString +
  7395. "\n ORDER BY pcp.displayno\n" +
  7396. " ,t_over.goodstypename2\n" +
  7397. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7398. " ,t_over.goodstypename\n" +
  7399. " ,t_over.goodscode\n";
  7400. return sqlString;
  7401. }
  7402. #endregion
  7403. /// <summary>
  7404. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7405. /// </summary>
  7406. /// <param name="user">登录用户信息</param>
  7407. /// <param name="se">查询条件</param>
  7408. /// <returns>查询结果</returns>
  7409. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7410. {
  7411. IDBConnection conn = null;
  7412. try
  7413. {
  7414. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7415. List<OracleParameter> parameters = new List<OracleParameter>();
  7416. string sqlString = "SELECT decode(g.gid,\n" +
  7417. " 7,\n" +
  7418. " '总计',\n" +
  7419. " 3,\n" +
  7420. " '合计【' || g.goodstypename2 || '】',\n" +
  7421. " 0,\n" +
  7422. " g.goodstypename2,\n" +
  7423. " '--') goodstypename2\n" +
  7424. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7425. " ,decode(g.gid,\n" +
  7426. " 1,\n" +
  7427. " '小计【' || g.goodscode || '】',\n" +
  7428. " 0,\n" +
  7429. " g.goodscode,\n" +
  7430. " '--') goodscode\n" +
  7431. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7432. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7433. " ,g.groutingcount\n" +
  7434. " ,g.barcodecount\n" +
  7435. " ,g.scrapcount\n" +
  7436. " ,g.barscrapcount\n" +
  7437. " ,g.delivercount\n" +
  7438. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7439. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7440. " ,gdd.goodstypename2\n" +
  7441. " ,gdd.goodstypename\n" +
  7442. " ,gdd.goodscode\n" +
  7443. " ,gdd.usercode\n" +
  7444. " ,gdd.MONITORName\n" +
  7445. " ,SUM(groutingcount) groutingcount\n" +
  7446. " ,SUM(barcodecount) barcodecount\n" +
  7447. " ,SUM(scrapcount) scrapcount\n" +
  7448. " ,SUM(barscrapcount) barscrapcount\n" +
  7449. " ,SUM(delivercount) delivercount\n" +
  7450. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7451. " ,gdd.usercode\n" +
  7452. " ,mu.usercode as MONITORName\n" +
  7453. " ,goods.goodscode\n" +
  7454. " ,gt.goodstypename\n" +
  7455. " , CASE\n" +
  7456. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7457. " gdd.groutingdate <= :gdataend THEN\n" +
  7458. " 1\n" +
  7459. " ELSE\n" +
  7460. " 0\n" +
  7461. " END groutingcount\n" +
  7462. " , CASE\n" +
  7463. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7464. " gdd.groutingdate <= :gdataend AND\n" +
  7465. " gdd.barcode IS NOT NULL THEN\n" +
  7466. " 1\n" +
  7467. " ELSE\n" +
  7468. " 0\n" +
  7469. " END barcodecount\n" +
  7470. " , CASE\n" +
  7471. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7472. " gdd.scraptime <= :sdataend AND\n" +
  7473. " gdd.scrapflag = '1' THEN\n" +
  7474. " 1\n" +
  7475. " ELSE\n" +
  7476. " 0\n" +
  7477. " END scrapcount\n" +
  7478. " , CASE\n" +
  7479. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7480. " gdd.scraptime <= :sdataend AND\n" +
  7481. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7482. " 1\n" +
  7483. " ELSE\n" +
  7484. " 0\n" +
  7485. " END barscrapcount\n" +
  7486. " , CASE\n" +
  7487. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7488. " gdd.delivertime <= :ddataend AND\n" +
  7489. " gdd.deliverflag = '1' THEN\n" +
  7490. " 1\n" +
  7491. " ELSE\n" +
  7492. " 0\n" +
  7493. " END delivercount\n" +
  7494. " FROM tp_pm_groutingdailydetail gdd\n" +
  7495. " LEFT JOIN tp_mst_goods goods\n" +
  7496. " ON goods.goodsid = gdd.goodsid\n" +
  7497. // 成型线
  7498. " LEFT JOIN tp_pc_groutingline gl" +
  7499. " ON gl.groutinglineid = GDD.GroutingLineID" +
  7500. // 成型班长
  7501. " LEFT JOIN tp_mst_user mu" +
  7502. " ON mu.userid = gl.MONITORID " +
  7503. " LEFT JOIN tp_mst_goodstype gt\n" +
  7504. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7505. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7506. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7507. " AND gt2.accountid = gt.accountid\n" +
  7508. " WHERE gdd.valueflag = '1'\n" +
  7509. " AND gdd.groutingflag = '1'\n" +
  7510. " AND gdd.accountid = :accountid\n" +
  7511. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7512. " gdd.groutingdate <= :gdataend) OR\n" +
  7513. " (gdd.scraptime >= :sdatabegin AND\n" +
  7514. " gdd.scraptime <= :sdataend) OR\n" +
  7515. " (gdd.delivertime >= :ddatabegin AND\n" +
  7516. " gdd.delivertime <= :ddataend))\n" +
  7517. " AND (:usercode IS NULL OR\n" +
  7518. " instr(gdd.usercode, :usercode) > 0)\n" +
  7519. " AND (:GoodsCode IS NULL OR\n" +
  7520. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7521. " AND (:goodstypecode IS NULL OR\n" +
  7522. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7523. " ORDER BY gt2.goodstypename\n" +
  7524. " ,gt.goodstypename\n" +
  7525. " ,goods.goodscode\n" +
  7526. " ,gdd.usercode) gdd\n" +
  7527. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7528. " ORDER BY gdd.goodstypename2\n" +
  7529. " ,gdd.goodstypename\n" +
  7530. " ,gdd.goodscode\n" +
  7531. " ,gdd.usercode) g";
  7532. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7533. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7534. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7535. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7536. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7537. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7538. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7539. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7540. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7541. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7542. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7543. ServiceResultEntity sre = new ServiceResultEntity();
  7544. if (data == null || data.Rows.Count == 0)
  7545. {
  7546. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7547. return sre;
  7548. }
  7549. sre.Data = new DataSet();
  7550. sre.Data.Tables.Add(data);
  7551. return sre;
  7552. }
  7553. catch (Exception ex)
  7554. {
  7555. throw ex;
  7556. }
  7557. finally
  7558. {
  7559. if (conn != null &&
  7560. conn.ConnState == ConnectionState.Open)
  7561. {
  7562. conn.Close();
  7563. }
  7564. }
  7565. }
  7566. #region 撤销产品汇总表
  7567. /// <summary>
  7568. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7569. /// </summary>
  7570. /// <param name="user">登录用户信息</param>
  7571. /// <param name="se">查询条件</param>
  7572. /// <returns>查询结果</returns>
  7573. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7574. {
  7575. IDBConnection conn = null;
  7576. try
  7577. {
  7578. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7579. List<OracleParameter> parameters = new List<OracleParameter>();
  7580. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7581. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7582. ServiceResultEntity sre = new ServiceResultEntity();
  7583. if (data == null || data.Rows.Count == 0)
  7584. {
  7585. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7586. return sre;
  7587. }
  7588. sre.Data = new DataSet();
  7589. sre.Data.Tables.Add(data);
  7590. return sre;
  7591. }
  7592. catch (Exception ex)
  7593. {
  7594. throw ex;
  7595. }
  7596. finally
  7597. {
  7598. if (conn != null &&
  7599. conn.ConnState == ConnectionState.Open)
  7600. {
  7601. conn.Close();
  7602. }
  7603. }
  7604. }
  7605. /// <summary>
  7606. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7607. /// </summary>
  7608. /// <returns>sql</returns>
  7609. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7610. {
  7611. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7612. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7613. string sqlString =
  7614. "SELECT decode(p.gid,\n" +
  7615. " 7,\n" +
  7616. " '总计',\n" +
  7617. " 3,\n" +
  7618. " '合计【' || p.procedurename || '】',\n" +
  7619. " 0,\n" +
  7620. " p.procedurename,\n" +
  7621. " '--') procedurename\n" +
  7622. " ,decode(p.gid,\n" +
  7623. " 1,\n" +
  7624. " '小计【' || p.goodstypename2 || '】',\n" +
  7625. " 0,\n" +
  7626. " p.goodstypename2,\n" +
  7627. " '--') goodstypename2\n" +
  7628. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7629. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7630. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7631. " ,p.codecount\n" +
  7632. " ,p.productionlineid\n" +
  7633. " ,p.procedureid\n" +
  7634. " ,p.goodstypecode2\n" +
  7635. " ,p.goodsid\n" +
  7636. " ,p.userid\n" +
  7637. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7638. " ,pd.productionlineid\n" +
  7639. " ,pd.procedureid\n" +
  7640. " ,p.procedurename\n" +
  7641. " ,p.displayno\n" +
  7642. " ,gt2.goodstypecode goodstypecode2\n" +
  7643. " ,gt2.goodstypename goodstypename2\n" +
  7644. " ,gt.goodstypecode\n" +
  7645. " ,gt.goodstypename\n" +
  7646. " ,goods.goodsid\n" +
  7647. " ,goods.goodscode\n" +
  7648. " ,pd.userid\n" +
  7649. " ,pd.usercode\n" +
  7650. " ,COUNT(*) codecount\n" +
  7651. " FROM tp_pm_productiondata pd\n" +
  7652. " LEFT JOIN tp_pc_procedure p\n" +
  7653. " ON p.procedureid = pd.procedureid\n" +
  7654. " LEFT JOIN tp_mst_goods goods\n" +
  7655. " ON goods.goodsid = pd.goodsid\n" +
  7656. " LEFT JOIN tp_mst_goodstype gt\n" +
  7657. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7658. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7659. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7660. " AND gt2.accountid = gt.accountid\n" +
  7661. " WHERE pd.valueflag = '0'\n" +
  7662. " AND pd.accountid = :accountid\n" +
  7663. " 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))" +
  7664. " 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))" +
  7665. " AND (:productionlineid IS NULL OR\n" +
  7666. " pd.productionlineid = :productionlineid)\n" +
  7667. " AND (:procedureids IS NULL OR\n" +
  7668. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7669. " AND (:goodstypecode IS NULL OR\n" +
  7670. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7671. " AND (:goodscode IS NULL OR\n" +
  7672. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7673. " AND (:PUserIDS IS NULL OR\n" +
  7674. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7675. " AND (:backusercode IS NULL OR\n" +
  7676. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7677. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7678. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7679. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7680. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7681. " 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" +
  7682. " ORDER BY p.displayno\n" +
  7683. " ,gt2.goodstypecode\n" +
  7684. " ,gt.goodstypecode\n" +
  7685. " ,goods.goodscode\n" +
  7686. " ,pd.usercode) p";
  7687. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7688. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7689. {
  7690. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7691. }
  7692. else
  7693. {
  7694. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7695. }
  7696. if (string.IsNullOrEmpty(se.UserIDS))
  7697. {
  7698. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7699. }
  7700. else
  7701. {
  7702. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7703. }
  7704. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7705. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7706. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7707. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7708. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7709. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7710. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7711. return sqlString;
  7712. }
  7713. /// <summary>
  7714. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7715. /// </summary>
  7716. /// <param name="user">登录用户信息</param>
  7717. /// <param name="se">查询条件</param>
  7718. /// <returns>查询结果</returns>
  7719. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7720. {
  7721. IDBConnection conn = null;
  7722. try
  7723. {
  7724. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7725. List<OracleParameter> parameters = new List<OracleParameter>();
  7726. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7727. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7728. ServiceResultEntity sre = new ServiceResultEntity();
  7729. if (data == null || data.Rows.Count == 0)
  7730. {
  7731. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7732. return sre;
  7733. }
  7734. sre.Data = new DataSet();
  7735. sre.Data.Tables.Add(data);
  7736. return sre;
  7737. }
  7738. catch (Exception ex)
  7739. {
  7740. throw ex;
  7741. }
  7742. finally
  7743. {
  7744. if (conn != null &&
  7745. conn.ConnState == ConnectionState.Open)
  7746. {
  7747. conn.Close();
  7748. }
  7749. }
  7750. }
  7751. /// <summary>
  7752. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7753. /// </summary>
  7754. /// <returns>sql</returns>
  7755. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7756. {
  7757. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7758. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7759. string sqlString =
  7760. "SELECT p.procedurename\n" +
  7761. " ,gt2.goodstypename goodstypename2\n" +
  7762. " ,gt.goodstypename\n" +
  7763. " ,goods.goodscode\n" +
  7764. " ,pd.barcode\n" +
  7765. " ,pd.usercode\n" +
  7766. " ,pd.createtime ptime\n" +
  7767. " ,pd.backoutusercode busercode\n" +
  7768. " ,pd.backouttime btime\n" +
  7769. " ,pd.groutingusercode\n" +
  7770. " ,pd.groutinglinecode\n" +
  7771. " ,pd.groutingmouldcode\n" +
  7772. " ,pd.groutingdate GDate\n" +
  7773. " FROM tp_pm_productiondata pd\n" +
  7774. " LEFT JOIN tp_pc_procedure p\n" +
  7775. " ON p.procedureid = pd.procedureid\n" +
  7776. " LEFT JOIN tp_mst_goods goods\n" +
  7777. " ON goods.goodsid = pd.goodsid\n" +
  7778. " LEFT JOIN tp_mst_goodstype gt\n" +
  7779. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7780. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7781. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7782. " AND gt2.accountid = gt.accountid\n" +
  7783. " WHERE pd.valueflag = '0'\n" +
  7784. " AND pd.accountid = :accountid\n" +
  7785. " 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))" +
  7786. " 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))" +
  7787. " AND (:productionlineid IS NULL OR\n" +
  7788. " pd.productionlineid = :productionlineid)\n" +
  7789. " AND (:procedureids IS NULL OR\n" +
  7790. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7791. " AND (:goodstypecode IS NULL OR\n" +
  7792. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7793. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7794. " AND (:PUserIDS IS NULL OR\n" +
  7795. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7796. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7797. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7798. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7799. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7800. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7801. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7802. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7803. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7804. " ORDER BY p.displayno\n" +
  7805. " ,gt2.goodstypename\n" +
  7806. " ,gt.goodstypename\n" +
  7807. " ,goods.goodscode\n" +
  7808. " ,pd.usercode\n" +
  7809. " ,pd.barcode\n" +
  7810. " ,pd.backoutusercode\n" +
  7811. " ,pd.backouttime";
  7812. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7813. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7814. {
  7815. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7816. }
  7817. else
  7818. {
  7819. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7820. }
  7821. if (string.IsNullOrEmpty(se.UserIDS))
  7822. {
  7823. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7824. }
  7825. else
  7826. {
  7827. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7828. }
  7829. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7830. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7831. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7832. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7833. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7834. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7835. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7836. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7837. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7838. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7839. return sqlString;
  7840. }
  7841. #endregion
  7842. /// <summary>
  7843. /// 工序收发存汇总表(初始化数据)
  7844. /// </summary>
  7845. /// <param name="user"></param>
  7846. /// <returns></returns>
  7847. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7848. {
  7849. IDBConnection conn = null;
  7850. try
  7851. {
  7852. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7853. OracleParameter[] parameters = new OracleParameter[]
  7854. {
  7855. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7856. };
  7857. string sqlString =
  7858. "SELECT t.ptid, t.name\n" +
  7859. " FROM tp_mst_rpt_transfer t\n" +
  7860. " WHERE t.AccountID = :AccountID\n" +
  7861. " AND t.valueflag = '1'\n" +
  7862. " ORDER BY t.displayno desc";
  7863. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7864. ServiceResultEntity sre = new ServiceResultEntity();
  7865. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7866. //{
  7867. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7868. // return sre;
  7869. //}
  7870. sre.Data = data;
  7871. return sre;
  7872. }
  7873. catch (Exception ex)
  7874. {
  7875. throw ex;
  7876. }
  7877. finally
  7878. {
  7879. if (conn != null &&
  7880. conn.ConnState == ConnectionState.Open)
  7881. {
  7882. conn.Close();
  7883. }
  7884. }
  7885. }
  7886. /// <summary>
  7887. /// 工序收发存汇总表
  7888. /// </summary>
  7889. /// <param name="user"></param>
  7890. /// <param name="se"></param>
  7891. /// <returns></returns>
  7892. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  7893. {
  7894. IDBTransaction conn = null;
  7895. try
  7896. {
  7897. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  7898. conn.Connect();
  7899. OracleParameter[] parameters = new OracleParameter[]
  7900. {
  7901. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7902. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  7903. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  7904. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  7905. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  7906. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  7907. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  7908. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  7909. };
  7910. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  7911. ServiceResultEntity sre = new ServiceResultEntity();
  7912. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7913. {
  7914. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7915. return sre;
  7916. }
  7917. //StringBuilder intdids = new StringBuilder();
  7918. //foreach (DataRow row in data.Tables[0].Rows)
  7919. //{
  7920. // if (intdids.Length > 0)
  7921. // {
  7922. // intdids.Append(", ");
  7923. // }
  7924. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  7925. //}
  7926. //string sqlString =
  7927. // "WITH ttm AS\n" +
  7928. // " (SELECT *\n" +
  7929. // " FROM TMP_RPT_TECDEP_D\n" +
  7930. // " pivot(SUM(m)\n" +
  7931. // " FOR intdid IN(" + intdids + ")))\n" +
  7932. // "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" +
  7933. // " FROM TMP_RPT_TECDEP_T t\n" +
  7934. // " LEFT JOIN ttm m\n" +
  7935. // " ON m.goodsid = t.goodsid\n" +
  7936. // " AND m.outtdid = t.tecdepid\n" +
  7937. // " ORDER BY t.goodscode, t.displayno";
  7938. //data = conn.GetSqlResultToDs(sqlString);
  7939. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7940. //{
  7941. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7942. // return sre;
  7943. //}
  7944. conn.Commit();
  7945. sre.Data = data;
  7946. return sre;
  7947. }
  7948. catch (Exception ex)
  7949. {
  7950. throw ex;
  7951. }
  7952. finally
  7953. {
  7954. if (conn != null &&
  7955. conn.ConnState == ConnectionState.Open)
  7956. {
  7957. conn.Disconnect();
  7958. }
  7959. }
  7960. }
  7961. #endregion 汇总报表
  7962. #region 公共函数
  7963. /// <summary>
  7964. /// 取得报表的查询数据源统计工序数据
  7965. /// </summary>
  7966. /// <param name="user">登录用户信息</param>
  7967. /// <param name="se">查询条件</param>
  7968. /// <returns>查询结果</returns>
  7969. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  7970. {
  7971. IDBConnection conn = null;
  7972. try
  7973. {
  7974. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7975. OracleParameter[] paras = new OracleParameter[]{
  7976. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  7977. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  7978. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  7979. };
  7980. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  7981. ServiceResultEntity sre = new ServiceResultEntity();
  7982. if (data == null || data.Tables.Count == 0)
  7983. {
  7984. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7985. return sre;
  7986. }
  7987. sre.Data = new DataSet();
  7988. sre.Data = data;
  7989. return sre;
  7990. }
  7991. catch (Exception ex)
  7992. {
  7993. throw ex;
  7994. }
  7995. finally
  7996. {
  7997. if (conn != null &&
  7998. conn.ConnState == ConnectionState.Open)
  7999. {
  8000. conn.Close();
  8001. }
  8002. }
  8003. }
  8004. /// <summary>
  8005. /// 取得报表数据源数据
  8006. /// </summary>
  8007. /// <param name="user">登录用户信息</param>
  8008. /// <returns>查询结果</returns>
  8009. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8010. {
  8011. IDBConnection conn = null;
  8012. try
  8013. {
  8014. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8015. string selSql = " select "
  8016. + " TP_MST_RptProcedure.Rptprocedureid,"
  8017. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8018. + " TP_MST_RptProcedure.Rptprocedurename,"
  8019. + " TP_MST_RptProcedure.Rptproceduretype,"
  8020. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8021. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8022. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8023. + " TP_MST_RptProcedure.Optimestamp "
  8024. + " from TP_MST_RptProcedure "
  8025. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8026. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8027. List<OracleParameter> parameters = new List<OracleParameter>();
  8028. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8029. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8030. ServiceResultEntity sre = new ServiceResultEntity();
  8031. if (data == null || data.Rows.Count == 0)
  8032. {
  8033. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8034. return sre;
  8035. }
  8036. sre.Data = new DataSet();
  8037. sre.Data.Tables.Add(data);
  8038. return sre;
  8039. }
  8040. catch (Exception ex)
  8041. {
  8042. throw ex;
  8043. }
  8044. finally
  8045. {
  8046. if (conn != null &&
  8047. conn.ConnState == ConnectionState.Open)
  8048. {
  8049. conn.Close();
  8050. }
  8051. }
  8052. }
  8053. /// <summary>
  8054. /// 取得窑炉数据
  8055. /// </summary>
  8056. /// <param name="user">登录用户信息</param>
  8057. /// <param name="pValue">使用标识条件</param>
  8058. /// <returns>查询结果</returns>
  8059. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8060. {
  8061. IDBConnection conn = null;
  8062. try
  8063. {
  8064. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8065. string selSql = string.Empty;
  8066. List<OracleParameter> parameters = new List<OracleParameter>();
  8067. //根据帐套查询数据
  8068. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8069. {
  8070. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8071. + "from TP_MST_Kiln where AccountID = :AccountID";
  8072. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8073. }
  8074. //根据帐套和标识查询数据
  8075. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8076. {
  8077. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8078. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8079. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8080. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8081. }
  8082. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8083. ServiceResultEntity sre = new ServiceResultEntity();
  8084. if (data == null || data.Rows.Count == 0)
  8085. {
  8086. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8087. return sre;
  8088. }
  8089. sre.Data = new DataSet();
  8090. sre.Data.Tables.Add(data);
  8091. return sre;
  8092. }
  8093. catch (Exception ex)
  8094. {
  8095. throw ex;
  8096. }
  8097. finally
  8098. {
  8099. if (conn != null &&
  8100. conn.ConnState == ConnectionState.Open)
  8101. {
  8102. conn.Close();
  8103. }
  8104. }
  8105. }
  8106. /// <summary>
  8107. /// 取得窑车数据
  8108. /// </summary>
  8109. /// <param name="user">登录用户信息</param>
  8110. /// <returns>查询结果</returns>
  8111. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8112. {
  8113. IDBConnection conn = null;
  8114. try
  8115. {
  8116. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8117. string selSql = String.Empty;
  8118. List<OracleParameter> parameters = new List<OracleParameter>();
  8119. //获取窑车管理的数据
  8120. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8121. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8122. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8123. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8124. ServiceResultEntity sre = new ServiceResultEntity();
  8125. if (data == null || data.Rows.Count == 0)
  8126. {
  8127. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8128. return sre;
  8129. }
  8130. sre.Data = new DataSet();
  8131. sre.Data.Tables.Add(data);
  8132. return sre;
  8133. }
  8134. catch (Exception ex)
  8135. {
  8136. throw ex;
  8137. }
  8138. finally
  8139. {
  8140. if (conn != null &&
  8141. conn.ConnState == ConnectionState.Open)
  8142. {
  8143. conn.Close();
  8144. }
  8145. }
  8146. }
  8147. /// <summary>
  8148. /// 取得生产线所有的工序
  8149. /// </summary>
  8150. /// <param name="user">登录用户信息</param>
  8151. /// <returns>查询结果</returns>
  8152. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8153. {
  8154. IDBConnection conn = null;
  8155. try
  8156. {
  8157. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8158. string selSql = "select "
  8159. + " tp_pc_procedure.procedureid, "
  8160. + " tp_pc_procedure.Procedurename "
  8161. + " from "
  8162. + " ( "
  8163. + " select TP_PM_ProductionData.Procedureid "
  8164. + " from TP_PM_ProductionData "
  8165. + " where TP_PM_ProductionData.accountid = :accountID "
  8166. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8167. + " group by TP_PM_ProductionData.Procedureid "
  8168. + " order by TP_PM_ProductionData.Procedureid "
  8169. + " )temp left join tp_pc_procedure "
  8170. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8171. List<OracleParameter> parameters = new List<OracleParameter>();
  8172. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8173. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8174. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8175. ServiceResultEntity sre = new ServiceResultEntity();
  8176. if (data == null || data.Rows.Count == 0)
  8177. {
  8178. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8179. return sre;
  8180. }
  8181. sre.Data = new DataSet();
  8182. sre.Data.Tables.Add(data);
  8183. return sre;
  8184. }
  8185. catch (Exception ex)
  8186. {
  8187. throw ex;
  8188. }
  8189. finally
  8190. {
  8191. if (conn != null &&
  8192. conn.ConnState == ConnectionState.Open)
  8193. {
  8194. conn.Close();
  8195. }
  8196. }
  8197. }
  8198. /// <summary>
  8199. /// 取得数据字典数据
  8200. /// </summary>
  8201. /// <param name="Pvalue">显示停用标识</param>
  8202. /// <param name="dictionaryType">字典类别</param>
  8203. /// <param name="user">登录用户信息</param>
  8204. /// <returns>查询结果</returns>
  8205. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8206. {
  8207. IDBConnection conn = null;
  8208. try
  8209. {
  8210. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8211. string selSql = String.Empty;
  8212. List<OracleParameter> parameters = new List<OracleParameter>();
  8213. //根据帐套获得数据字典管理的数据
  8214. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8215. {
  8216. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8217. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8218. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8219. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8220. }
  8221. //根据帐套,标识获得数据字典管理的数据
  8222. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8223. {
  8224. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8225. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8226. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8227. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8228. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8229. }
  8230. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8231. ServiceResultEntity sre = new ServiceResultEntity();
  8232. if (data == null || data.Rows.Count == 0)
  8233. {
  8234. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8235. return sre;
  8236. }
  8237. sre.Data = new DataSet();
  8238. sre.Data.Tables.Add(data);
  8239. return sre;
  8240. }
  8241. catch (Exception ex)
  8242. {
  8243. throw ex;
  8244. }
  8245. finally
  8246. {
  8247. if (conn != null &&
  8248. conn.ConnState == ConnectionState.Open)
  8249. {
  8250. conn.Close();
  8251. }
  8252. }
  8253. }
  8254. #endregion 公共函数
  8255. #endregion 统一使用Se模式rviceResultEntity类
  8256. /// <summary>
  8257. /// 获取注浆次数报表
  8258. /// </summary>
  8259. /// <param name="groutingLineEntity"></param>
  8260. /// <param name="user"></param>
  8261. /// <returns></returns>
  8262. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8263. {
  8264. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8265. try
  8266. {
  8267. con.Open();
  8268. OracleParameter[] paras = new OracleParameter[]{
  8269. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8270. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8271. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8272. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8273. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8274. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8275. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8276. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8277. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8278. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8279. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8280. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8281. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8282. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8283. new OracleParameter("AccountID",OracleDbType.Int32,
  8284. user.AccountID,ParameterDirection.Input),
  8285. new OracleParameter("UserId",OracleDbType.Int32,
  8286. user.UserID,ParameterDirection.Input),
  8287. new OracleParameter("PurviewType",OracleDbType.Int32,
  8288. groutingLineEntity.Purview,ParameterDirection.Input),
  8289. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8290. ParameterDirection.Output),
  8291. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8292. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8293. };
  8294. //调用获取符合条件的成型线信息
  8295. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8296. ServiceResultEntity sre = new ServiceResultEntity();
  8297. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8298. {
  8299. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8300. return sre;
  8301. }
  8302. sre.Data = new DataSet();
  8303. //DataTable dt=ds.Tables[0];
  8304. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8305. return sre;
  8306. }
  8307. catch (Exception ex)
  8308. {
  8309. throw ex;
  8310. }
  8311. finally
  8312. {
  8313. if (con.ConnState == ConnectionState.Open)
  8314. {
  8315. con.Close();
  8316. }
  8317. }
  8318. }
  8319. #region 在产产品汇总表
  8320. /// <summary>
  8321. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8322. /// </summary>
  8323. /// <param name="user">登录用户信息</param>
  8324. /// <param name="se">查询条件</param>
  8325. /// <returns>查询结果</returns>
  8326. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8327. {
  8328. IDBConnection conn = null;
  8329. try
  8330. {
  8331. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8332. List<OracleParameter> parameters = new List<OracleParameter>();
  8333. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8334. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8335. ServiceResultEntity sre = new ServiceResultEntity();
  8336. if (data == null || data.Rows.Count == 0)
  8337. {
  8338. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8339. return sre;
  8340. }
  8341. sre.Data = new DataSet();
  8342. sre.Data.Tables.Add(data);
  8343. return sre;
  8344. }
  8345. catch (Exception ex)
  8346. {
  8347. throw ex;
  8348. }
  8349. finally
  8350. {
  8351. if (conn != null &&
  8352. conn.ConnState == ConnectionState.Open)
  8353. {
  8354. conn.Close();
  8355. }
  8356. }
  8357. }
  8358. /// <summary>
  8359. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8360. /// </summary>
  8361. /// <returns>sql</returns>
  8362. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8363. {
  8364. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8365. //"select " +
  8366. //" ProcedureID," +
  8367. //" procedurecode, " +
  8368. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8369. //" productionlineid, " +
  8370. //" productionlinecode, " +
  8371. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8372. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8373. //" subGoodsTypecode, " +
  8374. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8375. //" Goodstypename, " +
  8376. //" InCount " +
  8377. #region
  8378. /*
  8379. "select " +
  8380. " ProcedureID," +
  8381. " procedurecode, " +
  8382. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8383. " productionlineid, " +
  8384. " productionlinecode, " +
  8385. " productionlinename, " +
  8386. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8387. " decode(productionlinename, '--', null, UserID) UserID, " +
  8388. " subGoodsTypecode, " +
  8389. " Goodsid," +
  8390. " Goodscode, " +
  8391. " Goodstypename, " +
  8392. " InCount from (" +
  8393. "select " +
  8394. " ProcedureID," +
  8395. " procedurecode, " +
  8396. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8397. " productionlineid, " +
  8398. " productionlinecode, " +
  8399. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8400. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8401. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8402. " subGoodsTypecode, " +
  8403. " Goodsid," +
  8404. " Goodscode, " +
  8405. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8406. " InCount " +
  8407. "from " +
  8408. "(" +
  8409. " select " +
  8410. " ProcedureID, " +
  8411. " procedurecode, " +
  8412. " procedurename, " +
  8413. " productionlineid, " +
  8414. " productionlinecode, " +
  8415. " productionlinename, " +
  8416. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8417. " decode(procedurecode,'--',null,Userid) Userid, " +
  8418. " subGoodsTypecode," +
  8419. " Goodsid," +
  8420. " Goodscode," +
  8421. " Goodstypename, " +
  8422. " InCount " +
  8423. " from ( select " +
  8424. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8425. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8426. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8427. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8428. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8429. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8430. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8431. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8432. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8433. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8434. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8435. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8436. " count(barcode) as InCount " +
  8437. " from tp_pm_inproduction " +
  8438. " left join tp_pc_procedure" +
  8439. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8440. " 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" +
  8441. " Where 1=1 " +
  8442. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8443. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8444. {
  8445. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8446. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8447. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8448. }
  8449. if (!string.IsNullOrEmpty(se.LineIDS))
  8450. {
  8451. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8452. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8453. }
  8454. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8455. {
  8456. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8457. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8458. }
  8459. if (!string.IsNullOrEmpty(se.GoodsCode))
  8460. {
  8461. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8462. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8463. }
  8464. selSql = selSql +
  8465. "group by " +
  8466. " rollup(tp_pc_procedure.ProcedureID, " +
  8467. " tp_pc_procedure.procedurecode, " +
  8468. " tp_pc_procedure.procedurename, " +
  8469. " tp_pm_inproduction.productionlineid, " +
  8470. " tp_pm_inproduction.productionlinecode, " +
  8471. " tp_pm_inproduction.productionlinename, " +
  8472. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8473. " TP_MST_User.Usercode," +
  8474. " TP_MST_Goods.Goodscode, " +
  8475. " TP_MST_User.UserID," +
  8476. " TP_MST_Goods.GoodsID, " +
  8477. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8478. "where 1=1 " +
  8479. "and (Goodstypename!='--')" +
  8480. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8481. "or (Goodstypename='--' and UserCode='合计') " +
  8482. "or (Goodstypename='--' and UserCode='总计') )";
  8483. */
  8484. #endregion
  8485. string sqlString = "select t.productionlineid\n" +
  8486. " ,t.productionlinecode\n" +
  8487. " ,decode(gid\n" +
  8488. " ,15\n" +
  8489. " ,'总计【' || t.productionlinename || '】'\n" +
  8490. " ,t.productionlinename) productionlinename\n" +
  8491. " ,t.ProcedureID\n" +
  8492. " ,t.procedurecode\n" +
  8493. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8494. " ,t.Goodstypeid2\n" +
  8495. " ,t.Goodstypecode2\n" +
  8496. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8497. " ,t.Goodsid\n" +
  8498. " ,t.Goodscode\n" +
  8499. " ,t.InCount\n" +
  8500. " from (select grouping_id(inp.productionlineid\n" +
  8501. " ,inp.ProcedureID\n" +
  8502. " ,gt2.Goodstypeid\n" +
  8503. " ,inp.Goodsid) gid\n" +
  8504. " ,inp.productionlineid\n" +
  8505. " ,pline.productionlinecode\n" +
  8506. " ,pline.productionlinename\n" +
  8507. " ,inp.ProcedureID\n" +
  8508. " ,p.procedurecode\n" +
  8509. " ,p.procedurename\n" +
  8510. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8511. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8512. " ,gt2.Goodstypename Goodstypename2\n" +
  8513. " ,inp.Goodsid\n" +
  8514. " ,g.Goodscode\n" +
  8515. " ,count(barcode) as InCount\n" +
  8516. " from tp_pm_inproduction inp\n" +
  8517. " inner join tp_pc_procedure p\n" +
  8518. " on inp.ProcedureID = p.ProcedureID\n" +
  8519. " inner join tp_pc_productionline pline\n" +
  8520. " on pline.productionlineid = inp.productionlineid\n" +
  8521. " inner join TP_MST_User u\n" +
  8522. " on inp.userid = u.Userid\n" +
  8523. " inner join TP_MST_Goods g\n" +
  8524. " on inp.goodsid = g.Goodsid\n" +
  8525. " inner join TP_MST_GoodsType gt\n" +
  8526. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8527. " inner join TP_MST_GoodsType gt2\n" +
  8528. " on gt.accountid = gt2.accountid\n" +
  8529. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8530. " where inp.AccountID = 1\n" +
  8531. " and inp.valueflag = '1'\n";
  8532. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8533. {
  8534. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8535. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8536. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8537. }
  8538. if (!string.IsNullOrEmpty(se.LineIDS))
  8539. {
  8540. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8541. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8542. }
  8543. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8544. {
  8545. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8546. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8547. }
  8548. if (!string.IsNullOrEmpty(se.GoodsCode))
  8549. {
  8550. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8551. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8552. }
  8553. 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";
  8554. return sqlString;
  8555. }
  8556. /// <summary>
  8557. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8558. /// </summary>
  8559. /// <param name="user">登录用户信息</param>
  8560. /// <param name="se">查询条件</param>
  8561. /// <returns>查询结果</returns>
  8562. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8563. {
  8564. IDBConnection conn = null;
  8565. try
  8566. {
  8567. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8568. List<OracleParameter> parameters = new List<OracleParameter>();
  8569. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8570. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8571. if (se != null)
  8572. {
  8573. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8574. {
  8575. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8576. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8577. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8578. }
  8579. if (!string.IsNullOrEmpty(se.LineIDS))
  8580. {
  8581. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8582. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8583. }
  8584. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8585. {
  8586. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8587. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8588. }
  8589. if (!string.IsNullOrEmpty(se.GoodsCode))
  8590. {
  8591. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8592. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8593. }
  8594. // 总单点击查询用
  8595. if (se.GoodsID.HasValue)
  8596. {
  8597. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8598. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8599. }
  8600. if (se.UserID.HasValue)
  8601. {
  8602. sql.Append(" AND A.userid = :userid ");
  8603. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8604. }
  8605. }
  8606. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8607. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8608. ServiceResultEntity sre = new ServiceResultEntity();
  8609. if (data == null || data.Rows.Count == 0)
  8610. {
  8611. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8612. return sre;
  8613. }
  8614. sre.Data = new DataSet();
  8615. sre.Data.Tables.Add(data);
  8616. return sre;
  8617. }
  8618. catch (Exception ex)
  8619. {
  8620. throw ex;
  8621. }
  8622. finally
  8623. {
  8624. if (conn != null &&
  8625. conn.ConnState == ConnectionState.Open)
  8626. {
  8627. conn.Close();
  8628. }
  8629. }
  8630. }
  8631. /// <summary>
  8632. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8633. /// </summary>
  8634. /// <returns>sql</returns>
  8635. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8636. {
  8637. string selSql =
  8638. "SELECT " +
  8639. " TP_PM_InProduction.BarCode, " +
  8640. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8641. " TP_PM_InProduction.GoodsName, " +
  8642. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8643. " TP_PM_InProduction.ProductionLineID, " +
  8644. " TP_PM_InProduction.ProductionLineCode, " +
  8645. " TP_PM_InProduction.ProductionLineName, " +
  8646. " TP_PM_InProduction.ModelType, " +
  8647. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8648. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8649. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8650. " TP_PM_InProduction.IsPublicBody, " +
  8651. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8652. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8653. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8654. " TP_PM_InProduction.GroutingDailyID, " +
  8655. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8656. " TP_PM_InProduction.GroutingDate, " +
  8657. " TP_PM_InProduction.GroutingLineID, " +
  8658. " TP_PM_InProduction.GroutingLineCode, " +
  8659. " TP_PM_InProduction.GroutingLineName, " +
  8660. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8661. " D.ProcedureName as CompleteProcedureName, " +
  8662. " TP_PM_InProduction.GMouldTypeID, " +
  8663. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8664. " TP_PM_InProduction.GroutingLineDetailID, " +
  8665. " TP_PM_InProduction.GroutingMouldCode, " +
  8666. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8667. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8668. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8669. " TP_PM_InProduction.Remarks, " +
  8670. " TP_PM_GroutingDailyDetail.glazingroom," +
  8671. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8672. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8673. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8674. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8675. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8676. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8677. "FROM TP_PM_InProduction " +
  8678. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8679. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8680. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8681. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8682. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8683. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8684. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8685. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8686. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8687. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8688. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8689. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8690. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8691. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8692. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8693. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8694. " and TP_PM_InProduction.AccountID=:AccountID ";
  8695. return selSql;
  8696. }
  8697. #endregion
  8698. /// <summary>
  8699. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8700. /// </summary>
  8701. /// <param name="user">登录用户信息</param>
  8702. /// <param name="se">查询条件</param>
  8703. /// <returns>查询结果</returns>
  8704. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8705. {
  8706. IDBConnection conn = null;
  8707. try
  8708. {
  8709. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8710. List<OracleParameter> parameters = new List<OracleParameter>();
  8711. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8712. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8713. ServiceResultEntity sre = new ServiceResultEntity();
  8714. if (data == null || data.Rows.Count == 0)
  8715. {
  8716. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8717. return sre;
  8718. }
  8719. sre.Data = new DataSet();
  8720. sre.Data.Tables.Add(data);
  8721. return sre;
  8722. }
  8723. catch (Exception ex)
  8724. {
  8725. throw ex;
  8726. }
  8727. finally
  8728. {
  8729. if (conn != null &&
  8730. conn.ConnState == ConnectionState.Open)
  8731. {
  8732. conn.Close();
  8733. }
  8734. }
  8735. }
  8736. /// <summary>
  8737. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8738. /// </summary>
  8739. /// <returns>sql</returns>
  8740. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8741. {
  8742. #region
  8743. //string selSql = "";
  8744. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8745. //selSql = selSql +
  8746. // "select " +
  8747. // " DefectProcedureID," +
  8748. // " DefectProcedureCode, " +
  8749. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8750. // " ProductionLineID, " +
  8751. // " ProductionLineCode," +
  8752. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8753. // " ProcedureID, " +
  8754. // " ProcedureCode," +
  8755. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8756. // " DefectCode, " +
  8757. // " DefectName, " +
  8758. // " DefectTypeName, " +
  8759. // " Userid," +
  8760. // " Usercode," +
  8761. // " Username," +
  8762. // " Goodstypename," +
  8763. // " Goodsid," +
  8764. // " Goodscode," +
  8765. // " Goodsname," +
  8766. // " InCount from (" +
  8767. // "select " +
  8768. // " DefectProcedureID," +
  8769. // " DefectProcedureCode, " +
  8770. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8771. // " ProductionLineID, " +
  8772. // " ProductionLineCode, " +
  8773. // " ProductionLineName, " +
  8774. // " ProcedureID, " +
  8775. // " ProcedureCode, " +
  8776. // " ProcedureName, " +
  8777. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8778. // " DefectName, " +
  8779. // " DefectTypeName, " +
  8780. // " Userid, " +
  8781. // " Usercode, " +
  8782. // " Username, " +
  8783. // " Goodstypename, " +
  8784. // " Goodsid, " +
  8785. // " Goodscode, " +
  8786. // " Goodsname, " +
  8787. // " InCount " +
  8788. // "from " +
  8789. // "(" +
  8790. // " select " +
  8791. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8792. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8793. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8794. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8795. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8796. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8797. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8798. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8799. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8800. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8801. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8802. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8803. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8804. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8805. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8806. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8807. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8808. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8809. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8810. // " count(TP_PM_Defect.barcode) as InCount " +
  8811. // " from TP_PM_Defect " +
  8812. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8813. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8814. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8815. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8816. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8817. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8818. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8819. // " and TP_PM_Defect.AccountID=:AccountID ";
  8820. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8821. //{
  8822. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8823. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8824. //}
  8825. //if (!string.IsNullOrEmpty(se.LineIDS))
  8826. //{
  8827. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8828. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8829. //}
  8830. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8831. //{
  8832. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8833. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8834. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8835. //}
  8836. //else
  8837. //{
  8838. // // modify by chenxy :没有选择时,应全查询出来。
  8839. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8840. //}
  8841. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8842. //{
  8843. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8844. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8845. //}
  8846. //if (!string.IsNullOrEmpty(se.KilnCode))
  8847. //{
  8848. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8849. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8850. //}
  8851. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8852. //{
  8853. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8854. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8855. //}
  8856. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8857. //{
  8858. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8859. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8860. //}
  8861. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8862. //{
  8863. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8864. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8865. //}
  8866. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8867. //{
  8868. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8869. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8870. //}
  8871. //if (!string.IsNullOrEmpty(se.DefectCode))
  8872. //{
  8873. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8874. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8875. //}
  8876. //if (!string.IsNullOrEmpty(se.DefectName))
  8877. //{
  8878. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  8879. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  8880. //}
  8881. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  8882. //{
  8883. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  8884. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  8885. //}
  8886. //if (se.CreateTimeStart.HasValue)
  8887. //{
  8888. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  8889. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  8890. //}
  8891. //if (se.CreateTimeEnd.HasValue)
  8892. //{
  8893. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  8894. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  8895. //}
  8896. //selSql = selSql +
  8897. // "group by " +
  8898. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  8899. // " TP_PM_Defect.DefectProcedureCode, " +
  8900. // " TP_PM_Defect.DefectProcedureName, " +
  8901. // " TP_PM_Defect.ProductionLineID, " +
  8902. // " TP_PM_Defect.ProductionLineCode, " +
  8903. // " TP_PM_Defect.ProductionLineName, " +
  8904. // " TP_PM_Defect.ProcedureID, " +
  8905. // " TP_PM_Defect.ProcedureCode," +
  8906. // " TP_PM_Defect.ProcedureName, " +
  8907. // " TP_PM_Defect.DefectCode, " +
  8908. // " TP_PM_Defect.DefectName, " +
  8909. // " TP_MST_DefectType.DefectTypeName, " +
  8910. // " TP_PM_Defect.Userid, " +
  8911. // " TP_PM_Defect.Usercode, " +
  8912. // " TP_PM_Defect.Username, " +
  8913. // " TP_MST_GoodsType.Goodstypename, " +
  8914. // " TP_PM_Defect.Goodsid, " +
  8915. // " TP_PM_Defect.Goodscode, " +
  8916. // " TP_PM_Defect.Goodsname " +
  8917. // " )) temp ) temp2 " +
  8918. // "where 1=1 " +
  8919. // "and ((Goodsname!='--' )" +
  8920. // "or (Goodsname='--' and defectcode='小计')" +
  8921. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  8922. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  8923. //////----------------------
  8924. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  8925. ////{
  8926. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  8927. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  8928. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  8929. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  8930. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  8931. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  8932. ////}
  8933. //////----------------------
  8934. //return selSql;
  8935. #endregion
  8936. string selSql =
  8937. "SELECT t.ProductionLineID\n" +
  8938. " ,t.ProductionLineCode\n" +
  8939. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  8940. " ,t.ProcedureID\n" +
  8941. " ,t.ProcedureCode\n" +
  8942. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  8943. " ,t.DefectProcedureID\n" +
  8944. " ,t.DefectProcedureCode\n" +
  8945. " ,decode(t.gid,\n" +
  8946. " 7,\n" +
  8947. " '合计【' || t.DefectProcedureName || '】',\n" +
  8948. " 0,\n" +
  8949. " t.DefectProcedureName,\n" +
  8950. " '--') DefectProcedureName\n" +
  8951. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  8952. " ,decode(t.gid,\n" +
  8953. " 3,\n" +
  8954. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  8955. " 0,\n" +
  8956. " t.DefectName,\n" +
  8957. " '--') DefectName\n" +
  8958. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  8959. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  8960. " ,t.Userid\n" +
  8961. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  8962. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  8963. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  8964. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  8965. " ,t.Goodsid\n" +
  8966. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  8967. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  8968. " ,t.InCount\n" +
  8969. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  8970. " pmd.DefectProcedureID,\n" +
  8971. " pmd.DefectCode,\n" +
  8972. " pmd.userid,\n" +
  8973. " pmd.goodsid) gid\n" +
  8974. " ,pmd.ProductionLineID\n" +
  8975. " ,pmd.ProductionLineCode\n" +
  8976. " ,pmd.ProductionLineName\n" +
  8977. " ,pmd.ProcedureID\n" +
  8978. " ,pmd.ProcedureCode\n" +
  8979. " ,pmd.ProcedureName\n" +
  8980. " ,pmd.DefectProcedureID\n" +
  8981. " ,pmd.DefectProcedureCode\n" +
  8982. " ,pmd.DefectProcedureName\n" +
  8983. " ,pmd.DefectCode\n" +
  8984. " ,pmd.DefectName\n" +
  8985. " ,dt.DefectTypeName\n" +
  8986. " ,pmd.Userid\n" +
  8987. " ,pmd.Usercode\n" +
  8988. " ,pmd.Username\n" +
  8989. " ,gt.Goodstypename\n" +
  8990. " ,pmd.Goodsid\n" +
  8991. " ,pmd.Goodscode\n" +
  8992. " ,pmd.Goodsname\n" +
  8993. " ,COUNT(pmd.barcode) InCount\n" +
  8994. " FROM tp_pm_defect pmd\n" +
  8995. " LEFT JOIN TP_MST_Goods g\n" +
  8996. " ON pmd.Goodsid = g.Goodsid\n" +
  8997. " LEFT JOIN TP_MST_GoodsType gt\n" +
  8998. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  8999. " LEFT JOIN TP_MST_Defect mstd\n" +
  9000. " ON pmd.DefectID = mstd.DefectID\n" +
  9001. " LEFT JOIN TP_MST_DefectType dt\n" +
  9002. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9003. " INNER JOIN tp_pm_productiondata pd\n" +
  9004. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9005. " -- 交接工序\n" +
  9006. " INNER JOIN tp_pm_productiondata hopd\n" +
  9007. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9008. " AND hopd.valueflag = '1'\n" +
  9009. " AND hopd.barcode = pd.barcode\n" +
  9010. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9011. " WHERE pmd.valueflag = '1'\n" +
  9012. " AND pd.ModelType = -1\n" +
  9013. " AND pmd.AccountID = :AccountID\n";
  9014. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9015. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9016. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9017. {
  9018. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9019. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9020. }
  9021. if (!string.IsNullOrEmpty(se.LineIDS))
  9022. {
  9023. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9024. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9025. }
  9026. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9027. {
  9028. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9029. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9030. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9031. }
  9032. else
  9033. {
  9034. // modify by chenxy :没有选择时,应全查询出来。
  9035. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9036. }
  9037. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9038. {
  9039. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9040. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9041. }
  9042. if (!string.IsNullOrEmpty(se.KilnCode))
  9043. {
  9044. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9045. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9046. }
  9047. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9048. {
  9049. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9050. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9051. }
  9052. if (!string.IsNullOrEmpty(se.GoodsCode))
  9053. {
  9054. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9055. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9056. }
  9057. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9058. {
  9059. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9060. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9061. }
  9062. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9063. {
  9064. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9065. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9066. }
  9067. if (!string.IsNullOrEmpty(se.DefectCode))
  9068. {
  9069. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9070. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9071. }
  9072. if (!string.IsNullOrEmpty(se.DefectName))
  9073. {
  9074. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9075. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9076. }
  9077. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9078. {
  9079. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9080. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9081. }
  9082. if (se.CreateTimeStart.HasValue)
  9083. {
  9084. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9085. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9086. }
  9087. if (se.CreateTimeEnd.HasValue)
  9088. {
  9089. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9090. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9091. }
  9092. // 交接时间
  9093. if (se.HandOverTimeStart.HasValue)
  9094. {
  9095. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9096. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9097. }
  9098. if (se.HandOverTimeEnd.HasValue)
  9099. {
  9100. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9101. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9102. }
  9103. selSql = selSql +
  9104. " 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" +
  9105. " ORDER BY pmd.ProductionLineCode\n" +
  9106. " ,pmd.ProcedureCode\n" +
  9107. " ,pmd.DefectProcedureCode\n" +
  9108. " ,pmd.DefectCode\n" +
  9109. " ,pmd.Usercode\n" +
  9110. " ,pmd.Goodscode) t";
  9111. return selSql;
  9112. }
  9113. /// <summary>
  9114. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9115. /// </summary>
  9116. /// <param name="user">登录用户信息</param>
  9117. /// <param name="se">查询条件</param>
  9118. /// <returns>查询结果</returns>
  9119. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9120. {
  9121. IDBConnection conn = null;
  9122. try
  9123. {
  9124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9125. List<OracleParameter> parameters = new List<OracleParameter>();
  9126. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9127. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9128. ServiceResultEntity sre = new ServiceResultEntity();
  9129. if (data == null || data.Rows.Count == 0)
  9130. {
  9131. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9132. return sre;
  9133. }
  9134. sre.Data = new DataSet();
  9135. sre.Data.Tables.Add(data);
  9136. return sre;
  9137. }
  9138. catch (Exception ex)
  9139. {
  9140. throw ex;
  9141. }
  9142. finally
  9143. {
  9144. if (conn != null &&
  9145. conn.ConnState == ConnectionState.Open)
  9146. {
  9147. conn.Close();
  9148. }
  9149. }
  9150. }
  9151. /// <summary>
  9152. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9153. /// </summary>
  9154. /// <returns>sql</returns>
  9155. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9156. {
  9157. // string selSql = @"select
  9158. // tp_pm_defect.productionlinename,
  9159. // tp_pm_defect.procedurename,
  9160. // tp_pm_defect.DefectProcedureCode,
  9161. // tp_pm_defect.DefectProcedureName,
  9162. // tp_pm_defect.DefectUserCode,
  9163. // tp_pm_defect.defectusername,
  9164. // tp_mst_defectType.DefectTypeName,
  9165. // TP_MST_Defect.Remarks DefectRemarks,
  9166. // tp_pm_defect.defectcode,
  9167. // tp_pm_defect.defectname,
  9168. // tp_pm_defect.UserCode,
  9169. // tp_pm_defect.username,
  9170. // tp_mst_goodstype.Goodstypename,
  9171. // tp_pm_defect.goodscode,
  9172. // tp_pm_defect.barcode,
  9173. // tp_pm_productiondata.groutingdate,
  9174. // tp_pm_productiondata.groutingnum,
  9175. // tp_pm_productiondata.groutingMouldCode,
  9176. // tp_pm_productiondata.KilnCarCode,
  9177. // tp_pm_productiondata.Procedureid,
  9178. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9179. // tp_pm_defect.DefectPositionCode,
  9180. // tp_pm_defect.DefectPositionName,
  9181. // tp_pm_productiondata.GroutingUserCode,
  9182. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9183. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9184. // ,TP_PM_Defect.CreateTime
  9185. // ,(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
  9186. // ,TP_MST_DefectFine.DefectFineCode
  9187. // ,TP_PM_Defect.DefectDeductionNum
  9188. // from tp_pm_defect
  9189. // left join TP_MST_Goods
  9190. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9191. // left join TP_MST_GoodsType
  9192. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9193. // left join TP_MST_Defect
  9194. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9195. // left join TP_MST_DefectType
  9196. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9197. // inner join tp_pm_productiondata
  9198. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9199. // left join TP_MST_DefectFine
  9200. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9201. // left join tp_mst_logo
  9202. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9203. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9204. // 追加交接时间,改判标识。
  9205. string selSql =
  9206. "SELECT pmd.productionlinename\n" +
  9207. " ,pmd.procedurename\n" +
  9208. " ,pmd.DefectProcedureCode\n" +
  9209. " ,pmd.DefectProcedureName\n" +
  9210. " ,pmd.DefectUserCode\n" +
  9211. " ,pmd.defectusername\n" +
  9212. " ,dt.DefectTypeName\n" +
  9213. " ,mstd.Remarks DefectRemarks\n" +
  9214. " ,pmd.defectcode\n" +
  9215. " ,d.alldefectcode\n" +
  9216. " ,pmd.defectname\n" +
  9217. " ,pmd.UserCode\n" +
  9218. " ,pmd.username\n" +
  9219. " ,gt.Goodstypename\n" +
  9220. " ,pmd.goodscode\n" +
  9221. " ,pmd.barcode\n" +
  9222. " ,pd.groutingdate\n" +
  9223. " ,pd.groutingnum\n" +
  9224. " ,pd.groutingMouldCode\n" +
  9225. " ,pd.groutingLineCode\n" +
  9226. " ,pd.KilnCarCode\n" +
  9227. " ,pd.Procedureid\n" +
  9228. " ,gl.goodslevelname Goodsleveltype\n" +
  9229. " ,pmd.DefectPositionCode\n" +
  9230. " ,pmd.DefectPositionName\n" +
  9231. " ,pd.GroutingUserCode\n" +
  9232. " , CASE\n" +
  9233. " WHEN logo.logoid IS NULL THEN\n" +
  9234. " NULL\n" +
  9235. " ELSE\n" +
  9236. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9237. " END AS LogoCodeName\n" +
  9238. " ,pmd.CreateTime\n" +
  9239. " ,mstdf.DefectFineCode\n" +
  9240. " ,pmd.DefectDeductionNum\n" +
  9241. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9242. " ,hopd.createtime handovertime\n" +
  9243. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9244. " FROM tp_pm_ProductionData pduc\n" +
  9245. " WHERE pduc.barcode = pmd.barcode\n" +
  9246. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9247. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9248. " FROM tp_pm_ProductionData pdcu\n" +
  9249. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9250. " WHERE pdcu.barcode = pmd.barcode\n" +
  9251. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9252. " , CASE\n" +
  9253. " WHEN EXISTS (SELECT 1\n" +
  9254. " FROM tp_pm_ProductionData pdud\n" +
  9255. " WHERE pdud.barcode = pmd.barcode\n" +
  9256. " AND pdud.modeltype = -1\n" +
  9257. " AND pdud.procedureid = pd.procedureid\n" +
  9258. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9259. " AND pdud.valueflag = '0') THEN\n" +
  9260. " 1\n" +
  9261. " ELSE\n" +
  9262. " 0\n" +
  9263. " END AS undoflag\n" +
  9264. " , CASE\n" +
  9265. " WHEN EXISTS (SELECT 1\n" +
  9266. " FROM tp_pm_semicheck sc\n" +
  9267. " WHERE sc.barcode = pmd.barcode\n" +
  9268. " AND sc.SEMICHECKTYPE = 1\n" +
  9269. " AND sc.valueflag = '1') THEN\n" +
  9270. " 1\n" +
  9271. " ELSE\n" +
  9272. " 0\n" +
  9273. " END reworkflag" +
  9274. " ,gdd.glazingroom" +
  9275. " ,gdd.retainflag" +
  9276. " FROM tp_pm_defect pmd\n" +
  9277. " LEFT JOIN TP_MST_Goods g\n" +
  9278. " ON pmd.Goodsid = g.Goodsid\n" +
  9279. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9280. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9281. " LEFT JOIN TP_MST_Defect mstd\n" +
  9282. " ON pmd.DefectID = mstd.DefectID\n" +
  9283. " LEFT JOIN TP_MST_DefectType dt\n" +
  9284. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9285. " INNER JOIN tp_pm_productiondata pd\n" +
  9286. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9287. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9288. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9289. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9290. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9291. "-- 交接工序\n" +
  9292. " INNER JOIN tp_pm_productiondata hopd\n" +
  9293. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9294. " AND hopd.barcode = pd.barcode\n" +
  9295. " AND hopd.valueflag = '1'\n" +
  9296. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9297. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9298. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9299. " LEFT JOIN tp_mst_logo logo\n" +
  9300. " ON pd.logoid = logo.logoid\n" +
  9301. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9302. " FROM tp_pm_defect def\n" +
  9303. " WHERE def.valueflag = '1'\n" +
  9304. //def.createtime
  9305. " group by def.barcode ) d\n" +
  9306. " ON d.barcode = pmd.barcode\n" +
  9307. " WHERE pmd.valueflag = '1' \n" +
  9308. " AND pd.ModelType = -1\n" +
  9309. " AND pmd.AccountID = :AccountID\n";
  9310. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9311. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9312. //selSql = selSql +
  9313. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9314. // " and TP_PM_Defect.AccountID=:AccountID ";
  9315. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9316. {
  9317. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9318. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9319. }
  9320. if (!string.IsNullOrEmpty(se.LineIDS))
  9321. {
  9322. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9323. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9324. }
  9325. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9326. {
  9327. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9328. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9329. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9330. }
  9331. else
  9332. {
  9333. // modify by chenxy :没有选择时,应全查询出来。
  9334. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9335. }
  9336. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9337. {
  9338. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9339. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9340. }
  9341. if (!string.IsNullOrEmpty(se.KilnCode))
  9342. {
  9343. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9344. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9345. }
  9346. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9347. {
  9348. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9349. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9350. }
  9351. if (!string.IsNullOrEmpty(se.GoodsCode))
  9352. {
  9353. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9354. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9355. }
  9356. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9357. {
  9358. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9359. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9360. }
  9361. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9362. {
  9363. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9364. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9365. }
  9366. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9367. {
  9368. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9369. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9370. }
  9371. if (!string.IsNullOrEmpty(se.DefectCode))
  9372. {
  9373. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9374. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9375. }
  9376. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9377. {
  9378. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9379. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9380. }
  9381. if (!string.IsNullOrEmpty(se.DefectName))
  9382. {
  9383. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9384. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9385. }
  9386. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9387. {
  9388. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9389. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9390. }
  9391. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9392. {
  9393. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9394. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9395. }
  9396. // 登记时间(缺陷)
  9397. if (se.CreateTimeStart.HasValue)
  9398. {
  9399. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9400. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9401. }
  9402. if (se.CreateTimeEnd.HasValue)
  9403. {
  9404. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9405. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9406. }
  9407. // 交接时间
  9408. if (se.HandOverTimeStart.HasValue)
  9409. {
  9410. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9411. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9412. }
  9413. if (se.HandOverTimeEnd.HasValue)
  9414. {
  9415. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9416. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9417. }
  9418. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9419. //{
  9420. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9421. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9422. //}
  9423. ////----------------------
  9424. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9425. //{
  9426. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9427. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9428. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9429. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9430. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9431. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9432. //}
  9433. ////----------------------
  9434. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9435. return selSql;
  9436. }
  9437. /// <summary>
  9438. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9439. /// </summary>
  9440. /// <param name="user">登录用户信息</param>
  9441. /// <param name="se">查询条件</param>
  9442. /// <returns>查询结果</returns>
  9443. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9444. {
  9445. IDBConnection conn = null;
  9446. try
  9447. {
  9448. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9449. List<OracleParameter> parameters = new List<OracleParameter>();
  9450. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9451. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9452. ServiceResultEntity sre = new ServiceResultEntity();
  9453. if (data == null || data.Rows.Count == 0)
  9454. {
  9455. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9456. return sre;
  9457. }
  9458. sre.Data = new DataSet();
  9459. sre.Data.Tables.Add(data);
  9460. return sre;
  9461. }
  9462. catch (Exception ex)
  9463. {
  9464. throw ex;
  9465. }
  9466. finally
  9467. {
  9468. if (conn != null &&
  9469. conn.ConnState == ConnectionState.Open)
  9470. {
  9471. conn.Close();
  9472. }
  9473. }
  9474. }
  9475. /// <summary>
  9476. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9477. /// </summary>
  9478. /// <returns>sql</returns>
  9479. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9480. {
  9481. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9482. // 追加交接时间,改判标识。
  9483. string selSql =
  9484. "SELECT pmd.productionlinename\n" +
  9485. " ,pmd.procedurename\n" +
  9486. " ,pmd.DefectProcedureCode\n" +
  9487. " ,pmd.DefectProcedureName\n" +
  9488. " ,pmd.DefectUserCode\n" +
  9489. " ,pmd.defectusername\n" +
  9490. " ,jobs.jobsname defectjobsname\n" +
  9491. " ,dt.DefectTypeName\n" +
  9492. " ,mstd.Remarks DefectRemarks\n" +
  9493. " ,pd.Remarks barcodeRemarks\n" +
  9494. " ,pmd.defectcode\n" +
  9495. " ,d.alldefectcode\n" +
  9496. " ,pmd.defectname\n" +
  9497. " ,pmd.UserCode\n" +
  9498. " ,pmd.username\n" +
  9499. " ,gt.Goodstypename\n" +
  9500. " ,pmd.goodscode\n" +
  9501. " ,pmd.barcode\n" +
  9502. " ,pd.groutingdate\n" +
  9503. " ,pd.groutingnum\n" +
  9504. " ,pd.groutingMouldCode\n" +
  9505. " ,pd.GroutingLineCode\n" +
  9506. " ,pd.KilnCarCode\n" +
  9507. " ,pd.Procedureid\n" +
  9508. " ,gl.goodslevelname Goodsleveltype\n" +
  9509. " ,pmd.DefectPositionCode\n" +
  9510. " ,pmd.DefectPositionName\n" +
  9511. " ,pd.GroutingUserCode\n" +
  9512. " , CASE\n" +
  9513. " WHEN logo.logoid IS NULL THEN\n" +
  9514. " NULL\n" +
  9515. " ELSE\n" +
  9516. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9517. " END AS LogoCodeName\n" +
  9518. //" ,pmd.CreateTime\n" +
  9519. " ,pd.CheckTime pdchecktime\n" +
  9520. " ,pmd.CheckTime\n" +
  9521. " ,mstdf.DefectFineCode\n" +
  9522. " ,pmd.DefectDeductionNum\n" +
  9523. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9524. " ,hopd.createtime handovertime\n" +
  9525. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9526. " FROM tp_pm_ProductionData pduc\n" +
  9527. " WHERE pduc.barcode = pmd.barcode\n" +
  9528. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9529. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9530. " FROM tp_pm_ProductionData pdcu\n" +
  9531. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9532. " WHERE pdcu.barcode = pmd.barcode\n" +
  9533. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9534. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9535. " FROM TP_PM_DefectResponsible dr\n" +
  9536. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9537. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9538. " ) AS DefectStaffNames\n" +
  9539. " , CASE\n" +
  9540. " WHEN pd.isrefire <> '0' THEN\n" +
  9541. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9542. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9543. " from tp_pm_productiondata p\n" +
  9544. " inner join tp_pm_defect d\n" +
  9545. " on d.productiondataid = p.productiondataid\n" +
  9546. " where p.valueflag = '1'\n" +
  9547. " and d.valueflag = '1'\n" +
  9548. " and p.barcode = pd.barcode\n" +
  9549. " and p.modeltype = -1\n" +
  9550. " and p.isrefire = '0')\n" +
  9551. " ELSE\n" +
  9552. " null\n" +
  9553. " END AS bsqx\n" +
  9554. " , CASE\n" +
  9555. " WHEN EXISTS (SELECT 1\n" +
  9556. " FROM tp_pm_ProductionData pdud\n" +
  9557. " WHERE pdud.barcode = pmd.barcode\n" +
  9558. " AND pdud.modeltype = -1\n" +
  9559. " AND pdud.procedureid = pd.procedureid\n" +
  9560. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9561. " AND pdud.valueflag = '0') THEN\n" +
  9562. " 1\n" +
  9563. " ELSE\n" +
  9564. " 0\n" +
  9565. " END AS undoflag\n" +
  9566. " ,gdd.retainflag" +
  9567. " FROM tp_pm_defect pmd\n" +
  9568. " LEFT JOIN TP_PC_Procedure p\n" +
  9569. " ON p.procedureid = pmd.procedureid\n" +
  9570. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9571. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9572. " LEFT JOIN TP_MST_Goods g\n" +
  9573. " ON pmd.Goodsid = g.Goodsid\n" +
  9574. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9575. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9576. " LEFT JOIN TP_MST_Defect mstd\n" +
  9577. " ON pmd.DefectID = mstd.DefectID\n" +
  9578. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9579. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9580. " LEFT JOIN TP_MST_DefectType dt\n" +
  9581. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9582. " INNER JOIN tp_pm_productiondata pd\n" +
  9583. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9584. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9585. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9586. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9587. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9588. //"-- 交接工序\n" +
  9589. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9590. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9591. //" AND hopd.valueflag = '1'\n" +
  9592. //" AND hopd.barcode = pd.barcode\n" +
  9593. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9594. " INNER JOIN tp_pm_productiondata hopd\n" +
  9595. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9596. " AND hopd.barcode = pd.barcode\n" +
  9597. " AND hopd.valueflag = '1'\n" +
  9598. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9599. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9600. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9601. " LEFT JOIN tp_mst_logo logo\n" +
  9602. " ON pd.logoid = logo.logoid\n" +
  9603. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9604. " FROM tp_pm_defect def\n" +
  9605. " WHERE def.valueflag = '1'\n" +
  9606. //def.createtime
  9607. " group by def.barcode ) d\n" +
  9608. " ON d.barcode = pmd.barcode\n" +
  9609. " WHERE pmd.valueflag = '1' \n" +
  9610. " AND pd.ModelType = -1\n" +
  9611. " AND pmd.AccountID = :AccountID\n";
  9612. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9613. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9614. //selSql = selSql +
  9615. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9616. // " and TP_PM_Defect.AccountID=:AccountID ";
  9617. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9618. {
  9619. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9620. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9621. }
  9622. if (!string.IsNullOrEmpty(se.LineIDS))
  9623. {
  9624. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9625. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9626. }
  9627. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9628. {
  9629. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9630. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9631. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9632. }
  9633. else
  9634. {
  9635. // modify by chenxy :没有选择时,应全查询出来。
  9636. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9637. }
  9638. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9639. {
  9640. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9641. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9642. }
  9643. if (!string.IsNullOrEmpty(se.KilnCode))
  9644. {
  9645. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9646. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9647. }
  9648. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9649. {
  9650. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9651. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9652. }
  9653. if (!string.IsNullOrEmpty(se.GoodsCode))
  9654. {
  9655. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9656. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9657. }
  9658. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9659. {
  9660. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9661. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9662. }
  9663. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9664. {
  9665. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9666. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9667. }
  9668. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9669. {
  9670. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9671. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9672. }
  9673. if (!string.IsNullOrEmpty(se.DefectCode))
  9674. {
  9675. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9676. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9677. }
  9678. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9679. {
  9680. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9681. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9682. }
  9683. if (!string.IsNullOrEmpty(se.DefectName))
  9684. {
  9685. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9686. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9687. }
  9688. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9689. {
  9690. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9691. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9692. }
  9693. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9694. {
  9695. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9696. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9697. }
  9698. //if (se.CreateTimeStart.HasValue)
  9699. //{
  9700. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9701. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9702. //}
  9703. //if (se.CreateTimeEnd.HasValue)
  9704. //{
  9705. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9706. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9707. //}
  9708. // 登记时间(第一次成检)
  9709. if (se.CreateTimeStart.HasValue)
  9710. {
  9711. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9712. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9713. }
  9714. if (se.CreateTimeEnd.HasValue)
  9715. {
  9716. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9717. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9718. }
  9719. // 缺陷登记时间
  9720. if (se.CheckTimeStart.HasValue)
  9721. {
  9722. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9723. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9724. }
  9725. if (se.CheckTimeEnd.HasValue)
  9726. {
  9727. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9728. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9729. }
  9730. // 交接时间
  9731. if (se.HandOverTimeStart.HasValue)
  9732. {
  9733. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9734. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9735. }
  9736. if (se.HandOverTimeEnd.HasValue)
  9737. {
  9738. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9739. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9740. }
  9741. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9742. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9743. return selSql;
  9744. }
  9745. /// <summary>
  9746. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9747. /// </summary>
  9748. /// <param name="user">登录用户信息</param>
  9749. /// <param name="se">查询条件</param>
  9750. /// <returns>查询结果</returns>
  9751. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9752. {
  9753. IDBConnection conn = null;
  9754. try
  9755. {
  9756. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9757. List<OracleParameter> parameters = new List<OracleParameter>();
  9758. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9759. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9760. ServiceResultEntity sre = new ServiceResultEntity();
  9761. if (data == null || data.Rows.Count == 0)
  9762. {
  9763. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9764. return sre;
  9765. }
  9766. sre.Data = new DataSet();
  9767. sre.Data.Tables.Add(data);
  9768. return sre;
  9769. }
  9770. catch (Exception ex)
  9771. {
  9772. throw ex;
  9773. }
  9774. finally
  9775. {
  9776. if (conn != null &&
  9777. conn.ConnState == ConnectionState.Open)
  9778. {
  9779. conn.Close();
  9780. }
  9781. }
  9782. }
  9783. /// <summary>
  9784. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9785. /// </summary>
  9786. /// <returns>sql</returns>
  9787. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9788. {
  9789. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9790. // 追加交接时间,改判标识。
  9791. string selSql =
  9792. //"SELECT pmd.productionlinename\n" +
  9793. //" ,pmd.procedurename\n" +
  9794. //" ,pmd.DefectProcedureCode\n" +
  9795. //" ,pmd.DefectProcedureName\n" +
  9796. //" ,pmd.DefectUserCode\n" +
  9797. //" ,pmd.defectusername\n" +
  9798. //" ,jobs.jobsname defectjobsname\n" +
  9799. //" ,dt.DefectTypeName\n" +
  9800. //" ,mstd.Remarks DefectRemarks\n" +
  9801. //" ,pd.Remarks barcodeRemarks\n" +
  9802. //" ,pmd.defectcode\n" +
  9803. //" ,d.alldefectcode\n" +
  9804. //" ,pmd.defectname\n" +
  9805. //" ,pmd.UserCode\n" +
  9806. //" ,pmd.username\n" +
  9807. //" ,gt.Goodstypename\n" +
  9808. //" ,pmd.goodscode\n" +
  9809. //" ,pmd.barcode\n" +
  9810. //" ,pd.groutingdate\n" +
  9811. //" ,pd.groutingnum\n" +
  9812. //" ,pd.groutingMouldCode\n" +
  9813. //" ,pd.GroutingLineCode\n" +
  9814. //" ,pd.KilnCarCode\n" +
  9815. //" ,pd.Procedureid\n" +
  9816. //" ,gl.goodslevelname Goodsleveltype\n" +
  9817. //" ,pmd.DefectPositionCode\n" +
  9818. //" ,pmd.DefectPositionName\n" +
  9819. //" ,pd.GroutingUserCode\n" +
  9820. //" , CASE\n" +
  9821. //" WHEN logo.logoid IS NULL THEN\n" +
  9822. //" NULL\n" +
  9823. //" ELSE\n" +
  9824. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9825. //" END AS LogoCodeName\n" +
  9826. ////" ,pmd.CreateTime\n" +
  9827. //" ,pd.CheckTime pdchecktime\n" +
  9828. //" ,pmd.CheckTime\n" +
  9829. //" ,mstdf.DefectFineCode\n" +
  9830. //" ,pmd.DefectDeductionNum\n" +
  9831. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9832. //" ,hopd.createtime handovertime\n" +
  9833. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9834. //" FROM tp_pm_ProductionData pduc\n" +
  9835. //" WHERE pduc.barcode = pmd.barcode\n" +
  9836. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9837. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9838. //" FROM tp_pm_ProductionData pdcu\n" +
  9839. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9840. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9841. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9842. //" , CASE\n" +
  9843. //" WHEN EXISTS (SELECT 1\n" +
  9844. //" FROM tp_pm_ProductionData pdud\n" +
  9845. //" WHERE pdud.barcode = pmd.barcode\n" +
  9846. //" AND pdud.modeltype = -1\n" +
  9847. //" AND pdud.procedureid = pd.procedureid\n" +
  9848. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9849. //" AND pdud.valueflag = '0') THEN\n" +
  9850. //" 1\n" +
  9851. //" ELSE\n" +
  9852. //" 0\n" +
  9853. //" END AS undoflag\n" +
  9854. "SELECT pmd.goodscode\n" +
  9855. " ,pmd.barcode\n" +
  9856. " ,pmd.defectcode\n" +
  9857. " ,pmd.defectname\n" +
  9858. " ,pmd.DefectPositionCode\n" +
  9859. " ,pmd.DefectPositionName\n" +
  9860. " ,gl.goodslevelname Goodsleveltype\n" +
  9861. " , CASE\n" +
  9862. " WHEN logo.logoid IS NULL THEN\n" +
  9863. " NULL\n" +
  9864. " ELSE\n" +
  9865. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9866. " END AS LogoCodeName\n" +
  9867. //" ,pmd.CreateTime\n" +
  9868. " ,pd.CheckTime pdchecktime\n" +
  9869. " ,pmd.CheckTime\n" +
  9870. " ,proddata.CheckTime protime\n" +
  9871. " ,proddata.UserCode prousercode\n" +
  9872. " ,proddata.PROCEDURENAME proname\n" +
  9873. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9874. " FROM tp_pm_defect pmd\n" +
  9875. " INNER JOIN tp_pm_productiondata proddata\n" +
  9876. " ON proddata.barcode = pmd.barcode\n " +
  9877. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  9878. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  9879. " AND proddata.valueflag = '1'\n" +
  9880. " INNER JOIN tp_pm_productiondata pd\n" +
  9881. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9882. " LEFT JOIN TP_PC_Procedure p\n" +
  9883. " ON p.procedureid = pmd.procedureid\n" +
  9884. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9885. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9886. " LEFT JOIN TP_MST_Goods g\n" +
  9887. " ON pmd.Goodsid = g.Goodsid\n" +
  9888. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9889. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9890. " LEFT JOIN TP_MST_Defect mstd\n" +
  9891. " ON pmd.DefectID = mstd.DefectID\n" +
  9892. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9893. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9894. " LEFT JOIN TP_MST_DefectType dt\n" +
  9895. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9896. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9897. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9898. "-- 交接工序\n" +
  9899. " INNER JOIN tp_pm_productiondata hopd\n" +
  9900. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9901. " AND hopd.barcode = pd.barcode\n" +
  9902. " AND hopd.valueflag = '1'\n" +
  9903. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9904. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9905. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9906. " LEFT JOIN tp_mst_logo logo\n" +
  9907. " ON pd.logoid = logo.logoid\n" +
  9908. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9909. //" FROM tp_pm_defect def\n" +
  9910. //" WHERE def.valueflag = '1'\n" +
  9911. ////def.createtime
  9912. //" group by def.barcode ) d\n" +
  9913. //" ON d.barcode = pmd.barcode\n" +
  9914. " WHERE pmd.valueflag = '1' \n" +
  9915. " AND pd.ModelType = -1\n" +
  9916. " AND pmd.AccountID = :AccountID\n";
  9917. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9918. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9919. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9920. //selSql = selSql +
  9921. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9922. // " and TP_PM_Defect.AccountID=:AccountID ";
  9923. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9924. {
  9925. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9926. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9927. }
  9928. if (!string.IsNullOrEmpty(se.LineIDS))
  9929. {
  9930. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9931. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9932. }
  9933. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9934. {
  9935. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9936. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9937. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9938. }
  9939. else
  9940. {
  9941. // modify by chenxy :没有选择时,应全查询出来。
  9942. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9943. }
  9944. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9945. {
  9946. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9947. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9948. }
  9949. if (!string.IsNullOrEmpty(se.KilnCode))
  9950. {
  9951. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9952. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9953. }
  9954. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9955. {
  9956. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9957. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9958. }
  9959. if (!string.IsNullOrEmpty(se.GoodsCode))
  9960. {
  9961. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9962. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9963. }
  9964. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9965. {
  9966. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9967. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9968. }
  9969. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9970. {
  9971. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9972. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9973. }
  9974. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9975. {
  9976. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9977. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9978. }
  9979. if (!string.IsNullOrEmpty(se.DefectCode))
  9980. {
  9981. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9982. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9983. }
  9984. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9985. {
  9986. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9987. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9988. }
  9989. if (!string.IsNullOrEmpty(se.DefectName))
  9990. {
  9991. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9992. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9993. }
  9994. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9995. {
  9996. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9997. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9998. }
  9999. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  10000. {
  10001. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  10002. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  10003. }
  10004. //if (se.CreateTimeStart.HasValue)
  10005. //{
  10006. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  10007. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10008. //}
  10009. //if (se.CreateTimeEnd.HasValue)
  10010. //{
  10011. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  10012. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10013. //}
  10014. // 成检登记时间
  10015. if (se.CreateTimeStart.HasValue)
  10016. {
  10017. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10018. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10019. }
  10020. if (se.CreateTimeEnd.HasValue)
  10021. {
  10022. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10023. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10024. }
  10025. // 缺陷登记时间
  10026. if (se.CheckTimeStart.HasValue)
  10027. {
  10028. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10029. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10030. }
  10031. if (se.CheckTimeEnd.HasValue)
  10032. {
  10033. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10034. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10035. }
  10036. // 交接时间
  10037. if (se.HandOverTimeStart.HasValue)
  10038. {
  10039. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10040. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10041. }
  10042. if (se.HandOverTimeEnd.HasValue)
  10043. {
  10044. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10045. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10046. }
  10047. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10048. selSql = selSql + " order by proddata.CheckTime ";
  10049. return selSql;
  10050. }
  10051. /// <summary>
  10052. /// 窑车状态主表查询
  10053. /// </summary>
  10054. /// <param name="kilnCode">窑炉编码</param>
  10055. /// <param name="kilnCarCode">窑车编码</param>
  10056. /// <param name="sUserInfo">用户基本信息</param>
  10057. /// <returns></returns>
  10058. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, 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_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10067. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10068. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10069. };
  10070. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", 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. return sre;
  10080. }
  10081. catch (Exception ex)
  10082. {
  10083. throw ex;
  10084. }
  10085. finally
  10086. {
  10087. if (con != null &&
  10088. con.ConnState == ConnectionState.Open)
  10089. {
  10090. con.Close();
  10091. }
  10092. }
  10093. }
  10094. /// <summary>
  10095. /// 窑车状态明细表查询
  10096. /// </summary>
  10097. /// <param name="kilnCarCode">窑车编码</param>
  10098. /// <param name="sUserInfo">用户基本信息</param>
  10099. /// <returns></returns>
  10100. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10101. {
  10102. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10103. try
  10104. {
  10105. con.Open();
  10106. OracleParameter[] paras = new OracleParameter[]{
  10107. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10108. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10109. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10110. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10111. };
  10112. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10113. ServiceResultEntity sre = new ServiceResultEntity();
  10114. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10115. {
  10116. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10117. return sre;
  10118. }
  10119. sre.Data = new DataSet();
  10120. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10121. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10122. return sre;
  10123. }
  10124. catch (Exception ex)
  10125. {
  10126. throw ex;
  10127. }
  10128. finally
  10129. {
  10130. if (con != null &&
  10131. con.ConnState == ConnectionState.Open)
  10132. {
  10133. con.Close();
  10134. }
  10135. }
  10136. }
  10137. /// <summary>
  10138. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10139. /// </summary>
  10140. /// <param name="user">登录用户信息</param>
  10141. /// <param name="se">查询条件</param>
  10142. /// <returns>查询结果</returns>
  10143. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10144. {
  10145. IDBConnection conn = null;
  10146. try
  10147. {
  10148. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10149. List<OracleParameter> parameters = new List<OracleParameter>();
  10150. parameters.Clear();
  10151. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10152. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10153. ServiceResultEntity sre = new ServiceResultEntity();
  10154. if (data == null || data.Rows.Count == 0)
  10155. {
  10156. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10157. return sre;
  10158. }
  10159. sre.Data = new DataSet();
  10160. sre.Data.Tables.Add(data);
  10161. return sre;
  10162. }
  10163. catch (Exception ex)
  10164. {
  10165. throw ex;
  10166. }
  10167. finally
  10168. {
  10169. if (conn != null &&
  10170. conn.ConnState == ConnectionState.Open)
  10171. {
  10172. conn.Close();
  10173. }
  10174. }
  10175. }
  10176. /// <summary>
  10177. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10178. /// </summary>
  10179. /// <returns>sql</returns>
  10180. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10181. {
  10182. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10183. #region
  10184. #endregion
  10185. string sql = @"
  10186. select gd.groutinglinecode,
  10187. gd.groutingmouldcode,
  10188. gd.mouldcode,
  10189. gd.usercode,
  10190. gs.goodscode,
  10191. gs.goodsname,
  10192. gs.goodsspecification,
  10193. gms.gmouldstatusname, -- 模具状态
  10194. --gs.goodsmodel,
  10195. gd.groutingcount, -- 注浆次数
  10196. --gd.groutingnum,
  10197. gd.scrapnum, -- 开模损坯数
  10198. gd.deliverpnum, -- 交坯数
  10199. gd.mingroutingdate, -- 开始注浆时间
  10200. gd.maxgroutingdate, -- 最后注浆时间
  10201. gld.beginuseddate, -- 开始使用时间
  10202. gld.enduseddate, -- 结束使用时间
  10203. zl.OutKilnCount, -- 质量登记数
  10204. zl.GoodCount, -- 正品数
  10205. zl.SubstandardCount, -- 副品数
  10206. zl.ReFireCount, -- 重烧数
  10207. zl.BadCount -- 次品数
  10208. from (select gdd.groutinglinecode,
  10209. gdd.groutingmouldcode,
  10210. gdd.mouldcode,
  10211. gdd.goodsid,
  10212. gdd.groutinglinedetailid,
  10213. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10214. max(gdd.groutingcount) groutingcount,
  10215. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10216. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10217. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10218. min(gdd.groutingdate) mingroutingdate,
  10219. max(gdd.groutingdate) maxgroutingdate
  10220. from tp_pm_groutingdailydetail gdd
  10221. where gdd.groutingflag = '1'
  10222. and gdd.AccountID = :AccountID
  10223. ";
  10224. // 成型线编码
  10225. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10226. {
  10227. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10228. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10229. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10230. }
  10231. // 模具编码
  10232. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10233. {
  10234. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10235. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10236. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10237. }
  10238. sql = sql + @"
  10239. group by gdd.groutinglinecode,
  10240. gdd.groutingmouldcode,
  10241. gdd.mouldcode,
  10242. gdd.goodsid,
  10243. gdd.groutinglinedetailid) gd
  10244. left join (select pdbc.mouldcode,
  10245. sum(1) OutKilnCount,
  10246. sum(case
  10247. when defect.defectprocedureid is not null and
  10248. glt.goodsleveltypeid in (5, 6, 7) then
  10249. 0
  10250. else
  10251. 1
  10252. end) GoodCount,
  10253. sum(case
  10254. when defect.defectprocedureid is not null and
  10255. glt.goodsleveltypeid = 7 then
  10256. 1
  10257. else
  10258. 0
  10259. end) SubstandardCount,
  10260. sum(case
  10261. when defect.defectprocedureid is not null and
  10262. glt.goodsleveltypeid = 6 then
  10263. 1
  10264. else
  10265. 0
  10266. end) ReFireCount,
  10267. sum(case
  10268. when defect.defectprocedureid is not null and
  10269. glt.goodsleveltypeid = 5 then
  10270. 1
  10271. else
  10272. 0
  10273. end) BadCount
  10274. from (select distinct pd.barcode,
  10275. pd.mouldcode,
  10276. pd.kilncarbatchno
  10277. from tp_pm_productiondata pd
  10278. where pd.valueflag = '1'";
  10279. // 开始注浆--开始
  10280. if (se.beginCreateTime.HasValue)
  10281. {
  10282. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10283. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10284. }
  10285. //--and pd.createtime > 查询条件。开始注浆日期开始
  10286. // --and pd.procedureid = :in_rptSprocedureId
  10287. sql = sql + @"
  10288. and pd.procedureid = 11
  10289. and pd.AccountID = 1) pdbc
  10290. left join (select kcbc.barcode,
  10291. kcbc.kilncarbatchno,
  10292. kcbc.goodsleveltypeid,
  10293. kcbc.productiondataid
  10294. from (select pd.barcode,
  10295. pd.kilncarbatchno,
  10296. pd.goodsleveltypeid,
  10297. pd.productiondataid,
  10298. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10299. from tp_pm_productiondata pd
  10300. where pd.valueflag = '1'
  10301. --and pd.AccountID = :AccountID
  10302. and pd.AccountID = :AccountID";
  10303. //--and pd.createtime > 查询条件。开始注浆日期开始
  10304. // 开始注浆--开始
  10305. if (se.beginCreateTime.HasValue)
  10306. {
  10307. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10308. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10309. }
  10310. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10311. and pd.modeltype = -1) kcbc
  10312. where kcbc.dataid = 1) glt
  10313. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10314. and pdbc.barcode = glt.barcode
  10315. left join (select distinct productiondataid, defectprocedureid
  10316. from tp_pm_defect def
  10317. where def.valueflag = '1'";
  10318. //--and pd.createtime > 查询条件。开始注浆日期开始
  10319. // 开始注浆--开始
  10320. if (se.beginCreateTime.HasValue)
  10321. {
  10322. sql = sql + " and def.createtime>=:groutingDateStart ";
  10323. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10324. }
  10325. sql = sql + @"
  10326. and def.AccountID = :AccountID) defect
  10327. on defect.productiondataid = glt.productiondataid
  10328. group by pdbc.mouldcode) zl
  10329. on zl.mouldcode = gd.mouldcode
  10330. left join tp_mst_goods gs
  10331. on gs.goodsid = gd.goodsid
  10332. left join tp_pc_groutinglinedetail gld
  10333. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10334. and gld.mouldcode = gd.mouldcode
  10335. left join tp_sys_gmouldstatus gms
  10336. on gms.gmouldstatusid = gld.gmouldstatus
  10337. where 1=1
  10338. ";
  10339. // 产品编码
  10340. if (!string.IsNullOrEmpty(se.goodscode))
  10341. {
  10342. //sql = sql + " and gs.goodscode=:goodscode";
  10343. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10344. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10345. }
  10346. // 成型工号
  10347. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10348. {
  10349. //sql = sql + " and gd.usercode=:usercode";
  10350. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10351. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10352. }
  10353. // 开始注浆--开始
  10354. if (se.beginCreateTime.HasValue)
  10355. {
  10356. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10357. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10358. }
  10359. // 开始注浆--结束
  10360. if (se.endCreateTime.HasValue)
  10361. {
  10362. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10363. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10364. }
  10365. // 结束注浆--开始
  10366. if (se.beginCreateTime2.HasValue)
  10367. {
  10368. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10369. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10370. }
  10371. // 结束注浆--结束
  10372. if (se.endCreateTime2.HasValue)
  10373. {
  10374. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10375. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10376. }
  10377. // 模具状态
  10378. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10379. {
  10380. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10381. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10382. }
  10383. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10384. return sql;
  10385. }
  10386. #region 工资产量统计
  10387. /// <summary>
  10388. /// 取得RPT080102画面(成型工产量)的查询数据
  10389. /// </summary>
  10390. /// <param name="user">登录用户信息</param>
  10391. /// <param name="se">查询条件</param>
  10392. /// <returns>查询结果</returns>
  10393. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10394. {
  10395. IDBTransaction conn = null;
  10396. try
  10397. {
  10398. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10399. conn.Connect();
  10400. OracleParameter[] paras = new OracleParameter[]{
  10401. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10402. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10403. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10404. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10405. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10406. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10407. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10408. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10409. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10410. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10411. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10412. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10413. };
  10414. conn.IsCommandTimeout = false;
  10415. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10416. ServiceResultEntity sre = new ServiceResultEntity();
  10417. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10418. {
  10419. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10420. return sre;
  10421. }
  10422. sre.Data = new DataSet();
  10423. sre.Data = data;
  10424. conn.Commit();
  10425. return sre;
  10426. }
  10427. catch (Exception ex)
  10428. {
  10429. throw ex;
  10430. }
  10431. finally
  10432. {
  10433. if (conn != null &&
  10434. conn.ConnState == ConnectionState.Open)
  10435. {
  10436. conn.Disconnect();
  10437. }
  10438. }
  10439. }
  10440. /// <summary>
  10441. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10442. /// </summary>
  10443. /// <param name="user">登录用户信息</param>
  10444. /// <param name="se">查询条件</param>
  10445. /// <returns>查询结果</returns>
  10446. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10447. {
  10448. IDBTransaction conn = null;
  10449. try
  10450. {
  10451. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10452. conn.Connect();
  10453. OracleParameter[] paras = new OracleParameter[]{
  10454. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10455. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10456. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10457. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10458. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10459. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10460. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10461. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10462. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10463. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10464. };
  10465. conn.IsCommandTimeout = false;
  10466. //DataSet data = null;
  10467. //if (se.ProcedureIDS.Contains(","))
  10468. //{
  10469. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10470. //}
  10471. //else
  10472. //{
  10473. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10474. //}
  10475. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10476. ServiceResultEntity sre = new ServiceResultEntity();
  10477. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10478. {
  10479. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10480. return sre;
  10481. }
  10482. sre.Data = new DataSet();
  10483. sre.Data = data;
  10484. conn.Commit();
  10485. return sre;
  10486. }
  10487. catch (Exception ex)
  10488. {
  10489. throw ex;
  10490. }
  10491. finally
  10492. {
  10493. if (conn != null &&
  10494. conn.ConnState == ConnectionState.Open)
  10495. {
  10496. conn.Disconnect();
  10497. }
  10498. }
  10499. }
  10500. /// <summary>
  10501. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10502. /// </summary>
  10503. /// <param name="user">登录用户信息</param>
  10504. /// <param name="se">查询条件</param>
  10505. /// <returns>查询结果</returns>
  10506. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10507. {
  10508. IDBTransaction conn = null;
  10509. try
  10510. {
  10511. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10512. conn.Connect();
  10513. OracleParameter[] paras = new OracleParameter[]{
  10514. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10515. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10516. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10517. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10518. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10519. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10520. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10521. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10522. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10523. };
  10524. conn.IsCommandTimeout = false;
  10525. DataSet data = null;
  10526. if (se.ProcedureIDS.Contains(","))
  10527. {
  10528. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10529. }
  10530. else
  10531. {
  10532. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10533. }
  10534. ServiceResultEntity sre = new ServiceResultEntity();
  10535. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10536. {
  10537. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10538. return sre;
  10539. }
  10540. sre.Data = data;
  10541. //string sqlString =
  10542. //"SELECT kk.procedurename\n" +
  10543. //" ,kk.usercode\n" +
  10544. //" ,kk.kilncode\n" +
  10545. //" ,kk.kdate\n" +
  10546. //" ,COUNT(*) kcount\n" +
  10547. //" FROM (SELECT k.usercode\n" +
  10548. //" ,kiln.kilncode\n" +
  10549. //" ,p.procedurename\n" +
  10550. //" ,trunc(k.createtime) kdate\n" +
  10551. //" FROM tp_pm_kilncardata k\n" +
  10552. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10553. //" ON kiln.kilnid = k.kilnid\n" +
  10554. //" LEFT JOIN tp_pc_procedure p\n" +
  10555. //" ON p.procedureid = k.procedureid\n" +
  10556. //" WHERE k.valueflag = '1'\n" +
  10557. //" AND k.AccountID = :in_AccountID\n" +
  10558. //" AND k.createtime >= :in_BeginDate\n" +
  10559. //" AND k.createtime <= :in_EndDate\n" +
  10560. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10561. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10562. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10563. string sqlString = "WITH kilnData AS\n" +
  10564. " (SELECT k.usercode\n" +
  10565. " ,kiln.kilncode\n" +
  10566. " ,p.procedurename\n" +
  10567. " ,trunc(k.createtime) kdate\n" +
  10568. " ,k.userid\n" +
  10569. " ,k.procedureid\n" +
  10570. " ,k.kilnid\n" +
  10571. " ,k.KILNCARBATCHNO\n" +
  10572. " FROM tp_pm_kilncardata k\n" +
  10573. " LEFT JOIN tp_mst_kiln kiln\n" +
  10574. " ON kiln.kilnid = k.kilnid\n" +
  10575. " LEFT JOIN tp_pc_procedure p\n" +
  10576. " ON p.procedureid = k.procedureid\n" +
  10577. " WHERE k.valueflag = '1'\n" +
  10578. " AND k.AccountID = :in_AccountID\n" +
  10579. " AND k.createtime >= :in_BeginDate\n" +
  10580. " AND k.createtime <= :in_EndDate\n" +
  10581. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10582. "SELECT kd.procedurename\n" +
  10583. " ,kd.usercode\n" +
  10584. " ,kd.kilncode\n" +
  10585. " ,kd.kdate\n" +
  10586. " ,kd.kcount\n" +
  10587. " ,kpd.kpcount\n" +
  10588. " FROM (SELECT kk.procedurename\n" +
  10589. " ,kk.usercode\n" +
  10590. " ,kk.kilncode\n" +
  10591. " ,kk.kdate\n" +
  10592. " ,kk.procedureid\n" +
  10593. " ,kk.userid\n" +
  10594. " ,kk.kilnid\n" +
  10595. " ,COUNT(*) kcount\n" +
  10596. " FROM kilnData kk\n" +
  10597. " GROUP BY kk.procedurename\n" +
  10598. " ,kk.usercode\n" +
  10599. " ,kk.kilncode\n" +
  10600. " ,kk.kdate\n" +
  10601. " ,kk.procedureid\n" +
  10602. " ,kk.userid\n" +
  10603. " ,kk.kilnid) kd\n" +
  10604. " LEFT JOIN (SELECT kk.kdate\n" +
  10605. " ,kk.procedureid\n" +
  10606. " ,kk.userid\n" +
  10607. " ,kk.kilnid\n" +
  10608. " ,COUNT(*) kpcount\n" +
  10609. " FROM kilnData kk\n" +
  10610. " INNER JOIN tp_pm_productiondata pd\n" +
  10611. " ON pd.valueflag = '1'\n" +
  10612. " AND pd.procedureid = kk.procedureid\n" +
  10613. " AND pd.kilnid = kk.kilnid\n" +
  10614. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10615. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10616. " ON kpd.kdate = kd.kdate\n" +
  10617. " AND kpd.procedureid = kd.procedureid\n" +
  10618. " AND kpd.userid = kd.userid\n" +
  10619. " AND kpd.kilnid = kd.kilnid\n" +
  10620. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10621. OracleParameter[] parascount = new OracleParameter[]{
  10622. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10623. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10624. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10625. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10626. };
  10627. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10628. if (dt != null)
  10629. {
  10630. sre.Data.Tables.Add(dt);
  10631. }
  10632. conn.Commit();
  10633. return sre;
  10634. }
  10635. catch (Exception ex)
  10636. {
  10637. throw ex;
  10638. }
  10639. finally
  10640. {
  10641. if (conn != null &&
  10642. conn.ConnState == ConnectionState.Open)
  10643. {
  10644. conn.Disconnect();
  10645. }
  10646. }
  10647. }
  10648. #endregion
  10649. /// <summary>
  10650. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10651. /// </summary>
  10652. /// <param name="searchEntity">生产数据实体类</param>
  10653. /// <param name="user">用户基本信息</param>
  10654. /// <returns>DataTable</returns>
  10655. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10656. {
  10657. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10658. string procsql = "PRO_RPT_GetProductionData";
  10659. try
  10660. {
  10661. IDataParameter[] paras = new OracleParameter[]
  10662. {
  10663. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10664. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10665. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10666. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10667. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10668. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10669. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10670. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10671. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10672. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10673. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10674. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10675. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10676. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10677. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10678. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10679. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10680. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10681. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10682. };
  10683. oracleConn.Open();
  10684. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10685. if (returnDs != null && returnDs.Tables.Count > 0)
  10686. {
  10687. return returnDs.Tables[0];
  10688. }
  10689. else
  10690. {
  10691. return null;
  10692. }
  10693. }
  10694. catch (Exception ex)
  10695. {
  10696. throw ex;
  10697. }
  10698. finally
  10699. {
  10700. if (oracleConn.ConnState == ConnectionState.Open)
  10701. {
  10702. oracleConn.Close();
  10703. }
  10704. }
  10705. }
  10706. /// <summary>
  10707. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10708. /// </summary>
  10709. /// <param name="user">登录用户信息</param>
  10710. /// <param name="se">查询条件</param>
  10711. /// <returns>查询结果</returns>
  10712. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10713. {
  10714. IDBConnection conn = null;
  10715. try
  10716. {
  10717. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10718. List<OracleParameter> parameters = new List<OracleParameter>();
  10719. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10720. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10721. ServiceResultEntity sre = new ServiceResultEntity();
  10722. if (data == null || data.Rows.Count == 0)
  10723. {
  10724. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10725. return sre;
  10726. }
  10727. sre.Data = new DataSet();
  10728. sre.Data.Tables.Add(data);
  10729. return sre;
  10730. }
  10731. catch (Exception ex)
  10732. {
  10733. throw ex;
  10734. }
  10735. finally
  10736. {
  10737. if (conn != null &&
  10738. conn.ConnState == ConnectionState.Open)
  10739. {
  10740. conn.Close();
  10741. }
  10742. }
  10743. }
  10744. /// <summary>
  10745. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10746. /// </summary>
  10747. /// <returns>sql</returns>
  10748. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10749. {
  10750. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10751. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10752. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10753. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10754. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10755. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10756. {
  10757. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10758. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10759. }
  10760. if (!string.IsNullOrEmpty(se.Remarks))
  10761. {
  10762. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10763. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10764. }
  10765. if (se.RecordDate.HasValue)
  10766. {
  10767. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10768. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10769. }
  10770. if (se.RecordDateEnd.HasValue)
  10771. {
  10772. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10773. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10774. }
  10775. selSql +=
  10776. // 温湿计查看权限
  10777. " AND EXISTS (SELECT UP.PurviewID" +
  10778. " FROM TP_MST_UserPurview UP" +
  10779. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10780. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10781. " AND UP.UserId = :UPUserId)";
  10782. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10783. selSql = selSql + " order by RecordDate asc";
  10784. return selSql;
  10785. }
  10786. /// <summary>
  10787. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10788. /// </summary>
  10789. /// <param name="user">登录用户信息</param>
  10790. /// <param name="se">查询条件</param>
  10791. /// <returns>查询结果</returns>
  10792. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10793. {
  10794. IDBConnection conn = null;
  10795. try
  10796. {
  10797. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10798. List<OracleParameter> parameters = new List<OracleParameter>();
  10799. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10800. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10801. ServiceResultEntity sre = new ServiceResultEntity();
  10802. if (data == null || data.Rows.Count == 0)
  10803. {
  10804. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10805. return sre;
  10806. }
  10807. sre.Data = new DataSet();
  10808. sre.Data.Tables.Add(data);
  10809. return sre;
  10810. }
  10811. catch (Exception ex)
  10812. {
  10813. throw ex;
  10814. }
  10815. finally
  10816. {
  10817. if (conn != null &&
  10818. conn.ConnState == ConnectionState.Open)
  10819. {
  10820. conn.Close();
  10821. }
  10822. }
  10823. }
  10824. /// <summary>
  10825. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10826. /// </summary>
  10827. /// <returns>sql</returns>
  10828. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10829. {
  10830. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10831. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10832. #region
  10833. // string sqlString = @"
  10834. // SELECT t.reworkprocedureid -- 返工工序id
  10835. // ,decode(gid,
  10836. // 7,
  10837. // '总计',
  10838. // 3,
  10839. // '合计【' || t.reworkprocedurename || '】',
  10840. // 0,
  10841. // t.reworkprocedurename,
  10842. // '--') reworkprocedurename -- 返工工序
  10843. // ,t.goodstypecode2 -- 产品二级类别
  10844. // ,decode(gid,
  10845. // 1,
  10846. // '小计【' || t.goodstypename2 || '】',
  10847. // 0,
  10848. // t.goodstypename2,
  10849. // '--') goodstypename2 -- 产品二级类别
  10850. // ,t.reworkuserid -- 返工工号id
  10851. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10852. // ,t.goodsid -- 产品id
  10853. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10854. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10855. // ,t.reworkcount -- 返工数
  10856. // ,t.badcount -- 不合格数
  10857. // ,t.regoodcount -- 复检合格数
  10858. // ,t.rebadcount -- 复检不合格数
  10859. // ,t.renocount -- 未复检
  10860. // --,t.renocountsum -- 待返工
  10861. // ,(SELECT COUNT(*)
  10862. // FROM tp_pm_semicheck sci
  10863. // WHERE sci.valueflag = '1'
  10864. // AND sci.backoutflag = '0'
  10865. // AND sci.semichecktype = 1
  10866. // AND sci.resemichecktype = 0
  10867. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10868. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10869. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10870. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10871. // ,sc.reworkprocedureid
  10872. // ,rp.procedurename reworkprocedurename
  10873. // ,gt2.goodstypecode goodstypecode2
  10874. // ,gt2.goodstypename goodstypename2
  10875. // ,sc.reworkuserid
  10876. // ,sc.reworkusercode
  10877. // ,g.goodsid
  10878. // ,g.goodscode
  10879. // ,gt.goodstypename
  10880. // , SUM(CASE
  10881. // WHEN sc.semichecktype = 1 THEN
  10882. // 1
  10883. // ELSE
  10884. // 0
  10885. // END) reworkcount
  10886. // , SUM(CASE
  10887. // WHEN sc.semichecktype = 2 THEN
  10888. // 1
  10889. // ELSE
  10890. // 0
  10891. // END) badcount
  10892. // , SUM(CASE
  10893. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  10894. // 1
  10895. // ELSE
  10896. // 0
  10897. // END) renocount
  10898. // , SUM(CASE
  10899. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  10900. // 1
  10901. // ELSE
  10902. // 0
  10903. // END) regoodcount
  10904. // , SUM(CASE
  10905. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  10906. // 1
  10907. // ELSE
  10908. // 0
  10909. // END) rebadcount
  10910. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  10911. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  10912. // --FROM tp_pm_semicheck sc
  10913. // FROM (SELECT semicheckid
  10914. // ,barcode
  10915. // ,productionlineid
  10916. // ,procedureid
  10917. // ,proceduretime
  10918. // ,proceduremodel
  10919. // ,modeltype
  10920. // ,organizationid
  10921. // ,goodsid
  10922. // ,goodscode
  10923. // ,userid
  10924. // ,usercode
  10925. // ,productiondataid
  10926. // ,logoid
  10927. // ,ispublicbody
  10928. // ,specialrepairflag
  10929. // ,goodslevelid
  10930. // ,goodsleveltypeid
  10931. // ,groutingdailyid
  10932. // ,groutingdailydetailid
  10933. // ,groutinglineid
  10934. // ,groutinglinecode
  10935. // ,groutinglinename
  10936. // ,gmouldtypeid
  10937. // ,canmanytimes
  10938. // ,groutinglinedetailid
  10939. // ,groutingdate
  10940. // ,groutingmouldcode
  10941. // ,mouldcode
  10942. // ,groutinguserid
  10943. // ,groutingusercode
  10944. // ,groutingnum
  10945. // ,semichecktype
  10946. // ,semicheckuserid
  10947. // ,semicheckusercode
  10948. // ,semichecktime
  10949. // ,reworkprocedureid
  10950. // ,reworkprocedurecode
  10951. // ,reworkuserid
  10952. // ,reworkusercode
  10953. // ,resemichecktype
  10954. // ,resemicheckuserid
  10955. // ,resemicheckusercode
  10956. // ,resemichecktime
  10957. // ,backoutflag
  10958. // ,backouttime
  10959. // ,backoutuserid
  10960. // ,backoutusercode
  10961. // ,remarks
  10962. // ,createtime
  10963. // ,createuserid
  10964. // ,updateuserid
  10965. // FROM tp_pm_semicheck sc
  10966. // WHERE sc.accountid = :accountid
  10967. // AND sc.valueflag = '1'
  10968. // AND sc.semichecktype = 1
  10969. // AND sc.backoutflag = '0'
  10970. // UNION ALL
  10971. // SELECT DISTINCT sc.semicheckid
  10972. // ,sc.barcode
  10973. // ,sc.productionlineid
  10974. // ,sc.procedureid
  10975. // ,sc.proceduretime
  10976. // ,sc.proceduremodel
  10977. // ,sc.modeltype
  10978. // ,sc.organizationid
  10979. // ,sc.goodsid
  10980. // ,sc.goodscode
  10981. // ,sc.userid
  10982. // ,sc.usercode
  10983. // ,sc.productiondataid
  10984. // ,sc.logoid
  10985. // ,sc.ispublicbody
  10986. // ,sc.specialrepairflag
  10987. // ,sc.goodslevelid
  10988. // ,sc.goodsleveltypeid
  10989. // ,sc.groutingdailyid
  10990. // ,sc.groutingdailydetailid
  10991. // ,sc.groutinglineid
  10992. // ,sc.groutinglinecode
  10993. // ,sc.groutinglinename
  10994. // ,sc.gmouldtypeid
  10995. // ,sc.canmanytimes
  10996. // ,sc.groutinglinedetailid
  10997. // ,sc.groutingdate
  10998. // ,sc.groutingmouldcode
  10999. // ,sc.mouldcode
  11000. // ,sc.groutinguserid
  11001. // ,sc.groutingusercode
  11002. // ,sc.groutingnum
  11003. // ,sc.semichecktype
  11004. // ,sc.semicheckuserid
  11005. // ,sc.semicheckusercode
  11006. // ,sc.semichecktime
  11007. // --,sc.reworkprocedureid
  11008. // --,sc.reworkprocedurecode
  11009. // --,sc.reworkuserid
  11010. // --,sc.reworkusercode
  11011. // ,scd.defectprocedureid
  11012. // ,scdp.procedurename
  11013. // ,scd.defectuserid
  11014. // ,scd.defectusercode
  11015. // ,sc.resemichecktype
  11016. // ,sc.resemicheckuserid
  11017. // ,sc.resemicheckusercode
  11018. // ,sc.resemichecktime
  11019. // ,sc.backoutflag
  11020. // ,sc.backouttime
  11021. // ,sc.backoutuserid
  11022. // ,sc.backoutusercode
  11023. // ,sc.remarks
  11024. // ,sc.createtime
  11025. // ,sc.createuserid
  11026. // ,sc.updateuserid
  11027. // FROM tp_pm_semicheck sc
  11028. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11029. // ON sc.semicheckid = scd.semicheckid
  11030. // LEFT JOIN tp_pc_procedure scdp
  11031. // ON scdp.procedureid = scd.defectprocedureid
  11032. // WHERE sc.accountid = :accountid
  11033. // AND sc.valueflag = '1'
  11034. // AND sc.semichecktype = 2
  11035. // AND sc.backoutflag = '0'
  11036. // ) sc
  11037. // LEFT JOIN tp_pc_procedure rp
  11038. // ON rp.procedureid = sc.reworkprocedureid
  11039. // INNER JOIN tp_mst_goods g
  11040. // ON g.goodsid = sc.goodsid
  11041. // INNER JOIN tp_mst_goodstype gt
  11042. // ON gt.goodstypeid = g.goodstypeid
  11043. // INNER JOIN tp_mst_goodstype gt2
  11044. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11045. // AND gt2.accountid = gt.accountid
  11046. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11047. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11048. // 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))";
  11049. #endregion
  11050. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11051. " ,decode(gid,\n" +
  11052. " 7,\n" +
  11053. " '总计',\n" +
  11054. " 3,\n" +
  11055. " '合计【' || t.reworkprocedurename || '】',\n" +
  11056. " 0,\n" +
  11057. " t.reworkprocedurename,\n" +
  11058. " '--') reworkprocedurename -- 返工工序\n" +
  11059. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11060. " ,decode(gid,\n" +
  11061. " 1,\n" +
  11062. " '小计【' || t.goodstypename2 || '】',\n" +
  11063. " 0,\n" +
  11064. " t.goodstypename2,\n" +
  11065. " '--') goodstypename2 -- 产品二级类别\n" +
  11066. " ,t.reworkuserid -- 返工工号id\n" +
  11067. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11068. " ,t.goodsid -- 产品id\n" +
  11069. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11070. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11071. " ,t.reworkcount -- 返工数\n" +
  11072. " ,t.badcount -- 不合格数\n" +
  11073. " ,t.regoodcount -- 复检合格数\n" +
  11074. " ,t.rebadcount -- 复检不合格数\n" +
  11075. " ,t.renocount -- 未复检\n" +
  11076. " ,t.renocountsum -- 待返工\n" +
  11077. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11078. " sct.goodstypecode2,\n" +
  11079. " sct.goodsid) gid\n" +
  11080. " ,sct.displayno\n" +
  11081. " ,sct.reworkprocedureid\n" +
  11082. " ,sct.reworkprocedurename\n" +
  11083. " ,sct.goodstypecode2\n" +
  11084. " ,sct.goodstypename2\n" +
  11085. " ,sct.reworkuserid\n" +
  11086. " ,sct.reworkusercode\n" +
  11087. " ,sct.goodsid\n" +
  11088. " ,sct.goodscode\n" +
  11089. " ,sct.goodstypename\n" +
  11090. " ,SUM(sct.reworkcount) reworkcount\n" +
  11091. " ,SUM(sct. badcount) badcount\n" +
  11092. " ,SUM(sct. renocount) renocount\n" +
  11093. " ,SUM(sct.regoodcount) regoodcount\n" +
  11094. " ,SUM(sct.rebadcount) rebadcount\n" +
  11095. " ,SUM(sct.renocountsum) renocountsum\n" +
  11096. " FROM (SELECT rp.displayno\n" +
  11097. " ,sc.reworkprocedureid\n" +
  11098. " ,rp.procedurename reworkprocedurename\n" +
  11099. " ,gt2.goodstypecode goodstypecode2\n" +
  11100. " ,gt2.goodstypename goodstypename2\n" +
  11101. " ,sc.reworkuserid\n" +
  11102. " ,sc.reworkusercode\n" +
  11103. " ,g.goodsid\n" +
  11104. " ,g.goodscode\n" +
  11105. " ,gt.goodstypename\n" +
  11106. " , SUM(CASE\n" +
  11107. " WHEN sc.semichecktype = 1 THEN\n" +
  11108. " 1\n" +
  11109. " ELSE\n" +
  11110. " 0\n" +
  11111. " END) reworkcount\n" +
  11112. " , SUM(CASE\n" +
  11113. " WHEN sc.semichecktype = 2 THEN\n" +
  11114. " 1\n" +
  11115. " ELSE\n" +
  11116. " 0\n" +
  11117. " END) badcount\n" +
  11118. " , SUM(CASE\n" +
  11119. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11120. " 1\n" +
  11121. " ELSE\n" +
  11122. " 0\n" +
  11123. " END) renocount\n" +
  11124. " , SUM(CASE\n" +
  11125. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11126. " 1\n" +
  11127. " ELSE\n" +
  11128. " 0\n" +
  11129. " END) regoodcount\n" +
  11130. " , SUM(CASE\n" +
  11131. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11132. " 1\n" +
  11133. " ELSE\n" +
  11134. " 0\n" +
  11135. " END) rebadcount\n" +
  11136. " ,(SELECT COUNT(*)\n" +
  11137. " FROM tp_pm_semicheck sci\n" +
  11138. " WHERE sci.valueflag = '1'\n" +
  11139. " AND sci.backoutflag = '0'\n" +
  11140. " AND sci.semichecktype = 1\n" +
  11141. " AND sci.resemichecktype = 0\n" +
  11142. " AND sci.accountid = :accountid\n" +
  11143. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11144. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11145. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11146. " FROM (SELECT semicheckid\n" +
  11147. " ,barcode\n" +
  11148. " ,productionlineid\n" +
  11149. " ,procedureid\n" +
  11150. " ,proceduretime\n" +
  11151. " ,proceduremodel\n" +
  11152. " ,modeltype\n" +
  11153. " ,organizationid\n" +
  11154. " ,goodsid\n" +
  11155. " ,goodscode\n" +
  11156. " ,userid\n" +
  11157. " ,usercode\n" +
  11158. " ,productiondataid\n" +
  11159. " ,logoid\n" +
  11160. " ,ispublicbody\n" +
  11161. " ,specialrepairflag\n" +
  11162. " ,goodslevelid\n" +
  11163. " ,goodsleveltypeid\n" +
  11164. " ,groutingdailyid\n" +
  11165. " ,groutingdailydetailid\n" +
  11166. " ,groutinglineid\n" +
  11167. " ,groutinglinecode\n" +
  11168. " ,groutinglinename\n" +
  11169. " ,gmouldtypeid\n" +
  11170. " ,canmanytimes\n" +
  11171. " ,groutinglinedetailid\n" +
  11172. " ,groutingdate\n" +
  11173. " ,groutingmouldcode\n" +
  11174. " ,mouldcode\n" +
  11175. " ,groutinguserid\n" +
  11176. " ,groutingusercode\n" +
  11177. " ,groutingnum\n" +
  11178. " ,semichecktype\n" +
  11179. " ,semicheckuserid\n" +
  11180. " ,semicheckusercode\n" +
  11181. " ,semichecktime\n" +
  11182. " ,reworkprocedureid\n" +
  11183. " ,reworkprocedurecode\n" +
  11184. " ,reworkuserid\n" +
  11185. " ,reworkusercode\n" +
  11186. " ,resemichecktype\n" +
  11187. " ,resemicheckuserid\n" +
  11188. " ,resemicheckusercode\n" +
  11189. " ,resemichecktime\n" +
  11190. " ,backoutflag\n" +
  11191. " ,backouttime\n" +
  11192. " ,backoutuserid\n" +
  11193. " ,backoutusercode\n" +
  11194. " ,remarks\n" +
  11195. " ,createtime\n" +
  11196. " ,createuserid\n" +
  11197. " ,updateuserid\n" +
  11198. " FROM tp_pm_semicheck sc\n" +
  11199. " WHERE sc.accountid = :accountid\n" +
  11200. " AND sc.valueflag = '1'\n" +
  11201. " AND sc.semichecktype = 1\n" +
  11202. " AND sc.backoutflag = '0'\n" +
  11203. " UNION ALL\n" +
  11204. " SELECT DISTINCT sc.semicheckid\n" +
  11205. " ,sc.barcode\n" +
  11206. " ,sc.productionlineid\n" +
  11207. " ,sc.procedureid\n" +
  11208. " ,sc.proceduretime\n" +
  11209. " ,sc.proceduremodel\n" +
  11210. " ,sc.modeltype\n" +
  11211. " ,sc.organizationid\n" +
  11212. " ,sc.goodsid\n" +
  11213. " ,sc.goodscode\n" +
  11214. " ,sc.userid\n" +
  11215. " ,sc.usercode\n" +
  11216. " ,sc.productiondataid\n" +
  11217. " ,sc.logoid\n" +
  11218. " ,sc.ispublicbody\n" +
  11219. " ,sc.specialrepairflag\n" +
  11220. " ,sc.goodslevelid\n" +
  11221. " ,sc.goodsleveltypeid\n" +
  11222. " ,sc.groutingdailyid\n" +
  11223. " ,sc.groutingdailydetailid\n" +
  11224. " ,sc.groutinglineid\n" +
  11225. " ,sc.groutinglinecode\n" +
  11226. " ,sc.groutinglinename\n" +
  11227. " ,sc.gmouldtypeid\n" +
  11228. " ,sc.canmanytimes\n" +
  11229. " ,sc.groutinglinedetailid\n" +
  11230. " ,sc.groutingdate\n" +
  11231. " ,sc.groutingmouldcode\n" +
  11232. " ,sc.mouldcode\n" +
  11233. " ,sc.groutinguserid\n" +
  11234. " ,sc.groutingusercode\n" +
  11235. " ,sc.groutingnum\n" +
  11236. " ,sc.semichecktype\n" +
  11237. " ,sc.semicheckuserid\n" +
  11238. " ,sc.semicheckusercode\n" +
  11239. " ,sc.semichecktime\n" +
  11240. " --,sc.reworkprocedureid\n" +
  11241. " --,sc.reworkprocedurecode\n" +
  11242. " --,sc.reworkuserid\n" +
  11243. " --,sc.reworkusercode\n" +
  11244. " ,scd.defectprocedureid\n" +
  11245. " ,scdp.procedurename\n" +
  11246. " ,scd.defectuserid\n" +
  11247. " ,scd.defectusercode\n" +
  11248. " ,sc.resemichecktype\n" +
  11249. " ,sc.resemicheckuserid\n" +
  11250. " ,sc.resemicheckusercode\n" +
  11251. " ,sc.resemichecktime\n" +
  11252. " ,sc.backoutflag\n" +
  11253. " ,sc.backouttime\n" +
  11254. " ,sc.backoutuserid\n" +
  11255. " ,sc.backoutusercode\n" +
  11256. " ,sc.remarks\n" +
  11257. " ,sc.createtime\n" +
  11258. " ,sc.createuserid\n" +
  11259. " ,sc.updateuserid\n" +
  11260. " FROM tp_pm_semicheck sc\n" +
  11261. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11262. " ON sc.semicheckid = scd.semicheckid\n" +
  11263. " AND scd.valueflag='1'\n" +
  11264. " LEFT JOIN tp_pc_procedure scdp\n" +
  11265. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11266. " WHERE sc.accountid = :accountid\n" +
  11267. " AND sc.valueflag = '1'\n" +
  11268. " AND sc.semichecktype = 2\n" +
  11269. " AND sc.backoutflag = '0') sc\n" +
  11270. " LEFT JOIN tp_pc_procedure rp\n" +
  11271. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11272. " INNER JOIN tp_mst_goods g\n" +
  11273. " ON g.goodsid = sc.goodsid\n" +
  11274. " INNER JOIN tp_mst_goodstype gt\n" +
  11275. " ON gt.goodstypeid = g.goodstypeid\n" +
  11276. " INNER JOIN tp_mst_goodstype gt2\n" +
  11277. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11278. " AND gt2.accountid = gt.accountid\n" +
  11279. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11280. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11281. " sc.GroutingDailyDetailID\n" //+
  11282. //" WHERE EXISTS (SELECT 1\n" +
  11283. //" FROM TP_MST_UserPurview up\n" +
  11284. //" WHERE up.PurviewType = 9\n" +
  11285. //" AND up.UserID = :UserID\n" +
  11286. //" AND (up.PurviewID = -1 OR\n" +
  11287. //" up.PurviewID = sc.procedureid))\n"
  11288. ;
  11289. // 完成工序集
  11290. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11291. {
  11292. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11293. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11294. }
  11295. // 完成时间起始
  11296. if (se.CDateTimeStart.HasValue)
  11297. {
  11298. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11299. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11300. }
  11301. // 完成时间结束
  11302. if (se.CDateTimeEnd.HasValue)
  11303. {
  11304. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11305. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11306. }
  11307. // 完成工号
  11308. if (!string.IsNullOrEmpty(se.CUserCode))
  11309. {
  11310. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11311. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11312. }
  11313. // 产品类别
  11314. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11315. {
  11316. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11317. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11318. }
  11319. // 产品编码
  11320. if (!string.IsNullOrEmpty(se.GoodsCode))
  11321. {
  11322. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11323. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11324. }
  11325. // 成型工号
  11326. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11327. {
  11328. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11329. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11330. }
  11331. // 注浆时间起始
  11332. if (se.GroutingDateTimeStart.HasValue)
  11333. {
  11334. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11335. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11336. }
  11337. // 注浆时间结束
  11338. if (se.GroutingDateTimeEnd.HasValue)
  11339. {
  11340. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11341. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11342. }
  11343. // 交坯时间起始
  11344. if (se.DeliveryDateTimeStart.HasValue)
  11345. {
  11346. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11347. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11348. }
  11349. // 交坯时间结束
  11350. if (se.DeliveryDateTimeEnd.HasValue)
  11351. {
  11352. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11353. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11354. }
  11355. // 半检状态
  11356. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11357. {
  11358. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11359. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11360. }
  11361. // 半检时间起始
  11362. if (se.SemiCheckDateTimeStart.HasValue)
  11363. {
  11364. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11365. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11366. }
  11367. // 半检时间结束
  11368. if (se.SemiCheckDateTimeEnd.HasValue)
  11369. {
  11370. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11371. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11372. }
  11373. // 半检工号
  11374. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11375. {
  11376. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11377. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11378. }
  11379. // 返工工序
  11380. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11381. {
  11382. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11383. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11384. }
  11385. // 返工工号
  11386. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11387. {
  11388. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11389. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11390. }
  11391. // 复检状态
  11392. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11393. {
  11394. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11395. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11396. }
  11397. // 复检时间起始
  11398. if (se.ReSemiCheckDateTimeStart.HasValue)
  11399. {
  11400. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11401. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11402. }
  11403. // 复检时间结束
  11404. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11405. {
  11406. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11407. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11408. }
  11409. // 复检工号
  11410. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11411. {
  11412. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11413. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11414. }
  11415. // 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),())
  11416. // ORDER BY rp.displayno
  11417. // ,gt2.goodstypename
  11418. // ,sc.reworkusercode
  11419. // ,g.goodscode
  11420. // ,gt.goodstypename, gid) t
  11421. // ";
  11422. sqlString = sqlString +
  11423. " GROUP BY rp.displayno\n" +
  11424. " ,sc.reworkprocedureid\n" +
  11425. " ,rp.procedurename\n" +
  11426. " ,gt2.goodstypecode\n" +
  11427. " ,gt2.goodstypename\n" +
  11428. " ,sc.reworkuserid\n" +
  11429. " ,sc.reworkusercode\n" +
  11430. " ,g.goodsid\n" +
  11431. " ,g.goodscode\n" +
  11432. " ,gt.goodstypename) sct\n" +
  11433. " 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" +
  11434. " ORDER BY sct.displayno\n" +
  11435. " ,sct.goodstypename\n" +
  11436. " ,sct.reworkusercode\n" +
  11437. " ,sct.goodscode\n" +
  11438. " ,sct.goodstypename\n" +
  11439. " ,gid) t";
  11440. return sqlString;
  11441. }
  11442. /// <summary>
  11443. /// 取得RPT080107(半检登记明细)的信息查询数据
  11444. /// </summary>
  11445. /// <param name="user">登录用户信息</param>
  11446. /// <param name="se">查询条件</param>
  11447. /// <returns>查询结果</returns>
  11448. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11449. {
  11450. IDBConnection conn = null;
  11451. try
  11452. {
  11453. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11454. List<OracleParameter> parameters = new List<OracleParameter>();
  11455. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11456. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11457. ServiceResultEntity sre = new ServiceResultEntity();
  11458. if (data == null || data.Rows.Count == 0)
  11459. {
  11460. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11461. return sre;
  11462. }
  11463. sre.Data = new DataSet();
  11464. sre.Data.Tables.Add(data);
  11465. return sre;
  11466. }
  11467. catch (Exception ex)
  11468. {
  11469. throw ex;
  11470. }
  11471. finally
  11472. {
  11473. if (conn != null &&
  11474. conn.ConnState == ConnectionState.Open)
  11475. {
  11476. conn.Close();
  11477. }
  11478. }
  11479. }
  11480. //xuwei add 2019-10-14
  11481. /// <summary>
  11482. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11483. /// </summary>
  11484. /// <param name="user">登录用户信息</param>
  11485. /// <param name="se">查询条件</param>
  11486. /// <returns>查询结果</returns>
  11487. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11488. {
  11489. IDBConnection conn = null;
  11490. try
  11491. {
  11492. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11493. List<OracleParameter> parameters = new List<OracleParameter>();
  11494. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11495. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11496. ServiceResultEntity sre = new ServiceResultEntity();
  11497. if (data == null || data.Rows.Count == 0)
  11498. {
  11499. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11500. return sre;
  11501. }
  11502. sre.Data = new DataSet();
  11503. sre.Data.Tables.Add(data);
  11504. return sre;
  11505. }
  11506. catch (Exception ex)
  11507. {
  11508. throw ex;
  11509. }
  11510. finally
  11511. {
  11512. if (conn != null &&
  11513. conn.ConnState == ConnectionState.Open)
  11514. {
  11515. conn.Close();
  11516. }
  11517. }
  11518. }
  11519. /// <summary>
  11520. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11521. /// </summary>
  11522. /// <returns>sql</returns>
  11523. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11524. {
  11525. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11526. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11527. string sqlString = @"
  11528. SELECT
  11529. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11530. p.PROCEDURECODE ,--AS 完成工序编码,
  11531. p.PROCEDURENAME ,--AS 完成工序,
  11532. sr.PROCEDURETIME ,--AS 完成时间,
  11533. sr.USERCODE ,--完成工号,
  11534. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11535. gt.GOODSTYPENAME ,--AS 产品类别,
  11536. g.GOODSCODE ,--AS 产品编码,
  11537. g.GOODSNAME,--AS 产品名称,
  11538. sr.BARCODE ,--AS 产品条码,
  11539. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11540. sr.SEMIREWORKTIME ,--AS 半检时间,
  11541. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11542. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11543. sr.BACKOUTFLAG ,--AS 撤销标识,
  11544. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11545. sr.BACKOUTTIME ,--AS 撤销时间,
  11546. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11547. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11548. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11549. sr.GROUTINGDATE ,--AS 注浆时间,
  11550. gd.DELIVERTIME ,--AS 交坯时间,
  11551. l.LOGONAME ,--AS 商标,
  11552. srd.DEFECTCODE ,--AS 缺陷编码,
  11553. srd.DEFECTNAME ,--AS 缺陷名称,
  11554. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11555. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11556. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11557. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11558. srd.DEFECTUSERCODE ,--AS 责任工号,
  11559. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11560. FROM
  11561. TP_PM_SEMIREWORK sr
  11562. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11563. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11564. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11565. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11566. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11567. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11568. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11569. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11570. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11571. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11572. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11573. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11574. WHERE
  11575. sr.VALUEFLAG = '1'
  11576. AND srd.VALUEFLAG = '1'
  11577. AND sr.AccountID=:AccountID
  11578. ";
  11579. //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))
  11580. // 完成工序
  11581. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11582. {
  11583. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11584. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11585. }
  11586. // 完成时间起始
  11587. if (se.CDateTimeStart.HasValue)
  11588. {
  11589. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11590. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11591. }
  11592. // 完成时间结束
  11593. if (se.CDateTimeEnd.HasValue)
  11594. {
  11595. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11596. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11597. }
  11598. // 完成工号
  11599. if (!string.IsNullOrEmpty(se.CUserCode))
  11600. {
  11601. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11602. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11603. }
  11604. // 产品类别
  11605. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11606. {
  11607. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11608. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11609. }
  11610. // 产品编码
  11611. if (!string.IsNullOrEmpty(se.GoodsCode))
  11612. {
  11613. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11614. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11615. }
  11616. // 成型工号
  11617. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11618. {
  11619. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11620. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11621. }
  11622. // 注浆时间起始
  11623. if (se.GroutingDateTimeStart.HasValue)
  11624. {
  11625. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11626. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11627. }
  11628. // 注浆时间结束
  11629. if (se.GroutingDateTimeEnd.HasValue)
  11630. {
  11631. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11632. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11633. }
  11634. // 交坯时间起始
  11635. if (se.DeliveryDateTimeStart.HasValue)
  11636. {
  11637. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11638. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11639. }
  11640. // 交坯时间结束
  11641. if (se.DeliveryDateTimeEnd.HasValue)
  11642. {
  11643. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11644. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11645. }
  11646. // 半检时间起始
  11647. if (se.SemiCheckDateTimeStart.HasValue)
  11648. {
  11649. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11650. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11651. }
  11652. // 半检时间结束
  11653. if (se.SemiCheckDateTimeEnd.HasValue)
  11654. {
  11655. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11656. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11657. }
  11658. // 半检工号
  11659. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11660. {
  11661. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11662. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11663. }
  11664. // 返修工序
  11665. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11666. {
  11667. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11668. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11669. }
  11670. // 返修工号
  11671. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11672. {
  11673. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11674. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11675. }
  11676. // 撤销标识
  11677. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11678. {
  11679. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11680. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11681. }
  11682. // 撤销时间起始
  11683. if (se.BackOutTimeStart.HasValue)
  11684. {
  11685. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11686. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11687. }
  11688. // 撤销时间结束
  11689. if (se.BackOutTimeEnd.HasValue)
  11690. {
  11691. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11692. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11693. }
  11694. // 撤销工号
  11695. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11696. {
  11697. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11698. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11699. }
  11700. // 产品条码
  11701. if (!string.IsNullOrEmpty(se.BarCode))
  11702. {
  11703. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11704. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11705. }
  11706. // 缺陷编码
  11707. if (!string.IsNullOrEmpty(se.DefectCode))
  11708. {
  11709. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11710. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11711. }
  11712. // 缺陷位置集
  11713. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11714. {
  11715. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11716. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11717. }
  11718. // 责任工序集
  11719. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11720. {
  11721. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11722. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11723. }
  11724. // 责任工号
  11725. if (!string.IsNullOrEmpty(se.DefectUser))
  11726. {
  11727. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11728. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11729. }
  11730. // 只显示最后一条半检记录
  11731. if (se.SemiCheckType == "1")
  11732. {
  11733. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11734. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11735. " from TP_PM_SEMIREWORK sw\n" +
  11736. " where sw.barcode = sr.barcode\n" +
  11737. " and sw.valueflag = '1'\n" +
  11738. " and (sw.backoutflag = '0')\n" +
  11739. " and sw.semireworkid > sr.semireworkid) )";
  11740. }
  11741. return sqlString;
  11742. }
  11743. //xuwei end
  11744. //xuwei add 2019-10-21
  11745. /// <summary>
  11746. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11747. /// </summary>
  11748. /// <param name="user">用户</param>
  11749. /// <param name="dataStr">统计日期</param>
  11750. /// <returns></returns>
  11751. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11752. {
  11753. IDBConnection conn = null;
  11754. try
  11755. {
  11756. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11757. string sqlStr = $@"
  11758. SELECT
  11759. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11760. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11761. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11762. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11763. FROM
  11764. TP_PM_SEMIREWORK sr
  11765. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11766. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11767. WHERE
  11768. sr.VALUEFLAG = '1'
  11769. AND sr.ACCOUNTID = '{user.AccountID}'
  11770. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11771. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11772. GROUP BY
  11773. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11774. ";
  11775. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11776. ServiceResultEntity sre = new ServiceResultEntity();
  11777. //if (data == null || data.Rows.Count == 0)
  11778. //{
  11779. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11780. // return sre;
  11781. //}
  11782. sre.Data = new DataSet();
  11783. sre.Data.Tables.Add(data);
  11784. return sre;
  11785. }
  11786. catch (Exception ex)
  11787. {
  11788. throw ex;
  11789. }
  11790. finally
  11791. {
  11792. if (conn != null &&
  11793. conn.ConnState == ConnectionState.Open)
  11794. {
  11795. conn.Close();
  11796. }
  11797. }
  11798. }
  11799. //xuwei end
  11800. /// <summary>
  11801. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11802. /// </summary>
  11803. /// <returns>sql</returns>
  11804. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11805. {
  11806. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11807. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11808. string sqlString = @"
  11809. select
  11810. SemiCheck.SemiCheckID,
  11811. CProcedure.ProcedureName as CProcedureName,
  11812. SemiCheck.ProcedureTime,
  11813. SemiCheck.UserCode,
  11814. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11815. GoodsType.GoodsTypeName,
  11816. Goods.GoodsCode,
  11817. SemiCheck.BarCode,
  11818. -- 复检后不显示半检状态
  11819. SemiCheckType.SemiCheckTypeName,
  11820. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11821. SemiCheck.SemiCheckUserCode,
  11822. SemiCheck.SemiCheckTime,
  11823. ReSemiCheckType.ReSemiCheckTypeName,
  11824. SemiCheck.ReSemiCheckUserCode,
  11825. SemiCheck.ReSemiCheckTime,
  11826. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11827. SemiCheck.BackOutUserCode,
  11828. SemiCheck.BackOutTime,
  11829. SemiCheck.GroutingUserCode,
  11830. SemiCheck.GroutingLineCode,
  11831. SemiCheck.GroutingMouldCode,
  11832. SemiCheck.GroutingDate,
  11833. GroutingDailyDetail.DeliverTime,
  11834. logo.logoName,
  11835. RProcedure.ProcedureName as RProcedureName,
  11836. SemiCheck.ReworkUserCode,
  11837. SemiCheckDefect.DefectCode,
  11838. SemiCheckDefect.DefectName as DefectName1,
  11839. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11840. SemiCheckDefect.DefectPositionName,
  11841. SemiCheckDefect.DefectPositionCode,
  11842. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11843. Procedure.ProcedureName,
  11844. inpp.ProcedureName CurrProcedureName,
  11845. DefectUser.username as DefectUser
  11846. from TP_PM_SemiCheck SemiCheck
  11847. left join TP_PC_Procedure CProcedure
  11848. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11849. left join TP_MST_Goods Goods
  11850. on SemiCheck.GoodsID=Goods.GoodsID
  11851. left join TP_MST_GoodsType GoodsType
  11852. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11853. left join TP_MST_GoodsType GoodsType2
  11854. on GoodsType2.accountid=GoodsType.accountid
  11855. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11856. left join TP_SYS_SemiCheckType SemiCheckType
  11857. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11858. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11859. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11860. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11861. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11862. left join TP_MST_Logo logo
  11863. on GroutingDailyDetail.LogoID=logo.LogoID
  11864. left join TP_PC_Procedure RProcedure
  11865. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11866. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11867. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11868. and SemiCheckDefect.ValueFlag='1'
  11869. left join TP_PC_Procedure Procedure
  11870. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11871. left join TP_MST_User DefectUser
  11872. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11873. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11874. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11875. where SemiCheck.AccountID=:AccountID
  11876. ";
  11877. //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))
  11878. // 完成工序
  11879. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11880. {
  11881. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  11882. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11883. }
  11884. // 完成时间起始
  11885. if (se.CDateTimeStart.HasValue)
  11886. {
  11887. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  11888. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11889. }
  11890. // 完成时间结束
  11891. if (se.CDateTimeEnd.HasValue)
  11892. {
  11893. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  11894. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11895. }
  11896. // 完成工号
  11897. if (!string.IsNullOrEmpty(se.CUserCode))
  11898. {
  11899. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  11900. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11901. }
  11902. // 产品类别
  11903. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11904. {
  11905. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11906. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11907. }
  11908. // 产品编码
  11909. if (!string.IsNullOrEmpty(se.GoodsCode))
  11910. {
  11911. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  11912. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11913. }
  11914. // 成型工号
  11915. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11916. {
  11917. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  11918. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11919. }
  11920. // 注浆时间起始
  11921. if (se.GroutingDateTimeStart.HasValue)
  11922. {
  11923. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  11924. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11925. }
  11926. // 注浆时间结束
  11927. if (se.GroutingDateTimeEnd.HasValue)
  11928. {
  11929. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  11930. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11931. }
  11932. // 交坯时间起始
  11933. if (se.DeliveryDateTimeStart.HasValue)
  11934. {
  11935. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11936. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11937. }
  11938. // 交坯时间结束
  11939. if (se.DeliveryDateTimeEnd.HasValue)
  11940. {
  11941. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11942. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11943. }
  11944. // 半检状态
  11945. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11946. {
  11947. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  11948. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11949. }
  11950. // 半检时间起始
  11951. if (se.SemiCheckDateTimeStart.HasValue)
  11952. {
  11953. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11954. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11955. }
  11956. // 半检时间结束
  11957. if (se.SemiCheckDateTimeEnd.HasValue)
  11958. {
  11959. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11960. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11961. }
  11962. // 半检工号
  11963. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11964. {
  11965. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11966. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11967. }
  11968. // 返工工序
  11969. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11970. {
  11971. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  11972. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11973. }
  11974. // 返工工号
  11975. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11976. {
  11977. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  11978. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11979. }
  11980. // 复检状态
  11981. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11982. {
  11983. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  11984. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11985. }
  11986. // 复检时间起始
  11987. if (se.ReSemiCheckDateTimeStart.HasValue)
  11988. {
  11989. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11990. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11991. }
  11992. // 复检时间结束
  11993. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11994. {
  11995. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11996. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11997. }
  11998. // 复检工号
  11999. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  12000. {
  12001. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  12002. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  12003. }
  12004. // 撤销标识
  12005. if (!string.IsNullOrEmpty(se.BackOutFlag))
  12006. {
  12007. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  12008. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  12009. }
  12010. // 撤销时间起始
  12011. if (se.BackOutTimeStart.HasValue)
  12012. {
  12013. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  12014. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12015. }
  12016. // 撤销时间结束
  12017. if (se.BackOutTimeEnd.HasValue)
  12018. {
  12019. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12020. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12021. }
  12022. // 撤销工号
  12023. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12024. {
  12025. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12026. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12027. }
  12028. // 产品条码
  12029. if (!string.IsNullOrEmpty(se.BarCode))
  12030. {
  12031. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12032. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12033. }
  12034. // 缺陷编码
  12035. if (!string.IsNullOrEmpty(se.DefectCode))
  12036. {
  12037. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12038. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12039. }
  12040. // 缺陷位置集
  12041. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12042. {
  12043. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12044. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12045. }
  12046. // 责任工序集
  12047. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12048. {
  12049. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12050. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12051. }
  12052. // 责任工号
  12053. if (!string.IsNullOrEmpty(se.DefectUser))
  12054. {
  12055. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12056. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12057. }
  12058. return sqlString;
  12059. }
  12060. /// <summary>
  12061. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12062. /// </summary>
  12063. /// <param name="user">登录用户信息</param>
  12064. /// <param name="se">查询条件</param>
  12065. /// <returns>查询结果</returns>
  12066. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12067. {
  12068. IDBConnection conn = null;
  12069. try
  12070. {
  12071. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12072. List<OracleParameter> parameters = new List<OracleParameter>();
  12073. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12074. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12075. ServiceResultEntity sre = new ServiceResultEntity();
  12076. if (data == null || data.Rows.Count == 0)
  12077. {
  12078. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12079. return sre;
  12080. }
  12081. sre.Data = new DataSet();
  12082. sre.Data.Tables.Add(data);
  12083. return sre;
  12084. }
  12085. catch (Exception ex)
  12086. {
  12087. throw ex;
  12088. }
  12089. finally
  12090. {
  12091. if (conn != null &&
  12092. conn.ConnState == ConnectionState.Open)
  12093. {
  12094. conn.Close();
  12095. }
  12096. }
  12097. }
  12098. /// <summary>
  12099. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12100. /// </summary>
  12101. /// <returns>sql</returns>
  12102. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12103. {
  12104. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12105. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12106. string sqlString = @"SELECT ts.gid
  12107. ,logoid
  12108. ,decode(ts.gid,
  12109. '23',
  12110. '总计【' || orderno || '】',
  12111. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12112. ,decode(ts.gid,
  12113. '3',
  12114. '合计【' || logoname || '】',
  12115. decode(ts.gid, '1', '--', logoname)) AS logoname
  12116. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12117. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12118. ,GoodsSpecification
  12119. ,fhtime
  12120. ,COUNT
  12121. FROM (SELECT grouping_id(l.logoid,
  12122. o.orderno,
  12123. l.logoname,
  12124. g.goodscode,
  12125. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12126. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12127. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12128. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12129. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12130. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12131. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12132. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12133. 1,
  12134. '--',
  12135. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12136. ,COUNT(f.fhtime) AS COUNT
  12137. FROM tp_pm_finishedproduct F
  12138. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12139. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12140. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12141. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12142. where f.fhtime is not null and f.AccountID=:AccountID ";
  12143. // 交接时间起始
  12144. if (se.FHTimeStart.HasValue)
  12145. {
  12146. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12147. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12148. }
  12149. // 交接时间结束
  12150. if (se.FHTimeEnd.HasValue)
  12151. {
  12152. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12153. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12154. }
  12155. // 订单号
  12156. if (!string.IsNullOrEmpty(se.OrderNo))
  12157. {
  12158. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12159. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12160. }
  12161. // 产品类别编码
  12162. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12163. {
  12164. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12165. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12166. }
  12167. // 产品编码
  12168. if (!string.IsNullOrEmpty(se.GoodsCode))
  12169. {
  12170. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12171. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12172. }
  12173. // 产品型号
  12174. if (!string.IsNullOrEmpty(se.GoodsModel))
  12175. {
  12176. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12177. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12178. }
  12179. // 产品商标ID集
  12180. if (!string.IsNullOrEmpty(se.LogoIDS))
  12181. {
  12182. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12183. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12184. }
  12185. // 交接工号
  12186. if (!string.IsNullOrEmpty(se.FHUserCode))
  12187. {
  12188. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12189. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12190. }
  12191. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12192. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12193. )ts
  12194. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12195. or (goodscode!='--')
  12196. or(logoname!='')
  12197. or (orderno!='--') and ts.gid!='7'";
  12198. return sqlString;
  12199. }
  12200. /// <summary>
  12201. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12202. /// </summary>
  12203. /// <param name="user">登录用户信息</param>
  12204. /// <param name="se">查询条件</param>
  12205. /// <returns>查询结果</returns>
  12206. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12207. {
  12208. IDBConnection conn = null;
  12209. try
  12210. {
  12211. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12212. List<OracleParameter> parameters = new List<OracleParameter>();
  12213. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12214. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12215. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12216. " nvl2(l.logoname,\n" +
  12217. " o.orderno,\n" +
  12218. " to_char('合计[') || o.orderno ||\n" +
  12219. " to_char(']')),\n" +
  12220. " '总计') orderno\n" +
  12221. " ,nvl2(l.logoname,\n" +
  12222. " nvl2(g.goodscode,\n" +
  12223. " l.logoname,\n" +
  12224. " to_char('小计[' || l.logoname || ']')),\n" +
  12225. " '--') logoname\n" +
  12226. " ,nvl(g.goodscode, '--') goodscode" +
  12227. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12228. " ,nvl(gdd.materialcode, '--') mcode" +
  12229. " ,f.logoid" +
  12230. " ,f.goodsid" +
  12231. " ,f.fhorderid" +
  12232. " ,COUNT(*) count" +
  12233. " FROM tp_pm_finishedproduct f\n" +
  12234. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12235. " ON gdd.barcode = f.barcode\n" +
  12236. " LEFT JOIN tp_mst_logo l\n" +
  12237. " ON f.logoid = l.logoid\n" +
  12238. " LEFT JOIN TP_PM_Order O\n" +
  12239. " ON f.Fhorderid = O.Orderid\n" +
  12240. " LEFT JOIN tp_mst_goods G\n" +
  12241. " ON g.goodsid = f.goodsid\n" +
  12242. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12243. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12244. " WHERE f.fhtime IS NOT NULL\n" +
  12245. " AND f.AccountID = :AccountID\n";
  12246. // 交接时间起始
  12247. if (cre.Properties["FHTimeStart"] != null)
  12248. {
  12249. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12250. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12251. }
  12252. // 交接时间结束
  12253. if (cre.Properties["FHTimeEnd"] != null)
  12254. {
  12255. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12256. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12257. }
  12258. // 订单号
  12259. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12260. {
  12261. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12262. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12263. }
  12264. // 产品类别编码
  12265. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12266. {
  12267. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12268. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12269. }
  12270. // 产品编码
  12271. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12272. {
  12273. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12274. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12275. }
  12276. // 产品型号
  12277. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12278. {
  12279. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12280. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12281. }
  12282. // 产品商标ID集
  12283. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12284. {
  12285. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12286. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12287. }
  12288. // 交接工号
  12289. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12290. {
  12291. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12292. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12293. }
  12294. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12295. 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),())";
  12296. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12297. ServiceResultEntity sre = new ServiceResultEntity();
  12298. if (data == null || data.Rows.Count == 0)
  12299. {
  12300. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12301. return sre;
  12302. }
  12303. sre.Data = new DataSet();
  12304. sre.Data.Tables.Add(data);
  12305. return sre;
  12306. }
  12307. catch (Exception ex)
  12308. {
  12309. throw ex;
  12310. }
  12311. finally
  12312. {
  12313. if (conn != null &&
  12314. conn.ConnState == ConnectionState.Open)
  12315. {
  12316. conn.Close();
  12317. }
  12318. }
  12319. }
  12320. /// <summary>
  12321. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12322. /// </summary>
  12323. /// <param name="user">登录用户信息</param>
  12324. /// <param name="se">查询条件</param>
  12325. /// <returns>查询结果</returns>
  12326. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12327. {
  12328. IDBConnection conn = null;
  12329. try
  12330. {
  12331. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12332. List<OracleParameter> parameters = new List<OracleParameter>();
  12333. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12334. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12335. ServiceResultEntity sre = new ServiceResultEntity();
  12336. if (data == null || data.Rows.Count == 0)
  12337. {
  12338. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12339. return sre;
  12340. }
  12341. sre.Data = new DataSet();
  12342. sre.Data.Tables.Add(data);
  12343. return sre;
  12344. }
  12345. catch (Exception ex)
  12346. {
  12347. throw ex;
  12348. }
  12349. finally
  12350. {
  12351. if (conn != null &&
  12352. conn.ConnState == ConnectionState.Open)
  12353. {
  12354. conn.Close();
  12355. }
  12356. }
  12357. }
  12358. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12359. {
  12360. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12361. string sqlString = "SELECT O.ORDERNO,\n" +
  12362. " F.FHTIME,\n" +
  12363. " F.FHUSERCODE,\n" +
  12364. " F.BARCODE,\n" +
  12365. " F.GOODSCODE,\n" +
  12366. " L.LOGONAME,\n" +
  12367. " F.GROUTINGUSERCODE,\n" +
  12368. " F.GROUTINGLINECODE,\n" +
  12369. " F.GROUTINGMOULDCODE,\n" +
  12370. " F.GROUTINGDATE,\n" +
  12371. " G.DELIVERTIME,\n" +
  12372. " GOODS.goodsmodel,\n" +
  12373. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12374. //" 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" +
  12375. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12376. " G.MATERIALCODE AS mcode,\n" +
  12377. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12378. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12379. " LEFT JOIN TP_PM_ORDER O\n" +
  12380. " ON F.FHORDERID = O.ORDERID\n" +
  12381. " LEFT JOIN TP_MST_LOGO L\n" +
  12382. " ON F.LOGOID = L.LOGOID\n" +
  12383. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12384. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12385. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12386. " ON F.GOODSID = GOODS.GOODSID\n" +
  12387. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12388. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12389. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12390. " AND F.FHTIME IS NOT NULL";
  12391. // 交接时间起始
  12392. if (se.FHTimeStart.HasValue)
  12393. {
  12394. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12395. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12396. }
  12397. // 交接时间结束
  12398. if (se.FHTimeEnd.HasValue)
  12399. {
  12400. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12401. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12402. }
  12403. // 订单号
  12404. if (!string.IsNullOrEmpty(se.OrderNo))
  12405. {
  12406. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12407. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12408. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12409. }
  12410. // 产品类别编码
  12411. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12412. {
  12413. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12414. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12415. }
  12416. // 产品编码
  12417. if (!string.IsNullOrEmpty(se.GoodsCode))
  12418. {
  12419. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12420. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12421. }
  12422. // 产品型号
  12423. if (!string.IsNullOrEmpty(se.GoodsModel))
  12424. {
  12425. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12426. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12427. }
  12428. // 产品商标ID集
  12429. if (!string.IsNullOrEmpty(se.LogoIDS))
  12430. {
  12431. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12432. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12433. }
  12434. // 交接工号
  12435. if (!string.IsNullOrEmpty(se.FHUserCode))
  12436. {
  12437. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12438. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12439. }
  12440. if (se.OrderID != null)
  12441. {
  12442. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12443. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12444. }
  12445. if (se.GoodsID != null)
  12446. {
  12447. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12448. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12449. }
  12450. if (se.LogoID != null)
  12451. {
  12452. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12453. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12454. }
  12455. return sqlString;
  12456. }
  12457. /// <summary>
  12458. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12459. /// </summary>
  12460. /// <param name="user">登录用户信息</param>
  12461. /// <param name="se">查询条件</param>
  12462. /// <returns>查询结果</returns>
  12463. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12464. {
  12465. IDBConnection conn = null;
  12466. try
  12467. {
  12468. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12469. List<OracleParameter> parameters = new List<OracleParameter>();
  12470. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12471. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12472. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12473. " nvl2(l.logoname,\n" +
  12474. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12475. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12476. " to_char(']')),\n" +
  12477. " '总计') fhtime\n" +
  12478. " ,nvl2(l.logoname,\n" +
  12479. " nvl2(g.goodscode,\n" +
  12480. " l.logoname,\n" +
  12481. " to_char('小计[' || l.logoname || ']')),\n" +
  12482. " '--') logoname\n" +
  12483. " ,nvl(g.goodscode, '--') goodscode" +
  12484. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12485. " ,nvl(gdd.materialcode, '--') mcode" +
  12486. " ,COUNT(*) goodscount" +
  12487. " FROM tp_pm_finishedproduct f\n" +
  12488. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12489. " ON gdd.barcode = f.barcode\n" +
  12490. " LEFT JOIN tp_mst_logo l\n" +
  12491. " ON f.logoid = l.logoid\n" +
  12492. " LEFT JOIN TP_PM_Order O\n" +
  12493. " ON f.Fhorderid = O.Orderid\n" +
  12494. " LEFT JOIN tp_mst_goods G\n" +
  12495. " ON g.goodsid = f.goodsid\n" +
  12496. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12497. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12498. " WHERE f.fhtime IS NOT NULL\n" +
  12499. " AND f.AccountID = :AccountID\n";
  12500. // 交接时间起始
  12501. if (cre.Properties["FHTimeStart"] != null)
  12502. {
  12503. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12504. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12505. }
  12506. // 交接时间结束
  12507. if (cre.Properties["FHTimeEnd"] != null)
  12508. {
  12509. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12510. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12511. }
  12512. // 订单号
  12513. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12514. {
  12515. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12516. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12517. }
  12518. // 产品类别编码
  12519. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12520. {
  12521. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12522. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12523. }
  12524. // 产品编码
  12525. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12526. {
  12527. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12528. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12529. }
  12530. // 产品型号
  12531. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12532. {
  12533. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12534. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12535. }
  12536. // 产品商标ID集
  12537. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12538. {
  12539. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12540. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12541. }
  12542. // 交接工号
  12543. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12544. {
  12545. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12546. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12547. }
  12548. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12549. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12550. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12551. ServiceResultEntity sre = new ServiceResultEntity();
  12552. if (data == null || data.Rows.Count == 0)
  12553. {
  12554. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12555. return sre;
  12556. }
  12557. sre.Data = new DataSet();
  12558. sre.Data.Tables.Add(data);
  12559. return sre;
  12560. }
  12561. catch (Exception ex)
  12562. {
  12563. throw ex;
  12564. }
  12565. finally
  12566. {
  12567. if (conn != null &&
  12568. conn.ConnState == ConnectionState.Open)
  12569. {
  12570. conn.Close();
  12571. }
  12572. }
  12573. }
  12574. /// <summary>
  12575. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12576. /// </summary>
  12577. /// <param name="user">登录用户信息</param>
  12578. /// <param name="se">查询条件</param>
  12579. /// <returns>查询结果</returns>
  12580. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12581. {
  12582. IDBConnection conn = null;
  12583. try
  12584. {
  12585. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12586. List<OracleParameter> parameters = new List<OracleParameter>();
  12587. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12588. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12589. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12590. //" nvl2(l.logoname,\n" +
  12591. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12592. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12593. //" to_char(']')),\n" +
  12594. //" '总计') fhtime\n" +
  12595. //" ,nvl2(l.logoname,\n" +
  12596. //" nvl2(g.goodscode,\n" +
  12597. //" l.logoname,\n" +
  12598. //" to_char('小计[' || l.logoname || ']')),\n" +
  12599. //" '--') logoname\n" +
  12600. " nvl(g.goodscode, '合计') goodscode" +
  12601. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12602. " ,nvl(gdd.materialcode, '--') mcode" +
  12603. " ,COUNT(*) goodscount" +
  12604. " FROM tp_pm_finishedproduct f\n" +
  12605. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12606. " ON gdd.barcode = f.barcode\n" +
  12607. " LEFT JOIN tp_mst_logo l\n" +
  12608. " ON f.logoid = l.logoid\n" +
  12609. " LEFT JOIN TP_PM_Order O\n" +
  12610. " ON f.Fhorderid = O.Orderid\n" +
  12611. " LEFT JOIN tp_mst_goods G\n" +
  12612. " ON g.goodsid = f.goodsid\n" +
  12613. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12614. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12615. " WHERE f.fhtime IS NOT NULL\n" +
  12616. " AND f.AccountID = :AccountID\n";
  12617. // 交接时间起始
  12618. if (cre.Properties["FHTimeStart"] != null)
  12619. {
  12620. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12621. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12622. }
  12623. // 交接时间结束
  12624. if (cre.Properties["FHTimeEnd"] != null)
  12625. {
  12626. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12627. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12628. }
  12629. // 订单号
  12630. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12631. {
  12632. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12633. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12634. }
  12635. // 产品类别编码
  12636. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12637. {
  12638. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12639. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12640. }
  12641. // 产品编码
  12642. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12643. {
  12644. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12645. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12646. }
  12647. // 产品型号
  12648. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12649. {
  12650. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12651. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12652. }
  12653. // 产品商标ID集
  12654. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12655. {
  12656. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12657. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12658. }
  12659. // 交接工号
  12660. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12661. {
  12662. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12663. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12664. }
  12665. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12666. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12667. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12668. ServiceResultEntity sre = new ServiceResultEntity();
  12669. if (data == null || data.Rows.Count == 0)
  12670. {
  12671. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12672. return sre;
  12673. }
  12674. sre.Data = new DataSet();
  12675. sre.Data.Tables.Add(data);
  12676. return sre;
  12677. }
  12678. catch (Exception ex)
  12679. {
  12680. throw ex;
  12681. }
  12682. finally
  12683. {
  12684. if (conn != null &&
  12685. conn.ConnState == ConnectionState.Open)
  12686. {
  12687. conn.Close();
  12688. }
  12689. }
  12690. }
  12691. /// <summary>
  12692. /// 取得PDA(产成品交接汇总表)的交接数量
  12693. /// </summary>
  12694. /// <param name="user">登录用户信息</param>
  12695. /// <param name="se">查询条件</param>
  12696. /// <returns>查询结果</returns>
  12697. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12698. {
  12699. IDBConnection conn = null;
  12700. try
  12701. {
  12702. DateTime dateStart = date;
  12703. DateTime dateEnd = dateStart.AddDays(1);
  12704. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12705. List<OracleParameter> parameters = new List<OracleParameter>();
  12706. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12707. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12708. " FROM tp_pm_finishedproduct f\n" +
  12709. " LEFT JOIN TP_PM_Order O\n" +
  12710. " ON f.Fhorderid = O.Orderid\n" +
  12711. " LEFT JOIN tp_mst_goods G\n" +
  12712. " ON g.goodsid = f.goodsid\n" +
  12713. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12714. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12715. " WHERE f.fhtime IS NOT NULL\n" +
  12716. " AND f.AccountID = :AccountID\n";
  12717. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12718. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12719. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12720. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12721. // 产品型号
  12722. if (!string.IsNullOrEmpty(goodscode))
  12723. {
  12724. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12725. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12726. }
  12727. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12728. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12729. ServiceResultEntity sre = new ServiceResultEntity();
  12730. if (data == null || data.Rows.Count == 0)
  12731. {
  12732. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12733. return sre;
  12734. }
  12735. sre.Data = new DataSet();
  12736. sre.Data.Tables.Add(data);
  12737. return sre;
  12738. }
  12739. catch (Exception ex)
  12740. {
  12741. throw ex;
  12742. }
  12743. finally
  12744. {
  12745. if (conn != null &&
  12746. conn.ConnState == ConnectionState.Open)
  12747. {
  12748. conn.Close();
  12749. }
  12750. }
  12751. }
  12752. /// <summary>
  12753. /// 获取在产品备份表
  12754. /// </summary>
  12755. /// <param name="cre"></param>
  12756. /// <param name="sUserInfo"></param>
  12757. /// <returns></returns>
  12758. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12759. {
  12760. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12761. try
  12762. {
  12763. ServiceResultEntity sre = new ServiceResultEntity();
  12764. string sqlString = "SELECT inpb.BackupMonth\n" +
  12765. " ,gdd.BarCode\n" +
  12766. //" ,inpb.GoodsID\n" +
  12767. " ,inpb.GoodsCode\n" +
  12768. " ,inpb.GoodsName\n" +
  12769. //" ,inpb.Userid\n" +
  12770. " ,worker.USERNAME AS UserName\n" +
  12771. " ,worker.USERCode AS UserCode\n" +
  12772. //" ,inpb.ProductionLineID\n" +
  12773. " ,inpb.ProductionLineCode\n" +
  12774. " ,inpb.ProductionLineName\n" +
  12775. //" ,inpb.ModelType\n" +
  12776. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12777. " ,inpb.IsPublicBody\n" +
  12778. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12779. " ,inpb.IsReworkFlag\n" +
  12780. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12781. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12782. //" ,inpb.GroutingDailyID\n" +
  12783. //" ,inpb.GroutingDailyDetailID\n" +
  12784. " ,inpb.GroutingDate\n" +
  12785. //" ,inpb.GroutingLineID\n" +
  12786. " ,inpb.GroutingLineCode\n" +
  12787. " ,inpb.GroutingLineName\n" +
  12788. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12789. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12790. //" ,inpb.GMouldTypeID\n" +
  12791. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12792. //" ,inpb.GroutingLineDetailID\n" +
  12793. " ,inpb.GroutingMouldCode\n" +
  12794. " ,inpb.SPECIALREPAIRFLAG\n" +
  12795. " ,inpb.GROUTINGUSERCODE\n" +
  12796. " ,gdd.GROUTINGCOUNT\n" +
  12797. " ,gdd.delivertime\n" +
  12798. " ,inpb.proceduretime\n" +
  12799. " ,inpb.Remarks\n" +
  12800. //" ,inpb.GoodsLevelID\n" +
  12801. " ,mgl.GOODSLEVELNAME\n" +
  12802. //" ,inpb.GoodsLevelTypeID\n" +
  12803. " ,mglt.GOODSLEVELTYPENAME\n" +
  12804. " ,inpb.BackupTime\n" +
  12805. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12806. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12807. " ,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" +
  12808. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12809. " INNER JOIN TP_MST_User worker\n" +
  12810. " ON worker.UserID = inpb.Userid\n" +
  12811. " INNER JOIN TP_PC_Procedure pro\n" +
  12812. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12813. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12814. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12815. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12816. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12817. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12818. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12819. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12820. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12821. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12822. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12823. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12824. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12825. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12826. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12827. " LEFT JOIN TP_MST_Logo logo\n" +
  12828. " ON inpb.logoid = logo.logoid\n" +
  12829. " LEFT JOIN TP_MST_Goods Goods\n" +
  12830. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12831. " WHERE inpb.AccountID = :AccountID" +
  12832. " AND inpb.BackupMonth = :BackupMonth" +
  12833. " ORDER BY pro.displayno,inpb.proceduretime";
  12834. OracleParameter[] oracleParameter = new OracleParameter[]
  12835. {
  12836. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12837. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12838. };
  12839. oracleConn.Open();
  12840. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12841. oracleConn.Close();
  12842. sre.Data = result;
  12843. return sre;
  12844. }
  12845. catch (Exception ex)
  12846. {
  12847. if (oracleConn.ConnState == ConnectionState.Open)
  12848. {
  12849. oracleConn.Close();
  12850. }
  12851. throw ex;
  12852. }
  12853. }
  12854. /// <summary>
  12855. /// 产成品单值明细表
  12856. /// </summary>
  12857. /// <param name="cre"></param>
  12858. /// <param name="sUserInfo"></param>
  12859. /// <returns></returns>
  12860. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12861. {
  12862. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12863. try
  12864. {
  12865. string sql =
  12866. "SELECT up.id, up.NAME\n" +
  12867. " FROM tp_mst_unitprice up\n" +
  12868. " WHERE up.accountid = :AccountID\n" +
  12869. " AND up.valueflag = '1'\n" +
  12870. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12871. " ORDER BY up.displayno";
  12872. OracleParameter[] opara = new OracleParameter[]
  12873. {
  12874. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12875. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12876. };
  12877. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  12878. StringBuilder upNames = new StringBuilder();
  12879. StringBuilder upTotals = new StringBuilder();
  12880. StringBuilder upSUMs = new StringBuilder();
  12881. foreach (DataRow item in upTable.Rows)
  12882. {
  12883. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  12884. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  12885. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  12886. }
  12887. ServiceResultEntity sre = new ServiceResultEntity();
  12888. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  12889. " ,g.goodscode\n" +
  12890. " ,g.materialcode\n" +
  12891. " ,lg.logoname\n" +
  12892. " ,nvl(fpcount, 0) fpcount\n" +
  12893. // " ,u1 AS \"单值1\"\n" +
  12894. //" ,u2 AS \"单值2\"\n" +
  12895. upNames +
  12896. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  12897. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  12898. upTotals +
  12899. " FROM (SELECT up.goodsid\n" +
  12900. " ,up.logoid\n" +
  12901. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  12902. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  12903. upSUMs +
  12904. " FROM TP_MST_UnitPriceGoods up\n" +
  12905. " WHERE up.accountid = :AccountID\n" +
  12906. " GROUP BY up.goodsid, up.logoid) upg\n" +
  12907. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  12908. " FROM tp_pm_finishedproduct fp\n" +
  12909. " WHERE fp.accountid = :AccountID\n" +
  12910. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  12911. " AND (:GoodsCode IS NULL OR\n" +
  12912. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  12913. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  12914. " ON fpp.goodsid = upg.goodsid\n" +
  12915. " AND fpp.logoid = upg.logoid\n" +
  12916. " INNER JOIN tp_mst_logo lg\n" +
  12917. " ON lg.logoid = upg.logoid\n" +
  12918. " INNER JOIN tp_mst_goods g\n" +
  12919. " ON g.goodsid = upg.goodsid\n" +
  12920. " INNER JOIN tp_mst_goodstype gt\n" +
  12921. " ON gt.goodstypeid = g.goodstypeid\n" +
  12922. " INNER JOIN tp_mst_goodstype gt2\n" +
  12923. " ON gt2.accountid = :AccountID\n" +
  12924. " AND length(gt2.goodstypecode) = 6\n" +
  12925. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  12926. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  12927. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  12928. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  12929. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  12930. " ORDER BY g.goodscode, lg.displayno";
  12931. OracleParameter[] oracleParameter = new OracleParameter[]
  12932. {
  12933. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12934. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  12935. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  12936. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  12937. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  12938. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  12939. };
  12940. oracleConn.Open();
  12941. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12942. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  12943. {
  12944. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12945. }
  12946. sre.Data = result;
  12947. oracleConn.Close();
  12948. return sre;
  12949. }
  12950. catch (Exception ex)
  12951. {
  12952. if (oracleConn.ConnState == ConnectionState.Open)
  12953. {
  12954. oracleConn.Close();
  12955. }
  12956. throw ex;
  12957. }
  12958. }
  12959. /// <summary>
  12960. /// 产成品单值明细表-单值名管理
  12961. /// </summary>
  12962. /// <param name="cre"></param>
  12963. /// <param name="sUserInfo"></param>
  12964. /// <returns></returns>
  12965. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12966. {
  12967. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12968. try
  12969. {
  12970. ServiceResultEntity sre = new ServiceResultEntity();
  12971. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  12972. " FROM TP_MST_UnitPrice t\n" +
  12973. " WHERE t.accountid = :accountid\n" +
  12974. " ORDER BY t.id";
  12975. OracleParameter[] oracleParameter = new OracleParameter[]
  12976. {
  12977. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12978. };
  12979. oracleConn.Open();
  12980. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12981. oracleConn.Close();
  12982. return sre;
  12983. }
  12984. catch (Exception ex)
  12985. {
  12986. if (oracleConn.ConnState == ConnectionState.Open)
  12987. {
  12988. oracleConn.Close();
  12989. }
  12990. throw ex;
  12991. }
  12992. }
  12993. /// <summary>
  12994. /// 产成品单值明细表-单值名管理
  12995. /// </summary>
  12996. /// <param name="cre"></param>
  12997. /// <param name="sUserInfo"></param>
  12998. /// <returns></returns>
  12999. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13000. {
  13001. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13002. try
  13003. {
  13004. ServiceResultEntity sre = new ServiceResultEntity();
  13005. // 检验参数的有效性
  13006. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  13007. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  13008. {
  13009. return sre;
  13010. }
  13011. oracleTrConn.Connect();
  13012. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  13013. {
  13014. // 新建
  13015. if (dataRow.RowState == DataRowState.Added)
  13016. {
  13017. #region 新增
  13018. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13019. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13020. "VALUES\n" +
  13021. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13022. OracleParameter[] oracleParameter = new OracleParameter[]
  13023. {
  13024. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13025. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13026. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13027. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13028. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13029. };
  13030. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13031. #endregion
  13032. }
  13033. else if (dataRow.RowState == DataRowState.Modified)
  13034. {
  13035. #region 更新
  13036. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13037. + " Name = :Name,"
  13038. + " DisplayNo = :DisplayNo,"
  13039. + " ValueFlag = :ValueFlag,"
  13040. + " UpdateUserID = :UserID"
  13041. + " WHERE ID = :ID";
  13042. OracleParameter[] oracleParameter = new OracleParameter[]
  13043. {
  13044. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13045. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13046. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13047. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13048. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13049. };
  13050. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13051. #endregion
  13052. }
  13053. else if (dataRow.RowState == DataRowState.Deleted)
  13054. {
  13055. #region 删除
  13056. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13057. OracleParameter[] oracleParameter = new OracleParameter[]
  13058. {
  13059. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13060. };
  13061. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13062. #endregion
  13063. }
  13064. }
  13065. oracleTrConn.Commit();
  13066. oracleTrConn.Disconnect();
  13067. return sre;
  13068. }
  13069. catch (Exception ex)
  13070. {
  13071. if (oracleTrConn.ConnState == ConnectionState.Open)
  13072. {
  13073. oracleTrConn.Rollback();
  13074. oracleTrConn.Disconnect();
  13075. }
  13076. throw ex;
  13077. }
  13078. finally
  13079. {
  13080. if (oracleTrConn.ConnState == ConnectionState.Open)
  13081. {
  13082. oracleTrConn.Disconnect();
  13083. }
  13084. }
  13085. }
  13086. /// <summary>
  13087. /// 获取模具跟踪表
  13088. /// </summary>
  13089. /// <param name="cre"></param>
  13090. /// <param name="sUserInfo"></param>
  13091. /// <returns></returns>
  13092. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13093. {
  13094. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13095. try
  13096. {
  13097. ServiceResultEntity sre = new ServiceResultEntity();
  13098. OracleParameter[] oracleParameter = new OracleParameter[]
  13099. {
  13100. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13101. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13102. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13103. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13104. };
  13105. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", 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. return sre;
  13112. }
  13113. catch (Exception ex)
  13114. {
  13115. if (oracleConn.ConnState == ConnectionState.Open)
  13116. {
  13117. oracleConn.Close();
  13118. }
  13119. throw ex;
  13120. }
  13121. }
  13122. /// <summary>
  13123. /// 获取模具收发存汇总表
  13124. /// </summary>
  13125. /// <param name="cre"></param>
  13126. /// <param name="sUserInfo"></param>
  13127. /// <returns></returns>
  13128. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13129. {
  13130. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13131. try
  13132. {
  13133. ServiceResultEntity sre = new ServiceResultEntity();
  13134. OracleParameter[] oracleParameter = new OracleParameter[]
  13135. {
  13136. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13137. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], 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_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13141. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13142. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13143. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13144. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13145. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13146. };
  13147. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13148. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13149. {
  13150. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13151. }
  13152. sre.Data = result;
  13153. oracleConn.Commit();
  13154. return sre;
  13155. }
  13156. catch (Exception ex)
  13157. {
  13158. if (oracleConn.ConnState == ConnectionState.Open)
  13159. {
  13160. oracleConn.Disconnect();
  13161. }
  13162. throw ex;
  13163. }
  13164. }
  13165. /// <summary>
  13166. /// 获取废弃产品汇总表
  13167. /// </summary>
  13168. /// <param name="cre"></param>
  13169. /// <param name="sUserInfo"></param>
  13170. /// <returns></returns>
  13171. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13172. {
  13173. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13174. try
  13175. {
  13176. ServiceResultEntity sre = new ServiceResultEntity();
  13177. OracleParameter[] oracleParameter = new OracleParameter[]
  13178. {
  13179. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13180. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13181. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13182. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13183. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], 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("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13187. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13188. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13189. };
  13190. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13191. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13192. {
  13193. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13194. }
  13195. sre.Data = result;
  13196. oracleConn.Commit();
  13197. return sre;
  13198. }
  13199. catch (Exception ex)
  13200. {
  13201. if (oracleConn.ConnState == ConnectionState.Open)
  13202. {
  13203. oracleConn.Disconnect();
  13204. }
  13205. throw ex;
  13206. }
  13207. }
  13208. /// <summary>
  13209. /// 获取废品损失汇总表
  13210. /// </summary>
  13211. /// <param name="cre"></param>
  13212. /// <param name="sUserInfo"></param>
  13213. /// <returns></returns>
  13214. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13215. {
  13216. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13217. try
  13218. {
  13219. ServiceResultEntity sre = new ServiceResultEntity();
  13220. OracleParameter[] oracleParameter = new OracleParameter[]
  13221. {
  13222. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13223. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13224. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13225. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13226. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13227. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13228. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13229. };
  13230. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13231. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13232. {
  13233. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13234. }
  13235. sre.Data = result;
  13236. oracleConn.Commit();
  13237. return sre;
  13238. }
  13239. catch (Exception ex)
  13240. {
  13241. if (oracleConn.ConnState == ConnectionState.Open)
  13242. {
  13243. oracleConn.Disconnect();
  13244. }
  13245. throw ex;
  13246. }
  13247. }
  13248. /// <summary>
  13249. /// 获取废品损失汇总-明细表
  13250. /// </summary>
  13251. /// <param name="cre"></param>
  13252. /// <param name="sUserInfo"></param>
  13253. /// <returns></returns>
  13254. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13255. {
  13256. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13257. try
  13258. {
  13259. ServiceResultEntity sre = new ServiceResultEntity();
  13260. OracleParameter[] oracleParameter = new OracleParameter[]
  13261. {
  13262. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13263. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13264. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13265. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13266. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13267. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13268. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13269. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13270. };
  13271. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13272. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13273. {
  13274. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13275. }
  13276. sre.Data = result;
  13277. oracleConn.Commit();
  13278. return sre;
  13279. }
  13280. catch (Exception ex)
  13281. {
  13282. if (oracleConn.ConnState == ConnectionState.Open)
  13283. {
  13284. oracleConn.Disconnect();
  13285. }
  13286. throw ex;
  13287. }
  13288. }
  13289. /// <summary>
  13290. /// 获取废品损失汇总表-半成品损失汇总表
  13291. /// </summary>
  13292. /// <param name="cre"></param>
  13293. /// <param name="sUserInfo"></param>
  13294. /// <returns></returns>
  13295. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13296. {
  13297. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13298. try
  13299. {
  13300. ServiceResultEntity sre = new ServiceResultEntity();
  13301. OracleParameter[] oracleParameter = new OracleParameter[]
  13302. {
  13303. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13304. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13305. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13306. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13307. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13308. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13309. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13310. };
  13311. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13312. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13313. {
  13314. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13315. }
  13316. StringBuilder cols = new StringBuilder();
  13317. StringBuilder sumCols = new StringBuilder();
  13318. foreach (DataRow item in result.Tables[0].Rows)
  13319. {
  13320. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13321. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13322. }
  13323. string sqlString = "SELECT gid\n" +
  13324. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13325. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13326. " ,gg.gc\n" +
  13327. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13328. " ,d\n" +
  13329. " ,c\n" +
  13330. " ,d-c g\n" +
  13331. cols +
  13332. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13333. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13334. " ,t.tecdepname gt2name\n" +
  13335. " ,td2.name td2name\n" +
  13336. " ,td2.displayno td2displayno\n" +
  13337. " ,SUM(g.d) d\n" +
  13338. " ,SUM(g.c) c\n" +
  13339. sumCols +
  13340. " FROM TMP_RPT_TECDEP_G g\n" +
  13341. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13342. " ON g.goodsid = t.goodsid\n" +
  13343. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13344. " ON s1.procedureid = g.pid\n" +
  13345. " INNER JOIN tp_mst_tecdep td1\n" +
  13346. " ON td1.id = s1.intecdepid\n" +
  13347. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13348. " ON s2.procedureid = g.f\n" +
  13349. " LEFT JOIN tp_mst_tecdep td2\n" +
  13350. " ON td2.id = s2.intecdepid\n" +
  13351. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13352. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13353. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13354. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13355. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13356. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13357. " FROM tp_pm_groutingdailydetail gdd\n" +
  13358. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13359. " ON gdd.goodsid = t.goodsid\n" +
  13360. " WHERE gdd.accountid = :in_accountid\n" +
  13361. " AND gdd.valueflag = '1'\n" +
  13362. " AND gdd.groutingflag = '1'\n" +
  13363. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13364. " :in_datetimeend\n" +
  13365. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13366. " ON gg.gt2id = tt.gt2id\n" +
  13367. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13368. oracleParameter = new OracleParameter[]
  13369. {
  13370. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13371. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13372. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13373. };
  13374. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13375. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13376. {
  13377. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13378. }
  13379. sre.Data = result;
  13380. oracleConn.Commit();
  13381. return sre;
  13382. }
  13383. catch (Exception ex)
  13384. {
  13385. if (oracleConn.ConnState == ConnectionState.Open)
  13386. {
  13387. oracleConn.Disconnect();
  13388. }
  13389. throw ex;
  13390. }
  13391. }
  13392. /// <summary>
  13393. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13394. /// </summary>
  13395. /// <param name="cre"></param>
  13396. /// <param name="sUserInfo"></param>
  13397. /// <returns></returns>
  13398. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13399. {
  13400. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13401. try
  13402. {
  13403. ServiceResultEntity sre = new ServiceResultEntity();
  13404. /*
  13405. string sqlString =
  13406. "SELECT gdrd.goodsid\n" +
  13407. " ,gdrd.goodscode\n" +
  13408. //" ,gdrd.groutinglineid\n" +
  13409. //" ,gdrd.groutinglinecode\n" +
  13410. //" ,gdrd.userid\n" +
  13411. //" ,gdrd.usercode\n" +
  13412. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13413. " ,rdd.gldcount -- 模具数\n" +
  13414. " , CASE\n" +
  13415. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13416. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13417. " ELSE\n" +
  13418. " NULL\n" +
  13419. " END rddays -- 存坯天数\n" +
  13420. " ,gdrd.reserveddays -- 应存天数\n" +
  13421. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13422. " FROM (SELECT gdd.goodsid\n" +
  13423. " ,gdd.goodscode\n" +
  13424. //" ,gdd.groutinglineid\n" +
  13425. //" ,gdd.groutinglinecode\n" +
  13426. //" ,gdd.userid\n" +
  13427. //" ,gdd.usercode\n" +
  13428. " ,g.reserveddays\n" +
  13429. " ,COUNT(*) gddc\n" +
  13430. " FROM tp_pm_groutingdailydetail gdd\n" +
  13431. " INNER JOIN tp_mst_goods g\n" +
  13432. " ON g.goodsid = gdd.goodsid\n" +
  13433. " INNER JOIN tp_mst_goodstype gt\n" +
  13434. " ON g.goodstypeid = gt.goodstypeid\n" +
  13435. " WHERE gdd.accountid = :accountid\n" +
  13436. " AND gdd.valueflag = '1'\n" +
  13437. " AND gdd.groutingflag = '1'\n" +
  13438. " AND gdd.barcode IS NOT NULL\n" +
  13439. " AND gdd.scrapflag = '0'\n" +
  13440. " AND gdd.deliverflag = '0'\n" +
  13441. " AND (:LineCode IS NULL OR\n" +
  13442. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13443. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13444. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13445. " AND (:GoodsTypeCode IS NULL OR\n" +
  13446. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13447. " AND (:DateBegin IS NULL OR\n" +
  13448. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13449. " GROUP BY gdd.goodsid\n" +
  13450. " ,gdd.goodscode\n" +
  13451. //" ,gdd.groutinglineid\n" +
  13452. //" ,gdd.groutinglinecode\n" +
  13453. //" ,gdd.userid\n" +
  13454. //" ,gdd.usercode\n" +
  13455. " ,g.reserveddays) gdrd\n" +
  13456. " LEFT JOIN (SELECT gld.goodsid\n" +
  13457. //" ,gld.groutinglineid\n" +
  13458. " ,COUNT(*) gldcount\n" +
  13459. " FROM tp_pc_groutinglinedetail gld\n" +
  13460. " INNER JOIN tp_pc_groutingline gl\n" +
  13461. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13462. " WHERE gld.valueflag = '1'\n" +
  13463. " AND gld.gmouldstatus = 1\n" +
  13464. " AND gl.accountid = :accountid\n" +
  13465. " AND gl.valueflag = '1'\n" +
  13466. " AND gl.gmouldstatus = 1\n" +
  13467. " GROUP BY gld.goodsid\n" +
  13468. //" ,gld.groutinglineid\n" +
  13469. " ) rdd\n" +
  13470. " ON rdd.goodsid = gdrd.goodsid\n" +
  13471. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13472. " ORDER BY gdrd.goodscode\n" +
  13473. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13474. "";
  13475. */
  13476. string sqlString =
  13477. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13478. " ,t.goodstypecode2\n" +
  13479. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13480. " 3,\n" +
  13481. " '总计',\n" +
  13482. " 1,\n" +
  13483. " '合计[' || t.goodstypename2 || ']',\n" +
  13484. " t.goodstypename2) goodstypename2\n" +
  13485. " ,t.goodstypename\n" +
  13486. " ,t.goodsid\n" +
  13487. " ,t.goodscode\n" +
  13488. //" ,t.groutinglineid\n" +
  13489. //" ,t.groutinglinecode\n" +
  13490. //" ,t.userid\n" +
  13491. //" ,t.usercode\n" +
  13492. " ,SUM(t.rdcount) rdcount\n" +
  13493. " ,t.gldcount -- 模具数\n" +
  13494. " ,t.rddays -- 存坯天数\n" +
  13495. " ,t.reserveddays -- 应存天数\n" +
  13496. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13497. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13498. " ,gt2.goodstypename goodstypename2\n" +
  13499. " ,gdrd.goodsid\n" +
  13500. " ,gdrd.goodscode\n" +
  13501. " ,gdrd.goodstypename\n" +
  13502. //" ,gdrd.groutinglineid\n" +
  13503. //" ,gdrd.groutinglinecode\n" +
  13504. //" ,gdrd.userid\n" +
  13505. //" ,gdrd.usercode\n" +
  13506. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13507. " ,rdd.gldcount -- 模具数\n" +
  13508. " , CASE\n" +
  13509. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13510. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13511. " ELSE\n" +
  13512. " NULL\n" +
  13513. " END rddays -- 存坯天数\n" +
  13514. " ,gdrd.reserveddays -- 应存天数\n" +
  13515. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13516. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13517. " FROM (SELECT gdd.goodsid\n" +
  13518. " ,gdd.goodscode\n" +
  13519. //" ,gdd.groutinglineid\n" +
  13520. //" ,gdd.groutinglinecode\n" +
  13521. //" ,gdd.userid\n" +
  13522. //" ,gdd.usercode\n" +
  13523. " ,g.reserveddays\n" +
  13524. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13525. " ,gt.goodstypename\n" +
  13526. " ,COUNT(*) gddc\n" +
  13527. " FROM tp_pm_groutingdailydetail gdd\n" +
  13528. " INNER JOIN tp_mst_goods g\n" +
  13529. " ON g.goodsid = gdd.goodsid\n" +
  13530. " INNER JOIN tp_mst_goodstype gt\n" +
  13531. " ON g.goodstypeid = gt.goodstypeid\n" +
  13532. " WHERE gdd.accountid = :accountid\n" +
  13533. " AND gdd.valueflag = '1'\n" +
  13534. " AND gdd.groutingflag = '1'\n" +
  13535. " AND gdd.barcode IS NOT NULL\n" +
  13536. " AND gdd.scrapflag = '0'\n" +
  13537. " AND gdd.deliverflag = '0'\n" +
  13538. " AND (:LineCode IS NULL OR\n" +
  13539. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13540. " AND (:UserCode IS NULL OR\n" +
  13541. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13542. " AND (:GoodsCode IS NULL OR\n" +
  13543. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13544. " AND (:GoodsTypeCode IS NULL OR\n" +
  13545. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13546. " AND (:DateBegin IS NULL OR\n" +
  13547. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13548. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13549. " ,gdd.goodsid\n" +
  13550. " ,gdd.goodscode\n" +
  13551. //" ,gdd.groutinglineid\n" +
  13552. //" ,gdd.groutinglinecode\n" +
  13553. //" ,gdd.userid\n" +
  13554. //" ,gdd.usercode\n" +
  13555. " ,g.reserveddays) gdrd\n" +
  13556. " LEFT JOIN (SELECT gld.goodsid\n" +
  13557. //" ,gld.groutinglineid\n" +
  13558. " ,COUNT(*) gldcount\n" +
  13559. " FROM tp_pc_groutinglinedetail gld\n" +
  13560. " INNER JOIN tp_pc_groutingline gl\n" +
  13561. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13562. " WHERE gld.valueflag = '1'\n" +
  13563. " AND gld.gmouldstatus = 1\n" +
  13564. " AND gl.accountid = :accountid\n" +
  13565. " AND gl.valueflag = '1'\n" +
  13566. " AND gl.gmouldstatus = 1\n" +
  13567. " GROUP BY gld.goodsid\n" +
  13568. //" , gld.groutinglineid" +
  13569. " ) rdd\n" +
  13570. " ON rdd.goodsid = gdrd.goodsid\n" +
  13571. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13572. " INNER JOIN tp_mst_goodstype gt2\n" +
  13573. " ON gt2.accountid = :accountid\n" +
  13574. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13575. " ORDER BY gt2.goodstypecode\n" +
  13576. " ,gdrd.goodscode\n" +
  13577. //" ,gdrd.groutinglinecode\n" +
  13578. //" ,gdrd.usercode" +
  13579. " ) t\n" +
  13580. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13581. OracleParameter[] oracleParameter = new OracleParameter[]
  13582. {
  13583. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13584. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13585. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13586. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13587. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13588. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13589. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13590. };
  13591. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13592. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13593. {
  13594. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13595. }
  13596. sre.Data = result;
  13597. return sre;
  13598. }
  13599. catch (Exception ex)
  13600. {
  13601. if (oracleConn.ConnState == ConnectionState.Open)
  13602. {
  13603. oracleConn.Close();
  13604. }
  13605. throw ex;
  13606. }
  13607. }
  13608. /// <summary>
  13609. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13610. /// </summary>
  13611. /// <param name="cre"></param>
  13612. /// <param name="sUserInfo"></param>
  13613. /// <returns></returns>
  13614. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13615. {
  13616. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13617. try
  13618. {
  13619. ServiceResultEntity sre = new ServiceResultEntity();
  13620. /*
  13621. string sqlString =
  13622. "SELECT gdrd.goodsid\n" +
  13623. " ,gdrd.goodscode\n" +
  13624. " ,gdrd.groutinglineid\n" +
  13625. " ,gdrd.groutinglinecode\n" +
  13626. " ,gdrd.userid\n" +
  13627. " ,gdrd.usercode\n" +
  13628. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13629. " ,rdd.gldcount -- 模具数\n" +
  13630. " , CASE\n" +
  13631. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13632. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13633. " ELSE\n" +
  13634. " NULL\n" +
  13635. " END rddays -- 存坯天数\n" +
  13636. " ,gdrd.reserveddays -- 应存天数\n" +
  13637. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13638. " FROM (SELECT gdd.goodsid\n" +
  13639. " ,gdd.goodscode\n" +
  13640. " ,gdd.groutinglineid\n" +
  13641. " ,gdd.groutinglinecode\n" +
  13642. " ,gdd.userid\n" +
  13643. " ,gdd.usercode\n" +
  13644. " ,g.reserveddays\n" +
  13645. " ,COUNT(*) gddc\n" +
  13646. " FROM tp_pm_groutingdailydetail gdd\n" +
  13647. " INNER JOIN tp_mst_goods g\n" +
  13648. " ON g.goodsid = gdd.goodsid\n" +
  13649. " INNER JOIN tp_mst_goodstype gt\n" +
  13650. " ON g.goodstypeid = gt.goodstypeid\n" +
  13651. " WHERE gdd.accountid = :accountid\n" +
  13652. " AND gdd.valueflag = '1'\n" +
  13653. " AND gdd.groutingflag = '1'\n" +
  13654. " AND gdd.barcode IS NOT NULL\n" +
  13655. " AND gdd.scrapflag = '0'\n" +
  13656. " AND gdd.deliverflag = '0'\n" +
  13657. " AND (:LineCode IS NULL OR\n" +
  13658. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13659. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13660. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13661. " AND (:GoodsTypeCode IS NULL OR\n" +
  13662. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13663. " AND (:DateBegin IS NULL OR\n" +
  13664. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13665. " GROUP BY gdd.goodsid\n" +
  13666. " ,gdd.goodscode\n" +
  13667. " ,gdd.groutinglineid\n" +
  13668. " ,gdd.groutinglinecode\n" +
  13669. " ,gdd.userid\n" +
  13670. " ,gdd.usercode\n" +
  13671. " ,g.reserveddays) gdrd\n" +
  13672. " LEFT JOIN (SELECT gld.goodsid\n" +
  13673. " ,gld.groutinglineid\n" +
  13674. " ,COUNT(*) gldcount\n" +
  13675. " FROM tp_pc_groutinglinedetail gld\n" +
  13676. " INNER JOIN tp_pc_groutingline gl\n" +
  13677. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13678. " WHERE gld.valueflag = '1'\n" +
  13679. " AND gld.gmouldstatus = 1\n" +
  13680. " AND gl.accountid = :accountid\n" +
  13681. " AND gl.valueflag = '1'\n" +
  13682. " AND gl.gmouldstatus = 1\n" +
  13683. " GROUP BY gld.goodsid\n" +
  13684. " ,gld.groutinglineid\n" +
  13685. " ) rdd\n" +
  13686. " ON rdd.goodsid = gdrd.goodsid\n" +
  13687. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13688. " ORDER BY gdrd.goodscode\n" +
  13689. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13690. "";
  13691. */
  13692. string sqlString =
  13693. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13694. " ,t.goodstypecode2\n" +
  13695. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13696. " 3,\n" +
  13697. " '总计',\n" +
  13698. " 1,\n" +
  13699. " '合计[' || t.goodstypename2 || ']',\n" +
  13700. " t.goodstypename2) goodstypename2\n" +
  13701. " ,t.goodsid\n" +
  13702. " ,t.goodscode\n" +
  13703. " ,t.groutinglineid\n" +
  13704. " ,t.groutinglinecode\n" +
  13705. " ,t.userid\n" +
  13706. " ,t.usercode\n" +
  13707. " ,t.MONITORName\n" +
  13708. " ,SUM(t.rdcount) rdcount\n" +
  13709. " ,t.gldcount -- 模具数\n" +
  13710. " ,t.rddays -- 存坯天数\n" +
  13711. " ,t.reserveddays -- 应存天数\n" +
  13712. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13713. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13714. " ,gt2.goodstypename goodstypename2\n" +
  13715. " ,gdrd.goodsid\n" +
  13716. " ,gdrd.goodscode\n" +
  13717. " ,gdrd.groutinglineid\n" +
  13718. " ,gdrd.groutinglinecode\n" +
  13719. " ,gdrd.userid\n" +
  13720. " ,gdrd.usercode\n" +
  13721. " ,mu.username MONITORName\n" +
  13722. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13723. " ,rdd.gldcount -- 模具数\n" +
  13724. " , CASE\n" +
  13725. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13726. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13727. " ELSE\n" +
  13728. " NULL\n" +
  13729. " END rddays -- 存坯天数\n" +
  13730. " ,gdrd.reserveddays -- 应存天数\n" +
  13731. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13732. " FROM (SELECT gdd.goodsid\n" +
  13733. " ,gdd.goodscode\n" +
  13734. " ,gdd.groutinglineid\n" +
  13735. " ,gdd.groutinglinecode\n" +
  13736. " ,gdd.userid\n" +
  13737. " ,gdd.usercode\n" +
  13738. " ,g.reserveddays\n" +
  13739. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13740. " ,COUNT(*) gddc\n" +
  13741. " FROM tp_pm_groutingdailydetail gdd\n" +
  13742. " INNER JOIN tp_mst_goods g\n" +
  13743. " ON g.goodsid = gdd.goodsid\n" +
  13744. " INNER JOIN tp_mst_goodstype gt\n" +
  13745. " ON g.goodstypeid = gt.goodstypeid\n" +
  13746. " WHERE gdd.accountid = :accountid\n" +
  13747. " AND gdd.valueflag = '1'\n" +
  13748. " AND gdd.groutingflag = '1'\n" +
  13749. " AND gdd.barcode IS NOT NULL\n" +
  13750. " AND gdd.scrapflag = '0'\n" +
  13751. " AND gdd.deliverflag = '0'\n" +
  13752. " AND (:LineCode IS NULL OR\n" +
  13753. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13754. " AND (:UserCode IS NULL OR\n" +
  13755. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13756. " AND (:GoodsCode IS NULL OR\n" +
  13757. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13758. " AND (:GoodsTypeCode IS NULL OR\n" +
  13759. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13760. " AND (:DateBegin IS NULL OR\n" +
  13761. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13762. " GROUP BY gt.goodstypecode\n" +
  13763. " ,gdd.goodsid\n" +
  13764. " ,gdd.goodscode\n" +
  13765. " ,gdd.groutinglineid\n" +
  13766. " ,gdd.groutinglinecode\n" +
  13767. " ,gdd.userid\n" +
  13768. " ,gdd.usercode\n" +
  13769. " ,g.reserveddays) gdrd\n" +
  13770. " LEFT JOIN (SELECT gld.goodsid\n" +
  13771. " ,gld.groutinglineid\n" +
  13772. " ,gl.MONITORID\n" +
  13773. " ,COUNT(*) gldcount\n" +
  13774. " FROM tp_pc_groutinglinedetail gld\n" +
  13775. " INNER JOIN tp_pc_groutingline gl\n" +
  13776. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13777. " WHERE gld.valueflag = '1'\n" +
  13778. " AND gld.gmouldstatus = 1\n" +
  13779. " AND gl.accountid = :accountid\n" +
  13780. " AND gl.valueflag = '1'\n" +
  13781. " AND gl.gmouldstatus = 1\n" +
  13782. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  13783. " ON rdd.goodsid = gdrd.goodsid\n" +
  13784. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13785. // 成型班长
  13786. " LEFT JOIN tp_mst_user mu\n" +
  13787. " ON mu.userid = rdd.MONITORID\n" +
  13788. " INNER JOIN tp_mst_goodstype gt2\n" +
  13789. " ON gt2.accountid = :accountid\n" +
  13790. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13791. " ORDER BY gt2.goodstypecode\n" +
  13792. " ,gdrd.goodscode\n" +
  13793. " ,gdrd.groutinglinecode\n" +
  13794. " ,gdrd.usercode) t\n" +
  13795. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2, t.goodsid, t.goodscode, t.groutinglineid, t.groutinglinecode, t.userid, t.usercode,t.MONITORName, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13796. OracleParameter[] oracleParameter = new OracleParameter[]
  13797. {
  13798. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13799. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13800. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13801. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13802. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13803. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13804. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13805. };
  13806. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13807. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13808. {
  13809. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13810. }
  13811. sre.Data = result;
  13812. return sre;
  13813. }
  13814. catch (Exception ex)
  13815. {
  13816. if (oracleConn.ConnState == ConnectionState.Open)
  13817. {
  13818. oracleConn.Close();
  13819. }
  13820. throw ex;
  13821. }
  13822. }
  13823. /// <summary>
  13824. /// 获取成型存坯汇总表-成型存坯明细表
  13825. /// </summary>
  13826. /// <param name="cre"></param>
  13827. /// <param name="sUserInfo"></param>
  13828. /// <returns></returns>
  13829. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13830. {
  13831. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13832. try
  13833. {
  13834. ServiceResultEntity sre = new ServiceResultEntity();
  13835. string sqlString = "SELECT gdd.barcode\n" +
  13836. //" ,gdd.groutinglineid\n" +
  13837. " ,gdd.groutinglinecode\n" +
  13838. " ,gdd.GroutingMouldCode\n" +
  13839. //" ,gdd.goodsid\n" +
  13840. " ,gdd.goodscode\n" +
  13841. //" ,gdd.userid\n" +
  13842. " ,gdd.usercode\n" +
  13843. " ,gdd.groutingdate\n" +
  13844. // 成型班长
  13845. " ,mu.username as MONITORName" +
  13846. " FROM tp_pm_groutingdailydetail gdd\n" +
  13847. " INNER JOIN tp_mst_goods g\n" +
  13848. " ON g.goodsid = gdd.goodsid\n" +
  13849. // 成型线
  13850. " LEFT JOIN tp_pc_groutingline gl" +
  13851. " ON gl.groutinglineid = GDD.GroutingLineID" +
  13852. // 成型班长
  13853. " LEFT JOIN tp_mst_user mu" +
  13854. " ON mu.userid = gl.MONITORID " +
  13855. " INNER JOIN tp_mst_goodstype gt\n" +
  13856. " ON g.goodstypeid = gt.goodstypeid\n" +
  13857. " WHERE gdd.accountid = :accountid\n" +
  13858. " AND gdd.valueflag = '1'\n" +
  13859. " AND gdd.groutingflag = '1'\n" +
  13860. " AND gdd.barcode IS NOT NULL\n" +
  13861. " AND gdd.scrapflag = '0'\n" +
  13862. " AND gdd.deliverflag = '0'\n" +
  13863. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13864. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13865. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13866. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13867. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13868. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13869. " AND (:GoodsTypeCode IS NULL OR\n" +
  13870. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13871. " AND (:DateBegin IS NULL OR\n" +
  13872. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13873. " ORDER BY gdd.barcode\n" +
  13874. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13875. "";
  13876. OracleParameter[] oracleParameter = new OracleParameter[]
  13877. {
  13878. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13879. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13880. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13881. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13882. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13883. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13884. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13885. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13886. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  13887. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  13888. };
  13889. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13890. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13891. {
  13892. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13893. }
  13894. sre.Data = result;
  13895. return sre;
  13896. }
  13897. catch (Exception ex)
  13898. {
  13899. if (oracleConn.ConnState == ConnectionState.Open)
  13900. {
  13901. oracleConn.Close();
  13902. }
  13903. throw ex;
  13904. }
  13905. }
  13906. /// <summary>
  13907. /// 年度各工序月产量统计表
  13908. /// </summary>
  13909. /// <param name="cre"></param>
  13910. /// <param name="sUserInfo"></param>
  13911. /// <returns></returns>
  13912. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13913. {
  13914. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13915. try
  13916. {
  13917. ServiceResultEntity sre = new ServiceResultEntity();
  13918. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  13919. string sqlString = "select gt2.goodstypecode\n" +
  13920. " ,nvl2(gt2.goodstypename\n" +
  13921. " ,nvl2(t.procedureid\n" +
  13922. " ,gt2.goodstypename\n" +
  13923. " ,'小计[' || gt2.goodstypename || ']')\n" +
  13924. " ,'总计') goodstypename\n" +
  13925. " ,p.displayno\n" +
  13926. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  13927. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  13928. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  13929. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  13930. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  13931. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  13932. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  13933. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  13934. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  13935. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  13936. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  13937. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  13938. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  13939. " ,sum(t.pcount) msum\n" +
  13940. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13941. " gt.goodstypecode\n" +
  13942. " ,0 procedureid\n" +
  13943. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  13944. " ,count(*) pcount\n" +
  13945. " from tp_pm_groutingdailydetail pd\n" +
  13946. " inner join tp_mst_goods g\n" +
  13947. " on g.goodsid = pd.goodsid\n" +
  13948. " inner join tp_mst_goodstype gt\n" +
  13949. " on gt.goodstypeid = g.goodstypeid\n" +
  13950. " where pd.accountid = :accountid\n" +
  13951. " and pd.groutingflag = '1'\n" +
  13952. " and pd.groutingdate >= :begindate\n" +
  13953. " and pd.groutingdate < :enddate\n" +
  13954. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13955. " gt.goodstypecode\n" +
  13956. " ,to_char(pd.groutingdate, 'mm')\n" +
  13957. " union all\n" +
  13958. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13959. " gt.goodstypecode\n" +
  13960. " ,pd.procedureid\n" +
  13961. " ,to_char(pd.createtime, 'mm') mm\n" +
  13962. " ,count(*) pcount\n" +
  13963. " from tp_pm_productiondata pd\n" +
  13964. " inner join tp_mst_goods g\n" +
  13965. " on g.goodsid = pd.goodsid\n" +
  13966. " inner join tp_mst_goodstype gt\n" +
  13967. " on gt.goodstypeid = g.goodstypeid\n" +
  13968. " where pd.accountid = :accountid\n" +
  13969. " and pd.createtime >= :begindate\n" +
  13970. " and pd.createtime < :enddate\n" +
  13971. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13972. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13973. " gt.goodstypecode\n" +
  13974. " ,pd.procedureid\n" +
  13975. " ,to_char(pd.createtime, 'mm')" +
  13976. " union all\n" +
  13977. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13978. " gt.goodstypecode\n" +
  13979. " ,pd.procedureid\n" +
  13980. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  13981. " ,count(*) pcount\n" +
  13982. " from tp_pm_productiondata pd\n" +
  13983. " inner join tp_mst_goods g\n" +
  13984. " on g.goodsid = pd.goodsid\n" +
  13985. " inner join tp_mst_goodstype gt\n" +
  13986. " on gt.goodstypeid = g.goodstypeid\n" +
  13987. " where pd.accountid = :accountid\n" +
  13988. " and pd.valueflag = '0'\n" +
  13989. " and pd.BACKOUTTIME >= :begindate\n" +
  13990. " and pd.BACKOUTTIME < :enddate\n" +
  13991. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13992. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13993. " gt.goodstypecode\n" +
  13994. " ,pd.procedureid\n" +
  13995. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  13996. " inner join tp_mst_goodstype gt2\n" +
  13997. " on gt2.accountid = 1\n" +
  13998. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  13999. " left join tp_pc_procedure p\n" +
  14000. " on p.procedureid = t.procedureid\n" +
  14001. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  14002. OracleParameter[] oracleParameter = new OracleParameter[]
  14003. {
  14004. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14005. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14006. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14007. };
  14008. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14009. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14010. {
  14011. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14012. }
  14013. sre.Data = result;
  14014. return sre;
  14015. }
  14016. catch (Exception ex)
  14017. {
  14018. throw ex;
  14019. }
  14020. finally
  14021. {
  14022. oracleConn?.Close();
  14023. }
  14024. }
  14025. /// <summary>
  14026. /// 半检返修缺陷汇总表
  14027. /// </summary>
  14028. /// <param name="cre"></param>
  14029. /// <param name="sUserInfo"></param>
  14030. /// <returns></returns>
  14031. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14032. {
  14033. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14034. try
  14035. {
  14036. ServiceResultEntity sre = new ServiceResultEntity();
  14037. string sqlString = "select dp.defectpositionid\n" +
  14038. " ,dp.defectpositioncode\n" +
  14039. " ,dp.defectpositionname\n" +
  14040. " ,'D_' || dp.defectpositionid colname\n" +
  14041. " from tp_mst_scdefectposition dp\n" +
  14042. " where dp.valueflag = '1'\n" +
  14043. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14044. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14045. {
  14046. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14047. }
  14048. sqlString += " order by dp.displayno";
  14049. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14050. if (scdTable == null || scdTable.Rows.Count == 0)
  14051. {
  14052. return sre;
  14053. }
  14054. List<string> pivotFor = new List<string>();
  14055. foreach (DataRow item in scdTable.Rows)
  14056. {
  14057. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14058. }
  14059. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14060. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14061. sqlString = "select *\n" +
  14062. " from (select srd.defectid\n" +
  14063. " ,scd.defectcode\n" +
  14064. " ,scd.defectname\n" +
  14065. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14066. " ,count(srd.semireworkdefectid) cc\n" +
  14067. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14068. " inner join TP_PM_SEMIREWORK sr\n" +
  14069. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14070. " left join tp_mst_semicheckdefect scd\n" +
  14071. " on scd.defectid = srd.defectid\n" +
  14072. " left join tp_mst_scdefectposition scdp\n" +
  14073. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14074. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14075. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14076. " where srd.valueflag = '1'\n" +
  14077. " and sr.BACKOUTFLAG = '0'\n" +
  14078. " and sr.valueflag = '1'\n" +
  14079. " and sr.accountid = :accountid\n";
  14080. // 半检日期
  14081. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14082. {
  14083. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14084. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14085. }
  14086. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14087. {
  14088. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14089. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14090. }
  14091. // 产品编码 GOODSCODE
  14092. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14093. {
  14094. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14095. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14096. }
  14097. // 成型工号 GROUTINGUSERCODE
  14098. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14099. {
  14100. //xuwei modify 2019-11-13
  14101. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14102. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14103. //xuwei end
  14104. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14105. }
  14106. // 半检工号 SEMIREWORKUSERCODE
  14107. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14108. {
  14109. //xuwei modify 2019-11-13
  14110. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14111. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14112. //xuwei end
  14113. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14114. }
  14115. // 缺陷位置 scdp.defectpositionname
  14116. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14117. {
  14118. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14119. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14120. }
  14121. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14122. {
  14123. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14124. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14125. }
  14126. // 缺陷名称 scd.defectname
  14127. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14128. {
  14129. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14130. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14131. }
  14132. // 缺陷编码 scd.defectcode
  14133. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14134. {
  14135. sqlString += " and scd.defectcode = :defectcode \n";
  14136. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14137. }
  14138. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14139. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14140. {
  14141. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14142. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14143. }
  14144. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14145. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14146. {
  14147. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14148. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14149. }
  14150. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14151. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14152. {
  14153. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14154. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14155. }
  14156. sqlString +=
  14157. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid),())) t\n" +
  14158. "pivot(sum(cc)\n" +
  14159. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14160. " order by defectid";
  14161. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14162. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14163. {
  14164. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14165. return sre;
  14166. }
  14167. DataTable table = result.Tables[0];
  14168. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14169. dataRow["defectname"] = "合计";
  14170. foreach (DataRow item in scdTable.Rows)
  14171. {
  14172. string colname = item["colname"] + "";
  14173. if (table.Columns.Contains(colname))
  14174. {
  14175. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14176. {
  14177. table.Columns.Remove(colname);
  14178. }
  14179. else
  14180. {
  14181. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14182. }
  14183. }
  14184. }
  14185. table.Columns["D_0"].Caption = "合计";
  14186. sre.Data = result;
  14187. return sre;
  14188. }
  14189. catch (Exception ex)
  14190. {
  14191. throw ex;
  14192. }
  14193. finally
  14194. {
  14195. oracleConn?.Close();
  14196. }
  14197. }
  14198. /// <summary>
  14199. /// 模具注浆分析表
  14200. /// </summary>
  14201. /// <param name="cre"></param>
  14202. /// <param name="sUserInfo"></param>
  14203. /// <returns></returns>
  14204. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14205. {
  14206. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14207. try
  14208. {
  14209. ServiceResultEntity sre = new ServiceResultEntity();
  14210. OracleParameter[] oracleParameter = new OracleParameter[]
  14211. {
  14212. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14213. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14214. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14215. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14216. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14217. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14218. };
  14219. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14220. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14221. {
  14222. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14223. }
  14224. sre.Data = result;
  14225. oracleConn.Commit();
  14226. return sre;
  14227. }
  14228. catch (Exception ex)
  14229. {
  14230. if (oracleConn.ConnState == ConnectionState.Open)
  14231. {
  14232. oracleConn.Disconnect();
  14233. }
  14234. throw ex;
  14235. }
  14236. }
  14237. /// <summary>
  14238. /// 成检产品预算分析表
  14239. /// </summary>
  14240. /// <param name="cre"></param>
  14241. /// <param name="sUserInfo"></param>
  14242. /// <returns></returns>
  14243. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14244. {
  14245. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14246. try
  14247. {
  14248. ServiceResultEntity sre = new ServiceResultEntity();
  14249. OracleParameter[] oracleParameter = new OracleParameter[]
  14250. {
  14251. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14252. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14253. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14254. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14255. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14256. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14257. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14258. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14259. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14260. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14261. };
  14262. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14263. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14264. {
  14265. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14266. }
  14267. sre.Data = result;
  14268. oracleConn.Commit();
  14269. return sre;
  14270. }
  14271. catch (Exception ex)
  14272. {
  14273. if (oracleConn.ConnState == ConnectionState.Open)
  14274. {
  14275. oracleConn.Disconnect();
  14276. }
  14277. throw ex;
  14278. }
  14279. }
  14280. /// <summary>
  14281. /// 成检产品预算分析表-设置
  14282. /// </summary>
  14283. /// <param name="cre"></param>
  14284. /// <param name="sUserInfo"></param>
  14285. /// <returns></returns>
  14286. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14287. {
  14288. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14289. try
  14290. {
  14291. ServiceResultEntity sre = new ServiceResultEntity();
  14292. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14293. " FROM tp_qco_prosetting s\n" +
  14294. " LEFT JOIN tp_pc_procedure p\n" +
  14295. " ON s.procedureid = p.procedureid\n" +
  14296. " WHERE s.accountid = :accountid";
  14297. OracleParameter[] oracleParameter = new OracleParameter[]
  14298. {
  14299. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14300. };
  14301. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14302. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14303. " FROM tp_mst_kiln k\n" +
  14304. " WHERE k.accountid = :accountid\n" +
  14305. " AND k.valueflag = '1'";
  14306. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14307. result.Tables.Add(dt);
  14308. sre.Data = result;
  14309. return sre;
  14310. }
  14311. catch (Exception ex)
  14312. {
  14313. if (oracleConn.ConnState == ConnectionState.Open)
  14314. {
  14315. oracleConn.Close();
  14316. }
  14317. throw ex;
  14318. }
  14319. }
  14320. /// <summary>
  14321. /// 成检产品预算分析表-设置
  14322. /// </summary>
  14323. /// <param name="cre"></param>
  14324. /// <param name="sUserInfo"></param>
  14325. /// <returns></returns>
  14326. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14327. {
  14328. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14329. try
  14330. {
  14331. ServiceResultEntity sre = new ServiceResultEntity();
  14332. OracleParameter[] oracleParameter = null;
  14333. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14334. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14335. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14336. {
  14337. oracleParameter = new OracleParameter[]
  14338. {
  14339. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14340. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14341. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14342. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14343. };
  14344. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14345. }
  14346. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14347. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14348. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14349. {
  14350. oracleParameter = new OracleParameter[]
  14351. {
  14352. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14353. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14354. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14355. };
  14356. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14357. }
  14358. oracleConn.Commit();
  14359. return sre;
  14360. }
  14361. catch (Exception ex)
  14362. {
  14363. if (oracleConn.ConnState == ConnectionState.Open)
  14364. {
  14365. oracleConn.Disconnect();
  14366. }
  14367. throw ex;
  14368. }
  14369. }
  14370. /// <summary>
  14371. /// 各工序质量表-恒洁三水
  14372. /// </summary>
  14373. /// <param name="cre"></param>
  14374. /// <param name="sUserInfo"></param>
  14375. /// <returns></returns>
  14376. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14377. {
  14378. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14379. try
  14380. {
  14381. int p1ID = 11; // 成检交接工序
  14382. int p2ID = 12; // 成检登记工序
  14383. string gtcode2 = cre.Properties["gtcode2"] + "";
  14384. if (gtcode2 != "001001" && gtcode2 != "001002")
  14385. {
  14386. gtcode2 = "[ALL]";
  14387. }
  14388. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14389. // goodsleveltypeid 次品 7
  14390. string sqlString = "select t.*\n" +
  14391. " ,gt.goodstypename\n" +
  14392. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14393. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14394. " ,decode(nvl(outk.outkcount, 0)\n" +
  14395. " ,0\n" +
  14396. " ,to_number(null)\n" +
  14397. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14398. " nvl(outk.outkcount, 0)\n" +
  14399. " ,4)) ccp\n" +
  14400. " from (select 10 pcode\n" +
  14401. " ,'成型' pname\n" +
  14402. " ,gt2.goodstypecode gtcode2\n" +
  14403. " ,count(*) defectcount\n" +
  14404. " from tp_pm_defect dd\n" +
  14405. " inner join tp_pm_productiondata pd\n" +
  14406. " on dd.productiondataid = pd.productiondataid\n" +
  14407. " inner join tp_mst_goods g\n" +
  14408. " on dd.goodsid = g.goodsid\n" +
  14409. " inner join tp_mst_goodstype gt\n" +
  14410. " on gt.goodstypeid = g.goodstypeid\n" +
  14411. " inner join tp_mst_goodstype gt2\n" +
  14412. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14413. " where dd.valueflag = '1'\n" +
  14414. " and dd.accountid = :accountid\n" +
  14415. " and pd.goodsleveltypeid = 7\n" + // 次品
  14416. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14417. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14418. " and dd.procedureid = :p2ID\n" +
  14419. " and dd.checktime >= :timebegin\n" +
  14420. " and dd.checktime < :timeend\n" +
  14421. ////" -- 交坯、干补\n" +
  14422. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14423. " 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" +
  14424. " 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" +
  14425. " )\n" +
  14426. " group by gt2.goodstypecode\n" +
  14427. " union all\n" +
  14428. " select 20 pcode\n" +
  14429. " ,'改洗' pname\n" +
  14430. " ,gt2.goodstypecode gtcode2\n" +
  14431. " ,count(*) defectcount\n" +
  14432. " from tp_pm_defect dd\n" +
  14433. " inner join tp_pm_productiondata pd\n" +
  14434. " on dd.productiondataid = pd.productiondataid\n" +
  14435. " inner join tp_mst_goods g\n" +
  14436. " on dd.goodsid = g.goodsid\n" +
  14437. " inner join tp_mst_goodstype gt\n" +
  14438. " on gt.goodstypeid = g.goodstypeid\n" +
  14439. " inner join tp_mst_goodstype gt2\n" +
  14440. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14441. " where dd.valueflag = '1'\n" +
  14442. " and dd.accountid = :accountid\n" +
  14443. " and pd.goodsleveltypeid = 7\n" + // 次品
  14444. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14445. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14446. " and dd.procedureid = :p2ID\n" +
  14447. " and dd.checktime >= :timebegin\n" +
  14448. " and dd.checktime < :timeend\n" +
  14449. ////" -- 改洗、吹风\n" +
  14450. //" and dd.defectprocedureid in (2, 62)\n" +
  14451. ////" -- 除不平\n" +
  14452. //" and dd.defectid not in (91, 240)\n" +
  14453. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14454. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14455. " )\n" +
  14456. " group by gt2.goodstypecode\n" +
  14457. " union all\n" +
  14458. " select 30 pcode\n" +
  14459. " ,'二检' pname\n" +
  14460. " ,gt2.goodstypecode gtcode2\n" +
  14461. " ,count(*) defectcount\n" +
  14462. " from tp_pm_defect dd\n" +
  14463. " inner join tp_pm_productiondata pd\n" +
  14464. " on dd.productiondataid = pd.productiondataid\n" +
  14465. " inner join tp_mst_goods g\n" +
  14466. " on dd.goodsid = g.goodsid\n" +
  14467. " inner join tp_mst_goodstype gt\n" +
  14468. " on gt.goodstypeid = g.goodstypeid\n" +
  14469. " inner join tp_mst_goodstype gt2\n" +
  14470. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14471. " where dd.valueflag = '1'\n" +
  14472. " and dd.accountid = :accountid\n" +
  14473. " and pd.goodsleveltypeid = 7\n" + // 次品
  14474. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14475. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14476. " and dd.procedureid = :p2ID\n" +
  14477. " and dd.checktime >= :timebegin\n" +
  14478. " and dd.checktime < :timeend\n" +
  14479. ////" -- 二检\n" +
  14480. //" and dd.defectprocedureid in (61)\n" +
  14481. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14482. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14483. " )\n" +
  14484. " group by gt2.goodstypecode\n" +
  14485. " union all\n" +
  14486. " select 40 pcode\n" +
  14487. " ,'施釉' pname\n" +
  14488. " ,gt2.goodstypecode gtcode2\n" +
  14489. " ,count(*) defectcount\n" +
  14490. " from tp_pm_defect dd\n" +
  14491. " inner join tp_pm_productiondata pd\n" +
  14492. " on dd.productiondataid = pd.productiondataid\n" +
  14493. " inner join tp_mst_goods g\n" +
  14494. " on dd.goodsid = g.goodsid\n" +
  14495. " inner join tp_mst_goodstype gt\n" +
  14496. " on gt.goodstypeid = g.goodstypeid\n" +
  14497. " inner join tp_mst_goodstype gt2\n" +
  14498. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14499. " where dd.valueflag = '1'\n" +
  14500. " and dd.accountid = :accountid\n" +
  14501. " and pd.goodsleveltypeid = 7\n" + // 次品
  14502. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14503. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14504. " and dd.procedureid = :p2ID\n" +
  14505. " and dd.checktime >= :timebegin\n" +
  14506. " and dd.checktime < :timeend\n" +
  14507. ////" -- 施釉\n" +
  14508. //" and dd.defectprocedureid in (3, 4)\n" +
  14509. ////" -- 除铁、铜脏\n" +
  14510. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14511. " 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" +
  14512. " 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" +
  14513. " )\n" +
  14514. " group by gt2.goodstypecode\n" +
  14515. " union all\n" +
  14516. " select 50 pcode\n" +
  14517. " ,'刮登' pname\n" +
  14518. " ,gt2.goodstypecode gtcode2\n" +
  14519. " ,count(*) defectcount\n" +
  14520. " from tp_pm_defect dd\n" +
  14521. " inner join tp_pm_productiondata pd\n" +
  14522. " on dd.productiondataid = pd.productiondataid\n" +
  14523. " inner join tp_mst_goods g\n" +
  14524. " on dd.goodsid = g.goodsid\n" +
  14525. " inner join tp_mst_goodstype gt\n" +
  14526. " on gt.goodstypeid = g.goodstypeid\n" +
  14527. " inner join tp_mst_goodstype gt2\n" +
  14528. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14529. " where dd.valueflag = '1'\n" +
  14530. " and dd.accountid = :accountid\n" +
  14531. " and pd.goodsleveltypeid = 7\n" + // 次品
  14532. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14533. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14534. " and dd.procedureid = :p2ID\n" +
  14535. " and dd.checktime >= :timebegin\n" +
  14536. " and dd.checktime < :timeend\n" +
  14537. ////" -- 登窑、入窑、卸窑\n" +
  14538. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14539. " 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" +
  14540. " 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" +
  14541. " )\n" +
  14542. " group by gt2.goodstypecode\n" +
  14543. " union all\n" +
  14544. " select 60 pcode\n" +
  14545. " ,'烧成' pname\n" +
  14546. " ,gt2.goodstypecode gtcode2\n" +
  14547. " ,count(*) defectcount\n" +
  14548. " from tp_pm_defect dd\n" +
  14549. " inner join tp_pm_productiondata pd\n" +
  14550. " on dd.productiondataid = pd.productiondataid\n" +
  14551. " inner join tp_mst_goods g\n" +
  14552. " on dd.goodsid = g.goodsid\n" +
  14553. " inner join tp_mst_goodstype gt\n" +
  14554. " on gt.goodstypeid = g.goodstypeid\n" +
  14555. " inner join tp_mst_goodstype gt2\n" +
  14556. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14557. " where dd.valueflag = '1'\n" +
  14558. " and dd.accountid = :accountid\n" +
  14559. " and pd.goodsleveltypeid = 7\n" + // 次品
  14560. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14561. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14562. " and dd.procedureid = :p2ID\n" +
  14563. " and dd.checktime >= :timebegin\n" +
  14564. " and dd.checktime < :timeend\n" +
  14565. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14566. //" and dd.defectid in (385\n" +
  14567. //" ,203\n" +
  14568. //" ,836\n" +
  14569. //" ,234\n" +
  14570. //" ,384\n" +
  14571. //" ,202\n" +
  14572. //" ,835\n" +
  14573. //" ,390\n" +
  14574. //" ,818\n" +
  14575. //" ,389\n" +
  14576. //" ,204\n" +
  14577. //" ,814\n" +
  14578. //" ,837\n" +
  14579. //" ,387)\n" +
  14580. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14581. //" 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" +
  14582. //" 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" +
  14583. //" )\n" +
  14584. " group by gt2.goodstypecode\n" +
  14585. " union all\n" +
  14586. " select 70 pcode\n" +
  14587. " ,'杂锈点' pname\n" +
  14588. " ,gt2.goodstypecode gtcode2\n" +
  14589. " ,count(*) defectcount\n" +
  14590. " from tp_pm_defect dd\n" +
  14591. " inner join tp_pm_productiondata pd\n" +
  14592. " on dd.productiondataid = pd.productiondataid\n" +
  14593. " inner join tp_mst_goods g\n" +
  14594. " on dd.goodsid = g.goodsid\n" +
  14595. " inner join tp_mst_goodstype gt\n" +
  14596. " on gt.goodstypeid = g.goodstypeid\n" +
  14597. " inner join tp_mst_goodstype gt2\n" +
  14598. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14599. " where dd.valueflag = '1'\n" +
  14600. " and dd.accountid = :accountid\n" +
  14601. " and pd.goodsleveltypeid = 7\n" + // 次品
  14602. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14603. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14604. " and dd.procedureid = :p2ID\n" +
  14605. " and dd.checktime >= :timebegin\n" +
  14606. " and dd.checktime < :timeend\n" +
  14607. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14608. //" and dd.defectid in\n" +
  14609. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14610. " and dd.defectid in (170,389,398,399)\n" +
  14611. //" 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" +
  14612. //" 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" +
  14613. //" )\n" +
  14614. " group by gt2.goodstypecode\n" +
  14615. " union all\n" +
  14616. " select 80 pcode\n" +
  14617. " ,'其他' pname\n" +
  14618. " ,gt2.goodstypecode gtcode2\n" +
  14619. " ,count(*) defectcount\n" +
  14620. " from tp_pm_defect dd\n" +
  14621. " inner join tp_pm_productiondata pd\n" +
  14622. " on dd.productiondataid = pd.productiondataid\n" +
  14623. " inner join tp_mst_goods g\n" +
  14624. " on dd.goodsid = g.goodsid\n" +
  14625. " inner join tp_mst_goodstype gt\n" +
  14626. " on gt.goodstypeid = g.goodstypeid\n" +
  14627. " inner join tp_mst_goodstype gt2\n" +
  14628. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14629. " where dd.valueflag = '1'\n" +
  14630. " and dd.accountid = :accountid\n" +
  14631. " and pd.goodsleveltypeid = 7\n" + // 次品
  14632. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14633. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14634. " and dd.procedureid = :p2ID\n" +
  14635. " and dd.checktime >= :timebegin\n" +
  14636. " and dd.checktime < :timeend\n" +
  14637. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14638. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14639. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14640. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14641. " )\n" +
  14642. " group by gt2.goodstypecode) t\n" +
  14643. " left join (select gt2.goodstypecode gtcode2\n" +
  14644. " ,count(*) outkcount\n" +
  14645. " from tp_pm_productiondata pd\n" +
  14646. " inner join tp_mst_goods g\n" +
  14647. " on pd.goodsid = g.goodsid\n" +
  14648. " inner join tp_mst_goodstype gt\n" +
  14649. " on gt.goodstypeid = g.goodstypeid\n" +
  14650. " inner join tp_mst_goodstype gt2\n" +
  14651. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14652. " where pd.valueflag = '1'\n" +
  14653. " and pd.accountid = :accountid\n" +
  14654. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14655. " and pd.procedureid = :p1ID\n" +
  14656. " and pd.createtime >= :timebegin\n" +
  14657. " and pd.createtime < :timeend\n" +
  14658. " group by gt2.goodstypecode) outk\n" +
  14659. " on t.gtcode2 = outk.gtcode2\n" +
  14660. " inner join tp_mst_goodstype gt\n" +
  14661. " on gt.goodstypecode = t.gtcode2\n" +
  14662. " and gt.accountid = :accountid\n" +
  14663. " order by t.pcode, t.gtcode2";
  14664. OracleParameter[] oracleParameter = new OracleParameter[]
  14665. {
  14666. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14667. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14668. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14669. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14670. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14671. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14672. };
  14673. ServiceResultEntity sre = new ServiceResultEntity();
  14674. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14675. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14676. {
  14677. sre.Data.Tables[0].TableName = "S";
  14678. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14679. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14680. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14681. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14682. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14683. {
  14684. sre1.Data.Tables[0].TableName = "D";
  14685. sre.Data.Merge(sre1.Data.Tables[0]);
  14686. }
  14687. }
  14688. sqlString =
  14689. "select t.gtcode2\n" +
  14690. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14691. " ,sum(t.outk) outk\n" +
  14692. " ,sum(t.cipin) cipin\n" +
  14693. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14694. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14695. " from (select gt2.goodstypecode gtcode2\n" +
  14696. " ,gt2.goodstypename gtname2\n" +
  14697. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14698. " ,nvl(sum(case\n" +
  14699. " when pd.procedureid = :p2ID and\n" +
  14700. " pd.goodsleveltypeid in (6, 7) then\n" +
  14701. " 1\n" +
  14702. " else\n" +
  14703. " 0\n" +
  14704. " end)\n" +
  14705. " ,0) cipin\n" +
  14706. " from tp_pm_productiondata pd\n" +
  14707. " inner join tp_mst_goods g\n" +
  14708. " on pd.goodsid = g.goodsid\n" +
  14709. " inner join tp_mst_goodstype gt\n" +
  14710. " on g.goodstypeid = gt.goodstypeid\n" +
  14711. " inner join tp_mst_goodstype gt2\n" +
  14712. " on length(gt2.goodstypecode) = 6\n" +
  14713. " and gt2.accountid = gt.accountid\n" +
  14714. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14715. " where pd.valueflag = '1'\n" +
  14716. " and pd.accountid = :accountid\n" +
  14717. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14718. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14719. //" and pd.checktime > date '2018-01-01'\n" +
  14720. " and pd.checktime >= :timebegin\n" +
  14721. " and pd.checktime < :timeend\n" +
  14722. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14723. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14724. oracleParameter = new OracleParameter[]
  14725. {
  14726. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14727. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14728. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14729. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14730. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14731. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14732. };
  14733. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14734. alldata.TableName = "A";
  14735. DataTable data = sre.Data.Tables[0];
  14736. foreach (DataRow item in alldata.Rows)
  14737. {
  14738. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14739. }
  14740. return sre;
  14741. }
  14742. catch (Exception ex)
  14743. {
  14744. if (oracleConn.ConnState == ConnectionState.Open)
  14745. {
  14746. oracleConn.Close();
  14747. }
  14748. throw ex;
  14749. }
  14750. }
  14751. /// <summary>
  14752. /// 各工序质量表-缺陷明细-恒洁三水
  14753. /// </summary>
  14754. /// <param name="cre"></param>
  14755. /// <param name="sUserInfo"></param>
  14756. /// <returns></returns>
  14757. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14758. {
  14759. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14760. try
  14761. {
  14762. //int p1ID = 11; // 成检交接工序
  14763. int p2ID = 12; // 成检登记工序
  14764. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14765. string sqlString =
  14766. "select :pcode pcode\n" +
  14767. " ,:pname pname\n" +
  14768. " ,gt2.goodstypecode gtcode2\n" +
  14769. " ,gt2.goodstypename gtname2\n" +
  14770. " ,dd.defectcode\n" +
  14771. " ,dd.defectname\n" +
  14772. " ,count(*) defectcount\n" +
  14773. " from tp_pm_defect dd\n" +
  14774. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14775. " inner join tp_mst_goods g\n" +
  14776. " on dd.goodsid = g.goodsid\n" +
  14777. " inner join tp_pm_productiondata pd\n" +
  14778. " on dd.productiondataid = pd.productiondataid\n" +
  14779. " inner join tp_mst_goodstype gt\n" +
  14780. " on gt.goodstypeid = g.goodstypeid\n" +
  14781. " inner join tp_mst_goodstype gt2\n" +
  14782. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14783. " and gt2.accountid = :accountid\n" +
  14784. " where dd.valueflag = '1'\n" +
  14785. " and dd.accountid = :accountid\n" +
  14786. " and pd.goodsleveltypeid = 7\n" + // 次品
  14787. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14788. " and dd.procedureid = :p2ID\n" +
  14789. " and gt2.goodstypecode = :gtcode2\n" +
  14790. " and dd.checktime >= :timebegin\n" +
  14791. " and dd.checktime < :timeend\n";
  14792. switch (pcode)
  14793. {
  14794. case 10:
  14795. ////" -- 交坯、干补\n" +
  14796. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14797. sqlString +=
  14798. " 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" +
  14799. " 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" +
  14800. " )\n";
  14801. break;
  14802. case 20:
  14803. sqlString +=
  14804. ////" -- 改洗、吹风\n" +
  14805. //" and dd.defectprocedureid in (2, 62)\n" +
  14806. ////" -- 除不平\n" +
  14807. //" and dd.defectid not in (91, 240)\n";
  14808. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14809. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14810. " )\n";
  14811. break;
  14812. case 30:
  14813. sqlString +=
  14814. ////" -- 二检\n" +
  14815. //" and dd.defectprocedureid in (61)\n";
  14816. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14817. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14818. " )\n";
  14819. break;
  14820. case 40:
  14821. sqlString +=
  14822. ////" -- 施釉\n" +
  14823. //" and dd.defectprocedureid in (3, 4)\n" +
  14824. ////" -- 除铁、铜脏\n" +
  14825. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14826. " 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" +
  14827. " 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" +
  14828. " )\n";
  14829. break;
  14830. case 50:
  14831. sqlString +=
  14832. ////" -- 登窑、入窑、卸窑\n" +
  14833. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14834. " 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" +
  14835. " 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" +
  14836. " )\n";
  14837. break;
  14838. case 60:
  14839. sqlString +=
  14840. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14841. //" and dd.defectid in (385\n" +
  14842. //" ,203\n" +
  14843. //" ,836\n" +
  14844. //" ,234\n" +
  14845. //" ,384\n" +
  14846. //" ,202\n" +
  14847. //" ,835\n" +
  14848. //" ,390\n" +
  14849. //" ,818\n" +
  14850. //" ,389\n" +
  14851. //" ,204\n" +
  14852. //" ,814\n" +
  14853. //" ,837\n" +
  14854. //" ,387)\n";
  14855. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14856. break;
  14857. case 70:
  14858. sqlString +=
  14859. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14860. //" and dd.defectid in\n" +
  14861. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14862. " and dd.defectid in (170,389,398,399)\n";
  14863. break;
  14864. case 80:
  14865. sqlString +=
  14866. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14867. //" and dd.defectid in (393, 180, 394, 395)\n";
  14868. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14869. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14870. " )\n";
  14871. break;
  14872. default:
  14873. break;
  14874. }
  14875. sqlString +=
  14876. " group by gt2.goodstypecode\n" +
  14877. " ,gt2.goodstypename\n" +
  14878. " ,dd.defectcode\n" +
  14879. " ,dd.defectname\n" +
  14880. " order by dd.defectcode";
  14881. OracleParameter[] oracleParameter = new OracleParameter[]
  14882. {
  14883. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14884. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14885. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14886. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  14887. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  14888. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  14889. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14890. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14891. };
  14892. ServiceResultEntity sre = new ServiceResultEntity();
  14893. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14894. return sre;
  14895. }
  14896. catch (Exception ex)
  14897. {
  14898. if (oracleConn.ConnState == ConnectionState.Open)
  14899. {
  14900. oracleConn.Close();
  14901. }
  14902. throw ex;
  14903. }
  14904. }
  14905. /// <summary>
  14906. /// 综合合格率分析表-半成品报废率分析表
  14907. /// </summary>
  14908. /// <param name="cre"></param>
  14909. /// <param name="sUserInfo"></param>
  14910. /// <returns></returns>
  14911. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14912. {
  14913. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14914. try
  14915. {
  14916. ServiceResultEntity sre = new ServiceResultEntity();
  14917. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14918. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14919. string sqlString = "select g.goodscode\n" +
  14920. " ,tt.d_num\n" +
  14921. " ,tt.b_num\n" +
  14922. " ,tt.f_num\n" +
  14923. " ,tt.s_num\n" +
  14924. " ,decode(tt.d_num\n" +
  14925. " ,0\n" +
  14926. " ,to_number(null)\n" +
  14927. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  14928. " from (select t.goodsid\n" +
  14929. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  14930. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  14931. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  14932. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  14933. " from (select gdd.goodsid\n" +
  14934. " ,'A' numtype\n" +
  14935. " ,count(gdd.groutingdailydetailid) id_num\n" +
  14936. " from tp_pm_groutingdailydetail gdd\n" +
  14937. " where gdd.groutingflag = '1'\n" +
  14938. " and gdd.valueflag = '1'\n" +
  14939. " and gdd.accountid = :accountid\n" +
  14940. " and gdd.deliverflag = '1'\n" +
  14941. " and gdd.delivertime >= :datebegin\n" +
  14942. " and gdd.delivertime < :dateend\n" +
  14943. " group by gdd.goodsid\n" +
  14944. " union all\n" +
  14945. " -- 半检不合格数 复检不合格数 损坯数\n" +
  14946. " select sp.goodsid\n" +
  14947. " ,sp.SCRAPTYPE numtype\n" +
  14948. " ,count(sp.scrapproductid) id_num\n" +
  14949. " from tp_pm_scrapproduct sp\n" +
  14950. " where sp.valueflag = '1'\n" +
  14951. " and sp.accountid = :accountid\n" +
  14952. " and sp.auditstatus = 1\n" +
  14953. " and sp.KILNID is null\n" +
  14954. " and sp.SCRAPTYPE <> '1'\n" +
  14955. " and sp.AUDITDATE >= :datebegin\n" +
  14956. " and sp.AUDITDATE < :dateend\n" +
  14957. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  14958. " group by t.goodsid) tt\n" +
  14959. " inner join tp_mst_goods g\n" +
  14960. " on tt.goodsid = g.goodsid\n" +
  14961. " order by g.goodscode";
  14962. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14963. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14964. //// 产品编码 GOODSCODE
  14965. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14966. //{
  14967. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14968. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14969. //}
  14970. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14971. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14972. {
  14973. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14974. return sre;
  14975. }
  14976. sre.Data = result;
  14977. return sre;
  14978. }
  14979. catch (Exception ex)
  14980. {
  14981. throw ex;
  14982. }
  14983. finally
  14984. {
  14985. oracleConn?.Close();
  14986. }
  14987. }
  14988. /// <summary>
  14989. /// 综合合格率分析表-综合优等率分析表
  14990. /// </summary>
  14991. /// <param name="cre"></param>
  14992. /// <param name="sUserInfo"></param>
  14993. /// <returns></returns>
  14994. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14995. {
  14996. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14997. try
  14998. {
  14999. ServiceResultEntity sre = new ServiceResultEntity();
  15000. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  15001. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  15002. string sqlString = "\n" +
  15003. "select g.goodscode\n" +
  15004. " ,pp.b_out_num\n" +
  15005. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  15006. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  15007. " ,decode(pp.b_out_num\n" +
  15008. " ,0\n" +
  15009. " ,to_number(null)\n" +
  15010. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  15011. " pp.b_out_num,4)) zh_r\n" +
  15012. " from (select p.goodsid\n" +
  15013. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  15014. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15015. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15016. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15017. " from tp_pm_productiondata p\n" +
  15018. " where p.valueflag = '1'\n" +
  15019. " and p.accountid = :accountid\n" +
  15020. " and (p.procedureid in (11, 58) or\n" +
  15021. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15022. " and p.createtime >= :datebegin\n" +
  15023. " and p.createtime < :dateend\n" +
  15024. " group by p.goodsid) pp\n" +
  15025. " inner join tp_mst_goods g\n" +
  15026. " on g.goodsid = pp.goodsid\n" +
  15027. " order by g.goodscode";
  15028. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15029. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15030. //// 产品编码 GOODSCODE
  15031. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15032. //{
  15033. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15034. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15035. //}
  15036. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15037. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15038. {
  15039. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15040. return sre;
  15041. }
  15042. sre.Data = result;
  15043. return sre;
  15044. }
  15045. catch (Exception ex)
  15046. {
  15047. throw ex;
  15048. }
  15049. finally
  15050. {
  15051. oracleConn?.Close();
  15052. }
  15053. }
  15054. #region 产成品交接撤销汇总表
  15055. /// <summary>
  15056. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15057. /// </summary>
  15058. /// <param name="user">登录用户信息</param>
  15059. /// <param name="se">查询条件</param>
  15060. /// <returns>查询结果</returns>
  15061. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15062. {
  15063. IDBConnection conn = null;
  15064. try
  15065. {
  15066. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15067. string sqlString = "SELECT TS.GID,\n" +
  15068. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15069. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15070. " GOODSCOUNT\n" +
  15071. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15072. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15073. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15074. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15075. " FROM TP_PM_FHUNDO F\n" +
  15076. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15077. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15078. " LEFT JOIN TP_MST_GOODS G\n" +
  15079. " ON G.GOODSID = GDD.GOODSID\n" +
  15080. " WHERE F.ACCOUNTID = :AccountID\n";
  15081. List<OracleParameter> parameters = new List<OracleParameter>();
  15082. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15083. // 撤销时间
  15084. if (orderEntity.UndoTimeStart != null)
  15085. {
  15086. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15087. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15088. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15089. }
  15090. // 产品型号
  15091. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15092. {
  15093. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15094. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15095. }
  15096. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15097. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15098. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15099. ServiceResultEntity sre = new ServiceResultEntity();
  15100. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15101. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15102. {
  15103. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15104. }
  15105. sre.Data = result;
  15106. return sre;
  15107. }
  15108. catch (Exception ex)
  15109. {
  15110. throw ex;
  15111. }
  15112. finally
  15113. {
  15114. if (conn != null &&
  15115. conn.ConnState == ConnectionState.Open)
  15116. {
  15117. conn.Close();
  15118. }
  15119. }
  15120. }
  15121. /// <summary>
  15122. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15123. /// </summary>
  15124. /// <param name="user">登录用户信息</param>
  15125. /// <param name="se">查询条件</param>
  15126. /// <returns>查询结果</returns>
  15127. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15128. {
  15129. IDBConnection conn = null;
  15130. try
  15131. {
  15132. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15133. string sqlString = "SELECT O.ORDERNO,\n" +
  15134. " F.FHTIME,\n" +
  15135. " F.FHUSERCODE,\n" +
  15136. " GDD.BARCODE,\n" +
  15137. " GOODS.GOODSCODE,\n" +
  15138. " L.LOGONAME,\n" +
  15139. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15140. " GDD.GROUTINGLINECODE,\n" +
  15141. " GDD.GROUTINGMOULDCODE,\n" +
  15142. " GDD.GROUTINGDATE,\n" +
  15143. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15144. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15145. " 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" +
  15146. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15147. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15148. " FROM TP_PM_FHUNDO F\n" +
  15149. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15150. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15151. " LEFT JOIN TP_PM_ORDER O\n" +
  15152. " ON F.FHORDERID = O.ORDERID\n" +
  15153. " LEFT JOIN TP_MST_LOGO L\n" +
  15154. " ON GDD.LOGOID = L.LOGOID\n" +
  15155. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15156. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15157. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15158. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15159. " WHERE F.ACCOUNTID = :AccountID";
  15160. List<OracleParameter> parameters = new List<OracleParameter>();
  15161. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15162. // 撤销时间
  15163. if (orderEntity.UndoTimeStart != null)
  15164. {
  15165. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15166. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15167. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15168. }
  15169. // 产品型号
  15170. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15171. {
  15172. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15173. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15174. }
  15175. ServiceResultEntity sre = new ServiceResultEntity();
  15176. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15177. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15178. {
  15179. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15180. }
  15181. sre.Data = result;
  15182. return sre;
  15183. }
  15184. catch (Exception ex)
  15185. {
  15186. throw ex;
  15187. }
  15188. finally
  15189. {
  15190. if (conn != null &&
  15191. conn.ConnState == ConnectionState.Open)
  15192. {
  15193. conn.Close();
  15194. }
  15195. }
  15196. }
  15197. #endregion
  15198. }
  15199. }